{"nl": {"description": "Polycarpus has postcards and photos hung in a row on the wall. He decided to put them away to the closet and hang on the wall a famous painter's picture. Polycarpus does it like that: he goes from the left to the right and removes the objects consecutively. As Polycarpus doesn't want any mix-ups to happen, he will not carry in his hands objects of two different types. In other words, Polycarpus can't carry both postcards and photos simultaneously. Sometimes he goes to the closet and puts the objects there, thus leaving his hands free. Polycarpus must put all the postcards and photos to the closet. He cannot skip objects. What minimum number of times he should visit the closet if he cannot carry more than 5 items?", "input_spec": "The only line of the input data contains a non-empty string consisting of letters \"С\" and \"P\" whose length does not exceed 100 characters. If the i-th character in the string is the letter \"С\", that means that the i-th object (the numbering goes from the left to the right) on Polycarpus' wall is a postcard. And if the i-th character is the letter \"P\", than the i-th object on the wall is a photo.", "output_spec": "Print the only number — the minimum number of times Polycarpus has to visit the closet.", "sample_inputs": ["CPCPCPC", "CCCCCCPPPPPP", "CCCCCCPPCPPPPPPPPPP", "CCCCCCCCCC"], "sample_outputs": ["7", "4", "6", "2"], "notes": "NoteIn the first sample Polycarpus needs to take one item to the closet 7 times.In the second sample Polycarpus can first take 3 postcards to the closet; then 3 more. He can take the 6 photos that are left in the similar way, going to the closet twice.In the third sample Polycarpus can visit the closet twice, both times carrying 3 postcards. Then he can take there 2 photos at once, then one postcard and finally, he can carry the last 10 photos if he visits the closet twice.In the fourth sample Polycarpus can visit the closet twice and take there all 10 postcards (5 items during each go)."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n ans, cnt, prev := 0, 0, '_'\n for _, v := range s {\n if cnt == 5 {\n prev = '_'\n }\n if v == prev {\n cnt++\n } else {\n ans++\n cnt = 1\n prev = v\n }\n }\n fmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n ans, cnt, prev := 0, 0, '_'\n for _, v := range s {\n if cnt == 5 {\n prev = '_'\n }\n if v == prev {\n cnt++\n } else {\n ans++\n cnt = 1\n prev = v\n }\n }\n fmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n ans, cnt, prev := 0, 0, '_'\n for _, v := range s {\n if cnt == 5 {\n prev = '_'\n }\n if v == prev {\n cnt++\n } else {\n ans++\n cnt = 1\n prev = v\n }\n }\n fmt.Println(ans)\n}"}, {"source_code": "package main\n\n\nimport \n\"fmt\"\n\n\nfunc main() {\n \nvar s string\n \nfmt.Scan(&s)\n \nans, cnt, prev := 0, 0, '_'\n \nfor _, v := range s {\n \nif cnt == 5 {\n \nprev = '_'\n \n}\n \nif v == prev {\n \ncnt++\n \n} else {\n\nans++\n \ncnt = 1\n \nprev = v\n \n}\n \n}\n \nfmt.Println(ans)\n\n}\n"}], "negative_code": [{"source_code": "// 284B\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tin := bufio.NewScanner(os.Stdin)\n\tnm := 3\n\tst := make([]int, nm)\n\tvar n int\n\tvar ln string\n\tin.Scan()\n\tn, _ = strconv.Atoi(in.Text())\n\tln = in.Text()\n\tfor i := 0; i < n; i++ {\n\t\tif ln[i] == 'F' {\n\t\t\tst[0]++\n\t\t}\n\t\tif ln[i] == 'I' {\n\t\t\tst[1]++\n\t\t}\n\t\tif ln[i] == 'A' {\n\t\t\tst[2]++\n\t\t}\n\t}\n\tvar out int\n\tout = 0\n\tif st[1] == 0 {\n\t\tout = n - (st[0])\n\t}\n\tif st[1] == 1 {\n\t\tout = 1\n\t}\n\tfmt.Println(out)\n}\n"}], "src_uid": "5257f6b50f5a610a17c35a47b3a0da11"} {"nl": {"description": "Vasya plays the sleuth with his friends. The rules of the game are as follows: those who play for the first time, that is Vasya is the sleuth, he should investigate a \"crime\" and find out what is happening. He can ask any questions whatsoever that can be answered with \"Yes\" or \"No\". All the rest agree beforehand to answer the questions like that: if the question’s last letter is a vowel, they answer \"Yes\" and if the last letter is a consonant, they answer \"No\". Of course, the sleuth knows nothing about it and his task is to understand that.Unfortunately, Vasya is not very smart. After 5 hours of endless stupid questions everybody except Vasya got bored. That’s why Vasya’s friends ask you to write a program that would give answers instead of them.The English alphabet vowels are: A, E, I, O, U, YThe English alphabet consonants are: B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, W, X, Z", "input_spec": "The single line contains a question represented by a non-empty line consisting of large and small Latin letters, spaces and a question mark. The line length does not exceed 100. It is guaranteed that the question mark occurs exactly once in the line — as the last symbol and that the line contains at least one letter.", "output_spec": "Print answer for the question in a single line: YES if the answer is \"Yes\", NO if the answer is \"No\". Remember that in the reply to the question the last letter, not the last character counts. I. e. the spaces and the question mark do not count as letters.", "sample_inputs": ["Is it a melon?", "Is it an apple?", "Is it a banana ?", "Is it an apple and a banana simultaneouSLY?"], "sample_outputs": ["NO", "YES", "YES", "YES"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t//\"strconv\"\n\t\"unicode\"\n\t//\"strings\"\n)\n\nfunc main() {\n var s string\n //fmt.Scan(&s)\n input:= bufio.NewScanner(os.Stdin)\n //input.Split(bufio.ScanLines)\n var c rune\n input.Scan()\n s=input.Text()\n //fmt.Println(s)\n //s = strings.TrimSpace(s)\n c = rune(s[len(s)-2])\n c = unicode.ToLower(c)\n var cek bool\n cek = unicode.IsSpace(c)\n //fmt.Println(cek)\n for i:=3;cek==true;i++ {\n \tc = rune(s[len(s)-i])\n \tc = unicode.ToLower(c)\n \tcek = unicode.IsSpace(c)\n }\n //fmt.Println(s)\n //fmt.Println(string(c))\n if (c == 'a' || c == 'e' || c == 'i' || c == 'u' || c == 'o' || c == 'y') {\n \tfmt.Println(\"YES\")\n \treturn\n }\n fmt.Println(\"NO\")\n}\n\n"}, {"source_code": "package main\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"bufio\"\n)\n\nfunc main() {\n\tvar q string\n\tvar i int\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanLines)\n\tr.Scan()\n\tq=r.Text()\n\ti=len(q)-2\n\tfor i>=0 {\n\t\tif q[i]==' ' {\n\t\t\ti--\n\t\t} else if q[i]=='a' || q[i]=='A' || q[i]=='e' || q[i]=='E' || q[i]=='u' || q[i]=='U' || q[i]=='y' || q[i]=='Y' || q[i]=='i' || q[i]=='I' || q[i]=='o' || q[i]=='O' {\n\t\tfmt.Println(\"YES\")\n\t\t\tbreak\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t\tbreak\n\t\t}\n\t}\n}"}, {"source_code": "//49A\npackage main\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"bufio\"\n)\n\nfunc main() {\n\tvar q string\n\tvar i int\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanLines)\n\tr.Scan()\n\tq=r.Text()\n\ti=len(q)-2\n\tfor i>=0 {\n\t\tif q[i]==' ' {\n\t\t\ti--\n\t\t} else if q[i]=='a' || q[i]=='A' || q[i]=='e' || q[i]=='E' || q[i]=='u' || q[i]=='U' || q[i]=='y' || q[i]=='Y' || q[i]=='i' || q[i]=='I' || q[i]=='o' || q[i]=='O' {\n\t\tfmt.Println(\"YES\")\n\t\t\tbreak\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t\tbreak\n\t\t}\n\t}\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strings\"\n)\n\nfunc main() {\n scanner := bufio.NewScanner(os.Stdin)\n scanner.Scan()\n for i := len(scanner.Text())-1; i >= 0; i-- {\n c := strings.ToUpper(string(scanner.Text()[i]))[0]\n if (c >= 'A') && (c <= 'Z') {\n if (c == 'A') || (c == 'E') || (c == 'I') || (c == 'O') || (c == 'U') || (c == 'Y') {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n break\n }\n }\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strings\"\n)\n\nfunc main() {\n scanner := bufio.NewScanner(os.Stdin) // variabel scanner adalah bufio yang menunjukan scanner baru\n scanner.Scan() //fungsi scanner scan\n for i := len(scanner.Text())-1; i >= 0; i-- { // lakukan selama kondisi ini\n c := strings.ToUpper(string(scanner.Text()[i]))[0] // variabel c aadlah string yang menunjuk kedalam toupper\n if (c >= 'A') && (c <= 'Z') { //lakukan selam kondisi ini\n if (c == 'A') || (c == 'E') || (c == 'I') || (c == 'O') || (c == 'U') || (c == 'Y') { // lakukan selam kondisi ini\n fmt.Println(\"YES\") // mencetak output\n } else { //\n fmt.Println(\"NO\") //mencetak output\n }\n break // berhenti\n }\n }\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strings\"\n)\n\nfunc main() {\n scanner := bufio.NewScanner(os.Stdin)\n scanner.Scan()\n for i := len(scanner.Text())-1; i >= 0; i-- {\n c := strings.ToUpper(string(scanner.Text()[i]))[0]\n if (c >= 'A') && (c <= 'Z') {\n if (c == 'A') || (c == 'E') || (c == 'I') || (c == 'O') || (c == 'U') || (c == 'Y') {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n break\n }\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strings\"\n)\n\n\nfunc check(upper string, vowel []string) bool {\n\tfor _, letter := range vowel {\n\t\tif upper == letter {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\tvowel := []string{ \"A\", \"E\", \"I\", \"O\", \"U\", \"Y\" }\n\n\tscanner.Scan()\n\tfor i := len(scanner.Text()) - 1; i >= 0; {\n\t\tupper := strings.ToUpper(string(scanner.Text()[i]))\n\t\tif upper != \" \" && upper != \"?\" {\n\t\t\tcheckVowel := check(upper, vowel)\n\t\t\tif checkVowel {\n\t\t\t\tfmt.Printf(\"%s\", \"YES\")\n\t\t\t\treturn \n\t\t\t} else {\n\t\t\t\tfmt.Printf(\"%s\", \"NO\")\n\t\t\t\treturn \n\t\t\t}\n\t\t} else {\n\t\t\ti --;\n\t\t}\n\t}\n\n\t// fmt.Println(scanner.Text())\n\t// fmt.Println(vowel)\n}\t\n\n\n\n\n"}, {"source_code": "// 49A-mic\npackage main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n \"strings\"\n)\n\nfunc main() {\n z := bufio.NewScanner(os.Stdin)\n var y bool\n var s []string\n y = false\n z.Scan()\n ss := z.Text()\n ss = strings.ToLower(ss)\n l := len(ss)\n for i := l - 1; i >= 0; i-- {\n if ss[i] == ' ' || ss[i] == '?' {\n continue\n } else {\n s = append(s, string(ss[i]))\n break\n }\n }\n if s[0] == \"a\" || s[0] == \"i\" || s[0] == \"u\" || s[0] == \"e\" || s[0] == \"o\" || s[0] == \"y\" {\n y = true\n }\n if y {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tvar question string\n\tvar vowel = map[string]bool{\n\t\t\"a\": true,\n\t\t\"e\": true,\n\t\t\"u\": true,\n\t\t\"o\": true,\n\t\t\"i\": true,\n\t\t\"y\": true,\n\t}\n\n\tscanner.Scan()\n\tquestion = scanner.Text()\n\n\tquestion = question[0 : len(question)-1]\n\tquestion = strings.TrimSpace(question)\n\n\tif _, ok := vowel[strings.ToLower(string(question[len(question)-1]))]; ok {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc scanln(a ...interface{}) { fmt.Fscanln(reader, a...) }\n\nfunc main() {\n\tdefer writer.Flush()\n\ts,_ := reader.ReadString('\\n')\n\ts = strings.Replace(s, \" \", \"\", -1)\n\ts = strings.Replace(s, \"?\", \"\", -1)\n\ts = strings.ToUpper(s)\n\t\n\tflag := true\n\tfor _, a := range []byte{'A', 'E', 'I', 'O', 'U', 'Y'} {\n\t\tif a == s[len(s)-3] {\n\t\t\tflag = false\n\t\t\tbreak\n\t\t}\n\t}\n\tif flag {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t//\"strconv\"\n\t\"unicode\"\n\t//\"strings\"\n)\n\nfunc main() {\n var s string\n //fmt.Scan(&s)\n input:= bufio.NewScanner(os.Stdin)\n //input.Split(bufio.ScanLines)\n var c rune\n input.Scan()\n s=input.Text()\n fmt.Println(s)\n //s = strings.TrimSpace(s)\n c = rune(s[len(s)-2])\n c = unicode.ToLower(c)\n var cek bool\n cek = unicode.IsSpace(c)\n //fmt.Println(cek)\n for i:=3;cek==true;i++ {\n \tc = rune(s[len(s)-i])\n \tc = unicode.ToLower(c)\n \tcek = unicode.IsSpace(c)\n }\n //fmt.Println(s)\n //fmt.Println(string(c))\n if (c == 'a' || c == 'e' || c == 'i' || c == 'u' || c == 'o' || c == 'y') {\n \tfmt.Println(\"YES\")\n \treturn\n }\n fmt.Println(\"NO\")\n}\n\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t//\"bufio\"\n\t//\"os\"\n\t//\"strconv\"\n\t\"unicode\"\n)\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n var c rune\n c = rune(s[len(s)-2])\n c = unicode.ToLower(c)\n if (c == 'a' || c == 'e' || c == 'i' || c == 'u' || c == 'o' || c == 'y') {\n \tfmt.Println(\"YES\")\n \treturn\n }\n fmt.Println(\"NO\")\n}\n\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc scanln(a ...interface{}) { fmt.Fscanln(reader, a...) }\n\nfunc main() {\n\tdefer writer.Flush()\n\ts,_ := reader.ReadString('\\n')\n\ts = strings.Replace(s, \" \", \"\", -1)\n\ts = strings.Replace(s, \"?\", \"\", -1)\n\ts = strings.ToUpper(s)\n\t\n\tflag := true\n\tfor _, a := range []byte{'A', 'E', 'I', 'O', 'U', 'Y'} {\n\t\tif a == s[len(s)-1] {\n\t\t\tflag = false\n\t\t\tbreak\n\t\t}\n\t}\n\tif flag {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc scanln(a ...interface{}) { fmt.Fscanln(reader, a...) }\n\nfunc main() {\n\tdefer writer.Flush()\n\ts,_ := reader.ReadString('\\n')\n\ts = strings.Replace(s, \" \", \"\", -1)\n\ts = strings.Replace(s, \"?\", \"\", -1)\n\ts = strings.ToUpper(s)\n\t\n\tflag := true\n\tfor _, a := range []byte{'A', 'E', 'I', 'O', 'U', 'Y'} {\n\t\tif a == s[len(s)-2] {\n\t\t\tflag = false\n\t\t\tbreak\n\t\t}\n\t}\n\tif flag {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}"}], "src_uid": "dea7eb04e086a4c1b3924eff255b9648"} {"nl": {"description": "Trouble came from the overseas lands: a three-headed dragon Gorynych arrived. The dragon settled at point C and began to terrorize the residents of the surrounding villages.A brave hero decided to put an end to the dragon. He moved from point A to fight with Gorynych. The hero rode from point A along a straight road and met point B on his way. The hero knows that in this land for every pair of roads it is true that they are either parallel to each other, or lie on a straight line, or are perpendicular to each other. He also knows well that points B and C are connected by a road. So the hero must either turn 90 degrees to the left or continue riding straight ahead or turn 90 degrees to the right. But he forgot where the point C is located.Fortunately, a Brave Falcon flew right by. It can see all three points from the sky. The hero asked him what way to go to get to the dragon's lair.If you have not got it, you are the falcon. Help the hero and tell him how to get him to point C: turn left, go straight or turn right.At this moment the hero is believed to stand at point B, turning his back to point A.", "input_spec": "The first input line contains two space-separated integers xa, ya (|xa|, |ya| ≤ 109) — the coordinates of point A. The second line contains the coordinates of point B in the same form, the third line contains the coordinates of point C. It is guaranteed that all points are pairwise different. It is also guaranteed that either point B lies on segment AC, or angle ABC is right.", "output_spec": "Print a single line. If a hero must turn left, print \"LEFT\" (without the quotes); If he must go straight ahead, print \"TOWARDS\" (without the quotes); if he should turn right, print \"RIGHT\" (without the quotes).", "sample_inputs": ["0 0\n0 1\n1 1", "-1 -1\n-3 -3\n-4 -4", "-4 -6\n-3 -7\n-2 -6"], "sample_outputs": ["RIGHT", "TOWARDS", "LEFT"], "notes": "NoteThe picture to the first sample: The red color shows points A, B and C. The blue arrow shows the hero's direction. The green color shows the hero's trajectory.The picture to the second sample: "}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"math\"\n)\n\nfunc scanInt(scanner *bufio.Scanner) int {\n\tscanner.Scan()\n\tx, _ := strconv.Atoi(scanner.Text())\n\treturn x\n}\n\nfunc equal(x, y float64) bool {\n\tdelta := x-y\n\tif (delta < 0) {\n\t\tdelta *= -1\n\t}\n\treturn delta <= 1e-6\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tax, ay := scanInt(scanner), scanInt(scanner)\n\tbx, by := scanInt(scanner), scanInt(scanner)\n\tcx, cy := scanInt(scanner), scanInt(scanner)\n\tx0, y0 := float64(bx-ax), float64(by-ay)\n\tl0 := math.Hypot(x0, y0)\n\tx0 /= l0\n\ty0 /= l0\n\tx1, y1 := float64(cx-bx), float64(cy-by)\n\tl1 := math.Hypot(x1, y1)\n\tx1 /= l1\n\ty1 /= l1\n\tif equal(x1, x0) && equal(y1, y0) {\n\t\twriter.WriteString(\"TOWARDS\\n\")\n\t} else if equal(x1, -y0) && equal(y1, x0) {\n\t\twriter.WriteString(\"LEFT\\n\")\n\t} else {\n\t\twriter.WriteString(\"RIGHT\\n\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n)\n\nfunc scanInt64(scanner *bufio.Scanner) int64 {\n\tscanner.Scan()\n\tx, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\treturn x\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tax, ay := scanInt64(scanner), scanInt64(scanner)\n\tbx, by := scanInt64(scanner), scanInt64(scanner)\n\tcx, cy := scanInt64(scanner), scanInt64(scanner)\n\tx0, y0 := bx-ax, by-ay\n\tx1, y1 := cx-bx, cy-by\n\tcross := x0*y1 - x1*y0\n\tif cross == 0 {\n\t\twriter.WriteString(\"TOWARDS\\n\")\n\t} else if cross > 0 {\n\t\twriter.WriteString(\"LEFT\\n\")\n\t} else {\n\t\twriter.WriteString(\"RIGHT\\n\")\n\t}\n}\n"}, {"source_code": "// 227A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a1, a2, b1, b2, c1, c2, x, y, z float64\n\tfmt.Scan(&a1, &a2)\n\tfmt.Scan(&b1, &b2)\n\tfmt.Scan(&c1, &c2)\n\tx = (b1 - a1) * (c2 - b2)\n\ty = (c1 - b1) * (b2 - a2)\n\tz = x - y\n\tif z == 0 {\n\t\tfmt.Print(\"TOWARDS\")\n\t} else if z < 0 {\n\t\tfmt.Print(\"RIGHT\")\n\t} else {\n\t\tfmt.Print(\"LEFT\")\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"math\"\n)\n\nfunc scanInt(scanner *bufio.Scanner) int {\n\tscanner.Scan()\n\tx, _ := strconv.Atoi(scanner.Text())\n\treturn x\n}\n\nfunc sign(x int) int {\n\ty := x\n\tif (y == 0) {\n\t\treturn 0\n\t}\n\tif (y < 0) {\n\t\treturn -1\n\t}\n\treturn 1\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tax, ay := scanInt(scanner), scanInt(scanner)\n\tbx, by := scanInt(scanner), scanInt(scanner)\n\tcx, cy := scanInt(scanner), scanInt(scanner)\n\tx0, y0 := float64(bx-ax), float64(by-ay)\n\tl0 := math.Hypot(x0, y0)\n\tx0 /= l0\n\ty0 /= l0\n\tx1, y1 := float64(cx-bx), float64(cy-by)\n\tl1 := math.Hypot(x1, y1)\n\tx1 /= l1\n\ty1 /= l1\n\t//writer.WriteString(fmt.Sprintf(\"(%.8f, %.8f) (%.8f, %.8f), dot product = %.8f\\n\",\n\t//\t\tx0, y0, x1, y1, x0*x1 + y0*y1))\n\tif x1 == x0 && y1 == y0 {\n\t\twriter.WriteString(\"TOWARDS\\n\")\n\t} else if x1 == -y0 && y1 == x0 {\n\t\twriter.WriteString(\"LEFT\\n\")\n\t} else {\n\t\twriter.WriteString(\"RIGHT\\n\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n)\n\nfunc scanInt(scanner *bufio.Scanner) int {\n\tscanner.Scan()\n\tx, _ := strconv.Atoi(scanner.Text())\n\treturn x\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tax, ay := scanInt(scanner), scanInt(scanner)\n\tbx, by := scanInt(scanner), scanInt(scanner)\n\tcx, cy := scanInt(scanner), scanInt(scanner)\n\tx0, y0 := bx-ax, by-ay\n\tx1, y1 := cx-bx, cy-by\n\tcross := x0*y1 - x1*y0\n\tif cross == 0 {\n\t\twriter.WriteString(\"TOWARDS\\n\")\n\t} else if cross > 0 {\n\t\twriter.WriteString(\"LEFT\\n\")\n\t} else {\n\t\twriter.WriteString(\"RIGHT\\n\")\n\t}\n}\n"}], "src_uid": "f6e132d1969863e9f28c87e5a44c2b69"} {"nl": {"description": "Let's denote a function $$$f(x)$$$ in such a way: we add $$$1$$$ to $$$x$$$, then, while there is at least one trailing zero in the resulting number, we remove that zero. For example, $$$f(599) = 6$$$: $$$599 + 1 = 600 \\rightarrow 60 \\rightarrow 6$$$; $$$f(7) = 8$$$: $$$7 + 1 = 8$$$; $$$f(9) = 1$$$: $$$9 + 1 = 10 \\rightarrow 1$$$; $$$f(10099) = 101$$$: $$$10099 + 1 = 10100 \\rightarrow 1010 \\rightarrow 101$$$. We say that some number $$$y$$$ is reachable from $$$x$$$ if we can apply function $$$f$$$ to $$$x$$$ some (possibly zero) times so that we get $$$y$$$ as a result. For example, $$$102$$$ is reachable from $$$10098$$$ because $$$f(f(f(10098))) = f(f(10099)) = f(101) = 102$$$; and any number is reachable from itself.You are given a number $$$n$$$; your task is to count how many different numbers are reachable from $$$n$$$.", "input_spec": "The first line contains one integer $$$n$$$ ($$$1 \\le n \\le 10^9$$$).", "output_spec": "Print one integer: the number of different numbers that are reachable from $$$n$$$.", "sample_inputs": ["1098", "10"], "sample_outputs": ["20", "19"], "notes": "NoteThe numbers that are reachable from $$$1098$$$ are:$$$1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1098, 1099$$$."}, "positive_code": [{"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc f(i int) int {\n i += 1\n for i%10 == 0 {\n i /= 10\n }\n return i\n}\n\nfunc main() {\n var N int\n fmt.Scan(&N)\n set := make(map[int]bool)\n cnt := 1\n set[N] = true\n for {\n N = f(N)\n if set[N] {\n break\n }\n set[N] = true\n cnt+=1\n }\n fmt.Println(cnt)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc Reachable_number(n int) int {\n\tcnt := 0\n\tfor n > 0 {\n\t\tcnt++\n\t\tif n < 10 {\n\t\t\tcnt += 8\n\t\t\tbreak\n\t\t} else {\n\t\t\tn++\n\t\t}\n\t\tfor n%10 == 0 {\n\t\t\tn /= 10\n\t\t}\n\t}\n\treturn cnt\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\\n\", &n)\n\tfmt.Printf(\"%d\\n\", Reachable_number(n))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tcnt := 0\n\tfmt.Scanf(\"%d\\n\", &n)\n\tfor n > 0 {\n\t\tcnt++\n\t\tif n < 10 {\n\t\t\tcnt += 8\n\t\t\tbreak\n\t\t} else {\n\t\t\tn++\n\t\t}\n\t\tfor n%10 == 0 {\n\t\t\tn /= 10\n\t\t}\n\t\t// fmt.Printf(\"%d\\n\", n)\n\t}\n\tfmt.Printf(\"%d\\n\", cnt)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x int\n\t_, _ = fmt.Scanf(\"%d\", &x)\n\n\tres := 1\n\n\tnumbers := map[int]bool{x: true}\n\n\tfor {\n\t\tx += 1\n\n\t\tfor x % 10 == 0 {\n\t\t\tx = x / 10\n\t\t}\n\n\t\tif _, ok := numbers[x]; ok {\n\t\t\tbreak\n\t\t}\n\n\t\tnumbers[x] = true\n\t\tres += 1\n\t}\n\n\tfmt.Println(res)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nvar n int\n\nfunc main() {\n\tfmt.Scanf(\"%d\", &n)\n\n\tans := 0\n\n\tfor n >= 10 {\n\t\tlast := 10 - n%10\n\n\t\tans = (ans + last)\n\t\tn = n + last\n\n\t\tfor n%10 == 0 {\n\t\t\tn = n / 10\n\t\t}\n\n\t}\n\n\tfmt.Println(ans + 9)\n}\n"}, {"source_code": "// ProblemURL : https://codeforces.com/problemset/problem/1157/A\n// ---------------------------------------------\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x int64\n\tfmt.Scan(&x)\n\tm := make(map[int64]bool, 1e5)\n\tf := func(x int64) int64 {\n\t\tx++\n\t\tfor x%10 == 0 {\n\t\t\tx /= 10\n\t\t}\n\t\treturn x\n\t}\n\tm[x] = true\n\tfor {\n\t\tx = f(x)\n\t\tif _, exists := m[x]; exists {\n\t\t\tbreak\n\t\t}\n\t\tm[x] = true\n\t}\n\tfmt.Println(len(m))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc solve(n int) int {\n\tm := map[int]bool{}\n\tm[n] = true\n\n\tfor ok := false; !ok; {\n\n\t\tn++\n\n\t\tfor n > 0 && n%10 == 0 {\n\t\t\tn /= 10\n\t\t}\n\n\t\tok = m[n]\n\t\tm[n] = true\n\t}\n\n\treturn len(m)\n}\n\nfunc main() {\n\tvar n int\n\n\tfmt.Scan(&n)\n\n\tans := solve(n)\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\",&n)\n\tvar i int\n\ti = n\n\tm := map[int]bool{}\n\tfor true{\n\t\tif(m[i] == false) {\n\t\tm[i] = true\n\t\ti ++\n\t\tfor i % 10 == 0{\n\t\t\ti /= 10\n\t\t}\n\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\n\t}\n\tfmt.Println(len(m))\n\n\n\n\n\n\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar i int\n\tfmt.Scanf(\"%d\", &i)\n\tj := i\n\tm := make(map[int]int)\n\tfor m[1] < 2 {\n\t\ti += 1\n\t\tfor i % 10 == 0 {\n\t\t\ti /= 10\n\t\t}\n\t\tm[i] += 1\n\t\t// fmt.Println(i)\n\t}\n\tm[j] += 1\n\tfmt.Println(len(m))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int;\n\tcnt := 0\n\tfmt.Scanf ( \"%d\", &n )\n\tfor n % 10 != n {\n\t\tcnt++\n\t\tn++\n\t\tfor n % 10 == 0 {\n\t\t\tn /= 10\n\t\t}\n\t}\n\n\tcnt += 9;\n\n\tfmt.Println ( cnt )\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\n// var input, inputerr = os.Open(\"./input\")\n// var output, outputerr = os.Create(\"./output\")\n// var reader = bufio.NewReader(input)\n// var writer = bufio.NewWriter(output)\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc scan(a ...interface{}) { fmt.Fscan(reader, a...) }\n\nfunc min(a ...int) int {\n\tmin := -1\n\tfor _, val := range a {\n\t\tif val < min {\n\t\t\tmin = val\n\t\t}\n\t}\n\treturn min\n}\n\nfunc max(a ...int) int {\n\tmax := -1\n\tfor _, val := range a {\n\t\tif val > max {\n\t\t\tmax = val\n\t\t}\n\t}\n\treturn max\n}\n\nfunc tr(n int) int {\n\tfor n%10 == 0 {\n\t\tn = n / 10\n\t}\n\treturn n\n}\n\nfunc main() {\n\tdefer writer.Flush() // STDOUT MUST BE FLUSHED MANUALLY!!!\n\tvar n int\n\tscan(&n)\n\tcnt := 0\n\tm := map[int]bool{}\n\n\tfor {\n\t\tif m[n] == false {\n\t\t\tm[n] = true\n\t\t\tcnt++\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t\tn++\n\t\tn = tr(n)\n\t}\n\tprint(cnt)\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc f(i int) int {\n i += 1\n for i%10 == 0 {\n i /= 10\n }\n return i\n}\n\nfunc main() {\n var N int\n fmt.Scan(&N)\n set := make(map[int]bool)\n cnt := 1\n for {\n N = f(N)\n if set[N] {\n break\n }\n set[N] = true\n cnt+=1\n }\n fmt.Println(cnt)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x int\n\t_, _ = fmt.Scanf(\"%d\", &x)\n\n\tres := 1\n\n\tfor x != 1 {\n\t\tx += 1\n\n\t\tfor x % 10 == 0 {\n\t\t\tx = x / 10\n\t\t}\n\n\t\tres += 1\n\t}\n\n\tfmt.Println(res)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x int\n\t_, _ = fmt.Scanf(\"%d\", &x)\n\n\tres := 1\n\n\tif x == 1 {\n\t\tfmt.Println(9)\n\t\treturn\n\t}\n\n\tfor x != 1 {\n\t\tx += 1\n\n\t\tfor x % 10 == 0 {\n\t\t\tx = x / 10\n\t\t}\n\n\t\tres += 1\n\t}\n\n\tfmt.Println(res)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x int64\n\tfmt.Scan(&x)\n\tm := make(map[int64]bool, 1e5)\n\tf := func(x int64) int64 {\n\t\tx++\n\t\tfor x%10 == 0 {\n\t\t\tx /= 10\n\t\t}\n\t\treturn x\n\t}\n\tm[x] = true\n\tfor {\n\t\tx = f(x)\n\t\tm[x] = true\n\t\tif x == 1 {\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(len(m))\n}\n"}, {"source_code": "package main\n\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int32\n\tfmt.Scanf(\"%d\",&n)\n\tvar i int32\n\ti = n\n\tm := map[int32]bool{}\n\tm[i] = true\n\ti ++\n\tm[1] = true\n\tfor true{\n\t\tif(i == 10){\n\t\t\tbreak\n\t\t}\n\t\tif i % 10 == 0 {\n\t\t\tfor i % 10 == 0{\n\t\t\t\ti /= 10\n\t\t\t}\n\t\t}\n\t\tm[i] = true\n\t\ti ++\n\n\t}\n\tfmt.Println(len(m))\n\n\n\n\n\n\n\n}\n"}, {"source_code": "package main\n\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int32\n\tfmt.Scanf(\"%d\",&n)\n\tvar i int32\n\ti = n\n\tvar ans int32\n\ti ++\n\tans += 2\n\tfor true{\n\t\tif(i == 10){\n\t\t\tbreak\n\t\t}\n\t\tif i % 10 == 0 {\n\t\t\tfor i % 10 == 0{\n\t\t\t\ti /= 10\n\t\t\t}\n\t\t}\n\t\ti ++\n\t\tans ++\n\t}\n\tfmt.Println(ans)\n\n\n\n\n}\n"}, {"source_code": "package main\n\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int32\n\tfmt.Scanf(\"%d\",&n)\n\tvar i int32\n\ti = n\n\tm := map[int32]bool{}\n\tm[i] = true\n\ti ++\n\tfor true{\n\t\tif(i == 10){\n\t\t\tbreak\n\t\t}\n\t\tif i % 10 == 0 {\n\n\t\t\tfor i % 10 == 0{\n\t\t\t\tm[i] = true\n\t\t\t\ti /= 10\n\n\t\t\t}\n\t\t}\n\t\tm[i] = true\n\t\ti ++\n\n\t}\n\tfmt.Println(len(m))\n\n\n\n\n\n}\n"}, {"source_code": "package main\n\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int32\n\tfmt.Scanf(\"%d\",&n)\n\tvar i int32\n\ti = n\n\tm := map[int32]bool{}\n\tm[i] = true\n\ti ++\n\tfor true{\n\t\tif(i == 10){\n\t\t\tbreak\n\t\t}\n\t\tif i % 10 == 0 {\n\n\t\t\tfor i % 10 == 0{\n\t\t\t\ti /= 10\n\t\t\t}\n\t\t}\n\t\tm[i] = true\n\t\ti ++\n\n\t}\n\tfmt.Println(len(m) + 1)\n\n\n\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar i int\n\tfmt.Scanf(\"%d\", &i)\n\tj := i\n\tm := make(map[int]int)\n\tfor m[1] == 0 || i == 1 {\n\t\ti += 1\n\t\tfor i % 10 == 0 {\n\t\t\ti /= 10\n\t\t}\n\t\tm[i] += 1\n\t}\n\tm[j] += 1\n\tfmt.Println(len(m))\n}\n"}], "src_uid": "055fbbde4b9ffd4473e6e716da6da899"} {"nl": {"description": "You are given a string $$$s$$$ consisting of lowercase Latin letters. Let the length of $$$s$$$ be $$$|s|$$$. You may perform several operations on this string.In one operation, you can choose some index $$$i$$$ and remove the $$$i$$$-th character of $$$s$$$ ($$$s_i$$$) if at least one of its adjacent characters is the previous letter in the Latin alphabet for $$$s_i$$$. For example, the previous letter for b is a, the previous letter for s is r, the letter a has no previous letters. Note that after each removal the length of the string decreases by one. So, the index $$$i$$$ should satisfy the condition $$$1 \\le i \\le |s|$$$ during each operation.For the character $$$s_i$$$ adjacent characters are $$$s_{i-1}$$$ and $$$s_{i+1}$$$. The first and the last characters of $$$s$$$ both have only one adjacent character (unless $$$|s| = 1$$$).Consider the following example. Let $$$s=$$$ bacabcab. During the first move, you can remove the first character $$$s_1=$$$ b because $$$s_2=$$$ a. Then the string becomes $$$s=$$$ acabcab. During the second move, you can remove the fifth character $$$s_5=$$$ c because $$$s_4=$$$ b. Then the string becomes $$$s=$$$ acabab. During the third move, you can remove the sixth character $$$s_6=$$$'b' because $$$s_5=$$$ a. Then the string becomes $$$s=$$$ acaba. During the fourth move, the only character you can remove is $$$s_4=$$$ b, because $$$s_3=$$$ a (or $$$s_5=$$$ a). The string becomes $$$s=$$$ acaa and you cannot do anything with it. Your task is to find the maximum possible number of characters you can remove if you choose the sequence of operations optimally.", "input_spec": "The only line of the input contains one integer $$$|s|$$$ ($$$1 \\le |s| \\le 100$$$) — the length of $$$s$$$. The second line of the input contains one string $$$s$$$ consisting of $$$|s|$$$ lowercase Latin letters.", "output_spec": "Print one integer — the maximum possible number of characters you can remove if you choose the sequence of moves optimally.", "sample_inputs": ["8\nbacabcab", "4\nbcda", "6\nabbbbb"], "sample_outputs": ["4", "3", "5"], "notes": "NoteThe first example is described in the problem statement. Note that the sequence of moves provided in the statement is not the only, but it can be shown that the maximum possible answer to this test is $$$4$$$.In the second example, you can remove all but one character of $$$s$$$. The only possible answer follows. During the first move, remove the third character $$$s_3=$$$ d, $$$s$$$ becomes bca. During the second move, remove the second character $$$s_2=$$$ c, $$$s$$$ becomes ba. And during the third move, remove the first character $$$s_1=$$$ b, $$$s$$$ becomes a. "}, "positive_code": [{"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 canRemove(i int, s []byte, n int) bool {\n\tok := false\n\tif i > 0 && s[i] > 'a' && s[i-1]-'a' == (s[i]-'a'-1) {\n\t\tok = true\n\t}\n\tif i+1 < n && s[i] > 'a' && s[i+1]-'a' == (s[i]-'a'-1) {\n\t\tok = true\n\t}\n\treturn ok\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\ts := NextBytes()\n\tvar removed int\n\tfor {\n\t\tremoval := -1\n\t\tfor ch := 26; removal == -1 && ch >= 0; ch-- {\n\t\t\tfor i := 0; removal == -1 && i < n; i++ {\n\t\t\t\tif s[i] == byte(ch+'a') && canRemove(i, s, n) {\n\t\t\t\t\tremoval = i\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif removal == -1 {\n\t\t\tbreak\n\t\t}\n\t\ts = append(s[:removal], s[removal+1:]...)\n\t\tremoved++\n\t\tn--\n\t\t// stderr(\"parti\", string(s), n)\n\t}\n\tfmt.Fprintln(out, removed)\n}\n"}, {"source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/1321/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 int\n\tS []rune\n)\n\nfunc main() {\n\tn = ReadInt()\n\tS = ReadRuneSlice()\n\n\tans := 0\n\tfor len(S) > 1 {\n\t\tnext := false\n\t\tmaxR := rune(0)\n\t\tidx := -1\n\n\t\tfor i := 0; i < len(S); i++ {\n\t\t\tif i == 0 && S[i]-S[i+1] == 1 {\n\t\t\t\tif ChMax(&maxR, S[i]) {\n\t\t\t\t\tidx = i\n\t\t\t\t}\n\n\t\t\t\tnext = true\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif i == len(S)-1 && S[i]-S[i-1] == 1 {\n\t\t\t\tif ChMax(&maxR, S[i]) {\n\t\t\t\t\tidx = i\n\t\t\t\t}\n\n\t\t\t\tnext = true\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif 0 < i && i < len(S)-1 && (S[i]-S[i-1] == 1 || S[i]-S[i+1] == 1) {\n\t\t\t\tif ChMax(&maxR, S[i]) {\n\t\t\t\t\tidx = i\n\t\t\t\t}\n\n\t\t\t\tnext = true\n\t\t\t}\n\t\t}\n\n\t\tif next {\n\t\t\tans++\n\t\t\ttmp := []rune{}\n\t\t\tfor i := 0; i < len(S); i++ {\n\t\t\t\tif i == idx {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\ttmp = append(tmp, S[i])\n\t\t\t}\n\n\t\t\tS = tmp\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfmt.Println(ans)\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 *rune, target rune) bool {\n\tif *updatedValue < target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\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"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tr := bufio.NewReader(os.Stdin)\n\n\tvar n int\n\tfmt.Fscanf(r, \"%d\\n\", &n)\n\n\tvar s string\n\tfmt.Fscanf(r, \"%s\\n\", &s)\n\n\tdeleted := make(map[int]bool)\n\n\tcount := 0\n\tfor ch := byte('z'); ch >= 'a'; ch-- {\n\t\tfor i, _ := range s {\n\t\t\tcur := s[i]\n\t\t\tif cur != ch {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tcan := false\n\n\t\t\tj := i\n\t\t\tfor j >= 0 && (deleted[j] || s[j] == cur) {\n\t\t\t\tj--\n\t\t\t}\n\t\t\tif j >= 0 && s[j]+1 == cur {\n\t\t\t\tcan = true\n\t\t\t}\n\n\t\t\tj = i\n\t\t\tfor j < n && (deleted[j] || s[j] == cur) {\n\t\t\t\tj++\n\t\t\t}\n\t\t\tif j < n && s[j]+1 == cur {\n\t\t\t\tcan = true\n\t\t\t}\n\n\t\t\tif can {\n\t\t\t\tdeleted[i] = true\n\t\t\t\tcount++\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Printf(\"%d\\n\", count)\n}\n\nfunc min(a, b byte) byte {\n\tif a <= b {\n\t\treturn a\n\t}\n\treturn b\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc run(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tvar n int\n\tvar s []byte\n\tFscan(in, &n, &s)\n\n\tif n == 1 {\n\t\tFprintln(out, 0)\n\t\treturn\n\t}\n\ts = append([]byte{0}, s...)\n\ts = append(s, 0)\n\n\tans := 0\n\t//s2 := []byte{}\n\t//for i := byte('z'); i >= 'a'; i-- {\n\t//\tlp := 0\n\t//\tfor j, b := range s {\n\t//\t\t//if j > 0 && lc == 0 {\n\t//\t\t//\tlc = s[j-1]\n\t//\t\t//}\n\t//\t\tif b == i && (s[j]-1 == s[lp] || s[j]-1 == s[j+1]) {\n\t//\t\t\tans++\n\t//\n\t//\t\t} else {\n\t//\t\t\ts2 = append(s2, b)\n\t//\t\t\tlp = j\n\t//\t\t}\n\t//\t}\n\t//\ts = s2\n\t//\ts2 = []byte{}\n\t//}\n\n\tfor curB := byte('z'); curB >= 'a'; curB-- {\n\t\tfor {\n\t\t\tdel := false\n\t\t\tfor i, b := range s {\n\t\t\t\tif b == curB && (s[i]-1 == s[i-1] || s[i]-1 == s[i+1]) {\n\t\t\t\t\tans++\n\t\t\t\t\tdel = true\n\t\t\t\t\ts = append(s[:i], s[i+1:]...)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !del {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tFprintln(out, ans)\n}\n\nfunc main() { run(os.Stdin, os.Stdout) }\n"}, {"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 CF1321C(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tvar n, ans int\n\tvar s []byte\n\tFscan(in, &n, &s)\n\ts = append([]byte{0}, s...)\n\ts = append(s, 0)\n\tfor curB := byte('z'); curB >= 'a'; curB-- {\n\touter:\n\t\tfor {\n\t\t\tfor i, b := range s {\n\t\t\t\tif b == curB && (b-1 == s[i-1] || b-1 == s[i+1]) {\n\t\t\t\t\tans++\n\t\t\t\t\ts = append(s[:i], s[i+1:]...)\n\t\t\t\t\tcontinue outer\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\tFprint(out, ans)\n}\n\nfunc main() { CF1321C(os.Stdin, os.Stdout) }\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tvar s string\n\tfmt.Scan(&n, &s)\n\trls := solve(n, s)\n\tfmt.Println(rls)\n}\n\nfunc solve(n int, s string) int {\n\tchs := []rune(s)\n\tfor ch := 'z'; ch > 'a'; ch-- {\n\t\tfor i := 1; i < len(chs); i++ {\n\t\t\tfor i < len(chs) && chs[i] == ch && chs[i-1] == ch-1 {\n\t\t\t\tchs = append(chs[:i], chs[i+1:]...)\n\t\t\t}\n\t\t}\n\t\tfor i := len(chs) - 2; i >= 0; i-- {\n\t\t\tif i+1 < len(chs) && chs[i] == ch && chs[i+1] == ch-1 {\n\t\t\t\tchs = append(chs[:i], chs[i+1:]...)\n\t\t\t}\n\t\t}\n\t}\n\treturn len(s) - len(chs)\n}\n"}, {"source_code": "// Author: sighduck\n// URL: https://codeforces.com/problemset/problem/1321/C\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Solve(n int, s string) int {\n\tc := 0\n\tletters := \"abcdefghijklmnopqrstuvwxyz\"\n\ta := []byte(s)\n\ti := 25\n\tflag := false\n\tfor i > 0 {\n\t\tl := letters[i]\n\t\tp := letters[i-1]\n\t\tfor j, elem := range a {\n\t\t\tif elem == l && ((j-1 >= 0 && a[j-1] == p) || (j+1 < len(a) && a[j+1] == p)) {\n\t\t\t\ta = append(a[:j], a[j+1:]...)\n\t\t\t\tc += 1\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\ti -= 1\n\t\t}\n\t\tflag = false\n\t}\n\treturn c\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n int\n\tvar s string\n\tfmt.Fscanf(reader, \"%d\\n%s\\n\", &n, &s)\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(n, s))\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\tr := bufio.NewReader(os.Stdin)\n\n\tvar n int\n\tfmt.Fscanf(r, \"%d\\n\", &n)\n\n\tvar s string\n\tfmt.Fscanf(r, \"%s\\n\", &s)\n\n\tcount := 0\n\n\tredo := true\n\tfor redo {\n\t\tredo = false\n\t\tmp := make(map[int]bool)\n\t\tfor i := 0; i < len(s)-1; i++ {\n\t\t\tif s[i] == s[i+1]+1 {\n\t\t\t\tfor i < len(s)-1 && s[i] == s[i+1]+1 {\n\t\t\t\t\tmp[i] = true\n\t\t\t\t\tredo = true\n\t\t\t\t\tcount++\n\t\t\t\t\ti++\n\t\t\t\t}\n\t\t\t} else if s[i] == s[i+1]-1 {\n\t\t\t\tfor i < len(s)-1 && s[i] == s[i+1]-1 {\n\t\t\t\t\tmp[i+1] = true\n\t\t\t\t\tredo = true\n\t\t\t\t\tcount++\n\t\t\t\t\ti++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tb := new(strings.Builder)\n\t\tfor i := 0; i < len(s); i++ {\n\t\t\tif !mp[i] {\n\t\t\t\tfmt.Fprintf(b, \"%c\", s[i])\n\t\t\t}\n\t\t}\n\n\t\ts = b.String()\n\t}\n\n\tfmt.Printf(\"%d\\n\", count)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc run(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tvar n int\n\tvar s []byte\n\tFscan(in, &n, &s)\n\n\tif n == 1 {\n\t\tFprintln(out, 0)\n\t\treturn\n\t}\n\n\tdp := make([][][26][26]int, n)\n\tfor _i := range dp {\n\t\tdp[_i] = make([][26][26]int, n)\n\t\tfor _j := range dp[_i] {\n\t\t\tfor i := range dp[_i][_j] {\n\t\t\t\tfor j := range dp[_i][_j][i] {\n\t\t\t\t\tdp[_i][_j][i][j] = -1\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\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 f func(l, r int, lc, rc byte) int\n\tf = func(l, r int, lc, rc byte) (_ans int) {\n\t\tif l == 0 &&r==1 {\n\t\t\tprint()\n\t\t}\n\n\t\tdv := &dp[l][r][lc-'a'][rc-'a']\n\t\tif *dv >= 0 {\n\t\t\treturn *dv\n\t\t}\n\t\tdefer func() { *dv = _ans }()\n\n\t\tif l == r {\n\t\t\tif s[l]-1 == lc || s[l]-1 == rc {\n\t\t\t\treturn 1\n\t\t\t}\n\t\t\treturn 0\n\t\t}\n\n\t\tfor i := l; i <= r; i++ {\n\t\t\tif i == l {\n\t\t\t\tif s[l]-1 == lc || s[l]-1 == s[l+1] {\n\t\t\t\t\tv := f(l+1, r, lc, rc)\n\t\t\t\t\t_ans = max(_ans, v+1)\n\t\t\t\t}\n\t\t\t} else if i == r {\n\t\t\t\tif s[r]-1 == rc || s[r]-1 == s[r-1] {\n\t\t\t\t\tv := f(l, r-1, lc, rc)\n\t\t\t\t\t_ans = max(_ans, v+1)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif s[i]-1 == s[i-1] || s[i]-1 == s[i+1] {\n\t\t\t\t\tv1 := f(l, i-1, lc, s[i+1])\n\t\t\t\t\tv2 := f(i+1, r, s[i-1], rc)\n\t\t\t\t\t_ans = max(_ans, v1+v2+1)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn\n\t}\n\n\tans := f(0, n-1, 'z', 'z')\n\tFprintln(out, ans)\n\n}\n\nfunc main() { run(os.Stdin, os.Stdout) }\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc run(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tvar n int\n\tvar s []byte\n\tFscan(in, &n, &s)\n\n\tif n == 1 {\n\t\tFprintln(out, 0)\n\t\treturn\n\t}\n\ts = append([]byte{0}, s...)\n\ts = append(s, 0)\n\n\tans := 0\n\ts2 := []byte{}\n\tfor i := byte('z'); i >= 'a'; i-- {\n\t\tlp := 0\n\t\tfor j, b := range s {\n\t\t\t//if j > 0 && lc == 0 {\n\t\t\t//\tlc = s[j-1]\n\t\t\t//}\n\t\t\tif b == i && (s[j]-1 == s[lp] || s[j]-1 == s[j+1]) {\n\t\t\t\tans++\n\n\t\t\t} else {\n\t\t\t\ts2 = append(s2, b)\n\t\t\t\tlp = j\n\t\t\t}\n\t\t}\n\t\ts = s2\n\t\ts2 = []byte{}\n\t}\n\n\tFprintln(out, ans)\n\n}\n\nfunc main() { run(os.Stdin, os.Stdout) }\n"}, {"source_code": "// Author: sighduck\n// URL: https://codeforces.com/problemset/problem/1321/C\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Range(arr []int) (int, int) {\n\tmax := arr[0]\n\tmin := arr[0]\n\tfor _, elem := range arr {\n\t\tif elem > max {\n\t\t\tmax = elem\n\t\t}\n\t\tif elem < min {\n\t\t\tmin = elem\n\t\t}\n\t}\n\treturn min, max\n}\n\nfunc Abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc _Solve(arr []int, moves int, min int, max int, current int, n int) int {\n\tif n == 1 || current == min-1 {\n\t\treturn moves\n\t}\n\tnewArr := []int{}\n\tremoved := false\n\tfor i := 0; i < n; i++ {\n\t\tif removed && arr[i] == current {\n\t\t\tmoves += 1\n\t\t\tremoved = true\n\t\t} else if arr[i] == current && i+1 < n && Abs(arr[i+1]-current) == 1 {\n\t\t\tmoves += 1\n\t\t\tremoved = true\n\t\t} else if arr[i] == current && i-1 >= 0 && Abs(arr[i-1]-current) == 1 {\n\t\t\tmoves += 1\n\t\t\tremoved = true\n\t\t} else {\n\t\t\tnewArr = append(newArr, arr[i])\n\t\t\tremoved = false\n\t\t}\n\t}\n\treturn _Solve(newArr, moves, min, max, current-1, len(newArr))\n}\n\nfunc Solve(n int, s string) int {\n\tarr := make([]int, n)\n\tfor i, elem := range s {\n\t\tarr[i] = int(elem)\n\t}\n\tmin, max := Range(arr)\n\treturn _Solve(arr, 0, min, max, max, n)\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n int\n\tvar s string\n\tfmt.Fscanf(reader, \"%d\\n%s\\n\", &n, &s)\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(n, s))\n}\n"}, {"source_code": "// Author: sighduck\n// URL: https://codeforces.com/problemset/problem/1321/C\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Solve(n int, s string) int {\n\ta := make([]int, n)\n\tfor i, elem := range s {\n\t\ta[i] = int(elem)\n\t}\n\tfor i := 122; i >= 97; i-- {\n\t\tfor j := 0; j < len(a); j++ {\n\t\t\tif a[j] == i && ((j+1 < len(a) && a[j+1] == i-1) || (j-1 >= 0 && a[j-1] == i-1)) {\n\t\t\t\ta = append(a[:j], a[j+1:]...)\n\t\t\t\tj -= 1\n\t\t\t}\n\t\t}\n\t}\n\treturn n - len(a)\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n int\n\tvar s string\n\tfmt.Fscanf(reader, \"%d\\n%s\\n\", &n, &s)\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(n, s))\n}\n"}, {"source_code": "// Author: sighduck\n// URL: https://codeforces.com/problemset/problem/1321/C\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\ntype Group struct {\n\tcount int\n\telem int\n}\n\nfunc group(a []int) []Group {\n\tgroups := []Group{}\n\tfor i, elem := range a {\n\t\tif i == 0 {\n\t\t\tgroups = append(groups, Group{count: 1, elem: elem})\n\t\t} else if groups[len(groups)-1].elem == elem {\n\t\t\tgroups[len(groups)-1].count += 1\n\t\t} else {\n\t\t\tgroups = append(groups, Group{count: 1, elem: elem})\n\t\t}\n\t}\n\treturn groups\n}\n\nfunc _Solve(groups []Group, current int, min int, moves int) int {\n\tif current == min-1 {\n\t\treturn moves\n\t}\n\tnewGroups := []Group{}\n\tfor i, group := range groups {\n\t\tif group.elem == current && i+1 < len(groups) && groups[i+1].elem == current-1 {\n\t\t\tmoves += group.count\n\t\t} else if group.elem == current && i-1 >= 0 && groups[i-1].elem == current-1 {\n\t\t\tmoves += group.count\n\t\t} else {\n\t\t\tnewGroups = append(newGroups, group)\n\t\t}\n\t}\n\treturn _Solve(newGroups, current-1, min, moves)\n}\n\nfunc Solve(n int, s string) int {\n\ta := make([]int, n)\n\tfor i, elem := range s {\n\t\ta[i] = int(elem)\n\t}\n\tgroups := group(a)\n\treturn _Solve(groups, 122, 97, 0)\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n int\n\tvar s string\n\tfmt.Fscanf(reader, \"%d\\n%s\\n\", &n, &s)\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(n, s))\n}\n"}], "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38"} {"nl": {"description": "Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills.Her problem is following: for given string, consisting of only 0 and 1, tell if it's possible to remove some digits in such a way, that remaining number is a representation of some positive integer, divisible by 64, in the binary numerical system.", "input_spec": "In the only line given a non-empty binary string s with length up to 100.", "output_spec": "Print «yes» (without quotes) if it's possible to remove digits required way and «no» otherwise.", "sample_inputs": ["100010001", "100"], "sample_outputs": ["yes", "no"], "notes": "NoteIn the first test case, you can get string 1 000 000 after removing two ones which is a representation of number 64 in the binary numerical system.You can read more about binary numeral system representation here: https://en.wikipedia.org/wiki/Binary_system"}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc I(i ...interface{}) error {\n\t_, err := fmt.Fscan(r, i...)\n\treturn err\n}\n\nfunc O(o ...interface{}) {\n\tfmt.Fprint(w, o...)\n}\n\nfunc readInt() int {\n\tvar o, neg bool\n\tvar i int\n\tb, err := r.ReadByte()\n\tfor err == nil {\n\t\tif b != ' ' && b != '\\n' && b != '\\r' {\n\t\t\tif b == '-' {\n\t\t\t\tneg = true\n\t\t\t} else {\n\t\t\t\ti = i*10 + int(b) - 48\n\t\t\t\to = true\n\t\t\t}\n\t\t} else if o {\n\t\t\tbreak\n\t\t}\n\t\tb, err = r.ReadByte()\n\t}\n\tif neg {\n\t\treturn -i\n\t}\n\treturn i\n}\n\nfunc writeInt(i int) {\n\tif i < 0 {\n\t\tw.WriteByte('-')\n\t\ti = -i\n\t}\n\tif i < 10 {\n\t\tw.WriteByte(byte(i + 48))\n\t\treturn\n\t}\n\tvar tmp, count int\n\ttmp = i\n\tfor tmp%10 == 0 {\n\t\ttmp /= 10\n\t\tcount++\n\t}\n\ttmp = 0\n\tfor i != 0 {\n\t\ttmp = tmp*10 + (i % 10)\n\t\ti /= 10\n\t}\n\tfor tmp != 0 {\n\t\tw.WriteByte(byte((tmp % 10) + 48))\n\t\ttmp /= 10\n\t}\n\tfor count > 0 {\n\t\tcount--\n\t\tw.WriteByte('0')\n\t}\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.goC\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tvar s string\n\tfor I(&s) == nil {\n\t\tsolve(s)\n\t}\n\tw.Flush()\n}\n\nfunc solve(s string) {\n\tfor i := range s {\n\t\tif s[i] == '1' && strings.Count(s[i:], \"0\") > 5 {\n\t\t\tO(\"yes\\n\")\n\t\t\treturn\n\t\t}\n\t}\n\tO(\"no\\n\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar local = false\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tsetup()\n\tresult := false\n\tinp := readString()\n\tzeroes := 0\n\tfor i := len(inp) - 1; i >= 0; i-- {\n\t\tif inp[i] == '0' {\n\t\t\tzeroes++\n\t\t}\n\n\t\tif inp[i] == '1' && zeroes >= 6 {\n\t\t\tresult = true\n\t\t}\n\t}\n\n\tif result {\n\t\tfmt.Println(\"yes\")\n\t} else {\n\t\tfmt.Println(\"no\")\n\t}\n}\n\nfunc setup() {\n\tsource := os.Stdin\n\tif local == true {\n\t\tfile, _ := os.Open(\"input.txt\")\n\t\tsource = file\n\t}\n\tscanner = bufio.NewScanner(source)\n\tscanner.Split(bufio.ScanWords)\n}\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tstr string\n\t\tcnt int\n\t)\n\tfound := false\n\tfmt.Scanf(\"%s\", &str)\n\tfor i := range str {\n\t\tif str[i] == '1' {\n\t\t\tfound = true\n\t\t} else if str[i] == '0' && found {\n\t\t\tcnt++\n\t\t}\n\t}\n\tif cnt >= 6 {\n\t\tfmt.Println(\"yes\")\n\t} else {\n\t\tfmt.Println(\"no\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar input string\n\tfmt.Scanln(&input)\n\tvar count0, i int\n\tfor count0, i = 0, len(input)-1; i>=0; i-- {\n\t\tif input[i] == '0' {\n\t\t\tcount0++\n\t\t}\n\t\tif count0 == 6 {\n\t\t\tbreak\n\t\t}\n\t}\n\tfor i = i-1; i>=0; i-- {\n\t\tif input[i] == '1' {\n\t\t\tfmt.Println(\"yes\")\n\t\t\treturn \n\t\t}\n\t}\n\tfmt.Println(\"no\")\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar input string\n\tfmt.Scanf(\"%s\\n\", &input)\n\n\tcan := false\n\n\tzeros := 0\n\tfor i := len(input) - 1; i >= 0; i-- {\n\t\tif input[i] == '0' {\n\t\t\tzeros++\n\t\t} else if zeros >= 6 {\n\t\t\tcan = true\n\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif can {\n\t\tfmt.Println(\"yes\")\n\t} else {\n\t\tfmt.Println(\"no\")\n\t}\n}\n"}, {"source_code": "// Codeforces helper functions\n// 20 Jan 18\n// samadhi\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\t// fmt.Println(\"Hello, world!\")\n\tin := gsls(reader)[0]\n\n\tif strings.Count(in, \"0\") >= 6 && strings.Count(in[:len(in)-6], \"1\") > 0 {\n\t}\n\n\tif strings.Count(in, \"1\") > 0 && strings.Count(in[strings.Index(in, \"1\"):], \"0\") >= 6 {\n\t\tfmt.Println(\"yes\")\n\t} else {\n\t\tfmt.Println(\"no\")\n\t}\n\n}\n\n// Input helpers\n\n// If you don't pass in a reference to the reader, and just instantiate a new\n// one every time, it will work locally, with IO typed at human-speed, but not\n// on Codeforces.\n\n// Get Space-separated Line as Strings\n//\n// Example input:\n// 1 test 382.0\n// Example output:\n// [\"1\", \"test\", \"382.0\"]\n\nfunc gsls(reader *bufio.Reader) (arr []string) {\n\t// Get a full line\n\tinput, _ := reader.ReadString('\\n')\n\n\t//Strip newline and return chars, if any\n\tinput = strings.TrimSuffix(input, \"\\n\")\n\tinput = strings.TrimSuffix(input, \"\\r\")\n\n\t// Split at the spaces into an array\n\tarr = strings.Split(input, \" \")\n\n\treturn\n}\n\n// Get Space-separated Line as Integers\n// Any non-valid integers will be 0\n//\n// Example input:\n// test 1 12.3 -117\n// Example output:\n// [0, 1, 0, -117]\n\nfunc gsli(reader *bufio.Reader) (arr []int) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.Atoi(e)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Get Space-separated Line as 64-bit Floats\n// Any non-valid floats will be 0\n//\n// Example input:\n// test 128.328 12 -11.0\n// Example output:\n// [0, 128.328, 12, -11]\n\nfunc gslf(reader *bufio.Reader) (arr []float64) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.ParseFloat(e, 64)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Math helpers\n\n// Positve Modulo\n// Returns x mod y, but always positive\n\nfunc posMod(x, y int) int {\n\treturn (x%y + y) % y\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"os\"\nimport \"bufio\"\n\nvar s string\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &s)\n\ti := 0\n\tzero := 0\n\n\tfor i < len(s) {\n\t\tif s[i] == '1' { break }\n\t\ti++\n\t}\n\n\tfor i < len(s) {\n\t\tif s[i] == '0' {\n\t\t\tzero++\n\t\t}\n\t\ti++\n\t}\n\n\tif zero > 5 {\n\t\tfmt.Printf(\"yes\")\n\t\tos.Exit(0)\n\t}\n\tfmt.Printf(\"no\")\n}\n\n\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\ta := readString()\n\tcnt := 0\n\tfor i := len(a) - 1; i >= 0; i-- {\n\t\tif a[i] == '0' {\n\t\t\tcnt++\n\t\t\tif cnt == 6 {\n\t\t\t\tfor j := i - 1; j >= 0; j-- {\n\t\t\t\t\tif a[j] == '1' {\n\t\t\t\t\t\tfmt.Println(\"yes\")\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfmt.Println(\"no\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(\"no\")\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar input string\n\tfmt.Scanf(\"%s\\n\", &input)\n\n\tif len(input) >= 7 {\n\t\tfmt.Println(\"yes\")\n\t} else {\n\t\tfmt.Println(\"no\")\n\t}\n}\n"}, {"source_code": "// Codeforces helper functions\n// 20 Jan 18\n// samadhi\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\t// fmt.Println(\"Hello, world!\")\n\tin := gsls(reader)[0]\n\n\tif strings.Count(in, \"0\") < 6 {\n\t\tfmt.Println(\"no\")\n\t} else {\n\t\tfmt.Println(\"yes\")\n\t}\n\n}\n\n// Input helpers\n\n// If you don't pass in a reference to the reader, and just instantiate a new\n// one every time, it will work locally, with IO typed at human-speed, but not\n// on Codeforces.\n\n// Get Space-separated Line as Strings\n//\n// Example input:\n// 1 test 382.0\n// Example output:\n// [\"1\", \"test\", \"382.0\"]\n\nfunc gsls(reader *bufio.Reader) (arr []string) {\n\t// Get a full line\n\tinput, _ := reader.ReadString('\\n')\n\n\t//Strip newline and return chars, if any\n\tinput = strings.TrimSuffix(input, \"\\n\")\n\tinput = strings.TrimSuffix(input, \"\\r\")\n\n\t// Split at the spaces into an array\n\tarr = strings.Split(input, \" \")\n\n\treturn\n}\n\n// Get Space-separated Line as Integers\n// Any non-valid integers will be 0\n//\n// Example input:\n// test 1 12.3 -117\n// Example output:\n// [0, 1, 0, -117]\n\nfunc gsli(reader *bufio.Reader) (arr []int) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.Atoi(e)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Get Space-separated Line as 64-bit Floats\n// Any non-valid floats will be 0\n//\n// Example input:\n// test 128.328 12 -11.0\n// Example output:\n// [0, 128.328, 12, -11]\n\nfunc gslf(reader *bufio.Reader) (arr []float64) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.ParseFloat(e, 64)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Math helpers\n\n// Positve Modulo\n// Returns x mod y, but always positive\n\nfunc posMod(x, y int) int {\n\treturn (x%y + y) % y\n}\n"}, {"source_code": "// Codeforces helper functions\n// 20 Jan 18\n// samadhi\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\t// fmt.Println(\"Hello, world!\")\n\tin := gsls(reader)[0]\n\n\tif strings.Count(in, \"0\") >= 6 && strings.Count(in[:len(in)-6], \"1\") > 0 {\n\t\tfmt.Println(\"yes\")\n\t} else {\n\t\tfmt.Println(\"no\")\n\t}\n\n}\n\n// Input helpers\n\n// If you don't pass in a reference to the reader, and just instantiate a new\n// one every time, it will work locally, with IO typed at human-speed, but not\n// on Codeforces.\n\n// Get Space-separated Line as Strings\n//\n// Example input:\n// 1 test 382.0\n// Example output:\n// [\"1\", \"test\", \"382.0\"]\n\nfunc gsls(reader *bufio.Reader) (arr []string) {\n\t// Get a full line\n\tinput, _ := reader.ReadString('\\n')\n\n\t//Strip newline and return chars, if any\n\tinput = strings.TrimSuffix(input, \"\\n\")\n\tinput = strings.TrimSuffix(input, \"\\r\")\n\n\t// Split at the spaces into an array\n\tarr = strings.Split(input, \" \")\n\n\treturn\n}\n\n// Get Space-separated Line as Integers\n// Any non-valid integers will be 0\n//\n// Example input:\n// test 1 12.3 -117\n// Example output:\n// [0, 1, 0, -117]\n\nfunc gsli(reader *bufio.Reader) (arr []int) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.Atoi(e)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Get Space-separated Line as 64-bit Floats\n// Any non-valid floats will be 0\n//\n// Example input:\n// test 128.328 12 -11.0\n// Example output:\n// [0, 128.328, 12, -11]\n\nfunc gslf(reader *bufio.Reader) (arr []float64) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.ParseFloat(e, 64)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Math helpers\n\n// Positve Modulo\n// Returns x mod y, but always positive\n\nfunc posMod(x, y int) int {\n\treturn (x%y + y) % y\n}\n"}, {"source_code": "// Codeforces helper functions\n// 20 Jan 18\n// samadhi\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\t// fmt.Println(\"Hello, world!\")\n\tin := gsls(reader)[0]\n\n\tif strings.Count(in, \"0\") < 6 && strings.Count(in, \"0\") > 0 {\n\t\tfmt.Println(\"no\")\n\t} else {\n\t\tfmt.Println(\"yes\")\n\t}\n\n}\n\n// Input helpers\n\n// If you don't pass in a reference to the reader, and just instantiate a new\n// one every time, it will work locally, with IO typed at human-speed, but not\n// on Codeforces.\n\n// Get Space-separated Line as Strings\n//\n// Example input:\n// 1 test 382.0\n// Example output:\n// [\"1\", \"test\", \"382.0\"]\n\nfunc gsls(reader *bufio.Reader) (arr []string) {\n\t// Get a full line\n\tinput, _ := reader.ReadString('\\n')\n\n\t//Strip newline and return chars, if any\n\tinput = strings.TrimSuffix(input, \"\\n\")\n\tinput = strings.TrimSuffix(input, \"\\r\")\n\n\t// Split at the spaces into an array\n\tarr = strings.Split(input, \" \")\n\n\treturn\n}\n\n// Get Space-separated Line as Integers\n// Any non-valid integers will be 0\n//\n// Example input:\n// test 1 12.3 -117\n// Example output:\n// [0, 1, 0, -117]\n\nfunc gsli(reader *bufio.Reader) (arr []int) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.Atoi(e)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Get Space-separated Line as 64-bit Floats\n// Any non-valid floats will be 0\n//\n// Example input:\n// test 128.328 12 -11.0\n// Example output:\n// [0, 128.328, 12, -11]\n\nfunc gslf(reader *bufio.Reader) (arr []float64) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.ParseFloat(e, 64)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Math helpers\n\n// Positve Modulo\n// Returns x mod y, but always positive\n\nfunc posMod(x, y int) int {\n\treturn (x%y + y) % y\n}\n"}, {"source_code": "// Codeforces helper functions\n// 20 Jan 18\n// samadhi\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\t// fmt.Println(\"Hello, world!\")\n\tin := gsls(reader)[0]\n\n\tif strings.Count(in, \"0\") >= 6 && strings.Count(in, \"1\") > 0 && strings.Index(in, \"1\") <= len(in)-6 {\n\t\tfmt.Println(\"yes\")\n\t} else {\n\t\tfmt.Println(\"no\")\n\t}\n\n}\n\n// Input helpers\n\n// If you don't pass in a reference to the reader, and just instantiate a new\n// one every time, it will work locally, with IO typed at human-speed, but not\n// on Codeforces.\n\n// Get Space-separated Line as Strings\n//\n// Example input:\n// 1 test 382.0\n// Example output:\n// [\"1\", \"test\", \"382.0\"]\n\nfunc gsls(reader *bufio.Reader) (arr []string) {\n\t// Get a full line\n\tinput, _ := reader.ReadString('\\n')\n\n\t//Strip newline and return chars, if any\n\tinput = strings.TrimSuffix(input, \"\\n\")\n\tinput = strings.TrimSuffix(input, \"\\r\")\n\n\t// Split at the spaces into an array\n\tarr = strings.Split(input, \" \")\n\n\treturn\n}\n\n// Get Space-separated Line as Integers\n// Any non-valid integers will be 0\n//\n// Example input:\n// test 1 12.3 -117\n// Example output:\n// [0, 1, 0, -117]\n\nfunc gsli(reader *bufio.Reader) (arr []int) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.Atoi(e)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Get Space-separated Line as 64-bit Floats\n// Any non-valid floats will be 0\n//\n// Example input:\n// test 128.328 12 -11.0\n// Example output:\n// [0, 128.328, 12, -11]\n\nfunc gslf(reader *bufio.Reader) (arr []float64) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.ParseFloat(e, 64)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Math helpers\n\n// Positve Modulo\n// Returns x mod y, but always positive\n\nfunc posMod(x, y int) int {\n\treturn (x%y + y) % y\n}\n"}, {"source_code": "// Codeforces helper functions\n// 20 Jan 18\n// samadhi\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\t// fmt.Println(\"Hello, world!\")\n\tin := gsls(reader)[0]\n\n\tif strings.Count(in, \"0\") < 6 || strings.Count(in, \"1\") == 0 {\n\t\tfmt.Println(\"no\")\n\t} else {\n\t\tfmt.Println(\"yes\")\n\t}\n\n}\n\n// Input helpers\n\n// If you don't pass in a reference to the reader, and just instantiate a new\n// one every time, it will work locally, with IO typed at human-speed, but not\n// on Codeforces.\n\n// Get Space-separated Line as Strings\n//\n// Example input:\n// 1 test 382.0\n// Example output:\n// [\"1\", \"test\", \"382.0\"]\n\nfunc gsls(reader *bufio.Reader) (arr []string) {\n\t// Get a full line\n\tinput, _ := reader.ReadString('\\n')\n\n\t//Strip newline and return chars, if any\n\tinput = strings.TrimSuffix(input, \"\\n\")\n\tinput = strings.TrimSuffix(input, \"\\r\")\n\n\t// Split at the spaces into an array\n\tarr = strings.Split(input, \" \")\n\n\treturn\n}\n\n// Get Space-separated Line as Integers\n// Any non-valid integers will be 0\n//\n// Example input:\n// test 1 12.3 -117\n// Example output:\n// [0, 1, 0, -117]\n\nfunc gsli(reader *bufio.Reader) (arr []int) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.Atoi(e)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Get Space-separated Line as 64-bit Floats\n// Any non-valid floats will be 0\n//\n// Example input:\n// test 128.328 12 -11.0\n// Example output:\n// [0, 128.328, 12, -11]\n\nfunc gslf(reader *bufio.Reader) (arr []float64) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.ParseFloat(e, 64)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Math helpers\n\n// Positve Modulo\n// Returns x mod y, but always positive\n\nfunc posMod(x, y int) int {\n\treturn (x%y + y) % y\n}\n"}, {"source_code": "// Codeforces helper functions\n// 20 Jan 18\n// samadhi\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\t// fmt.Println(\"Hello, world!\")\n\tin := gsls(reader)[0]\n\n\tif strings.Count(in, \"0\") < 6 && strings.Count(in, \"1\") > 0 {\n\t\tfmt.Println(\"no\")\n\t} else {\n\t\tfmt.Println(\"yes\")\n\t}\n\n}\n\n// Input helpers\n\n// If you don't pass in a reference to the reader, and just instantiate a new\n// one every time, it will work locally, with IO typed at human-speed, but not\n// on Codeforces.\n\n// Get Space-separated Line as Strings\n//\n// Example input:\n// 1 test 382.0\n// Example output:\n// [\"1\", \"test\", \"382.0\"]\n\nfunc gsls(reader *bufio.Reader) (arr []string) {\n\t// Get a full line\n\tinput, _ := reader.ReadString('\\n')\n\n\t//Strip newline and return chars, if any\n\tinput = strings.TrimSuffix(input, \"\\n\")\n\tinput = strings.TrimSuffix(input, \"\\r\")\n\n\t// Split at the spaces into an array\n\tarr = strings.Split(input, \" \")\n\n\treturn\n}\n\n// Get Space-separated Line as Integers\n// Any non-valid integers will be 0\n//\n// Example input:\n// test 1 12.3 -117\n// Example output:\n// [0, 1, 0, -117]\n\nfunc gsli(reader *bufio.Reader) (arr []int) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.Atoi(e)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Get Space-separated Line as 64-bit Floats\n// Any non-valid floats will be 0\n//\n// Example input:\n// test 128.328 12 -11.0\n// Example output:\n// [0, 128.328, 12, -11]\n\nfunc gslf(reader *bufio.Reader) (arr []float64) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.ParseFloat(e, 64)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Math helpers\n\n// Positve Modulo\n// Returns x mod y, but always positive\n\nfunc posMod(x, y int) int {\n\treturn (x%y + y) % y\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"os\"\nimport \"bufio\"\n\nvar s string\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &s)\n\tzero := 0\n\tone := 0\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] == '0' {\n\t\t\tzero++\n\t\t} else {\n\t\t\tone++\n\t\t}\n\t}\n\n\tif one == 0 || zero >= 6 {\n\t\tfmt.Printf(\"yes\")\n\t} else {\n\t\tfmt.Printf(\"no\")\n\t}\n}\n\n\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"os\"\nimport \"bufio\"\n\nvar s string\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &s)\n\tzero := 0\n\tone := 0\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] == '0' {\n\t\t\tzero++\n\t\t} else {\n\t\t\tone++\n\t\t}\n\t}\n\n\tif one > 0 && zero >= 6 {\n\t\tfmt.Printf(\"yes\")\n\t} else {\n\t\tfmt.Printf(\"no\")\n\t}\n}\n\n\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"os\"\nimport \"bufio\"\n\nvar s string\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &s)\n\tzero := 0\n\tone := 0\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] == '0' {\n\t\t\tzero++\n\t\t} else {\n\t\t\tone++\n\t\t}\n\t}\n\n\tif one > 1 && zero >= 6 {\n\t\tfmt.Printf(\"yes\")\n\t} else {\n\t\tfmt.Printf(\"no\")\n\t}\n}\n\n\n"}], "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca"} {"nl": {"description": "Little Joty has got a task to do. She has a line of n tiles indexed from 1 to n. She has to paint them in a strange pattern.An unpainted tile should be painted Red if it's index is divisible by a and an unpainted tile should be painted Blue if it's index is divisible by b. So the tile with the number divisible by a and b can be either painted Red or Blue.After her painting is done, she will get p chocolates for each tile that is painted Red and q chocolates for each tile that is painted Blue.Note that she can paint tiles in any order she wants.Given the required information, find the maximum number of chocolates Joty can get.", "input_spec": "The only line contains five integers n, a, b, p and q (1 ≤ n, a, b, p, q ≤ 109).", "output_spec": "Print the only integer s — the maximum number of chocolates Joty can get. Note that the answer can be too large, so you should use 64-bit integer type to store it. In C++ you can use the long long integer type and in Java you can use long integer type.", "sample_inputs": ["5 2 3 12 15", "20 2 3 3 5"], "sample_outputs": ["39", "51"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"strconv\"\n\t// \"sort\"\n\t// \"strings\"\n)\n\nvar (\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\tlog.SetOutput(ioutil.Discard)\n\t// log.SetOutput(os.Stderr)\n\n\tn, a, b, p, q := nextInt64(), nextInt64(), nextInt64(), nextInt64(), nextInt64()\n\tlog.Print(n*gcd(a, b)/(a*b), min(p, q))\n\tprintln(n/a*p + n/b*q - n*gcd(a, b)/(a*b)*min(p, q))\n}\n\nfunc gcd(x, y int64) int64 {\n\tfor y != 0 {\n\t\tx, y = y, x%y\n\t}\n\treturn x\n}\n\nfunc min(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n"}, {"source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/678/C\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\tn, a, b, p, q int64\n)\n\nfunc main() {\n\tn = ReadInt64()\n\ta, b, p, q = ReadInt64_4()\n\n\tred := n / a\n\tred *= p\n\n\tblue := n / b\n\tblue *= q\n\n\tans := red + blue\n\n\tc := Lcm(a, b)\n\ttmp := n / c\n\ttmp *= Min(p, q)\n\n\tans -= tmp\n\tfmt.Println(ans)\n}\n\n// Min returns the min integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Min(integers ...int64) int64 {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// Gcd returns the Greatest Common Divisor of two natural numbers.\n// Gcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Gcd uses the Euclidean Algorithm.\nfunc Gcd(a, b int64) int64 {\n\tif a < 0 || b < 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\n\tif a == 0 {\n\t\treturn b\n\t}\n\tif b == 0 {\n\t\treturn a\n\t}\n\n\tif a < b {\n\t\ta, b = b, a\n\t}\n\n\t// Euclidean Algorithm\n\tfor b > 0 {\n\t\tdiv := a % b\n\t\ta, b = b, div\n\t}\n\n\treturn a\n}\n\n// Lcm returns the Least Common Multiple of two natural numbers.\n// Lcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Lcd uses the Euclidean Algorithm indirectly.\nfunc Lcm(a, b int64) int64 {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\n\t// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2\n\t// a' and b' are relatively prime numbers\n\t// gcd consists of prime numbers, that are included in a and b\n\tgcd := Gcd(a, b)\n\n\t// not (a * b / gcd), because of reducing a probability of overflow\n\treturn (a / gcd) * b\n}\n\n// NegativeMod can calculate a right residual whether value is positive or negative.\nfunc NegativeMod(val, m int64) int64 {\n\tres := val % m\n\tif res < 0 {\n\t\tres += m\n\t}\n\treturn res\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"strconv\"\n\t// \"sort\"\n\t// \"strings\"\n)\n\nvar (\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\tlog.SetOutput(ioutil.Discard)\n\t// log.SetOutput(os.Stderr)\n\n\tn, a, b, p, q := nextInt64(), nextInt64(), nextInt64(), nextInt64(), nextInt64()\n\n\tprintln(n/a*p + n/b*q - n/(a*b)*gcd(a, b)*min(p, q))\n}\n\nfunc gcd(x, y int64) int64 {\n\tfor y != 0 {\n\t\tx, y = y, x%y\n\t}\n\treturn x\n}\n\nfunc min(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"strconv\"\n\t// \"sort\"\n\t// \"strings\"\n)\n\nvar (\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\tlog.SetOutput(ioutil.Discard)\n\t// log.SetOutput(os.Stderr)\n\n\tn, a, b, p, q := nextInt64(), nextInt64(), nextInt64(), nextInt64(), nextInt64()\n\n\tprintln(n/a*p + n/b*q - n/(a*b)*min(p, q))\n}\n\nfunc min(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n"}], "src_uid": "35d8a9f0d5b5ab22929ec050b55ec769"} {"nl": {"description": "A positive integer is called a 2-3-integer, if it is equal to 2x·3y for some non-negative integers x and y. In other words, these integers are such integers that only have 2 and 3 among their prime divisors. For example, integers 1, 6, 9, 16 and 108 — are 2-3 integers, while 5, 10, 21 and 120 are not.Print the number of 2-3-integers on the given segment [l, r], i. e. the number of sich 2-3-integers t that l ≤ t ≤ r.", "input_spec": "The only line contains two integers l and r (1 ≤ l ≤ r ≤ 2·109).", "output_spec": "Print a single integer the number of 2-3-integers on the segment [l, r].", "sample_inputs": ["1 10", "100 200", "1 2000000000"], "sample_outputs": ["7", "5", "326"], "notes": "NoteIn the first example the 2-3-integers are 1, 2, 3, 4, 6, 8 and 9.In the second example the 2-3-integers are 108, 128, 144, 162 and 192."}, "positive_code": [{"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var l, r, ans, a, b int64\n fmt.Scanf(\"%d %d\", &l, &r)\n ans = 0\n a = 1\n b = 1\n for i := 0; i < 33; i++ {\n b = 1\n for j := 0; j < 24; j++ {\n if a * b > r {\n break\n }\n if (l <= a * b) && (a * b <= r) {\n ans++\n }\n b *= 3\n }\n a *= 2\n }\n fmt.Println(ans)\n}\n"}, {"source_code": "package main \n\nimport \"fmt\"\n\nfunc main() {\n\tvar l, r int64\n\tfmt.Scan(&l, &r)\n\tvar p2 [32]int64\n\tvar p3 [32]int64\n\tp2[0] = 1\n\tp3[0] = 1\n\tm := 1\n\tk := 1\n\tfor i := 0; i < 32; i++ {\n\t\tp2[m] = p2[m - 1] * 2\n\t\tif p2[m] > r {\n\t\t break\n\t\t}\n\t\tm++\n\t}\n\tfor i := 0; i < 32; i++ {\n\t\tp3[k] = p3[k - 1] * 3\n\t\tif p3[k] > r {\n\t\t break\n\t\t}\n\t\tk++\n\t}\n\tans := 0\n\tfor i := 0; i < m; i++ {\n\t for j := 0; j < k; j++ {\n\t \n\t if p2[i] * p3[j] >= l && p2[i] * p3[j] <= r {\n\t ans++\n\t } \n\t }\n\t}\n\tfmt.Printf(\"%d\\n\", ans)\n}"}, {"source_code": "package main\nimport\t( \n\t\t\"fmt\"\n\t\t\"bufio\"\n\t\t\"os\"\n\t\t\"strconv\"\n\t\t_\"math\"\n\t\t_\"math/big\"\n\t\t_\"math/rand\"\n\t\t_\"io/ioutil\"\n\t\t_\"io\"\n\t\t)\nvar M map[int]bool\nconst oo = 2 * 1000 * 1000 * 1000\nfunc main() {\n\tvar l,r int\n\tM = make(map[int]bool,0)\n\tdfs(1)\n\tans := 0\n\tfmt.Scanf(\"%d%d\",&l,&r)\n\tfor v,_ := range(M) {\n\t\tif l <= v && v <= r {\n\t\t\tans += 1\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\nfunc dfs(node int) {\n\tM[node] = true\n\tif node <= oo / 2 && M[node * 2] != true {\n\t\tdfs(node * 2)\n\t}\n\tif node <= oo / 3 && M[node * 3] != true {\n\t\tdfs(node * 3)\n\t}\n}\nfunc gcd(x,y int) int {\n\tif y == 0 {\n\t\treturn x\n\t} else {\n\t\treturn gcd(y,x % y)\n\t}\n}\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t} else {\n\t\treturn x\n\t}\n}\nfunc max(x,y int) int {\n\tif x > y {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc min(x,y int) int {\n\tif x < y {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nvar scanner *bufio.Scanner\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 readInt() int {\n\tscanner.Scan()\n\tval, _ := strconv.Atoi(scanner.Text())\n\treturn val\n}"}, {"source_code": "package main\n\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar a, b float64\n\tfmt.Scanln(&a, &b)\n\tsum := 0\n\tfor i := 0; i <= 31; i++ {\n\t for j := 0; j<=19; j++{\n\t foo:=math.Pow(2, float64(i))\n\t bar:=math.Pow(3, float64(j))\n\t if foo*bar>=a && foo*bar<=b{\n\t //fmt.Println(foo*bar)\n\t sum++;\n\t }\n\t }\n\t} \n\tfmt.Println(sum)\n}\n"}, {"source_code": "package main \n\nimport \"fmt\"\nvar l, r int64\nvar ans int64 = 0\nfunc dfs(x int64,y int64) {\n if x >= l {\n ans += 1\n }\n if y == 0 {\n if x*2<=r {\n dfs(x*2,0)\n }\n }\n if x*3<=r {\n dfs(x*3,1)\n }\n}\nfunc main() {\n\tfmt.Scan(&l, &r)\n\tdfs(1,0)\n\tfmt.Println(ans)\n}"}, {"source_code": "package main\nimport \"fmt\"\n\nfunc main(){\n\t// your code goes here\n\tvar l, r, ans1, ans2, res int64\n\tfmt.Scan(&l, &r)\n\tres = 0;\n\tfor i:=0; i <= 30; i++{\n\t\tfor j := 0; j <= 20; j++{\n\t\t\tans1 = 1;\n\t\t\tans2 = 1;\n\t\t\tfor k := 0; k < i; k++{\n\t\t\t\tans1 *= 2;\n\t\t\t}\n\t\t\tfor k := 0; k < j; k++{\n\t\t\t\tans2 *= 3;\n\t\t\t}\n\t\t\tif ans1 * ans2 >= l{\n\t\t\t\tif ans1 * ans2 <= r{\n\t\t\t\t\tres++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Printf(\"%d\", res)\n}"}, {"source_code": "package main \n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k int64\n\tfmt.Scan(&n, &k)\n\t\n\taa := make([]int64, 31, 31)\n\taa[0]=1\n\tfor i := 1; i <=30; i++ {\n\t aa[i]=aa[i-1]*2;\n\t}\n\tbb := make([]int64, 20, 20)\n\tbb[0]=1\n\tfor i := 1; i <=19; i++ {\n\t bb[i]=bb[i-1]*3;\n\t}\n\t\n\tcount := 0\n\tfor i := 0; i <= 30; i++ {\n\t for j := 0; j <= 19; j++ {\n\t if aa[i]*bb[j]>=n && aa[i]*bb[j]<=k {\n\t count++;\n\t }\n\t }\n\t}\n\t\n\tfmt.Println(count)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar l int64\n var r int64\n\tfmt.Scan(&l)\n\tfmt.Scan(&r)\n var ans = 0\n\tfor i := 0; i < 33; i++ {\n for j := 0; j < 33; j++ {\n var me int64\n me = 1\n for k :=0; k < i; k++ {\n me = me * 2\n }\n for k :=0; k < j; k++ {\n me = me * 3\n if me > r {\n break\n }\n }\n if me >= l {\n if me <= r{\n ans = ans + 1\n }\n }\n }\n\t}\n fmt.Printf(\"%d\\n\",ans)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var a int64\n var b int64\n \n var cap int64\n cap = 2000000001\n \n fmt.Scan(&a)\n fmt.Scan(&b)\n \n var cur1 int64\n cur1 = 1\n \n var answer int\n answer = 0\n \n for x := 0; x < 32; x++ {\n var cur2 int64\n cur2 = cur1\n for y := 0; y < 20; y++ {\n if cur2 >= cap {\n break\n }\n if cur2 >= a {\n if cur2 <= b {\n answer++\n }\n }\n \n cur2 *= 3\n }\n \n cur1 *= 2\n }\n\n fmt.Println(answer)\n}"}, {"source_code": "package main\n \nimport \"fmt\"\n \nfunc main() {\n\tvar r uint64\n\tvar l uint64\n\tfmt.Scan(&l)\n\tfmt.Scan(&r)\n\tvar ans uint64\n\tans=0\n\tl=l-1\n\tvar ast uint64\n\tast=1\n\tvar erkl uint64\n\terkl = 1\n\tvar hl uint64\n\thl=0\n\tvar hr uint64\n\thr = 0\n\tfor ;erkl<=l;erkl=erkl*2{\n\t\thl+=1\n\t}\n\tvar erkr uint64\n\terkr = 1\n\tfor ;erkr<=r;erkr=erkr*2{\n\t\thr+=1\n\t}\n\t\n\tfor i := 0; ast <= r; i++ {\n\t\tfor ;ast*erkl>l;erkl/=2{\n\t\t\thl-=1\n\t\t}\n\t\tfor ;ast*erkr>r;erkr/=2{\n\t\t\thr-=1\n\t\t}\n\t\tast = ast*3\n\t\tans=ans+hr-hl\n }\n\tfmt.Println(ans)\n \n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var l, r int64\n fmt.Scan(&l, &r)\n var arr [] int64\n var x int64\n LIM := int64(2000000000)\n var flag int\n for i := 0; i < 32; i++ {\n for j := 0; j < 32; j++ {\n x = 1\n flag = 1\n for pw := 1; pw <= i; pw++ {\n if x * 2 > LIM {\n flag = 0\n }\n x = x * 2\n }\n for pw := 1; pw <= j; pw++ {\n if (x * 3 > LIM) {\n flag = 0\n }\n x = x * 3\n }\n if flag == 1 {\n arr = append(arr, x)\n }\n }\n }\n n := len(arr)\n res := 0\n for i := 0; i < n; i++ {\n if l <= arr[i] {\n if arr[i] <= r {\n res = res + 1\n }\n } \n }\n fmt.Println(res)\n}"}, {"source_code": "package main\nimport \"fmt\"\nfunc main() {\n\tvar l int64\n var r int64\n\tvar ans int64\n\tvar m int64\n\tfmt.Scan(&l)\n fmt.Scan(&r)\n\tans = 0;\n\tfor i := int64(1); i <= 2000000000; i*=2 {\n for j := int64(1); j <= 2000000000; j*=3 {\n\t\t\tm=i*j\n if l<=m{\n if(m<=r){\n ans++\n }\n }\n\t }\n }\nfmt.Println(ans)\n}\n"}, {"source_code": "package main \n\nimport \"fmt\"\n\nfunc main() {\n\tvar l, r, c int64\n\tfmt.Scan(&l, &r)\n\tc = 0\n\tfor i := 0; i < 32; i++ {\n\t var x int64\n\t x = 1\n\t for j := 0; j < i; j++ {\n\t x = x*2\n\t }\n\t for j := 0; j < 21; j++ {\n\t if x > l - 1 {\n\t if x < r + 1 {\n\t c = c+1\n\t }\n\t }\n\t x = x*3\n\t }\n\t}\n\tfmt.Println(c)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc check(n int64, p2 int, p3 int) bool {\n for i := 0; i < p2; i++ {\n n = n / 2\n }\n for i := 0; i < p3; i++ {\n n = n / 3\n }\n return n >= 1\n}\n\nfunc solve(n int64) int {\n c := 0\n for i := 0; i < 32; i++ {\n for j := 0; j < 25; j++ {\n if check(n, i, j) {\n c += 1\n }\n }\n }\n return c\n}\n\nfunc main() {\n var l, r int64\n fmt.Scan(&l, &r)\n ans := solve(r) - solve(l - 1)\n\tfmt.Println(ans)\n}\n\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var i, j, s, a, b, x, ans int64\n fmt.Scanln(&a, &b)\n ans = 0\n \n x = 1;\n for i=0; i<31; i++ {\n s = x\n \n for j=0; j<30; j++ {\n if s > b {\n break\n }\n \n if s >= a {\n ans++\n }\n \n s *= 3\n }\n \n x *= 2\n }\n \n \n \n fmt.Print(ans)\n}"}, {"source_code": "package main\nimport \"fmt\"\n \nfunc main() {\n var l int64\n var r int64\n var cur int64\n var res int64\n fmt.Scan(&l)\n fmt.Scan(&r)\n cur = 1\n for i:= 0; i < 33; i++ {\n \tvar ocur int64\n \tocur = cur\n \tfor j := 0; j < 20; j++ {\n \t\tif cur >= l {\n \t\t\tif cur <= r {\n \t\t\t\tres = res + 1\n \t\t\t}\n \t\t}\n \t\tcur = cur * 3 \t\n \t}\n \tcur = ocur * 2\n }\n fmt.Printf(\"%d\", res)\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"sort\"\n )\n\nvar a [100000]int\nvar l, r int\nvar ans, ans1, j int64\n\nfunc main() {\n\tfmt.Scanf(\"%d %d\", &l, &r)\n\tnum:=0\n\tans=1\n for i:=0; i<=30; i++{\n a[num]=int(ans)\n num++\n ans1=ans\n for (ans1=i){\n fmt.Printf(\"%d\", j-i)\n \n } else{\n fmt.Printf(\"%d\", 0)\n }\n}"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"math\"\n\nfunc main() {\n\tvar min float64\n\tvar max float64\n\tfmt.Scan(&min)\n\tfmt.Scan(&max)\n\tvar res int\n\tres = 0;\n\tfor i := 0; i < 31; i++ {\n\t for y := 0; y < 20; y++ {\n\t var x float64\n\t x = math.Pow(2,float64(i))*math.Pow(3,float64(y));\n\t if x >= min {\n\t if x <= max {\n\t res++;\n\t }\n\t }\n\t }\n\t}\n\tfmt.Println(res);\n}"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n\t\"os\"\n)\n\nvar a [100002]int\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\t\n\tvar l int64\n\tvar r int64\n\tvar ans int64\n\tans = 0\n\tfmt.Fscan(in, &l)\n\tfmt.Fscan(in, &r)\n\t\n\tvar now int64\n\tnow = 1\n\n\tfor i := 0; i <= 30; i++ {\n\t\tvar kek int64\n\t\tkek = now\n\t\tfor j := 0; j <= 30; j++ {\n\t\t\tif kek >= l && kek <= r {\n\t\t\t\tans += 1\n\t\t\t}\n\t\t\tkek *= 3\n\t\t\tif kek > r {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tnow *= 2\n\t\tif now > r {\n\t\t\tbreak\n\t\t}\n\t}\n\n fmt.Print(ans)\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n )\n \nvar log3 = math.Log2(3.0) \nvar l,r float64 \nfunc find_divs(upper float64, num float64) int {\n var total_num int \n for i := int(upper); i>0; i-- {\n d := num/math.Pow(3,float64(i))\n total_num += int(math.Log2(d))\n }\n return total_num\n}\nfunc main(){\n\n\tfmt.Scanf(\"%f %f\", &l, &r)\n\tr2max := math.Log2(r)\n r3max := r2max/log3\n r2min := math.Log2(l)\n r3min := r2min/log3 \n var extra, extra_rem int\n if l == 1 {\n extra = 1\n }\n if l!= 1 && (r2min == math.Trunc(r2min) || r3min == math.Trunc(r3min) || int(l)%6 == 0) {\n extra_rem = 1\n }\n var total23divs int \n total23divs = find_divs(r3max, r) - find_divs(r3min, l)\n total := int(r2max) + int(r3max) - int(r2min) - int(r3min) + total23divs + extra + extra_rem\n\tfmt.Println( total)\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n )\n \nvar log3 = math.Log2(3.0) \nvar l,r float64 \nfunc find_divs(upper float64, num float64) int {\n var total_num int \n power := math.Pow(3, math.Trunc(upper))\n d := num/power\n total_num += int(math.Log2(d))\n for i := int(upper)-1; i>0; i-- {\n d *= 3 \n total_num += int(math.Log2(d))\n }\n return total_num\n}\nfunc main(){\n\tfmt.Scanf(\"%f %f\", &l, &r)\n\tr2max := math.Log2(r)\n r3max := r2max/log3\n r2min := math.Log2(l)\n r3min := r2min/log3 \n var extra, extra_rem int\n if l == 1 {\n extra = 1\n } else {\n if r2min == math.Trunc(r2min) || r3min == math.Trunc(r3min) || int(l)%6 == 0 {\n extra_rem = 1\n }\n }\n var total23divs int \n\n total23divs = find_divs(r3max, r) - find_divs(r3min, l)\n total := int(r2max) + int(r3max) - int(r2min) - int(r3min) + total23divs + extra + extra_rem\n\tfmt.Println( total)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var a int64\n var b int64\n var l int64\n var r int64\n var ans int64\n a = 1\n b = 1\n ans = 0\n\tfmt.Scan(&l)\n\tfmt.Scan(&r)\n\tfor i := 0; i <= 19; i++ {\n\t b = 1\n\t for j := 0; j <= 30; j ++ {\n\t if a * b >= l {\n\t if a * b <= r {\n\t ans = ans + 1\n\t }\n\t }\n\t b = b * 2\n\t }\n\t a = a * 3\n\t}\n\tfmt.Printf( \"%d\", ans )\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var afl int64\n var bfa int64\n var lrt int64\n var rgh int64\n var cnt int64\n afl = 1\n bfa = 1\n cnt = 0\n\tfmt.Scan(&lrt)\n\tfmt.Scan(&rgh)\n\tfor it := 0; it <= 19; it++ {\n\t bfa = 1\n\t for jt := 0; jt <= 30; jt ++ {\n\t if afl * bfa >= lrt {\n\t if afl * bfa <= rgh {\n\t cnt = cnt + 1\n\t }\n\t }\n\t bfa = bfa * 2\n\t }\n\t afl = afl * 3\n\t}\n\tfmt.Printf( \"%d\", cnt )\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar l,r,ot,i,j int64\n\tot = 0;\n\tfmt.Scan(&l,&r)\n\tj = 1;\n\tfor j <= r {\n\t i = j;\n \tfor i <= r {\n\t if (i>=l) {ot++;}\n\t i*=2 ;\n\t }\n\tj*=3 ;\n\t}\n\tfmt.Printf(\"%d\", ot)\n\t\n}"}, {"source_code": "package main\nimport \"fmt\"\n\nfunc main() {\n\n arr := [326]int{1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 32, 36, 48, 54, 64, 72, 81, 96, 108, 128, 144, 162, 192, 216, 243, 256, 288, 324, 384, 432, 486, 512, 576, 648, 729, 768, 864, 972, 1024, 1152, 1296, 1458, 1536, 1728, 1944, 2048, 2187, 2304, 2592, 2916, 3072, 3456, 3888, 4096, 4374, 4608, 5184, 5832, 6144, 6561, 6912, 7776, 8192, 8748, 9216, 10368, 11664, 12288, 13122, 13824, 15552, 16384, 17496, 18432, 19683, 20736, 23328, 24576, 26244, 27648, 31104, 32768, 34992, 36864, 39366, 41472, 46656, 49152, 52488, 55296, 59049, 62208, 65536, 69984, 73728, 78732, 82944, 93312, 98304, 104976, 110592, 118098, 124416, 131072, 139968, 147456, 157464, 165888, 177147, 186624, 196608, 209952, 221184, 236196, 248832, 262144, 279936, 294912, 314928, 331776, 354294, 373248, 393216, 419904, 442368, 472392, 497664, 524288, 531441, 559872, 589824, 629856, 663552, 708588, 746496, 786432, 839808, 884736, 944784, 995328, 1048576, 1062882, 1119744, 1179648, 1259712, 1327104, 1417176, 1492992, 1572864, 1594323, 1679616, 1769472, 1889568, 1990656, 2097152, 2125764, 2239488, 2359296, 2519424, 2654208, 2834352, 2985984, 3145728, 3188646, 3359232, 3538944, 3779136, 3981312, 4194304, 4251528, 4478976, 4718592, 4782969, 5038848, 5308416, 5668704, 5971968, 6291456, 6377292, 6718464, 7077888, 7558272, 7962624, 8388608, 8503056, 8957952, 9437184, 9565938, 10077696, 10616832, 11337408, 11943936, 12582912, 12754584, 13436928, 14155776, 14348907, 15116544, 15925248, 16777216, 17006112, 17915904, 18874368, 19131876, 20155392, 21233664, 22674816, 23887872, 25165824, 25509168, 26873856, 28311552, 28697814, 30233088, 31850496, 33554432, 34012224, 35831808, 37748736, 38263752, 40310784, 42467328, 43046721, 45349632, 47775744, 50331648, 51018336, 53747712, 56623104, 57395628, 60466176, 63700992, 67108864, 68024448, 71663616, 75497472, 76527504, 80621568, 84934656, 86093442, 90699264, 95551488, 100663296, 102036672, 107495424, 113246208, 114791256, 120932352, 127401984, 129140163, 134217728, 136048896, 143327232, 150994944, 153055008, 161243136, 169869312, 172186884, 181398528, 191102976, 201326592, 204073344, 214990848, 226492416, 229582512, 241864704, 254803968, 258280326, 268435456, 272097792, 286654464, 301989888, 306110016, 322486272, 339738624, 344373768, 362797056, 382205952, 387420489, 402653184, 408146688, 429981696, 452984832, 459165024, 483729408, 509607936, 516560652, 536870912, 544195584, 573308928, 603979776, 612220032, 644972544, 679477248, 688747536, 725594112, 764411904, 774840978, 805306368, 816293376, 859963392, 905969664, 918330048, 967458816, 1019215872, 1033121304, 1073741824, 1088391168, 1146617856, 1162261467, 1207959552, 1224440064, 1289945088, 1358954496, 1377495072, 1451188224, 1528823808, 1549681956, 1610612736, 1632586752, 1719926784, 1811939328, 1836660096, 1934917632 }\n \n var L int\n var R int\n \n fmt.Scan(&L)\n fmt.Scan(&R)\n //fmt.Print(arr[0])\n \n var l int\n var r int\n \n l = 0\n r = 325\n \n for l != r {\n mid := (l + r) / 2\n if arr[mid] >= L {\n r = mid\n }\n if arr[mid] < L {\n l = mid + 1\n }\n }\n \n lb := l\n \n if arr[lb] < L {\n lb += 1\n }\n \n l = 0\n r = 325\n \n for l != r {\n mid := (l + r) / 2\n if mid == l{\n mid += 1\n }\n if arr[mid] <= R {\n l = mid\n }\n if arr[mid] > R {\n r = mid - 1\n }\n }\n \n rb := l\n if arr[rb] > R {\n rb -= 1\n }\n \n fmt.Print(rb - lb + 1)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc pwer (a, p int64) int64 {\n var m int64 = 1\n for ; p > 0; p -- {\n m = m * a\n }\n return m\n}\n\nfunc main() {\n var l, r int64\n fmt.Scan(&l, &r)\n var answer, a, b int64 = 0, 0, 0\n for a = 0; a < 39; a ++ {\n\t\tfor b = 0; b < 39; b ++ {\n\t\t var c int64 = pwer(2, a) * pwer(3, b)\n\t\t if ((l <= c) && (c <= r)) {\n\t\t answer ++\n\t\t }\n\t\t}\n\t}\n fmt.Println(answer)\n}"}], "negative_code": [{"source_code": "package main\n\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scanln(&a, &b)\n\tsum := 0\n\tfor i := 0; i <= 30; i++ {\n\t for j := 0; j<= 19; j++{\n\t foo:=int(math.Pow(2, float64(i)))\n\t bar:=int(math.Pow(3, float64(j)))\n\t if foo*bar>=a && foo*bar<=b{\n\t sum++;\n\t }\n\t }\n\t} \n\tfmt.Println(sum)\n}\n"}, {"source_code": "package main\nimport \"fmt\"\n\nfunc main(){\n\t// your code goes here\n\tvar l, r, ans1, ans2, res int\n\tfmt.Scan(&l, &r)\n\tres = 0;\n\tfor i:=0; i <= 30; i++{\n\t\tfor j := 0; j <= 20; j++{\n\t\t\tans1 = 1;\n\t\t\tans2 = 1;\n\t\t\tfor k := 0; k < i; k++{\n\t\t\t\tans1 *= 2;\n\t\t\t}\n\t\t\tfor k := 0; k < j; k++{\n\t\t\t\tans2 *= 3;\n\t\t\t}\n\t\t\tif ans1 * ans2 >= l{\n\t\t\t\tif ans1 * ans2 <= r{\n\t\t\t\t\tres++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Printf(\"%d\", res)\n}"}, {"source_code": "package main \n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k int64\n\tfmt.Scan(&n, &k)\n\t\n\taa := make([]int64, 31, 31)\n\taa[0]=1\n\tfor i := 1; i <=30; i++ {\n\t aa[i]=aa[i-1]*2;\n\t}\n\tbb := make([]int64, 20, 20)\n\tbb[0]=1\n\tfor i := 1; i <=19; i++ {\n\t bb[i]=bb[i-1]*3;\n\t}\n\t\n\tcount := 0\n\tfor i := 0; i < 30; i++ {\n\t for j := 0; j < 19; j++ {\n\t if aa[i]*bb[j]>=n && aa[i]*bb[j]<=k {\n\t count++;\n\t }\n\t }\n\t}\n\t\n\tfmt.Println(count)\n}"}, {"source_code": "package main\n\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scanln(&a, &b)\n\tsum := 0\n\tfor i := 0; i <= 30; i++ {\n\t for j := 0; j<= 19; j++{\n\t foo:=int(math.Pow(2, float64(i)))\n\t bar:=int(math.Pow(3, float64(j)))\n\t if foo*bar>=a && foo*bar<=b{\n\t sum++;\n\t }\n\t }\n\t}\n\tfmt.Println(sum)\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"sort\"\n )\n\nvar a [100000]int\nvar l, r int\nvar ans, ans1, j int64\n\nfunc main() {\n\tfmt.Scanf(\"%d %d\", &l, &r)\n\tnum:=0\n\tans=1\n for i:=0; i<=30; i++{\n a[num]=int(ans)\n num++\n ans1=ans\n for (ans1=i){\n fmt.Printf(\"%d\", j-i)\n \n } else{\n fmt.Printf(\"%d\", 0)\n }\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n )\n \nvar log3 = math.Log2(3.0) \nvar l,r float64 \nfunc find_divs(upper float64, num float64) int {\n var total_num int \n for i := int(upper); i>0; i-- {\n d := num/math.Pow(3,float64(i))\n total_num += int(math.Log2(d))\n }\n return total_num\n}\nfunc main(){\n\tfmt.Scanf(\"%f %f\", &l, &r)\n\tr2max := math.Log2(r)\n r3max := r2max/log3\n r2min := math.Log2(l)\n r3min := r2min/log3 \n var extra int\n if l == 1 {\n extra = 1\n } else {\n extra = 0\n }\n var total23divs int \n total23divs = find_divs(r3max, r) - find_divs(r3min, l)\n total := int(r2max) + int(r3max) - int(r2min) - int(r3min) + total23divs + extra\n\tfmt.Println( total)\n}"}, {"source_code": "package main\nimport \"fmt\"\n\nfunc main() {\n\n arr := [326]int{1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 32, 36, 48, 54, 64, 72, 81, 96, 108, 128, 144, 162, 192, 216, 243, 256, 288, 324, 384, 432, 486, 512, 576, 648, 729, 768, 864, 972, 1024, 1152, 1296, 1458, 1536, 1728, 1944, 2048, 2187, 2304, 2592, 2916, 3072, 3456, 3888, 4096, 4374, 4608, 5184, 5832, 6144, 6561, 6912, 7776, 8192, 8748, 9216, 10368, 11664, 12288, 13122, 13824, 15552, 16384, 17496, 18432, 19683, 20736, 23328, 24576, 26244, 27648, 31104, 32768, 34992, 36864, 39366, 41472, 46656, 49152, 52488, 55296, 59049, 62208, 65536, 69984, 73728, 78732, 82944, 93312, 98304, 104976, 110592, 118098, 124416, 131072, 139968, 147456, 157464, 165888, 177147, 186624, 196608, 209952, 221184, 236196, 248832, 262144, 279936, 294912, 314928, 331776, 354294, 373248, 393216, 419904, 442368, 472392, 497664, 524288, 531441, 559872, 589824, 629856, 663552, 708588, 746496, 786432, 839808, 884736, 944784, 995328, 1048576, 1062882, 1119744, 1179648, 1259712, 1327104, 1417176, 1492992, 1572864, 1594323, 1679616, 1769472, 1889568, 1990656, 2097152, 2125764, 2239488, 2359296, 2519424, 2654208, 2834352, 2985984, 3145728, 3188646, 3359232, 3538944, 3779136, 3981312, 4194304, 4251528, 4478976, 4718592, 4782969, 5038848, 5308416, 5668704, 5971968, 6291456, 6377292, 6718464, 7077888, 7558272, 7962624, 8388608, 8503056, 8957952, 9437184, 9565938, 10077696, 10616832, 11337408, 11943936, 12582912, 12754584, 13436928, 14155776, 14348907, 15116544, 15925248, 16777216, 17006112, 17915904, 18874368, 19131876, 20155392, 21233664, 22674816, 23887872, 25165824, 25509168, 26873856, 28311552, 28697814, 30233088, 31850496, 33554432, 34012224, 35831808, 37748736, 38263752, 40310784, 42467328, 43046721, 45349632, 47775744, 50331648, 51018336, 53747712, 56623104, 57395628, 60466176, 63700992, 67108864, 68024448, 71663616, 75497472, 76527504, 80621568, 84934656, 86093442, 90699264, 95551488, 100663296, 102036672, 107495424, 113246208, 114791256, 120932352, 127401984, 129140163, 134217728, 136048896, 143327232, 150994944, 153055008, 161243136, 169869312, 172186884, 181398528, 191102976, 201326592, 204073344, 214990848, 226492416, 229582512, 241864704, 254803968, 258280326, 268435456, 272097792, 286654464, 301989888, 306110016, 322486272, 339738624, 344373768, 362797056, 382205952, 387420489, 402653184, 408146688, 429981696, 452984832, 459165024, 483729408, 509607936, 516560652, 536870912, 544195584, 573308928, 603979776, 612220032, 644972544, 679477248, 688747536, 725594112, 764411904, 774840978, 805306368, 816293376, 859963392, 905969664, 918330048, 967458816, 1019215872, 1033121304, 1073741824, 1088391168, 1146617856, 1162261467, 1207959552, 1224440064, 1289945088, 1358954496, 1377495072, 1451188224, 1528823808, 1549681956, 1610612736, 1632586752, 1719926784, 1811939328, 1836660096, 1934917632 }\n \n var L int\n var R int\n \n fmt.Scan(&L)\n fmt.Scan(&R)\n //fmt.Print(arr[0])\n \n var l int\n var r int\n \n l = 0\n r = 325\n \n for l != r {\n mid := (l + r) / 2\n if arr[mid] >= L {\n r = mid\n }\n if arr[mid] < L {\n l = mid + 1\n }\n }\n \n lb := l\n \n l = 0\n r = 325\n \n for l != r {\n mid := (l + r) / 2\n if mid == l{\n mid += 1\n }\n if arr[mid] <= R {\n l = mid\n }\n if arr[mid] > R {\n r = mid - 1\n }\n }\n \n rb := l\n \n fmt.Print(rb - lb + 1)\n}"}], "src_uid": "05fac54ed2064b46338bb18f897a4411"} {"nl": {"description": "You are given an integer N. Consider all possible segments on the coordinate axis with endpoints at integer points with coordinates between 0 and N, inclusive; there will be of them.You want to draw these segments in several layers so that in each layer the segments don't overlap (they might touch at the endpoints though). You can not move the segments to a different location on the coordinate axis. Find the minimal number of layers you have to use for the given N.", "input_spec": "The only input line contains a single integer N (1 ≤ N ≤ 100).", "output_spec": "Output a single integer - the minimal number of layers required to draw the segments for the given N.", "sample_inputs": ["2", "3", "4"], "sample_outputs": ["2", "4", "6"], "notes": "NoteAs an example, here are the segments and their optimal arrangement into layers for N = 4. "}, "positive_code": [{"source_code": "package main\n\nimport(\n\t\"fmt\"\n\t// \"sort\"\n\t// \"math\"\n\t// \"strconv\"\n\t// \"strings\"\n\t\"os\"\n\t\"bufio\"\n)\n\nfunc min(a,b int) int{\n\tif ab{\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc toInt(buf []byte) (o int) {\n\tfor _, v := range buf {\n\t\to = o*10 + int(v-'0')\n\t}\n\treturn\n}\n\ntype pair struct {\n\tfirst int\n\tsecond int\n}\n\ntype pairs []pair\n\nfunc (a pairs) Len() int {return len(a)}\nfunc (a pairs) Swap(i,j int) {a[i], a[j] = a[j], a[i]}\nfunc (a pairs) Less(i,j int) bool {\n\treturn a[i].first < a[j].first\n\tif a[i].first > a[j].first {\n\t\treturn false\n\t}\n\treturn a[i].second <= a[j].second\n}\n\nvar dp[5002][5002] int64\nvar sum[5002] int64\nvar MD int64 = 1000000007\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\t//in, _ := os.Open(\"a.txt\")\n\tvar n int\n\tans := 0\n\tfmt.Fscanf(in, \"%d\\n\", &n)\n\tfor i := 0; i < n; i++ {\n\t\tres := 0\n\t\tfor j :=0; j <= n; j++ {\n\t\t\tfor k := j + 1; k <= n; k++ {\n\t\t\t\tif i >= j && i + 1 <= k {\n\t\t\t\t\tres++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tans = max(ans, res)\n\t}\n\tfmt.Println(ans)\n}"}, {"source_code": "package main\n\nimport(\n\t\"fmt\"\n\t// \"sort\"\n\t// \"math\"\n\t// \"strconv\"\n\t// \"strings\"\n\t\"os\"\n\t\"bufio\"\n)\n\nfunc min(a,b int) int{\n\tif ab{\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc toInt(buf []byte) (o int) {\n\tfor _, v := range buf {\n\t\to = o*10 + int(v-'0')\n\t}\n\treturn\n}\n\ntype pair struct {\n\tfirst int\n\tsecond int\n}\n\ntype pairs []pair\n\nfunc (a pairs) Len() int {return len(a)}\nfunc (a pairs) Swap(i,j int) {a[i], a[j] = a[j], a[i]}\nfunc (a pairs) Less(i,j int) bool {\n\treturn a[i].first < a[j].first\n\tif a[i].first > a[j].first {\n\t\treturn false\n\t}\n\treturn a[i].second <= a[j].second\n}\n\nvar dp[5002][5002] int64\nvar sum[5002] int64\nvar MD int64 = 1000000007\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\t//in, _ := os.Open(\"a.txt\")\n\tvar n int\n\tans := 0\n\tfmt.Fscanf(in, \"%d\\n\", &n)\n\tfor i := 0; i < n; i++ {\n\t\tres := 0\n\t\tfor j :=0; j <= n; j++ {\n\t\t\tfor k := j + 1; k <= n; k++ {\n\t\t\t\tif i >= j && i + 1 <= k {\n\t\t\t\t\tres++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tans = max(ans, res)\n\t}\n\tfmt.Println(ans)\n}"}, {"source_code": "package main\n \nimport \"fmt\"\n\nfunc min(a, b int) int {\n if a < b {\n return a\n } else {\n return b\n }\n}\n\nfunc main() {\n n := 0\n fmt.Scan(&n)\n l := 1\n for i := 1; i < n; i++ {\n l += min(i, n-i+1)\n }\n fmt.Print(l)\n}"}, {"source_code": "package main\n\nimport\n(\n\t\"fmt\"\n\t\n)\n\n\nfunc main() {\n\n\tvar a int\n\tfmt.Scanln(&a)\n\tfmt.Print(((a+1)/2)*((a-(a+1)/2)+1))\n\t}\n"}], "negative_code": [], "src_uid": "f8af5dfcf841a7f105ac4c144eb51319"} {"nl": {"description": "Vasya decided to learn to play chess. Classic chess doesn't seem interesting to him, so he plays his own sort of chess.The queen is the piece that captures all squares on its vertical, horizontal and diagonal lines. If the cell is located on the same vertical, horizontal or diagonal line with queen, and the cell contains a piece of the enemy color, the queen is able to move to this square. After that the enemy's piece is removed from the board. The queen cannot move to a cell containing an enemy piece if there is some other piece between it and the queen. There is an n × n chessboard. We'll denote a cell on the intersection of the r-th row and c-th column as (r, c). The square (1, 1) contains the white queen and the square (1, n) contains the black queen. All other squares contain green pawns that don't belong to anyone.The players move in turns. The player that moves first plays for the white queen, his opponent plays for the black queen.On each move the player has to capture some piece with his queen (that is, move to a square that contains either a green pawn or the enemy queen). The player loses if either he cannot capture any piece during his move or the opponent took his queen during the previous move. Help Vasya determine who wins if both players play with an optimal strategy on the board n × n.", "input_spec": "The input contains a single number n (2 ≤ n ≤ 109) — the size of the board.", "output_spec": "On the first line print the answer to problem — string \"white\" or string \"black\", depending on who wins if the both players play optimally. If the answer is \"white\", then you should also print two integers r and c representing the cell (r, c), where the first player should make his first move to win. If there are multiple such cells, print the one with the minimum r. If there are still multiple squares, print the one with the minimum c.", "sample_inputs": ["2", "3"], "sample_outputs": ["white\n1 2", "black"], "notes": "NoteIn the first sample test the white queen can capture the black queen at the first move, so the white player wins.In the second test from the statement if the white queen captures the green pawn located on the central vertical line, then it will be captured by the black queen during the next move. So the only move for the white player is to capture the green pawn located at (2, 1). Similarly, the black queen doesn't have any other options but to capture the green pawn located at (2, 3), otherwise if it goes to the middle vertical line, it will be captured by the white queen.During the next move the same thing happens — neither the white, nor the black queen has other options rather than to capture green pawns situated above them. Thus, the white queen ends up on square (3, 1), and the black queen ends up on square (3, 3). In this situation the white queen has to capture any of the green pawns located on the middle vertical line, after that it will be captured by the black queen. Thus, the player who plays for the black queen wins."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\n// Input & Output\nvar (\n\tinput = bufio.NewScanner(os.Stdin)\n\toutput = bufio.NewWriter(os.Stdout)\n)\n\nfunc main() {\n\tvar n uint64\n\tinput.Scan()\n\tn, _ = strconv.ParseUint(input.Text(), 10, 64)\n\tif n%2 == 1 {\n\t\tfmt.Fprintln(output, \"black\")\n\t} else {\n\t\tfmt.Fprintln(output, \"white\")\n\t\tfmt.Fprintln(output, 1, 2)\n\t}\n\tdefer output.Flush()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\n// Input & Output\nvar (\n\tinput = bufio.NewReader(os.Stdin)\n\toutput = bufio.NewWriter(os.Stdout)\n)\n\nfunc main() {\n\tvar n int64\n\tfmt.Fscan(input, &n)\n\tif n%2 == 1 {\n\t\tfmt.Fprintln(output, \"black\")\n\t} else {\n\t\tfmt.Fprintln(output, \"white\")\n\t\tfmt.Fprintln(output, 1, 2)\n\t}\n\tdefer output.Flush()\n}\n"}, {"source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF493D(in io.Reader, out io.Writer) {\n\tvar n int\n\tFscan(in, &n)\n\tif n&1 > 0 {\n\t\tFprint(out, \"black\")\n\t} else {\n\t\tFprint(out, \"white\\n1 2\")\n\t}\n}\n\nfunc main() { CF493D(os.Stdin, os.Stdout) }\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tif n%2 == 0 {\n\t\tfmt.Println(\"white\")\n\t\tfmt.Println(1, 2)\n\t} else {\n\t\tfmt.Println(\"black\")\n\t}\n}\n"}, {"source_code": "package main\nimport \"fmt\"\n\nfunc main() {\n\tvar x int\n\tfmt.Scanf(\"%d\", &x)\n\tif x % 2 == 0 {\n\t\tfmt.Println(\"white\")\n\t\tfmt.Println(1, 2)\n\t} else {\n\t\tfmt.Println(\"black\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"strconv\"\n \"bufio\"\n \"os\"\n \"fmt\"\n)\n// var file, _ = os.Open(\"input.txt\")\n// var outfile, _ = os.Create(\"output.txt\")\n// var in = bufio.NewScanner(file)\n// var out = bufio.NewWriter(outfile)\nvar in = bufio.NewScanner(os.Stdin)\nvar out = bufio.NewWriter(os.Stdout)\n\nfunc next() string {\n if !in.Scan() {\n panic(\"Scan error\")\n }\n return in.Text()\n}\n\nfunc nextInt() int {\n ret, _ := strconv.Atoi(next())\n return ret\n}\n\nfunc nextFloat() float64 {\n ret, _ := strconv.ParseFloat(next(), 64)\n return ret\n}\n\nfunc main() {\n defer out.Flush()\n in.Split(bufio.ScanWords)\n n := nextInt()\n if n % 2 == 1 {\n fmt.Fprintln(out, \"black\")\n } else {\n fmt.Fprintln(out, \"white\")\n fmt.Fprintln(out, \"1 2\")\n }\n}\n"}], "negative_code": [], "src_uid": "52e07d176aa1d370788f94ee2e61df93"} {"nl": {"description": "Consider a linear function f(x) = Ax + B. Let's define g(0)(x) = x and g(n)(x) = f(g(n - 1)(x)) for n > 0. For the given integer values A, B, n and x find the value of g(n)(x) modulo 109 + 7.", "input_spec": "The only line contains four integers A, B, n and x (1 ≤ A, B, x ≤ 109, 1 ≤ n ≤ 1018) — the parameters from the problem statement. Note that the given value n can be too large, so you should use 64-bit integer type to store it. In C++ you can use the long long integer type and in Java you can use long integer type.", "output_spec": "Print the only integer s — the value g(n)(x) modulo 109 + 7.", "sample_inputs": ["3 4 1 1", "3 4 2 1", "3 4 3 1"], "sample_outputs": ["7", "25", "79"], "notes": null}, "positive_code": [{"source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/678/D\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\ta, b, x, n int64\n)\n\nfunc main() {\n\ta, b, n, x = ReadInt64_4()\n\n\tA := [][]int64{\n\t\t[]int64{a, b},\n\t\t[]int64{0, 1},\n\t}\n\n\tAK := powMat(A, n, MOD)\n\n\tans := AK[0][0] * x\n\tans %= MOD\n\tans += AK[0][1]\n\tans %= MOD\n\tfmt.Println(ans)\n}\n\n// ↓でもいい\n// func main() {\n// \ta, b, n, x = ReadInt64_4()\n\n// \tA := [][]int64{\n// \t\t[]int64{a + 1, NegativeMod(-a, MOD)},\n// \t\t[]int64{1, 0},\n// \t}\n\n// \tAK := powMat(A, n-1, MOD)\n\n// \tans := int64(0)\n\n// \tbig := (a*x + b) % MOD\n// \tbig *= AK[0][0]\n// \tans += big\n// \tans %= MOD\n\n// \tsml := AK[0][1]\n// \tsml *= x\n// \tsml %= MOD\n// \tans += sml\n// \tans %= MOD\n\n// \tfmt.Println(ans)\n// }\n\n// NegativeMod can calculate a right residual whether value is positive or negative.\nfunc NegativeMod(val, m int64) int64 {\n\tres := val % m\n\tif res < 0 {\n\t\tres += m\n\t}\n\treturn res\n}\n\n// n*nのint型正方行列を生成する\nfunc newMat(n int64) [][]int64 {\n\tvar i int64\n\n\tA := make([][]int64, n)\n\tfor i = 0; i < n; i++ {\n\t\tA[i] = make([]int64, n)\n\t}\n\n\treturn A\n}\n\n// 行列A, Bに関するA*Bの計算\nfunc mul(A, B [][]int64, mod int64) [][]int64 {\n\tvar i, j, k int64\n\tvar lenA, lenB, lenB0 int64\n\tlenA = int64(len(A))\n\tlenB = int64(len(B))\n\tlenB0 = int64(len(B[0]))\n\n\tC := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tC[i] = make([]int64, lenB0)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tfor k = 0; k < lenB; k++ {\n\t\t\tfor j = 0; j < lenB0; j++ {\n\t\t\t\tC[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod\n\t\t\t}\n\t\t}\n\t}\n\n\treturn C\n}\n\n// 行列Aに関するA^nの計算\nfunc powMat(A [][]int64, n, mod int64) [][]int64 {\n\tvar i int64\n\tvar lenA int64\n\tlenA = int64(len(A))\n\n\tB := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i] = make([]int64, lenA)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i][i] = 1\n\t}\n\tfor n > 0 {\n\t\tif n&1 == 1 {\n\t\t\tB = mul(B, A, mod)\n\t\t}\n\t\tA = mul(A, A, mod)\n\t\tn = (n >> 1)\n\t}\n\n\treturn B\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n"}, {"source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF678D(in io.Reader, out io.Writer) {\n\tconst p int64 = 1e9 + 7\n\tpow := func(x, n int64) int64 {\n\t\tres := int64(1)\n\t\tfor ; n > 0; n >>= 1 {\n\t\t\tif n&1 == 1 {\n\t\t\t\tres = res * x % p\n\t\t\t}\n\t\t\tx = x * x % p\n\t\t}\n\t\treturn res\n\t}\n\n\tvar a, b, n, x int64\n\tFscan(in, &a, &b, &n, &x)\n\tif an := pow(a, n); a == 1 {\n\t\tFprint(out, (an*x+n%p*b)%p)\n\t} else {\n\t\tFprint(out, (an*x+(an-1)%p*pow(a-1, p-2)%p*b)%p)\n\t}\n}\n\nfunc main() { CF678D(os.Stdin, os.Stdout) }\n"}, {"source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/678/D\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\ta, b, x, n int64\n)\n\n// ↓でもいい\nfunc main() {\n\ta, b, n, x = ReadInt64_4()\n\n\tA := [][]int64{\n\t\t[]int64{a + 1, NegativeMod(-a, MOD)},\n\t\t[]int64{1, 0},\n\t}\n\n\tAK := powMat(A, n-1, MOD)\n\n\tans := int64(0)\n\n\tbig := (a*x + b) % MOD\n\tbig *= AK[0][0]\n\tans += big\n\tans %= MOD\n\n\tsml := AK[0][1]\n\tsml *= x\n\tsml %= MOD\n\tans += sml\n\tans %= MOD\n\n\tfmt.Println(ans)\n}\n\n// NegativeMod can calculate a right residual whether value is positive or negative.\nfunc NegativeMod(val, m int64) int64 {\n\tres := val % m\n\tif res < 0 {\n\t\tres += m\n\t}\n\treturn res\n}\n\n// n*nのint型正方行列を生成する\nfunc newMat(n int64) [][]int64 {\n\tvar i int64\n\n\tA := make([][]int64, n)\n\tfor i = 0; i < n; i++ {\n\t\tA[i] = make([]int64, n)\n\t}\n\n\treturn A\n}\n\n// 行列A, Bに関するA*Bの計算\nfunc mul(A, B [][]int64, mod int64) [][]int64 {\n\tvar i, j, k int64\n\tvar lenA, lenB, lenB0 int64\n\tlenA = int64(len(A))\n\tlenB = int64(len(B))\n\tlenB0 = int64(len(B[0]))\n\n\tC := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tC[i] = make([]int64, lenB0)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tfor k = 0; k < lenB; k++ {\n\t\t\tfor j = 0; j < lenB0; j++ {\n\t\t\t\tC[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod\n\t\t\t}\n\t\t}\n\t}\n\n\treturn C\n}\n\n// 行列Aに関するA^nの計算\nfunc powMat(A [][]int64, n, mod int64) [][]int64 {\n\tvar i int64\n\tvar lenA int64\n\tlenA = int64(len(A))\n\n\tB := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i] = make([]int64, lenA)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i][i] = 1\n\t}\n\tfor n > 0 {\n\t\tif n&1 == 1 {\n\t\t\tB = mul(B, A, mod)\n\t\t}\n\t\tA = mul(A, A, mod)\n\t\tn = (n >> 1)\n\t}\n\n\treturn B\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n"}, {"source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/678/D\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\ta, b, x, n int64\n)\n\nfunc main() {\n\ta, b, n, x = ReadInt64_4()\n\n\t// A := [][]int64{\n\t// \t[]int64{a + 1, -a},\n\t// \t[]int64{1, 0},\n\t// }\n\tA := [][]int64{\n\t\t[]int64{a + 1, NegativeMod(-a, MOD)},\n\t\t[]int64{1, 0},\n\t}\n\n\tAK := powMat(A, n-1, MOD)\n\n\tans := int64(0)\n\n\tbig := (a*x + b) % MOD\n\tbig *= AK[0][0]\n\tans += big\n\tans %= MOD\n\n\tsml := AK[0][1]\n\tsml *= x\n\tsml %= MOD\n\tans += sml\n\tans %= MOD\n\n\tfmt.Println(ans)\n}\n\n// NegativeMod can calculate a right residual whether value is positive or negative.\nfunc NegativeMod(val, m int64) int64 {\n\tres := val % m\n\tif res < 0 {\n\t\tres += m\n\t}\n\treturn res\n}\n\n// n*nのint型正方行列を生成する\nfunc newMat(n int64) [][]int64 {\n\tvar i int64\n\n\tA := make([][]int64, n)\n\tfor i = 0; i < n; i++ {\n\t\tA[i] = make([]int64, n)\n\t}\n\n\treturn A\n}\n\n// 行列A, Bに関するA*Bの計算\nfunc mul(A, B [][]int64, mod int64) [][]int64 {\n\tvar i, j, k int64\n\tvar lenA, lenB, lenB0 int64\n\tlenA = int64(len(A))\n\tlenB = int64(len(B))\n\tlenB0 = int64(len(B[0]))\n\n\tC := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tC[i] = make([]int64, lenB0)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tfor k = 0; k < lenB; k++ {\n\t\t\tfor j = 0; j < lenB0; j++ {\n\t\t\t\tC[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod\n\t\t\t}\n\t\t}\n\t}\n\n\treturn C\n}\n\n// 行列Aに関するA^nの計算\nfunc powMat(A [][]int64, n, mod int64) [][]int64 {\n\tvar i int64\n\tvar lenA int64\n\tlenA = int64(len(A))\n\n\tB := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i] = make([]int64, lenA)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i][i] = 1\n\t}\n\tfor n > 0 {\n\t\tif n&1 == 1 {\n\t\t\tB = mul(B, A, mod)\n\t\t}\n\t\tA = mul(A, A, mod)\n\t\tn = (n >> 1)\n\t}\n\n\treturn B\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n"}], "negative_code": [{"source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/678/D\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\ta, b, x, n int64\n)\n\nfunc main() {\n\ta, b, n, x = ReadInt64_4()\n\n\tA := [][]int64{\n\t\t[]int64{a + 1, -a},\n\t\t[]int64{1, 0},\n\t}\n\t// A := [][]int64{\n\t// \t[]int64{a + 1, NegativeMod(-a, MOD)},\n\t// \t[]int64{1, 0},\n\t// }\n\n\tAK := powMat(A, n-1, MOD)\n\n\t// ans := AK[0][0]*(a*x+b) + AK[0][1]*x\n\t// ans %= MOD\n\n\tans := int64(0)\n\tans += AK[0][0] * (a*x + b)\n\tans = NegativeMod(ans, MOD)\n\tans += AK[0][1] * x\n\tans = NegativeMod(ans, MOD)\n\tfmt.Println(ans)\n}\n\n// NegativeMod can calculate a right residual whether value is positive or negative.\nfunc NegativeMod(val, m int64) int64 {\n\tres := val % m\n\tif res < 0 {\n\t\tres += m\n\t}\n\treturn res\n}\n\n// n*nのint型正方行列を生成する\nfunc newMat(n int64) [][]int64 {\n\tvar i int64\n\n\tA := make([][]int64, n)\n\tfor i = 0; i < n; i++ {\n\t\tA[i] = make([]int64, n)\n\t}\n\n\treturn A\n}\n\n// 行列A, Bに関するA*Bの計算\nfunc mul(A, B [][]int64, mod int64) [][]int64 {\n\tvar i, j, k int64\n\tvar lenA, lenB, lenB0 int64\n\tlenA = int64(len(A))\n\tlenB = int64(len(B))\n\tlenB0 = int64(len(B[0]))\n\n\tC := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tC[i] = make([]int64, lenB0)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tfor k = 0; k < lenB; k++ {\n\t\t\tfor j = 0; j < lenB0; j++ {\n\t\t\t\tC[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod\n\t\t\t}\n\t\t}\n\t}\n\n\treturn C\n}\n\n// 行列Aに関するA^nの計算\nfunc powMat(A [][]int64, n, mod int64) [][]int64 {\n\tvar i int64\n\tvar lenA int64\n\tlenA = int64(len(A))\n\n\tB := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i] = make([]int64, lenA)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i][i] = 1\n\t}\n\tfor n > 0 {\n\t\tif n&1 == 1 {\n\t\t\tB = mul(B, A, mod)\n\t\t}\n\t\tA = mul(A, A, mod)\n\t\tn = (n >> 1)\n\t}\n\n\treturn B\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n"}, {"source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/678/D\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\ta, b, x, n int64\n)\n\nfunc main() {\n\ta, b, n, x = ReadInt64_4()\n\n\tA := [][]int64{\n\t\t[]int64{a + 1, -a},\n\t\t[]int64{1, 0},\n\t}\n\t// A := [][]int64{\n\t// \t[]int64{a + 1, NegativeMod(-a, MOD)},\n\t// \t[]int64{1, 0},\n\t// }\n\n\tAK := powMat(A, n-1, MOD)\n\n\tans := int64(0)\n\n\tbig := (a*x + b) % MOD\n\tbig *= AK[0][0]\n\tans += big\n\tans %= MOD\n\n\tsml := AK[0][1]\n\tsml *= x\n\tsml %= MOD\n\tans += sml\n\tans %= MOD\n\n\tfmt.Println(ans)\n}\n\n// NegativeMod can calculate a right residual whether value is positive or negative.\nfunc NegativeMod(val, m int64) int64 {\n\tres := val % m\n\tif res < 0 {\n\t\tres += m\n\t}\n\treturn res\n}\n\n// n*nのint型正方行列を生成する\nfunc newMat(n int64) [][]int64 {\n\tvar i int64\n\n\tA := make([][]int64, n)\n\tfor i = 0; i < n; i++ {\n\t\tA[i] = make([]int64, n)\n\t}\n\n\treturn A\n}\n\n// 行列A, Bに関するA*Bの計算\nfunc mul(A, B [][]int64, mod int64) [][]int64 {\n\tvar i, j, k int64\n\tvar lenA, lenB, lenB0 int64\n\tlenA = int64(len(A))\n\tlenB = int64(len(B))\n\tlenB0 = int64(len(B[0]))\n\n\tC := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tC[i] = make([]int64, lenB0)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tfor k = 0; k < lenB; k++ {\n\t\t\tfor j = 0; j < lenB0; j++ {\n\t\t\t\tC[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod\n\t\t\t}\n\t\t}\n\t}\n\n\treturn C\n}\n\n// 行列Aに関するA^nの計算\nfunc powMat(A [][]int64, n, mod int64) [][]int64 {\n\tvar i int64\n\tvar lenA int64\n\tlenA = int64(len(A))\n\n\tB := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i] = make([]int64, lenA)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i][i] = 1\n\t}\n\tfor n > 0 {\n\t\tif n&1 == 1 {\n\t\t\tB = mul(B, A, mod)\n\t\t}\n\t\tA = mul(A, A, mod)\n\t\tn = (n >> 1)\n\t}\n\n\treturn B\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n"}, {"source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/678/D\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\ta, b, x, n int64\n)\n\nfunc main() {\n\ta, b, n, x = ReadInt64_4()\n\n\t// A := [][]int64{\n\t// \t[]int64{a + 1, -a},\n\t// \t[]int64{1, 0},\n\t// }\n\tA := [][]int64{\n\t\t[]int64{a + 1, NegativeMod(-a, MOD)},\n\t\t[]int64{1, 0},\n\t}\n\n\tAK := powMat(A, n-1, MOD)\n\n\t// ans := AK[0][0]*(a*x+b) + AK[0][1]*x\n\t// ans %= MOD\n\n\tans := int64(0)\n\tans += AK[0][0] * (a*x + b)\n\tans = NegativeMod(ans, MOD)\n\tans += AK[0][1] * x\n\tans = NegativeMod(ans, MOD)\n\tfmt.Println(ans)\n}\n\n// NegativeMod can calculate a right residual whether value is positive or negative.\nfunc NegativeMod(val, m int64) int64 {\n\tres := val % m\n\tif res < 0 {\n\t\tres += m\n\t}\n\treturn res\n}\n\n// n*nのint型正方行列を生成する\nfunc newMat(n int64) [][]int64 {\n\tvar i int64\n\n\tA := make([][]int64, n)\n\tfor i = 0; i < n; i++ {\n\t\tA[i] = make([]int64, n)\n\t}\n\n\treturn A\n}\n\n// 行列A, Bに関するA*Bの計算\nfunc mul(A, B [][]int64, mod int64) [][]int64 {\n\tvar i, j, k int64\n\tvar lenA, lenB, lenB0 int64\n\tlenA = int64(len(A))\n\tlenB = int64(len(B))\n\tlenB0 = int64(len(B[0]))\n\n\tC := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tC[i] = make([]int64, lenB0)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tfor k = 0; k < lenB; k++ {\n\t\t\tfor j = 0; j < lenB0; j++ {\n\t\t\t\tC[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod\n\t\t\t}\n\t\t}\n\t}\n\n\treturn C\n}\n\n// 行列Aに関するA^nの計算\nfunc powMat(A [][]int64, n, mod int64) [][]int64 {\n\tvar i int64\n\tvar lenA int64\n\tlenA = int64(len(A))\n\n\tB := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i] = make([]int64, lenA)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i][i] = 1\n\t}\n\tfor n > 0 {\n\t\tif n&1 == 1 {\n\t\t\tB = mul(B, A, mod)\n\t\t}\n\t\tA = mul(A, A, mod)\n\t\tn = (n >> 1)\n\t}\n\n\treturn B\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n"}, {"source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/678/D\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\ta, b, x, n int64\n)\n\nfunc main() {\n\ta, b, n, x = ReadInt64_4()\n\n\tA := [][]int64{\n\t\t[]int64{a + 1, -a},\n\t\t[]int64{1, 0},\n\t}\n\n\tAK := powMat(A, n-1, MOD)\n\n\tans := AK[0][0]*(a*x+b) + AK[0][1]*x\n\tans %= MOD\n\tfmt.Println(ans)\n}\n\n// NegativeMod can calculate a right residual whether value is positive or negative.\nfunc NegativeMod(val, m int64) int64 {\n\tres := val % m\n\tif res < 0 {\n\t\tres += m\n\t}\n\treturn res\n}\n\n// n*nのint型正方行列を生成する\nfunc newMat(n int64) [][]int64 {\n\tvar i int64\n\n\tA := make([][]int64, n)\n\tfor i = 0; i < n; i++ {\n\t\tA[i] = make([]int64, n)\n\t}\n\n\treturn A\n}\n\n// 行列A, Bに関するA*Bの計算\nfunc mul(A, B [][]int64, mod int64) [][]int64 {\n\tvar i, j, k int64\n\tvar lenA, lenB, lenB0 int64\n\tlenA = int64(len(A))\n\tlenB = int64(len(B))\n\tlenB0 = int64(len(B[0]))\n\n\tC := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tC[i] = make([]int64, lenB0)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tfor k = 0; k < lenB; k++ {\n\t\t\tfor j = 0; j < lenB0; j++ {\n\t\t\t\tC[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod\n\t\t\t}\n\t\t}\n\t}\n\n\treturn C\n}\n\n// 行列Aに関するA^nの計算\nfunc powMat(A [][]int64, n, mod int64) [][]int64 {\n\tvar i int64\n\tvar lenA int64\n\tlenA = int64(len(A))\n\n\tB := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i] = make([]int64, lenA)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i][i] = 1\n\t}\n\tfor n > 0 {\n\t\tif n&1 == 1 {\n\t\t\tB = mul(B, A, mod)\n\t\t}\n\t\tA = mul(A, A, mod)\n\t\tn = (n >> 1)\n\t}\n\n\treturn B\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n"}, {"source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/678/D\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\ta, b, x, n int64\n)\n\nfunc main() {\n\ta, b, n, x = ReadInt64_4()\n\n\tA := [][]int64{\n\t\t[]int64{a + 1, -a},\n\t\t[]int64{1, 0},\n\t}\n\t// A := [][]int64{\n\t// \t[]int64{a + 1, NegativeMod(-a, MOD)},\n\t// \t[]int64{1, 0},\n\t// }\n\n\tAK := powMat(A, n-1, MOD)\n\n\tans := AK[0][0]*(a*x+b) + AK[0][1]*x\n\t// ans %= MOD\n\tans = NegativeMod(ans, MOD)\n\tfmt.Println(ans)\n}\n\n// NegativeMod can calculate a right residual whether value is positive or negative.\nfunc NegativeMod(val, m int64) int64 {\n\tres := val % m\n\tif res < 0 {\n\t\tres += m\n\t}\n\treturn res\n}\n\n// n*nのint型正方行列を生成する\nfunc newMat(n int64) [][]int64 {\n\tvar i int64\n\n\tA := make([][]int64, n)\n\tfor i = 0; i < n; i++ {\n\t\tA[i] = make([]int64, n)\n\t}\n\n\treturn A\n}\n\n// 行列A, Bに関するA*Bの計算\nfunc mul(A, B [][]int64, mod int64) [][]int64 {\n\tvar i, j, k int64\n\tvar lenA, lenB, lenB0 int64\n\tlenA = int64(len(A))\n\tlenB = int64(len(B))\n\tlenB0 = int64(len(B[0]))\n\n\tC := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tC[i] = make([]int64, lenB0)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tfor k = 0; k < lenB; k++ {\n\t\t\tfor j = 0; j < lenB0; j++ {\n\t\t\t\tC[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod\n\t\t\t}\n\t\t}\n\t}\n\n\treturn C\n}\n\n// 行列Aに関するA^nの計算\nfunc powMat(A [][]int64, n, mod int64) [][]int64 {\n\tvar i int64\n\tvar lenA int64\n\tlenA = int64(len(A))\n\n\tB := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i] = make([]int64, lenA)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i][i] = 1\n\t}\n\tfor n > 0 {\n\t\tif n&1 == 1 {\n\t\t\tB = mul(B, A, mod)\n\t\t}\n\t\tA = mul(A, A, mod)\n\t\tn = (n >> 1)\n\t}\n\n\treturn B\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n"}, {"source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/678/D\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\ta, b, x, n int64\n)\n\nfunc main() {\n\ta, b, n, x = ReadInt64_4()\n\n\t// A := [][]int64{\n\t// \t[]int64{a + 1, -a},\n\t// \t[]int64{1, 0},\n\t// }\n\tA := [][]int64{\n\t\t[]int64{a + 1, NegativeMod(-a, MOD)},\n\t\t[]int64{1, 0},\n\t}\n\n\tAK := powMat(A, n-1, MOD)\n\n\tans := AK[0][0]*(a*x+b) + AK[0][1]*x\n\tans %= MOD\n\tfmt.Println(ans)\n}\n\n// NegativeMod can calculate a right residual whether value is positive or negative.\nfunc NegativeMod(val, m int64) int64 {\n\tres := val % m\n\tif res < 0 {\n\t\tres += m\n\t}\n\treturn res\n}\n\n// n*nのint型正方行列を生成する\nfunc newMat(n int64) [][]int64 {\n\tvar i int64\n\n\tA := make([][]int64, n)\n\tfor i = 0; i < n; i++ {\n\t\tA[i] = make([]int64, n)\n\t}\n\n\treturn A\n}\n\n// 行列A, Bに関するA*Bの計算\nfunc mul(A, B [][]int64, mod int64) [][]int64 {\n\tvar i, j, k int64\n\tvar lenA, lenB, lenB0 int64\n\tlenA = int64(len(A))\n\tlenB = int64(len(B))\n\tlenB0 = int64(len(B[0]))\n\n\tC := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tC[i] = make([]int64, lenB0)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tfor k = 0; k < lenB; k++ {\n\t\t\tfor j = 0; j < lenB0; j++ {\n\t\t\t\tC[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod\n\t\t\t}\n\t\t}\n\t}\n\n\treturn C\n}\n\n// 行列Aに関するA^nの計算\nfunc powMat(A [][]int64, n, mod int64) [][]int64 {\n\tvar i int64\n\tvar lenA int64\n\tlenA = int64(len(A))\n\n\tB := make([][]int64, lenA)\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i] = make([]int64, lenA)\n\t}\n\n\tfor i = 0; i < lenA; i++ {\n\t\tB[i][i] = 1\n\t}\n\tfor n > 0 {\n\t\tif n&1 == 1 {\n\t\t\tB = mul(B, A, mod)\n\t\t}\n\t\tA = mul(A, A, mod)\n\t\tn = (n >> 1)\n\t}\n\n\treturn B\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n"}], "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e"} {"nl": {"description": "Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $$$1$$$, $$$5$$$, $$$10$$$ and $$$50$$$ respectively. The use of other roman digits is not allowed.Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence simply as the sum of digits in it.For example, the number XXXV evaluates to $$$35$$$ and the number IXI — to $$$12$$$.Pay attention to the difference to the traditional roman system — in our system any sequence of digits is valid, moreover the order of digits doesn't matter, for example IX means $$$11$$$, not $$$9$$$.One can notice that this system is ambiguous, and some numbers can be written in many different ways. Your goal is to determine how many distinct integers can be represented by exactly $$$n$$$ roman digits I, V, X, L.", "input_spec": "The only line of the input file contains a single integer $$$n$$$ ($$$1 \\le n \\le 10^9$$$) — the number of roman digits to use.", "output_spec": "Output a single integer — the number of distinct integers which can be represented using $$$n$$$ roman digits exactly.", "sample_inputs": ["1", "2", "10"], "sample_outputs": ["4", "10", "244"], "notes": "NoteIn the first sample there are exactly $$$4$$$ integers which can be represented — I, V, X and L.In the second sample it is possible to represent integers $$$2$$$ (II), $$$6$$$ (VI), $$$10$$$ (VV), $$$11$$$ (XI), $$$15$$$ (XV), $$$20$$$ (XX), $$$51$$$ (IL), $$$55$$$ (VL), $$$60$$$ (XL) and $$$100$$$ (LL)."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nvar v []int64 = []int64{0,4,10,20,35,56,83,116,155,198,244,292}\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\n\tvar n int64\n\tfmt.Fscanf(reader, \"%d\", &n)\n\t\n\tif int(n) < len(v) {\n\t\tfmt.Printf(\"%d\", v[n])\n\t} else {\n\t\tfmt.Printf(\"%d\", 49 * (n - int64(len(v)) + 1) + v[len(v) - 1])\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF997B(in io.Reader, out io.Writer) {\n\ta := [...]int{0, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244}\n\tvar n int64\n\tFscan(in, &n)\n\tif n < 11 {\n\t\tFprint(out, a[n])\n\t} else {\n\t\tFprint(out, 49*n-247)\n\t}\n}\n\nfunc main() { CF997B(os.Stdin, os.Stdout) }\n"}], "negative_code": [], "src_uid": "75ec99318736a8a1b62a8d51efd95355"} {"nl": {"description": "Fafa owns a company that works on huge projects. There are n employees in Fafa's company. Whenever the company has a new project to start working on, Fafa has to divide the tasks of this project among all the employees.Fafa finds doing this every time is very tiring for him. So, he decided to choose the best l employees in his company as team leaders. Whenever there is a new project, Fafa will divide the tasks among only the team leaders and each team leader will be responsible of some positive number of employees to give them the tasks. To make this process fair for the team leaders, each one of them should be responsible for the same number of employees. Moreover, every employee, who is not a team leader, has to be under the responsibility of exactly one team leader, and no team leader is responsible for another team leader.Given the number of employees n, find in how many ways Fafa could choose the number of team leaders l in such a way that it is possible to divide employees between them evenly.", "input_spec": "The input consists of a single line containing a positive integer n (2 ≤ n ≤ 105) — the number of employees in Fafa's company.", "output_spec": "Print a single integer representing the answer to the problem.", "sample_inputs": ["2", "10"], "sample_outputs": ["1", "3"], "notes": "NoteIn the second sample Fafa has 3 ways: choose only 1 employee as a team leader with 9 employees under his responsibility. choose 2 employees as team leaders with 4 employees under the responsibility of each of them. choose 5 employees as team leaders with 1 employee under the responsibility of each of them. "}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n int\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &n)\n\tfact := make([]int, 0)\n\tcount := 0\n\tfor n%2 == 0 {\n\t\tcount++\n\t\tn /= 2\n\t}\n\tfact = append(fact, count)\n\tcount = 0\n\tfor i := 3; n > 1; i += 2 {\n\t\tfor n%i == 0 {\n\t\t\tn /= i\n\t\t\tcount++\n\t\t}\n\t\tif count > 0 {\n\t\t\tfact = append(fact, count)\n\t\t\tcount = 0\n\t\t}\n\t}\n\tans := 1\n\tfor i := 0; i < len(fact); i++ {\n\t\tans *= (fact[i] + 1)\n\t}\n\tfmt.Println(ans - 1)\n}\n"}, {"source_code": "// A. Fafa and his Company\n/*\nFafa owns a company that works on huge projects. There are n employees\nin Fafa's company. Whenever the company has a new project to start working on,\nFafa has to divide the tasks of this project among all the employees.\n\nFafa finds doing this every time is very tiring for him. So,\nhe decided to choose the best l employees in his company as team leaders.\nWhenever there is a new project, Fafa will divide the tasks among only\nthe team leaders and each team leader will be responsible of some positive\nnumber of employees to give them the tasks. To make this process fair\nfor the team leaders, each one of them should be responsible for the same\nnumber of employees. Moreover, every employee, who is not a team leader,\nhas to be under the responsibility of exactly one team leader,\nand no team leader is responsible for another team leader.\n\nGiven the number of employees n, find in how many ways Fafa could choose\nthe number of team leaders l in such a way that it is possible to divide\nemployees between them evenly.\n\nInput\n\nThe input consists of a single line containing a positive integer\nn (2 ≤ n ≤ 105) — the number of employees in Fafa's company.\n\nOutput\n\nPrint a single integer representing the answer to the problem.\n\nExamples\nInput\n2\n\nOutput\n1\n\nInput\n10\n\nOutput\n3\n\nNote\nIn the second sample Fafa has 3 ways:\n\n choose only 1 employee as a team leader with 9 employees under his responsibility.\n choose 2 employees as team leaders with 4 employees under the responsibility of each of them.\n choose 5 employees as team leaders with 1 employee under the responsibility of each of them.\n*/\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput, _, _ := reader.ReadLine()\n\tin, _ := strconv.Atoi(string(input))\n\tsol935A(in)\n}\n\nfunc sol935A(in int) {\n\tcount := 0\n\tfor i := 1; i < in; i++ {\n\t\tif in%i == 0 {\n\t\t\tcount++\n\t\t}\n\t}\n\tfmt.Print(count)\n}\n"}, {"source_code": "// A. Fafa and his Company\n/*\nFafa owns a company that works on huge projects. There are n employees\nin Fafa's company. Whenever the company has a new project to start working on,\nFafa has to divide the tasks of this project among all the employees.\n\nFafa finds doing this every time is very tiring for him. So,\nhe decided to choose the best l employees in his company as team leaders.\nWhenever there is a new project, Fafa will divide the tasks among only\nthe team leaders and each team leader will be responsible of some positive\nnumber of employees to give them the tasks. To make this process fair\nfor the team leaders, each one of them should be responsible for the same\nnumber of employees. Moreover, every employee, who is not a team leader,\nhas to be under the responsibility of exactly one team leader,\nand no team leader is responsible for another team leader.\n\nGiven the number of employees n, find in how many ways Fafa could choose\nthe number of team leaders l in such a way that it is possible to divide\nemployees between them evenly.\n\nInput\n\nThe input consists of a single line containing a positive integer\nn (2 ≤ n ≤ 105) — the number of employees in Fafa's company.\n\nOutput\n\nPrint a single integer representing the answer to the problem.\n\nExamples\nInput\n2\n\nOutput\n1\n\nInput\n10\n\nOutput\n3\n\nNote\nIn the second sample Fafa has 3 ways:\n\n choose only 1 employee as a team leader with 9 employees under his responsibility.\n choose 2 employees as team leaders with 4 employees under the responsibility of each of them.\n choose 5 employees as team leaders with 1 employee under the responsibility of each of them.\n*/\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput, _, _ := reader.ReadLine()\n\tin, _ := strconv.Atoi(string(input))\n\tsol935A(in)\n}\n\nfunc sol935A(in int) {\n\tcount := 0\n\tfor i := 1; i <= in/2; i++ {\n\t\tif in%i == 0 {\n\t\t\tcount++\n\t\t}\n\t}\n\tfmt.Print(count)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\td := 0\n\tfor i:=2 ; i<=n; i++{\n\t\tif (n%i==0){\n\t\t\td++\n\t\t}\n\t}\n\tfmt.Println(d)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tcnt := 0\n\tvar n int\n\tfmt.Scan(&n)\n\tfor i := 1; i <= n/2; i++ {\n\t\tif (n-i)%i == 0 {\n\t\t\tcnt++\n\t\t}\n\t}\n\tfmt.Println(cnt)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tvar count = 0\n\t_, _ = fmt.Scan(&n)\n\tfor i := 1; i < n; i++ {\n\t\tif (n - i) % i == 0 {\n\t\t\tcount ++\n\t\t}\n\t}\n\tfmt.Println(count)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\n\tcnt := 0\n\tfor i := 1; i <= n/2; i++ {\n\t\tif (n-i)%i == 0 {\n\t\t\tcnt++\n\t\t}\n\t}\n\tfmt.Println(cnt)\n}\n"}, {"source_code": "package main\n \nimport \"fmt\"\n \nfunc main(){\n\tvar a int\n var itog int\n\tfmt.Scan(&a)\n\tfor i := 2; i <= a; i++ {\n\t\tif a % i == 0 {\n\t\t itog +=1\n\t\t}\n\t}\n\tfmt.Println(itog)\n}"}, {"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\tcnt := 0\n\tfor i := 1; i < n; i++ {\n\t\tif (n % i) == 0 {\n\t\t\tcnt++\n\t\t}\n\t}\n\tfmt.Println(cnt)\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"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tcnt := 0\n\tfor i:=2; i<=n; i++ {\n\t\tif (n%i==0) {\n\t\t\tcnt++\n\t\t};\n\t}\n\tfmt.Println(cnt);\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tk := 0\n\tk1 := 1\n\tfmt.Scan(&n)\n\tfor k1 != n {\n\t\tif (n-k1)%k1 == 0 && k1 != n {\n\t\t\tk++\n\t\t\t//fmt.Println((n-k1), (n-k1)%k1)\n\t\t}\n\t\tk1++\n\t}\n\tfmt.Println(k)\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\n\tvar n int\n\tfmt.Scanf(\"%d\\n\", &n)\n\n\tcount := 0\n\tfor i := 1; i <= n/2; i += 1 {\n\t\tif (n - i) % i ==0 {\n\t\t\tcount+=1\n\t\t}\n\t}\n\tfmt.Print(count)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc Employee(number int) int {\n\tvar array []int\n\tfor i:=1;i<=number/2;i++ {\n\t\tif number % i == 0 {\n\t\t\tarray = append(array,i)\n\t\t}\n\t}\n\treturn len(array)\n}\n\nfunc main() {\n\tvar number int\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _ := reader.ReadString('\\n')\n\ttext = strings.TrimRight(text,\"\\r\\n\")\n\tnumber,_ = strconv.Atoi(text)\n\tfmt.Println(Employee(number))\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar input int\n\t_, err := fmt.Scanf(\"%d\", &input)\n\n\t//validate input\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t\treturn\n\t}\n\n\tif input < 2 || float64(input) > math.Pow10(5) {\n\t\tfmt.Println(\"input out of range\")\n\t\treturn\n\t}\n\n\tcount := 1\n\n\tfor numberOfLeaders := 2; numberOfLeaders <= input/2; numberOfLeaders ++ {\n\t\tif input % numberOfLeaders == 0 {\n\t\t\tcount += 1\n\t\t}\n\t}\n\n\tfmt.Println(count)\n}"}, {"source_code": "//A. Фафа и его компания\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, rez int\n\n\tfmt.Scan(&n)\n\n\tfor i := 2; i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\trez++\n\t\t}\n\t}\n\n\tfmt.Println(rez)\n}\n"}, {"source_code": "// Codeforces helper functions\n// 20 Jan 18\n// samadhi\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n\t\"unicode\"\n)\n\nconst debug = true\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tn := gsli(reader)[0]\n\n\tways := 0\n\tfor i := 1; i <= 50000; i++ {\n\t\tif (n-i)%i == 0 && n-i > 0 {\n\t\t\tways++\n\t\t}\n\t}\n\n\tfmt.Printf(\"%v\", ways)\n\n}\n\n// Input helpers\n\n// If you don't pass in a reference to the reader, and just instantiate a new\n// one every time, it will work locally, with IO typed at human-speed, but not\n// on Codeforces.\n\n// Get Space-separated Line as Strings\n//\n// Example input:\n// 1 test 382.0\n// Example output:\n// [\"1\", \"test\", \"382.0\"]\n\nfunc gsls(reader *bufio.Reader) (arr []string) {\n\t// Get a full line\n\tinput, _ := reader.ReadString('\\n')\n\n\t//Strip newline and return chars, if any\n\tinput = strings.TrimSuffix(input, \"\\n\")\n\tinput = strings.TrimSuffix(input, \"\\r\")\n\n\t// Split at the spaces into an array\n\tarr = strings.Split(input, \" \")\n\n\treturn\n}\n\n// Get Space-separated Line as Integers\n// Any non-valid integers will be 0\n//\n// Example input:\n// test 1 12.3 -117\n// Example output:\n// [0, 1, 0, -117]\n\nfunc gsli(reader *bufio.Reader) (arr []int) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.Atoi(e)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Get Space-separated Line as 64-bit Floats\n// Any non-valid floats will be 0\n//\n// Example input:\n// test 128.328 12 -11.0\n// Example output:\n// [0, 128.328, 12, -11]\n\nfunc gslf(reader *bufio.Reader) (arr []float64) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.ParseFloat(e, 64)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// String helpers\n\n// Is Lowercase\n// Given some string[i], return whether it is lower case or not.\n\nfunc isl(b byte) bool {\n\tvar r rune\n\tr = rune(b)\n\treturn unicode.IsLower(r)\n}\n\n// Math helpers\n\n// Positve Modulo\n// Returns x mod y, but always positive\n\nfunc posMod(x, y int) int {\n\treturn (x%y + y) % y\n}\n\n// Max Int\n// Returns the max of two ints\n\nfunc maxInt(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\n// Output helpers\n\nfunc yes() {\n\tfmt.Println(\"Yes\")\n}\n\nfunc no() {\n\tfmt.Println(\"No\")\n}\n\n// Debug helpers\n\n// From https://groups.google.com/forum/#!topic/golang-nuts/Qlxs3V77nss\n\nfunc dbg(s string, a ...interface{}) {\n\tif debug {\n\t\tfmt.Printf(s, a...)\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar n, cnt int\n\tfmt.Scan(&n)\n\tfor i := 2; i <= n; i++ {\n\t\tif n % i == 0 {\n\t\t\tcnt ++\n\t\t}\n\t}\n\tfmt.Println(cnt)\n}\n\n"}, {"source_code": " package main\n \n import \"fmt\"\n \n func main() {\n \tvar numOfEmployee int\n \tfmt.Scan(&numOfEmployee)\n \tvar count int = 0\n \tfor i :=1; i <= numOfEmployee/2; i++ {\n \t\tres := numOfEmployee - i\n \t\tif res % i == 0 {\n \t\t\tcount++\n \t\t}\n \t}\n \tfmt.Println(count)\n }"}, {"source_code": " package main\n \n import (\n \t\"fmt\"\n )\n \n func main() {\n \tvar numOfEmployee int\n \tfmt.Scan(&numOfEmployee)\n \tvar count int = 0\n \tfor i :=1; i <= numOfEmployee/2; i++ {\n \t\tres := numOfEmployee - i\n \t\tif res % i == 0 {\n \t\t\tcount++\n \t\t}\n \t}\n \tfmt.Println(count)\n }"}, {"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 n uint32\n\tvar c uint32 = 0\n\tfmt.Fscanf(in, \"%d\\n\", &n)\n\tfor i := 1; uint32(i) <= n/2; i++ {\n\t\tif (n-uint32(i))%uint32(i) == 0 {\n\t\t\tc++\n\t\t}\n\t}\n\tfmt.Println(c)\n}\n"}, {"source_code": "package main\n \nimport \"fmt\"\n \nfunc main(){\n\tvar n int\n var res int\n\tfmt.Scan(&n)\n\tfor i := 2; i <= n; i++ {\n\t\tif n % i == 0 {\n\t\t res +=1\n\t\t}\n\t}\n\tfmt.Println(res)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tvar count int = 0\n\tfmt.Scan(&n)\n\tfor i := 1; i < (n/2)+1; i++ {\n\t\tif n%i == 0 {\n\t\t\tcount += 1\n\t\t}\n\t}\n\tfmt.Print(count)\n}\n"}, {"source_code": "package main\n \nimport \"fmt\"\n \nfunc main() {\n\tvar n int\n\tfmt.Scanln(&n)\n\tans := 0\n\tfor i := 1; i < n; i++ {\n\t\tif n % i == 0 {\n\t\t\tans++\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar t,num int\n\tfmt.Scan(&t)\n\tfor i:=1;i 0 {\n\t\tif (n-i)%i == 0 {\n\t\t\tcount++\n\t\t}\n\t\ti++\n\t}\n\n\treturn count\n}\n"}, {"source_code": "package main\n \nimport \"fmt\"\n \nfunc main() {\n\tvar n int\n\tk := 0\n\tk1 := 1\n\tfmt.Scan(&n)\n\tfor k1 != n {\n\t\tif (n-k1)%k1 == 0 && k1 != n {\n\t\t\tk++\n\t\t\t//fmt.Println((n-k1), (n-k1)%k1)\n\t\t}\n\t\tk1++\n\t}\n\tfmt.Println(k)\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tvar k int\n\n\tfmt.Scan(&n)\n\n\tfor i := 1; i <= n-i; i++ {\n\t\tif (n-i)%i == 0 {\n\t\t\tk++\n\t\t}\n\t}\n\n\tfmt.Println(k)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\trs := 1\n\tn := 0\n\tfmt.Scan(&n)\n\tfor i := 2; i < n; i++ {\n\t\tif n%i == 0 {\n\t\t\trs++\n\t\t}\n\t}\n\tfmt.Print(rs)\n}\n"}, {"source_code": "// cf935a project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, c int\n\tfmt.Scan(&n)\n\tfor i := 2; i <= n/2; i++ {\n\t\tif n%i == 0 {\n\t\t\tc++\n\t\t}\n\t}\n\tc++\n\tfmt.Println(c)\n}"}, {"source_code": "package main\nimport \"fmt\"\nfunc main() {\n var n, ruk, yes int\n yes = 1\n fmt.Scan(&n)\n for ruk = 2; ruk <= n/2; ruk++{\n if (n - ruk) % ruk == 0{\n yes++\n }\n }\n fmt.Print(yes)\n}"}, {"source_code": "package main\nimport \"fmt\"\n\nfunc main(){\n\tvar n,count,i int64\n\tfmt.Scan(&n)\n\tcount=0\n\tfor i=1 ; i n; i /= 2 {\n\t}\n\n\tfor ; i*x < n; i++ {\n\t}\n\tfmt.Println(i - 1)\n}\n"}], "src_uid": "8551308e5ff435e0fc507b89a912408a"} {"nl": {"description": "Alice and Bob play 5-in-a-row game. They have a playing field of size 10 × 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts.In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins immediately.Alice wins if some crosses in the field form line of length not smaller than 5. This line can be horizontal, vertical and diagonal.", "input_spec": "You are given matrix 10 × 10 (10 lines of 10 characters each) with capital Latin letters 'X' being a cross, letters 'O' being a nought and '.' being an empty cell. The number of 'X' cells is equal to the number of 'O' cells and there is at least one of each type. There is at least one empty cell. It is guaranteed that in the current arrangement nobody has still won.", "output_spec": "Print 'YES' if it's possible for Alice to win in one turn by putting cross in some empty cell. Otherwise print 'NO'.", "sample_inputs": ["XX.XX.....\n.....OOOO.\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n..........", "XXOXX.....\nOO.O......\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n.........."], "sample_outputs": ["YES", "NO"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"os\"\n\t\"fmt\"\n\t\"bufio\"\n)\n\nfunc winpos(table [][]byte, sx, sy, dx, dy int) bool {\n\tx, y := sx, sy\n\ti := 0\n\tfor i < 5 {\n\t if x>=10 || y>=10 || x<0 || y<0{\n\t return false\n\t }\n\t \n\t\tif table[x][y]!='X' {\n\t\t\treturn false\n\t\t}\n\t\t\n\t\tx += dx\n\t\ty += dy\n\t\t\n\t\ti++\n\t}\n\t\n\treturn true\n}\n\nfunc win(table [][]byte) bool {\n\tfor i := 0; i < 10; i++ {\n\t\tfor j := 0;j < 10; j++ {\n\t\t\tif winpos(table, i, j, 0, 1) || winpos(table, i, j, 1, 0) || winpos(table, i, j, 1, 1) || winpos(table,i,j,1,-1) {\n\t\t\t\treturn true \n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn false\n}\n\nfunc main() {\n stdin := bufio.NewReader(os.Stdin)\n\ttable := make([][]byte, 10)\n\tfor i := 0; i < 10; i++ {\n\t\ttable[i], _, _ = stdin.ReadLine()\n\t\t\n\t}\n\t\n\tfor i := 0; i < 10; i++ {\n\t\tfor j := 0;j < 10; j++ {\n\t\t\tif table[i][j]=='.' {\n\t\t\t\ttable[i][j]='X'\n\t\t\t\tif win(table) {\n\t\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\t\tos.Exit(0)\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\ttable[i][j]='.'\n\t\t\t}\n\t\t}\n\t}\n\t\n\tfmt.Println(\"NO\")\n\tos.Exit(0)\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"os\"\n\t\"fmt\"\n\t\"bufio\"\n)\n\nfunc winpos(table [][]byte, sx, sy, dx, dy int) bool {\n\tx, y := sx, sy\n\ti := 0\n\tfor i < 5 {\n\t if x>=10 || y>=10 {\n\t return false\n\t }\n\t \n\t\tif table[x][y]!='X' {\n\t\t\treturn false\n\t\t}\n\t\t\n\t\tx += dx\n\t\ty += dy\n\t\t\n\t\ti++\n\t}\n\t\n\treturn true\n}\n\nfunc win(table [][]byte) bool {\n\tfor i := 0; i < 10; i++ {\n\t\tfor j := 0;j < 10; j++ {\n\t\t\tif winpos(table, i, j, 0, 1) || winpos(table, i, j, 1, 0) || winpos(table, i, j, 1, 1) {\n\t\t\t\treturn true \n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn false\n}\n\nfunc main() {\n stdin := bufio.NewReader(os.Stdin)\n\ttable := make([][]byte, 10)\n\tfor i := 0; i < 10; i++ {\n\t\ttable[i], _, _ = stdin.ReadLine()\n\t\t\n\t}\n\t\n\tfor i := 0; i < 10; i++ {\n\t\tfor j := 0;j < 10; j++ {\n\t\t\tif table[i][j]=='.' {\n\t\t\t\ttable[i][j]='X'\n\t\t\t\tif win(table) {\n\t\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\t\tos.Exit(0)\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\ttable[i][j]='.'\n\t\t\t}\n\t\t}\n\t}\n\t\n\tfmt.Println(\"NO\")\n\tos.Exit(0)\n}\n"}], "src_uid": "d5541028a2753c758322c440bdbf9ec6"} {"nl": {"description": "Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes. Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold: the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 < x2; the triangle formed by point A, B and C is rectangular and isosceles ( is right); all points of the favorite rectangle are located inside or on the border of triangle ABC; the area of triangle ABC is as small as possible. Help the bear, find the required points. It is not so hard to proof that these points are unique.", "input_spec": "The first line contains two integers x, y ( - 109 ≤ x, y ≤ 109, x ≠ 0, y ≠ 0).", "output_spec": "Print in the single line four integers x1, y1, x2, y2 — the coordinates of the required points.", "sample_inputs": ["10 5", "-10 5"], "sample_outputs": ["0 15 15 0", "-15 0 0 15"], "notes": "NoteFigure to the first sample"}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x, y int\n\tfmt.Scan(&x, &y)\n\tif x < 0 {\n\t\tif y < 0 {\n\t\t\tfmt.Println(x+y, 0, 0, x+y)\n\t\t} else {\n\t\t\tfmt.Println(x-y, 0, 0, y-x)\n\t\t}\n\t} else {\n\t\tif y < 0 {\n\t\t\tfmt.Println(0, y-x, x-y, 0)\n\t\t} else {\n\t\t\tfmt.Println(0, x+y, x+y, 0)\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\nimport (\n\t\"fmt\"\n\t//\"unicode/utf8\"\n)\n\nfunc main() {\n\tvar a,b int64\n\tfmt.Scan(&a,&b)\n\tif a>0 && b>0 {\n\t\tfmt.Print(\"0 \",a+b,a+b,\" 0\")\n\t\tfmt.Println()\n\t} else if a<0 && b>0 {\n\t\tfmt.Print(a-b,\" 0 \",\"0 \",b-a)\n\t\tfmt.Println()\n\t} else if a<0 && b<0 {\n\t\tfmt.Print(a+b,\" 0 \",\"0 \",a+b)\n\t\tfmt.Println()\n\t} else if a>0 && b<0 {\n\t fmt.Print(\"0 \",b-a,a-b,\" 0\")\n\t fmt.Println()\n\t}\n\n}\n\n\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x, y, gradient, c int64\n\n\tfmt.Scan(&x, &y)\n\n\tgradient = x*y/abs(x*y)\n\tc = y + gradient*x\n\n\tif x < 0 {\n\t\tfmt.Println(-abs(c), 0, 0, c)\n\t} else {\n\t\tfmt.Println(0, c, abs(c), 0)\n\t}\n}\n\nfunc abs(n int64) int64 {\n\tif n < 0 {\n\t\treturn -n\n\t} else {\n\t\treturn n\n\t}\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var x,y int\n fmt.Scan(&x,&y)\n if x < 0 {\n if y < 0 {\n fmt.Println(x+y,0,0,x+y)\n } else {\n fmt.Println(x-y,0,0,-(x-y))\n }\n } else {\n if y < 0 {\n fmt.Println(0,-(x-y),x-y,0)\n } else {\n fmt.Println(0,x+y,x+y,0)\n }\n }\n}\n"}, {"source_code": "package main\nimport (\n\t\"fmt\"\n\t//\"unicode/utf8\"\n)\n\nfunc main() {\n\tvar a,b int64 //input\n\tfmt.Scan(&a,&b)\n\tif a>0 && b>0 {\n\t\tfmt.Print(\"0 \",a+b,a+b,\" 0\")\n\t\tfmt.Println()\n\t} else if a<0 && b>0 {\n\t\tfmt.Print(a-b,\" 0 \",\"0 \",b-a)\n\t\tfmt.Println()\n\t} else if a<0 && b<0 {\n\t\tfmt.Print(a+b,\" 0 \",\"0 \",a+b)\n\t\tfmt.Println()\n\t} else if a>0 && b<0 {\n\t fmt.Print(\"0 \",b-a,a-b,\" 0\")\n\t fmt.Println()\n\t}\n\n}\n\n\n"}, {"source_code": "// 336A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a,b int\n\tfmt.Scan(&a, &b)\n\tx := a+b\n\ty:= a-b\n\tif a>0{\n\t\tif b>0{\n\t\t\tfmt.Println(0,x,x,0)\n\t\t}else{\n\t\t\tfmt.Println(0,-y,y,0)\n\t\t}\n\t} else{\n\t\tif b>0{\n\t\t\tfmt.Println(y,0,0,-y)\n\t\t}else{\n\t\t\tfmt.Println(x,0,0,x)\n\t\t}\n\t}\n\t\n}"}, {"source_code": "// 258A-mic\npackage main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var i, k float64\n fmt.Scan(&i, &k)\n t := int64(math.Abs(math.Abs(i) + math.Abs(k)))\n if i > 0 && k > 0 {\n fmt.Printf(\"0 %d %d 0\\n\", t, t)\n } else if i > 0 && k < 0 {\n fmt.Printf(\"0 %d %d 0\\n\", -t, t)\n } else if i < 0 && k > 0 {\n fmt.Printf(\"%d 0 0 %d\\n\", -t, t)\n } else {\n fmt.Printf(\"%d 0 0 %d\\n\", -t, -t)\n }\n}\n"}, {"source_code": "package main\nimport (\n \"fmt\"\n //\"unicode/utf8\"\n)\n\nfunc main() {\n var a,b int64\n fmt.Scan(&a,&b)\n if a>0 && b>0 {\n fmt.Print(\"0 \",a+b,a+b,\" 0\")\n fmt.Println()\n } else if a<0 && b>0 {\n fmt.Print(a-b,\" 0 \",\"0 \",b-a)\n fmt.Println()\n } else if a<0 && b<0 {\n fmt.Print(a+b,\" 0 \",\"0 \",a+b)\n fmt.Println()\n } else if a>0 && b<0 {\n fmt.Print(\"0 \",b-a,a-b,\" 0\")\n fmt.Println()\n }\n\n}\n\n\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var x,y int\n fmt.Scan(&x,&y)\n if x < 0 {\n if y < 0 {\n fmt.Println(x+y,0,0,x+y)\n } else {\n fmt.Println(x-y,0,0,-(x-y))\n }\n } else {\n if y < 0 {\n fmt.Println(0,-(x-y),x-y,0)\n } else {\n fmt.Println(0,x+y,x+y,0)\n }\n }\n}\n"}], "negative_code": [{"source_code": "package main\nimport (\n\t\"fmt\"\n\t//\"unicode/utf8\"\n)\n\nfunc main() {\n\tvar a,b int64\n\tfmt.Scan(&a,&b)\n\tif a>0 && b>0 {\n\t\tfmt.Print(\"0 \",a+b,a+b,\" 0\")\n\t\tfmt.Println()\n\t} else if a<0 && b>0 {\n\t\tfmt.Print(a-b,\"0 \",\"0 \",b-a)\n\t\tfmt.Println()\n\t} else if a<0 && b<0 {\n\t\tfmt.Print(a+b,\"0 \",\"0 \",a+b)\n\t\tfmt.Println()\n\t} else if a>0 && b<0 {\n\t fmt.Print(\"0 \",b-a,a-b,\" 0\")\n\t fmt.Println()\n\t}\n\n}\n\n\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x, y, gradient, c int\n\n\tfmt.Scan(&x, &y)\n\n\tgradient = x*y/abs(x*y)\n\tc = y + gradient*x\n\n\tif x < 0 {\n\t\tfmt.Println(-abs(c), 0, 0, c)\n\t} else {\n\t\tfmt.Println(0, c, abs(c), 0)\n\t}\n}\n\nfunc abs(n int) int {\n\tif n < 0 {\n\t\treturn -n\n\t} else {\n\t\treturn n\n\t}\n}"}, {"source_code": "// 336A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a,b int\n\tfmt.Scan(&a, &b)\n\tx := a+b\n\ty:= a-b\n\tif x>0{\n\t\tif y>0{\n\t\t\tfmt.Println(0,x,x,0)\n\t\t}else{\n\t\t\tfmt.Println(0,-y,y,0)\n\t\t}\n\t} else{\n\t\tif y>0{\n\t\t\tfmt.Println(y,0,0,-y)\n\t\t}else{\n\t\t\tfmt.Println(x,0,0,x)\n\t\t}\n\t}\n\t\n}"}, {"source_code": "// 258A-mic\npackage main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var i, k int\n fmt.Scan(&i, &k)\n t := int64(math.Abs(float64(i + k)))\n if i > 0 && k > 0 {\n fmt.Printf(\"0 %d %d 0\\n\", t, t)\n } else if i > 0 && k < 0 {\n fmt.Printf(\"0 %d %d 0\\n\", -t, t)\n } else if i < 0 && k > 0 {\n fmt.Printf(\"%d 0 0 %d\\n\", -t, t)\n } else {\n fmt.Println(\"%d 0 0 %d\\n\", -t, -t)\n }\n}\n"}, {"source_code": "// 258A-mic\npackage main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var i, k float64\n fmt.Scan(&i, &k)\n t := int64(math.Abs(math.Abs(i) + math.Abs(k)))\n if i > 0 && k > 0 {\n fmt.Printf(\"0 %d %d 0\\n\", t, t)\n } else if i > 0 && k < 0 {\n fmt.Printf(\"0 %d %d 0\\n\", -t, t)\n } else if i < 0 && k > 0 {\n fmt.Printf(\"%d 0 0 %d\\n\", -t, t)\n } else {\n fmt.Println(\"%d 0 0 %d\\n\", -t, -t)\n }\n}\n"}], "src_uid": "e2f15a9d9593eec2e19be3140a847712"} {"nl": {"description": "Today, Osama gave Fadi an integer $$$X$$$, and Fadi was wondering about the minimum possible value of $$$max(a, b)$$$ such that $$$LCM(a, b)$$$ equals $$$X$$$. Both $$$a$$$ and $$$b$$$ should be positive integers.$$$LCM(a, b)$$$ is the smallest positive integer that is divisible by both $$$a$$$ and $$$b$$$. For example, $$$LCM(6, 8) = 24$$$, $$$LCM(4, 12) = 12$$$, $$$LCM(2, 3) = 6$$$.Of course, Fadi immediately knew the answer. Can you be just like Fadi and find any such pair?", "input_spec": "The first and only line contains an integer $$$X$$$ ($$$1 \\le X \\le 10^{12}$$$).", "output_spec": "Print two positive integers, $$$a$$$ and $$$b$$$, such that the value of $$$max(a, b)$$$ is minimum possible and $$$LCM(a, b)$$$ equals $$$X$$$. If there are several possible such pairs, you can print any.", "sample_inputs": ["2", "6", "4", "1"], "sample_outputs": ["1 2", "2 3", "1 4", "1 1"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tt := int64(1)\n\t//fmt.Fscanf(in, \"%d\\n\", &t)\n\tfor tt := int64(0); tt < t; tt++ {\n\t\tn := int64(0)\n\t\tfmt.Fscanf(in, \"%d\\n\", &n)\n\t\ta, b := int64(1), n\n\t\tfor i := int64(1); i*i <= n; i++ {\n\t\t\tif n%i == 0 {\n\t\t\t\tif max(i, n/i) < max(a, b) && gcd(i, n/i) == 1 {\n\t\t\t\t\ta, b = i, n/i\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfmt.Fprintf(out, \"%d %d\\n\", a, b)\n\t}\n\treturn\n}\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc gcd(a, b int64) int64 {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn gcd(b, a%b)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc min(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar x, xx int64\n\tfmt.Scan(&x)\n\tsqrtx := int64(math.Sqrt(float64(x)))\n\ta := make([]int64, 0, 20)\n\txx = x\n\tfor i := int64(2); i <= sqrtx; i++ {\n\t\tvar b int64 = 1\n\t\tfor xx % i == 0 {\n\t\t\tb *= i\n\t\t\txx /= i\n\t\t}\n\t\tif b > 1 {\n\t\t\ta = append(a, b)\n\t\t}\n\t}\n\t// fmt.Println(a)\n\tans := x\n\tfor i := 0; i < (1 << uint(len(a))); i++ {\n\t\tvar tmp int64 = 1\n\t\tfor j := 0; j < len(a); j++ {\n\t\t\tif (i & (1 << uint(j))) != 0 {\n\t\t\t\ttmp *= a[j]\n\t\t\t}\n\t\t}\n\t\t// fmt.Println(i, tmp)\n\t\ttmp = max(tmp, x/tmp)\n\t\tans = min(ans, tmp)\n\t}\n\tfmt.Println(ans, x/ans)\n}\n\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc gcd(a int64, b int64) int64 {\n if b == 0 { return a }\n return gcd(b, a % b)\n}\n\nfunc lcm(a int64, b int64) int64 {\n return a / gcd(a, b) * b\n}\n\nfunc min(a int64, b int64) int64 {\n if a < b { return a }\n return b\n}\n\nfunc max(a int64, b int64) int64 {\n if a > b { return a }\n return b\n}\n\nfunc main() {\n var x int64\n fmt.Scanf(\"%d\", &x)\n ans := x\n for i := int64(1); i * i < x; i++ {\n if x % i != 0 { continue }\n\n j := x / i\n if lcm(i, j) == x {\n ans = min(ans, max(i, j))\n }\n }\n fmt.Println(x / ans, ans)\n}\n\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"sync\"\n)\nfunc gcd(a,b int64)int64{\n\tif(a==0){\n\t\treturn b\n\t}\n\treturn gcd(b%a,a)\n}\nfunc lcm(a,b int64)int64{\n\treturn a/gcd(a,b)*b\n}\nfunc min(a,b int64)int64{\n\tif(a>b){\n\t\treturn b\n\t}else{\n\t\treturn a\n\t}\n}\nfunc max(a,b int64)int64{\n\tif(a>b){\n\t\treturn a\n\t}\n\treturn b\n}\nfunc main(){\n\tvar n int64\n\tfmt.Scan(&n)\n\tvar mx int64\n\tmx=n\n\tfor i:=int64(1);int64(i*i)<=n;i++{\n\t\tif(n%i==0&&lcm(i,n/i)==n){\n\t\t\tmx=min(mx,max(i,n/i))\n\t\t}\n\t}\n\tfmt.Println(mx,n/mx)\n}\n\n/*********************** utility ***********************/\n\nvar out chan string\nvar in *bufio.Scanner\nvar outWg *sync.WaitGroup\n\nfunc init() {\n\t//set input\n\tin = bufio.NewScanner(os.Stdin)\n\tin.Buffer(make([]byte, 1024), int(2e+5))\n\tin.Split(bufio.ScanWords)\n\n\t// set output\n\tout = make(chan string, 16)\n\toutWg = &sync.WaitGroup{}\n\toutWg.Add(1)\n\n\twriter := bufio.NewWriterSize(os.Stdout, int(2e+5))\n\tgo func(writer *bufio.Writer) {\n\t\tdefer outWg.Done()\n\t\tdefer writer.Flush()\n\n\t\tfor line := range out {\n\t\t\twriter.WriteString(line + \"\\n\")\n\t\t}\n\t}(writer)\n}\n\nfunc ReadString() string {\n\tin.Scan()\n\treturn in.Text()\n}\n\nfunc ReadStringSlice(n int) []string {\n\ts := make([]string, n)\n\tfor i := 0; i < n; i++ {\n\t\ts[i] = ReadString()\n\t}\n\treturn s\n}\n\nfunc ReadInt() int {\n\tintStr := ReadString()\n\ti, _ := strconv.Atoi(intStr)\n\treturn i\n}\n\nfunc ReadIntSlice(n int) []int {\n\tarr := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tarr[i] = ReadInt()\n\t}\n\treturn arr\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc isPrime(number int64) bool {\n\tif number <= 1 {\n\t\treturn false\n\t}\n\tif number == 2 {\n\t\treturn true\n\t}\n\tif number%2 == 0 {\n\t\treturn false\n\t}\n\tsqrNumber := int64(math.Sqrt(float64(number)))\n\n\tfor i := int64(2); i <= sqrNumber; i++ {\n\t\tif number%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc gcd(m int64, n int64) int64 {\n\tif n == 0 {\n\t\treturn m\n\t}\n\treturn gcd(n, m%n)\n}\n\nfunc MaxLCM(n int64) (ansA int64, ansB int64) {\n\tif isPrime(n) || n == 1 {\n\t\treturn 1, n\n\t}\n\tsqrNumber := int64(math.Sqrt(float64(n)))\n\tvar ANS_END int64 = int64(math.Pow(10, 12)) + 1\n\tansA = ANS_END\n\tansB = ANS_END\n\tfor i := int64(1); i <= sqrNumber; i++ {\n\t\ta := i\n\t\tif n%a == 0 {\n\t\t\tb := n / a\n\t\t\tif b < ansB && (a == 1 || gcd(a, b) == 1) {\n\t\t\t\tansA = a\n\t\t\t\tansB = b\n\t\t\t}\n\t\t}\n\t}\n\treturn ansA, ansB\n}\n\nfunc main() {\n\tvar n int64 = 0\n\tfmt.Scanf(\"%d\\n\", &n)\n\tfmt.Println(MaxLCM(n))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc max(a,b int64) int64 {\n\tif a bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\tx int64\n)\n\nfunc main() {\n\tx = ReadInt64()\n\n\tif x == 1 {\n\t\tfmt.Println(1, 1)\n\t\treturn\n\t}\n\n\tmemo := TrialDivision(x)\n\tA := []int64{}\n\tfor k, v := range memo {\n\t\tA = append(A, PowInt(k, v))\n\t}\n\n\tans := int64(INF_BIT60)\n\tma, mb := int64(-1), int64(-1)\n\tn := len(A)\n\tfor i := 0; i < (1 << uint(n)); i++ {\n\t\ta, b := int64(1), int64(1)\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif NthBit(int64(i), j) == 1 {\n\t\t\t\ta *= A[j]\n\t\t\t} else {\n\t\t\t\tb *= A[j]\n\t\t\t}\n\t\t}\n\n\t\tif ChMin(&ans, Max(a, b)) {\n\t\t\tma, mb = a, b\n\t\t}\n\t}\n\n\tfmt.Println(ma, mb)\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// Max returns the max integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Max(integers ...int64) int64 {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m < integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// NthBit returns nth bit value of an argument.\n// n starts from 0.\nfunc NthBit(num int64, nth int) int64 {\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 int64, nth int) int64 {\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 int64, nth int) int64 {\n\treturn num & ^(1 << uint(nth))\n}\n\n// PopCount returns the number of ON bit of an argument.\nfunc PopCount(num int64) 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// PowInt is integer version of math.Pow\n// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).\nfunc PowInt(a, e int64) int64 {\n\tif a < 0 || e < 0 {\n\t\tpanic(errors.New(\"[argument error]: PowInt does not accept negative integers\"))\n\t}\n\n\tif e == 0 {\n\t\treturn 1\n\t}\n\n\tif e%2 == 0 {\n\t\thalfE := e / 2\n\t\thalf := PowInt(a, halfE)\n\t\treturn half * half\n\t}\n\n\treturn a * PowInt(a, e-1)\n}\n\n// 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"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\tsc = bufio.NewScanner(os.Stdin)\n\twr = bufio.NewWriter(os.Stdout)\n)\n\nfunc scanInt() int {\n\tsc.Scan()\n\ta, _ := strconv.Atoi(sc.Text())\n\treturn a\n}\n\nfunc scanInt64() int64 {\n\tsc.Scan()\n\ta, _ := strconv.ParseInt(sc.Text(), 10, 64)\n\treturn a\n}\n\nfunc scanInts(n int) []int {\n\tres := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = scanInt()\n\t}\n\treturn res\n}\n\nfunc scanText() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc printInts(a ...int) {\n\tfor i, e := range a {\n\t\tfmt.Fprint(wr, e)\n\t\tif i != len(a)-1 {\n\t\t\tfmt.Fprint(wr, \" \")\n\t\t}\n\t}\n\tfmt.Fprintln(wr)\n\twr.Flush()\n}\n\n\n\nvar (\n\tx int64\n\tfac []int64\n)\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\tx = scanInt64()\n\tans := x\n\tret := [...]int64 {1, x}\n\tfor i := int64(2); i * i <= x; i++ {\n\t\tif x % i == 0 {\n\t\t\tmul := int64(1)\n\t\t\tfor x % i == 0 {\n\t\t\t\tx /= i\n\t\t\t\tmul *= i\n\t\t\t}\n\t\t\tfac = append(fac, mul)\n\t\t}\n\t}\n\tif x != 1 {\n\t\tfac = append(fac, x)\n\t}\n\tfacLen := uint(len(fac))\n\tfor mask := uint(0); mask < (1 << facLen); mask++ {\n\t\tmul := [...]int64 {1, 1}\n\t\tfor i := uint(0); i < facLen; i++ {\n\t\t\tmul[mask >> i & 1] *= fac[i]\n\t\t}\n\t\tif mul[0] > mul[1] {\n\t\t\tmul[0], mul[1] = mul[1], mul[0]\n\t\t}\n\t\tmaxMul := mul[0]\n\t\tif mul[1] > maxMul {\n\t\t\tmaxMul = mul[1]\n\t\t}\n\t\tif maxMul < ans {\n\t\t\tans = maxMul\n\t\t\tret[0], ret[1] = mul[0], mul[1]\n\t\t}\n\t}\n\tfmt.Printf(\"%d %d\\n\", ret[0], ret[1])\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"sync\"\n)\nfunc __gcd(a, b int64) int64 {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn __gcd(b, a % b)\n}\nfunc work() {\n\tn := ReadInt()\n\ta, b := n, int64(1)\n\tfor i := int64(2); i * i <= n; i++ {\n\t\tif n % i == 0 {\n\t\t\tc, d := n / i, i\n\t\t\tif __gcd(c, d) == 1 {\n\t\t\t\ta, b = c, d\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(a, b)\n}\nfunc main() {\n\twork()\n\tclose(out)\n}\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nvar out chan string\nvar in *bufio.Scanner\nvar outWg *sync.WaitGroup\nfunc ReadString() string {\n\tin.Scan()\n\treturn in.Text()\n}\nfunc ReadStringSlice(n int) []string {\n\ts := make([]string, n)\n\tfor i := 0; i < n; i++ {\n\t\ts[i] = ReadString()\n\t}\n\treturn s\n}\nfunc ReadInt() int64 {\n\tintStr := ReadString()\n\ti, _ := strconv.ParseInt(intStr, 10, 64)\n\treturn i\n}\nfunc ReadIntSlice(n int) []int64 {\n\tarr := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tarr[i] = ReadInt()\n\t}\n\treturn arr\n}\nfunc init() {\n\t//set input\n\tin = bufio.NewScanner(os.Stdin)\n\tin.Buffer(make([]byte, 1024), int(2e+5))\n\tin.Split(bufio.ScanWords)\n\n\t//set output\n\tout = make(chan string, 16)\n\toutWg = &sync.WaitGroup{}\n\toutWg.Add(1)\n\n\twriter := bufio.NewWriterSize(os.Stdout, int(2e+5))\n\tgo func(write *bufio.Writer) {\n\t\tdefer outWg.Done()\n\t\tdefer write.Flush()\n\n\t\tfor line := range out {\n\t\t\twrite.WriteString(line + \"\\n\")\n\t\t}\n\t}(writer)\n}"}, {"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\tX := readll()\n\tminv := int64(10000000000000)\n\tvar ansa, ansb int64\n\tfor i := int64(1); i*i <= X; i++ {\n\t\tif X%i != 0 {\n\t\t\tcontinue\n\t\t}\n\t\tb := X / i\n\t\tif gcdll(i, b) != 1 {\n\t\t\tcontinue\n\t\t}\n\t\tv := maxll(i, b)\n\t\tif v < minv {\n\t\t\tminv = v\n\t\t\tansa = i\n\t\t\tansb = b\n\t\t}\n\t}\n\tprintln(ansa, ansb)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"sync\"\n)\n\nfunc main() {\n\n\tx := ReadInt64()\n\tans := int64(0)\n\tfor i := int64(1); i*i <= x; i++ {\n\t\tif x%i == 0 && LCM(x/i, i) == x {\n\t\t\tans = i\n\t\t}\n\t}\n\n\tout <- fmt.Sprintf(\"%v %v\", ans, (x / ans))\n\tclose(out)\n\toutWg.Wait()\n}\n\n/*********************** I/O ***********************/\n\nvar out chan string\nvar in *bufio.Scanner\nvar outWg *sync.WaitGroup\n\nfunc init() {\n\t//set input\n\tin = bufio.NewScanner(os.Stdin)\n\tin.Buffer(make([]byte, 1024), int(2e+5))\n\tin.Split(bufio.ScanWords)\n\n\t// set output\n\tout = make(chan string, 16)\n\toutWg = &sync.WaitGroup{}\n\toutWg.Add(1)\n\n\twriter := bufio.NewWriterSize(os.Stdout, int(2e+5))\n\tgo func(writer *bufio.Writer) {\n\t\tdefer outWg.Done()\n\t\tdefer writer.Flush()\n\n\t\tfor line := range out {\n\t\t\twriter.WriteString(line + \"\\n\")\n\t\t}\n\t}(writer)\n}\n\nfunc ReadString() string {\n\tin.Scan()\n\treturn in.Text()\n}\n\nfunc ReadStringSlice(n int) []string {\n\ts := make([]string, n)\n\tfor i := 0; i < n; i++ {\n\t\ts[i] = ReadString()\n\t}\n\treturn s\n}\n\nfunc ReadInt64() int64 {\n\tintStr := ReadString()\n\ti, err := strconv.ParseInt(intStr, 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn i\n}\n\nfunc ReadInt64Slice(n int) []int64 {\n\tarr := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tarr[i] = ReadInt64()\n\t}\n\treturn arr\n}\n\n/*********************** Utils ***********************/\n\nfunc Max(args ...int64) int64 {\n\tmaxV := int64(math.MinInt64)\n\tfor _, v := range args {\n\t\tif v > maxV {\n\t\t\tmaxV = v\n\t\t}\n\t}\n\treturn maxV\n}\n\nfunc Min(args ...int64) int64 {\n\tminV := int64(math.MaxInt64)\n\tfor _, v := range args {\n\t\tif v < minV {\n\t\t\tminV = v\n\t\t}\n\t}\n\treturn minV\n}\n\nfunc GCD(a, b int64) int64 {\n\tif (a == 0) {\n\t\treturn b\n\t}\n\treturn GCD(b%a, a)\n}\n\nfunc LCM(a, b int64) int64 {\n\treturn a / GCD(a, b) * b\n}\n\nfunc S(v int64) string {\n\treturn strconv.FormatInt(v, 64)\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc min(a int64, b int64) int64 {\n if a < b { return a }\n return b\n}\n\nfunc max(a int64, b int64) int64 {\n if a > b { return a }\n return b\n}\n\nfunc main() {\n var x int64\n fmt.Scanf(\"%d\", &x)\n ans := x\n for i := int64(1); i * i < x; i++ {\n j := x / i\n ans = min(ans, max(i, j))\n }\n fmt.Println(x / ans, ans)\n}\n\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc isPrime(number int64) bool {\n if number <= 1 {\n return false\n }\n if number == 2 {\n return true\n }\n if number%2 == 0 {\n return false\n }\n sqrNumber := int64(math.Sqrt(float64(number)))\n\n for i := int64(2); i <= sqrNumber; i++ {\n if number%i == 0 {\n return false\n }\n }\n return true\n}\n\nfunc gcd(m int64, n int64) int64 {\n if n == 0 {\n return m\n }\n return gcd(n, m%n)\n}\n\nfunc MaxLCM(n int64) (ansA int64, ansB int64) {\n if isPrime(n) || n == 1 {\n return 1, n \n }\n sqrNumber := int64(math.Sqrt(float64(n)))\n var ANS_END int64 = int64(math.Pow(10, 12)) + 1\n ansA = ANS_END\n ansB = ANS_END\n for i := int64(1); i <= sqrNumber; i++ {\n a := i\n if n%a == 0 {\n b := n / a\n if b < ansB {\n ansA = a\n ansB = b\n }\n }\n }\n return ansA, ansB\n}\n \nfunc main() {\n var n int64 = 0\n fmt.Scanf(\"%d\\n\", &n)\n fmt.Println(MaxLCM(n))\n} \n "}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc isPrime(number int64) bool {\n\tif number <= 1 {\n\t\treturn false\n\t}\n\tif number == 2 {\n\t\treturn true\n\t}\n\tif number%2 == 0 {\n\t\treturn false\n\t}\n\tsqrNumber := int64(math.Sqrt(float64(number)))\n\n\tfor i := int64(2); i <= sqrNumber; i++ {\n\t\tif number%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc gcd(m int64, n int64) int64 {\n\tif n == 0 {\n\t\treturn m\n\t}\n\treturn gcd(n, m%n)\n}\n\nfunc MaxLCM(n int64) (ansA int64, ansB int64) {\n\tif isPrime(n) || n == 1 {\n\t\treturn 1, n\n\t}\n\tsqrNumber := int64(math.Sqrt(float64(n)))\n\tvar ANS_END int64 = int64(math.Pow(10, 12)) + 1\n\tansA = ANS_END\n\tansB = ANS_END\n\tfor i := int64(1); i <= sqrNumber; i++ {\n\t\ta := i\n\t\tif n%a == 0 {\n\t\t\tb := n / a\n\t\t\tif b < ansB && a != b {\n\t\t\t\tansA = a\n\t\t\t\tansB = b\n\t\t\t}\n\t\t}\n\t}\n\treturn ansA, ansB\n}\n\nfunc main() {\n\tvar n int64 = 0\n\tfmt.Scanf(\"%d\\n\", &n)\n\tfmt.Println(MaxLCM(n))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc max(a,b int64) int64 {\n\tif a c {\n\t\t\t\ta, b = c, d\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(a, b)\n}\nfunc main() {\n\twork()\n\tclose(out)\n}\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\nvar out chan string\nvar in *bufio.Scanner\nvar outWg *sync.WaitGroup\nfunc ReadString() string {\n\tin.Scan()\n\treturn in.Text()\n}\nfunc ReadStringSlice(n int) []string {\n\ts := make([]string, n)\n\tfor i := 0; i < n; i++ {\n\t\ts[i] = ReadString()\n\t}\n\treturn s\n}\nfunc ReadInt() int64 {\n\tintStr := ReadString()\n\ti, _ := strconv.ParseInt(intStr, 10, 64)\n\treturn i\n}\nfunc ReadIntSlice(n int) []int64 {\n\tarr := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tarr[i] = ReadInt()\n\t}\n\treturn arr\n}\nfunc init() {\n\t//set input\n\tin = bufio.NewScanner(os.Stdin)\n\tin.Buffer(make([]byte, 1024), int(2e+5))\n\tin.Split(bufio.ScanWords)\n\n\t//set output\n\tout = make(chan string, 16)\n\toutWg = &sync.WaitGroup{}\n\toutWg.Add(1)\n\n\twriter := bufio.NewWriterSize(os.Stdout, int(2e+5))\n\tgo func(write *bufio.Writer) {\n\t\tdefer outWg.Done()\n\t\tdefer write.Flush()\n\n\t\tfor line := range out {\n\t\t\twrite.WriteString(line + \"\\n\")\n\t\t}\n\t}(writer)\n}"}], "src_uid": "e504a04cefef3da093573f9df711bcea"} {"nl": {"description": "Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem.A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit.More formally, if a game designer selected cells having coordinates (x1, y1) and (x2, y2), where x1 ≤ x2 and y1 ≤ y2, then all cells having center coordinates (x, y) such that x1 ≤ x ≤ x2 and y1 ≤ y ≤ y2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x2 - x1 is divisible by 2.Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map.Help him implement counting of these units before painting. ", "input_spec": "The only line of input contains four integers x1, y1, x2, y2 ( - 109 ≤ x1 ≤ x2 ≤ 109,  - 109 ≤ y1 ≤ y2 ≤ 109) — the coordinates of the centers of two cells.", "output_spec": "Output one integer — the number of cells to be filled.", "sample_inputs": ["1 1 5 5"], "sample_outputs": ["13"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x1, y1, x2, y2 int64\n\tfmt.Scanf(\"%d %d %d %d\", &x1, &y1, &x2, &y2)\n\n\tvar dx, dy, num_prim_cols, num_sec_cols, len_prim_cols, len_sec_cols int64\n\tdx = x2 - x1\n\tdy = y2 - y1\n\tnum_prim_cols = dx / 2 + 1 //dx guaranteed to be divisible by 2\n\tnum_sec_cols = num_prim_cols - 1\n\tlen_prim_cols = dy / 2 + 1\n\tlen_sec_cols = 0\n//\tfmt.Printf(\"dx=\\t%d\\ndy=\\t%d\\nprim_cols=\\t%d\\nsec_cols=\\t%d\\n\", dx, dy, num_prim_cols, num_sec_cols)\n\n\tif ( dy % 2 == 0) {\n\t\tlen_sec_cols = dy / 2\n\t} else {\n\t\tlen_sec_cols = dy / 2 + 1\n\t}\n//\tfmt.Printf(\"\\nlen_prim_cols=\\t%d\\nlen_sec_cols=\\t%d\\n\", len_prim_cols, len_sec_cols)\n\t\n\tfmt.Println(num_prim_cols * len_prim_cols + num_sec_cols * len_sec_cols)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc inc(x int64) int64 {\n\treturn x + 1\n}\nfunc dec(x int64) int64 {\n\treturn x - 1\n}\nfunc isOdd(x int64) bool {\n\treturn x%1 == 1\n}\n\nfunc isNotOdd(x int64) bool {\n\treturn !isOdd(x)\n}\n\nfunc readInt(scanner *bufio.Scanner) int64 {\n\tscanner.Scan()\n\traw := scanner.Text()\n\tresult, _ := strconv.ParseInt(strings.Trim(raw, \" \\n\\r\"), 10, 64)\n\treturn result\n}\nfunc getWithCalc(x int64, cond func(int64) bool, f func(int64) int64) int64 {\n\tif cond(x) {\n\t\treturn f(x)\n\t}\n\treturn x\n}\nfunc check(x1, y1, x2, y2 int64) int64 {\n\n\ta1 := 1 + (getWithCalc(x2, isOdd, dec)-getWithCalc(x1, isOdd, inc))/2\n\tb1 := 1 + (getWithCalc(y2, isOdd, dec)-getWithCalc(y1, isOdd, inc))/2\n\n\ta2 := 1 + (getWithCalc(x2, isNotOdd, dec)-getWithCalc(x1, isNotOdd, inc))/2\n\tb2 := 1 + (getWithCalc(y2, isNotOdd, dec)-getWithCalc(y1, isNotOdd, inc))/2\n\n\treturn a1*b1 + a2*b2\n}\nfunc solve(in io.Reader, out io.Writer) {\n\treader := bufio.NewScanner(in)\n\treader.Split(bufio.ScanWords)\n\n\tfmt.Fprintln(out, check(readInt(reader), readInt(reader), readInt(reader), readInt(reader)))\n}\n\nfunc main() {\n\tsolve(os.Stdin, os.Stdout)\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x1, y1, x2, y2 int64\n\tfmt.Scanf(\"%d %d %d %d\", &x1, &y1, &x2, &y2)\n\n\tvar dx, dy, num_prim_cols, num_sec_cols, len_prim_cols, len_sec_cols int64\n\tdx = x2 - x1\n\tdy = y2 - y1\n\tnum_prim_cols = dx / 2 + 1 //dx guaranteed to be divisible by 2\n\tnum_sec_cols = num_prim_cols - 1\n\tlen_prim_cols = dy / 2 + 1\n\tlen_sec_cols = 0\n\tfmt.Printf(\"dx=\\t%d\\ndy=\\t%d\\nprim_cols=\\t%d\\nsec_cols=\\t%d\\n\",\n\t\tdx, dy, num_prim_cols, num_sec_cols)\n\n\tif ( dy % 2 == 0) {\n\t\tlen_sec_cols = dy / 2\n\t} else {\n\t\tlen_sec_cols = dy / 2 + 1\n\t}\n\tfmt.Printf(\"\\nlen_prim_cols=\\t%d\\nlen_sec_cols=\\t%d\\n\",\n\t\tlen_prim_cols, len_sec_cols)\n\t\n\tfmt.Println(\"Total cells = \", num_prim_cols * len_prim_cols + num_sec_cols * len_sec_cols)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x1, y1, x2, y2 int64\n\tfmt.Scanf(\"%d %d %d %d\", &x1, &y1, &x2, &y2)\n\n\tvar dx, dy, num_prim_cols, num_sec_cols, len_prim_cols, len_sec_cols int64\n\tdx = x2 - x1\n\tdy = y2 - y1\n\tnum_prim_cols = dx / 2 + 1 //dx guaranteed to be divisible by 2\n\tnum_sec_cols = num_prim_cols - 1\n\tlen_prim_cols = dy / 2 + 1\n\tlen_sec_cols = 0\n//\tfmt.Printf(\"dx=\\t%d\\ndy=\\t%d\\nprim_cols=\\t%d\\nsec_cols=\\t%d\\n\", dx, dy, num_prim_cols, num_sec_cols)\n\n\tif ( dy % 2 == 0) {\n\t\tlen_sec_cols = dy / 2\n\t} else {\n\t\tlen_sec_cols = dy / 2 + 1\n\t}\n//\tfmt.Printf(\"\\nlen_prim_cols=\\t%d\\nlen_sec_cols=\\t%d\\n\", len_prim_cols, len_sec_cols)\n\t\n\tfmt.Println(\"Total cells = \", num_prim_cols * len_prim_cols + num_sec_cols * len_sec_cols)\n}\n"}], "src_uid": "00cffd273df24d1676acbbfd9a39630d"} {"nl": {"description": "Kirill plays a new computer game. He came to the potion store where he can buy any potion. Each potion is characterized by two integers — amount of experience and cost. The efficiency of a potion is the ratio of the amount of experience to the cost. Efficiency may be a non-integer number.For each two integer numbers a and b such that l ≤ a ≤ r and x ≤ b ≤ y there is a potion with experience a and cost b in the store (that is, there are (r - l + 1)·(y - x + 1) potions).Kirill wants to buy a potion which has efficiency k. Will he be able to do this?", "input_spec": "First string contains five integer numbers l, r, x, y, k (1 ≤ l ≤ r ≤ 107, 1 ≤ x ≤ y ≤ 107, 1 ≤ k ≤ 107).", "output_spec": "Print \"YES\" without quotes if a potion with efficiency exactly k can be bought in the store and \"NO\" without quotes otherwise. You can output each of the letters in any register.", "sample_inputs": ["1 10 1 10 1", "1 5 6 10 1"], "sample_outputs": ["YES", "NO"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar a,b,c,d,e int\n\tvar ans=false\n\tfmt.Scanf(\"%d %d %d %d %d\",&a,&b,&c,&d,&e)\n\tfor i:=c;i<=d;i++ {\n\t\tvar comp=int64(i)*int64(e)\n\t\tif int64(a)<=comp && comp<=int64(b){\n\t\t\tans=true\n\t\t}\n\t}\n\tif ans{\n\t\tfmt.Printf(\"YES\\n\")\n\t} else{\n\t\tfmt.Printf(\"NO\\n\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar l, r, x, y, k int64\n\tfmt.Scanf(\"%d %d %d %d %d\", &l, &r, &x, &y, &k)\n\tfor i := l; i <= r; i++ {\n\t\tif (x*k <= i) && (i <= y*k) && (i%k == 0) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tl := readInt64()\n\tr := readInt64()\n\tx := readInt64()\n\ty := readInt64()\n\tk := readInt64()\n\tfor j := x; j <= y; j++ {\n\t\tt := j * k\n\t\tif t > r {\n\t\t\tbreak\n\t\t}\n\t\tif t >= l && t <= r {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\t// for i := l; i <= r; i++ {\n\t// \tfor j := x; j <= y; j++ {\n\t// \t\tif i%j == 0 && i/j == k {\n\t// \t\t\tfmt.Println(\"YES\")\n\t// \t\t\treturn\n\t// \t\t}\n\t// \t}\n\t// }\n\tfmt.Println(\"NO\")\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar l, r, x, y, k int64\n\tfmt.Scanf(\"%d %d %d %d %d\", &l, &r, &x, &y, &k)\n\tfor cost := x; cost <= y; cost++ {\n\t\texperience := k * cost\n\t\tif experience >= l && experience <= r {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var l, r, x, y, k int\n fmt.Scanf(\"%d %d %d %d %d\\n\", &l, &r, &x, &y, &k)\n for b := x; b <= y; b++ {\n a := int64(b) * int64(k)\n if int64(l) <= a && a <= int64(r) {\n fmt.Printf(\"YES\\n\")\n return\n }\n }\n fmt.Printf(\"NO\\n\")\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar l, r, x, y, k int64\n\tfmt.Scan(&l, &r, &x, &y, &k)\n\tif x*k < l {\n\t\tx = (l + k - 1) / k\n\t}\n\tif y*k > r {\n\t\ty = r / k\n\t}\n\tif x > y {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar a,b,c,d,e int\n\tvar ans=false\n\tfmt.Scanf(\"%d %d %d %d %d\",&a,&b,&c,&d,&e)\n\tfor i:=c;i=worst && k<=best\t{\n\t\tfmt.Printf(\"YES\\n\")\n\t} else{\n\t\tfmt.Printf(\"NO\\n\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar l, r, x, y, k int\n\tfmt.Scanf(\"%d %d %d %d %d\", &l, &r, &x, &y, &k)\n\tfor i := l; i <= r; i++ {\n\t\tif (x*k <= i) && (i <= y*k) && (i%k == 0) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar l, r, x, y, k int\n\tfmt.Scanf(\"%d %d %d %d %d\", &l, &r, &x, &y, &k)\n\tfor cost := x; cost <= y; cost++ {\n\t\texperience := k * cost\n\t\tif experience >= l && experience <= r {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar l, r, x, y, k int\n\tfmt.Scan(&l, &r, &x, &y, &k)\n\tif x*k < l {\n\t\tx = (l + k - 1) / k\n\t}\n\tif y*k > r {\n\t\ty = r / k\n\t}\n\tif x > y {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n"}], "src_uid": "1110d3671e9f77fd8d66dca6e74d2048"} {"nl": {"description": "The Tower of Hanoi is a well-known mathematical puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape.The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules: Only one disk can be moved at a time. Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack i.e. a disk can only be moved if it is the uppermost disk on a stack. No disk may be placed on top of a smaller disk. With three disks, the puzzle can be solved in seven moves. The minimum number of moves required to solve a Tower of Hanoi puzzle is 2n - 1, where n is the number of disks. (c) Wikipedia.SmallY's puzzle is very similar to the famous Tower of Hanoi. In the Tower of Hanoi puzzle you need to solve a puzzle in minimum number of moves, in SmallY's puzzle each move costs some money and you need to solve the same puzzle but for minimal cost. At the beginning of SmallY's puzzle all n disks are on the first rod. Moving a disk from rod i to rod j (1 ≤ i, j ≤ 3) costs tij units of money. The goal of the puzzle is to move all the disks to the third rod.In the problem you are given matrix t and an integer n. You need to count the minimal cost of solving SmallY's puzzle, consisting of n disks.", "input_spec": "Each of the first three lines contains three integers — matrix t. The j-th integer in the i-th line is tij (1 ≤ tij ≤ 10000; i ≠ j). The following line contains a single integer n (1 ≤ n ≤ 40) — the number of disks. It is guaranteed that for all i (1 ≤ i ≤ 3), tii = 0.", "output_spec": "Print a single integer — the minimum cost of solving SmallY's puzzle.", "sample_inputs": ["0 1 1\n1 0 1\n1 1 0\n3", "0 2 2\n1 0 100\n1 2 0\n3", "0 2 1\n1 0 100\n1 2 0\n5"], "sample_outputs": ["7", "19", "87"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nvar dp [41][3][3]uint64\nvar t [3][3]uint64\n\nfunc min(a, b uint64) uint64 {\n\tif a < b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &t[0][0], &t[0][1], &t[0][2])\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &t[1][0], &t[1][1], &t[1][2])\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &t[2][0], &t[2][1], &t[2][2])\n\tvar n int\n\tfmt.Fscanf(reader, \"%d\", &n)\n\n\tfor i := 1; i <= n; i++ {\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tfor k := 0; k < 3; k++ {\n\t\t\t\tif j == k {\n\t\t\t\t\tcontinue\n\t\t\t\t} else {\n\t\t\t\t\tl := 3 - j - k\n\t\t\t\t\tdp[i][j][k] = dp[i-1][j][l] + t[j][k] + dp[i-1][l][k]\n\t\t\t\t\tdp[i][j][k] = min(dp[i-1][j][k]+dp[i-1][k][l]+t[j][k]+dp[i-1][l][k], dp[i][j][k])\n\t\t\t\t\tdp[i][j][k] = min(dp[i-1][j][l]+t[j][k]+dp[i-1][l][j]+dp[i-1][j][k], dp[i][j][k])\n\t\t\t\t\tdp[i][j][k] = min(dp[i-1][j][k]+dp[i-1][k][l]+t[j][k]+dp[i-1][l][j]+dp[i-1][j][k], dp[i][j][k])\n\n\t\t\t\t\tdp[i][j][k] = min(2*dp[i-1][j][k]+t[j][l]+dp[i-1][k][j]+t[l][k], dp[i][j][k])\n\t\t\t\t\tdp[i][j][k] = min(2*(dp[i-1][j][l]+dp[i-1][l][k])+t[j][l]+dp[i-1][k][j]+t[l][k], dp[i][j][k])\n\t\t\t\t\tdp[i][j][k] = min(2*dp[i-1][j][k]+t[j][l]+dp[i-1][k][l]+dp[i-1][l][j]+t[l][k], dp[i][j][k])\n\t\t\t\t\tdp[i][j][k] = min(2*(dp[i-1][j][l]+dp[i-1][l][k])+t[j][l]+dp[i-1][k][l]+dp[i-1][l][j]+t[l][k], dp[i][j][k])\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Printf(\"%d\", dp[n][0][2])\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nvar dp [40][3][3]uint64\n\nfunc min(a, b uint64) uint64 {\n\tif a < b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &dp[0][0][0], &dp[0][0][1], &dp[0][0][2])\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &dp[0][1][0], &dp[0][1][1], &dp[0][1][2])\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &dp[0][2][0], &dp[0][2][1], &dp[0][2][2])\n\tvar n int\n\tfmt.Fscanf(reader, \"%d\", &n)\n\n\tfor i := 1; i < n; i++ {\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tfor k := 0; k < 3; k++ {\n\t\t\t\tif j == k {\n\t\t\t\t\tcontinue\n\t\t\t\t} else {\n\t\t\t\t\tl := 3 - j - k\n\t\t\t\t\tdp[i][j][k] = dp[i-1][j][l] + dp[0][j][k] + dp[i-1][l][k]\n\t\t\t\t\tdp[i][j][k] = min(dp[i-1][j][k]+dp[i-1][k][l]+dp[0][j][k]+dp[i-1][l][k], dp[i][j][k])\n\t\t\t\t\tdp[i][j][k] = min(dp[i-1][j][l]+dp[0][j][k]+dp[i-1][l][j]+dp[i-1][j][k], dp[i][j][k])\n\t\t\t\t\tdp[i][j][k] = min(dp[i-1][j][k]+dp[i-1][k][l]+dp[0][j][k]+dp[i-1][l][j]+dp[i-1][j][k], dp[i][j][k])\n\n\t\t\t\t\tdp[i][j][k] = min(2*dp[i-1][j][k]+dp[0][j][l]+dp[i-1][k][j]+dp[0][l][k], dp[i][j][k])\n\t\t\t\t\tdp[i][j][k] = min(2*(dp[i-1][j][l]+dp[i-1][l][k])+dp[0][j][l]+dp[i-1][k][j]+dp[0][l][k], dp[i][j][k])\n\t\t\t\t\tdp[i][j][k] = min(2*dp[i-1][j][k]+dp[0][j][l]+dp[i-1][k][l]+dp[i-1][l][j]+dp[0][l][k], dp[i][j][k])\n\t\t\t\t\tdp[i][j][k] = min(2*(dp[i-1][j][l]+dp[i-1][l][k])+dp[0][j][l]+dp[i-1][k][l]+dp[i-1][l][j]+dp[0][l][k], dp[i][j][k])\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Printf(\"%d\", dp[n-1][0][2])\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nvar dp [40][3][3]uint64\n\nfunc min(a, b uint64) uint64 {\n\tif a < b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &dp[0][0][0], &dp[0][0][1], &dp[0][0][2])\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &dp[0][1][0], &dp[0][1][1], &dp[0][1][2])\n\tfmt.Fscanf(reader, \"%d %d %d\\n\", &dp[0][2][0], &dp[0][2][1], &dp[0][2][2])\n\tvar n int\n\tfmt.Fscanf(reader, \"%d\", &n)\n\n\tfor i := 1; i < n; i++ {\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tfor k := 0; k < 3; k++ {\n\t\t\t\tif j == k {\n\t\t\t\t\tcontinue\n\t\t\t\t} else {\n\t\t\t\t\tl := 3 - j - k\n\t\t\t\t\tdp[i][j][k] = dp[i-1][j][l] + dp[0][j][k] + dp[i-1][l][k]\n\t\t\t\t\tdp[i][j][k] = min(dp[i-1][j][k]+dp[i-1][k][l]+dp[0][j][k]+dp[i-1][l][k], dp[i][j][k])\n\t\t\t\t\tdp[i][j][k] = min(dp[i-1][j][l]+dp[0][j][k]+dp[i-1][l][j]+dp[i-1][j][k], dp[i][j][k])\n\t\t\t\t\tdp[i][j][k] = min(dp[i-1][j][k]+dp[i-1][k][l]+dp[0][j][k]+dp[i-1][l][j]+dp[i-1][j][k], dp[i][j][k])\n\n\t\t\t\t\tdp[i][j][k] = min(2*dp[i-1][j][k]+dp[0][j][l]+dp[i-1][k][j]+dp[0][l][k], dp[i][j][k])\n\t\t\t\t\tdp[i][j][k] = min(2*(dp[i-1][j][l]+dp[i-1][l][k])+dp[0][j][l]+dp[i-1][k][j]+dp[0][l][k], dp[i][j][k])\n\t\t\t\t\tdp[i][j][k] = min(2*dp[i-1][j][k]+dp[0][j][l]+dp[i-1][k][l]+dp[i-1][l][j]+dp[0][l][k], dp[i][j][k])\n\t\t\t\t\tdp[i][j][k] = min(2*(dp[i-1][j][l]+dp[i-1][l][k])+dp[0][j][l]+dp[i-1][k][l]+dp[i-1][l][j]+dp[0][l][k], dp[i][j][k])\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Printf(\"%+v\\n\", dp[0])\n\tfmt.Printf(\"%d\", dp[n-1][0][2])\n}\n"}], "src_uid": "c4c20228624365e39299d0a6e8fe7095"} {"nl": {"description": "You have a set of $$$n$$$ weights. You know that their masses are $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ grams, but you don't know which of them has which mass. You can't distinguish the weights.However, your friend does know the mass of each weight. You can ask your friend to give you exactly $$$k$$$ weights with the total mass $$$m$$$ (both parameters $$$k$$$ and $$$m$$$ are chosen by you), and your friend will point to any valid subset of weights, if it is possible.You are allowed to make this query only once. Find the maximum possible number of weights you can reveal after this query.", "input_spec": "The first line contains a single integer $$$n$$$ ($$$1 \\le n \\le 100$$$) — the number of weights. The second line contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\le a_i \\le 100$$$) — the masses of the weights.", "output_spec": "Print the maximum number of weights you can learn the masses for after making a single query.", "sample_inputs": ["4\n1 4 2 2", "6\n1 2 4 4 4 9"], "sample_outputs": ["2", "2"], "notes": "NoteIn the first example we can ask for a subset of two weights with total mass being equal to $$$4$$$, and the only option is to get $$$\\{2, 2\\}$$$.Another way to obtain the same result is to ask for a subset of two weights with the total mass of $$$5$$$ and get $$$\\{1, 4\\}$$$. It is easy to see that the two remaining weights have mass of $$$2$$$ grams each.In the second example we can ask for a subset of two weights with total mass being $$$8$$$, and the only answer is $$$\\{4, 4\\}$$$. We can prove it is not possible to learn masses for three weights in one query, but we won't put the proof here."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nconst (\n\tMaxSum = 10005\n\tMaxNums = 101\n\tType = 2\n\tSame = 0\n\tDifferent = 1\n)\n\nvar n int\nvar a [MaxNums]int\nvar dp[MaxSum][MaxNums][Type]bool\n\nfunc computeDp() {\n\tdp[a[0]][1][Same] = true\n\tfor i := 1; i < n; i++ {\n\t\tfor s := MaxSum - 1; s >= 0; s-- {\n\t\t\tfor cnt := 1; cnt <= i; cnt++ {\n\t\t\t\tif dp[s][cnt][Same] {\n\t\t\t\t\tk := s / cnt\n\t\t\t\t\tif k == a[i] {\n\t\t\t\t\t\tdp[s+k][cnt+1][Same] = true\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdp[s+a[i]][cnt+1][Different] = true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif dp[s][cnt][Different] {\n\t\t\t\t\tdp[s+a[i]][cnt+1][Different] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdp[a[i]][1][Same] = true\n\t}\n}\n\nfunc main() {\n\tfmt.Scanf(\"%d\\n\", &n)\n\tcounter := make(map[int]int)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &a[i])\n\t\tcounter[a[i]]++\n\t}\n\n\tif len(counter) == 2 {\n\t\tfmt.Println(n)\n\t\treturn\n\t}\n\n\tcomputeDp()\n\n\tbest := 1\n\tfor weight := range counter {\n\t\tfor count := 1; count <= counter[weight]; count++ {\n\t\t\tif dp[weight*count][count][Same] && !dp[weight*count][count][Different] && best < count {\n\t\t\t\tbest = count\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(best)\n}"}], "negative_code": [], "src_uid": "ccc4b27889598266e8efe73b8aa3666c"} {"nl": {"description": "Karen is getting ready for a new school day! It is currently hh:mm, given in a 24-hour format. As you know, Karen loves palindromes, and she believes that it is good luck to wake up when the time is a palindrome.What is the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palindrome?Remember that a palindrome is a string that reads the same forwards and backwards. For instance, 05:39 is not a palindrome, because 05:39 backwards is 93:50. On the other hand, 05:50 is a palindrome, because 05:50 backwards is 05:50.", "input_spec": "The first and only line of input contains a single string in the format hh:mm (00 ≤  hh  ≤ 23, 00 ≤  mm  ≤ 59).", "output_spec": "Output a single integer on a line by itself, the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palindrome.", "sample_inputs": ["05:39", "13:31", "23:59"], "sample_outputs": ["11", "0", "1"], "notes": "NoteIn the first test case, the minimum number of minutes Karen should sleep for is 11. She can wake up at 05:50, when the time is a palindrome.In the second test case, Karen can wake up immediately, as the current time, 13:31, is already a palindrome.In the third test case, the minimum number of minutes Karen should sleep for is 1 minute. She can wake up at 00:00, when the time is a palindrome."}, "positive_code": [{"source_code": "// karen.go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scanf(\"%s\", &s)\n\n\tss := strings.Split(s, \":\")\n\tif len(ss) == 2 {\n\t\tvar cnt int = 0\n\t\tfor {\n\t\t\tif []byte(ss[0])[0] == []byte(ss[1])[1] && []byte(ss[0])[1] == []byte(ss[1])[0] {\n\t\t\t\tfmt.Println(cnt)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tcnt++\n\t\t\tm, _ := strconv.Atoi(ss[1])\n\t\t\tm = m + 1\n\t\t\tn, _ := strconv.Atoi(ss[0])\n\t\t\tif m == 60 {\n\t\t\t\tm = 0\n\t\t\t\tn = n + 1\n\t\t\t\tif n == 24 {\n\t\t\t\t\tn = 0\n\t\t\t\t}\n\t\t\t}\n\t\t\tss[0] = fmt.Sprintf(\"%02d\", n)\n\t\t\tss[1] = fmt.Sprintf(\"%02d\", m)\n\t\t}\n\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scanf(\"%s\", &s)\n\tfor minute := 0; ; minute++ {\n\t\tif isPalinrom(s) {\n\t\t\tfmt.Println(minute)\n\t\t\tbreak\n\t\t}\n\t\ts = inc(s)\n\t}\n}\n\nfunc inc(s string) string {\n\tele := strings.Split(s, \":\")\n\tminute, _ := strconv.Atoi(ele[1])\n\thour, _ := strconv.Atoi(ele[0])\n\tif minute == 59 {\n\t\thour++\n\t\tif hour == 24 {\n\t\t\thour = 0\n\t\t}\n\t\tminute = 0\n\t} else {\n\t\tminute++\n\t}\n\treturn fmt.Sprintf(\"%02d:%02d\", hour, minute)\n}\n\nfunc isPalinrom(s string) bool {\n\tfor i:= 0; i < len(s) / 2; i++ {\n\t\tif(s[i] != s[len(s)-i-1]) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\n\nfunc getLine() string {\n\ts, _ := reader.ReadString('\\n')\n\tif strings.HasSuffix(s, \"\\r\\n\") {\n\t\ts = s[:len(s)-2]\n\t} else if strings.HasSuffix(s, \"\\n\") {\n\t\ts = s[:len(s)-1]\n\t}\n\treturn s\n}\nfunc getLine2Int() (n int) {\n\tscanf(\"%d\\n\", &n)\n\treturn\n}\nfunc getLine2Int2() (a, b int) {\n\tscanf(\"%d %d\\n\", &a, &b)\n\treturn\n}\nfunc getLine2Ints(n int) []int {\n\tans := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tscanf(\"%d \", &ans[i])\n\t}\n\tscanf(\"%d\\n\", &ans[n-1])\n\treturn ans\n}\n\nfunc pcheck(i bool) {\n\tif i {\n\t\tprintf(\"YES\\n\")\n\t} else {\n\t\tprintf(\"NO\\n\")\n\t}\n}\n\nvar debug = true\n\nfunc see(a interface{}) {\n\tif debug {\n\t\tprintf(\"DEBUG:%v\\n\", a)\n\t}\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\tvar hh, mm int\n\tscanf(\"%d:%d\\n\", &hh, &mm)\n\tfor i := 0; i < 24*60; i++ {\n\t\thtom := hh%10*10 + hh/10\n\t\tif htom == mm {\n\t\t\tprintf(\"%d\\n\", i)\n\t\t\treturn\n\t\t}\n\t\tmm = (mm + 1) % 60\n\t\tif mm == 0 {\n\t\t\thh = (hh + 1) % 24\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\ntype Time struct {\n\tminutes int\n\thours int\n}\n\nfunc (t *Time) is_pal() bool {\n\tstr := t.ToString()\n\treturn str[0] == str[4] && str[1] == str[3]\n}\n\nfunc (t *Time) AddMinute() {\n\tif t.minutes == 59 {\n\t\tt.AddHour()\n\t\tt.minutes = 0\n\t} else {\n\t\tt.minutes = t.minutes + 1\n\t}\n}\n\nfunc (t *Time) AddHour() {\n\tif t.hours == 23 {\n\t\tt.hours = 00\n\t}else{\n\t\tt.hours++\n\t}\n}\n\n\nfunc (t *Time) ToString() string {\n\treturn fmt.Sprintf(\"%02d\", t.hours) + \":\" + fmt.Sprintf(\"%02d\", t.minutes)\n}\n\nfunc main() {\n\n\tans := 0\n\tvar in string\n\tfmt.Scanf(\"%s\", &in)\n\tvar time Time\n\tvar err error\n\ttime.hours, err = strconv.Atoi(in[:2])\n\ttime.minutes, err = strconv.Atoi(in[3:])\n\n\tif err != nil {\n\t\t// handle error\n\t\tfmt.Println(err)\n\t}\n\n\tfor {\n\t\tif time.is_pal() {\n\t\t\tfmt.Println(ans)\n\t\t\tbreak\n\t\t}\n\t\tans++\n\t\ttime.AddMinute()\n\t\t//fmt.Print(ans )\n\t\t//fmt.Println(\" \" + time.ToString())\n\n\t}\n\n}\n"}, {"source_code": "// Codeforces helper functions\n// 20 Jan 18\n// samadhi\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n\t\"unicode\"\n)\n\nconst debug = false\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tin := gsls(reader)[0]\n\n\tdbg(\"hh:mm: %v\\n\", in)\n\n\th := in[0:2]\n\tm := in[3:5]\n\n\tdbg(\"h: %v m: %v\\n\", h, m)\n\tdbg(\"%v\\n\", isPalindrome(h, m))\n\n\ti := 0\n\n\tfor !isPalindrome(h, m) {\n\t\th, m = increment(h, m)\n\t\ti++\n\t\tdbg(\"Increased to %v:%v...\\n\", h, m)\n\t}\n\n\tfmt.Print(i)\n\n\treturn\n\n}\n\nfunc isPalindrome(h, m string) bool {\n\treturn string(h[1])+string(h[0]) == m\n}\n\nfunc increment(h, m string) (string, string) {\n\thi, _ := strconv.Atoi(h)\n\tmi, _ := strconv.Atoi(m)\n\n\tmi++\n\tif mi == 60 {\n\t\tmi = 0\n\t\thi++\n\t\tif hi == 24 {\n\t\t\thi = 0\n\t\t}\n\t}\n\n\th = strconv.FormatInt(int64(hi), 10)\n\tif len(h) == 1 {\n\t\th = \"0\" + h\n\t}\n\n\tm = strconv.FormatInt(int64(mi), 10)\n\tif len(m) == 1 {\n\t\tm = \"0\" + m\n\t}\n\n\treturn h, m\n}\n\n// Input helpers\n\n// If you don't pass in a reference to the reader, and just instantiate a new\n// one every time, it will work locally, with IO typed at human-speed, but not\n// on Codeforces.\n\n// Get Space-separated Line as Strings\n//\n// Example input:\n// 1 test 382.0\n// Example output:\n// [\"1\", \"test\", \"382.0\"]\n\nfunc gsls(reader *bufio.Reader) (arr []string) {\n\t// Get a full line\n\tinput, _ := reader.ReadString('\\n')\n\n\t//Strip newline and return chars, if any\n\tinput = strings.TrimSuffix(input, \"\\n\")\n\tinput = strings.TrimSuffix(input, \"\\r\")\n\n\t// Split at the spaces into an array\n\tarr = strings.Split(input, \" \")\n\n\treturn\n}\n\n// Get Space-separated Line as Integers\n// Any non-valid integers will be 0\n//\n// Example input:\n// test 1 12.3 -117\n// Example output:\n// [0, 1, 0, -117]\n\nfunc gsli(reader *bufio.Reader) (arr []int) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.Atoi(e)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Get Space-separated Line as 64-bit Floats\n// Any non-valid floats will be 0\n//\n// Example input:\n// test 128.328 12 -11.0\n// Example output:\n// [0, 128.328, 12, -11]\n\nfunc gslf(reader *bufio.Reader) (arr []float64) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.ParseFloat(e, 64)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// String helpers\n\n// Is Lowercase\n// Given some string[i], return whether it is lower case or not.\n\nfunc isl(b byte) bool {\n\tvar r rune\n\tr = rune(b)\n\treturn unicode.IsLower(r)\n}\n\n// Math helpers\n\n// Positve Modulo\n// Returns x mod y, but always positive\n\nfunc posMod(x, y int) int {\n\treturn (x%y + y) % y\n}\n\n// Max Int\n// Returns the max of two ints\n\nfunc maxInt(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\n// Output helpers\n\nfunc yes() {\n\tfmt.Println(\"Yes\")\n}\n\nfunc no() {\n\tfmt.Println(\"No\")\n}\n\n// Debug helpers\n\n// From https://groups.google.com/forum/#!topic/golang-nuts/Qlxs3V77nss\n\nfunc dbg(s string, a ...interface{}) {\n\tif debug {\n\t\tfmt.Printf(s, a...)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc toNum(s string) int {\n h := (int(s[0]) - int('0')) * 10 + (int(s[1]) - int('0'))\n m := (int(s[3]) - int('0')) * 10 + (int(s[4]) - int('0'))\n return h * 60 + m\n}\n\nfunc isPalindrome(n int) bool {\n h := n / 60\n m := n % 60\n\n a := fmt.Sprintf(\"%02d:%02d\", h, m)\n for i := 0; i < len(a); i++ {\n if a[i] != a[len(a) - 1 - i] {\n return false\n }\n }\n return true\n}\n\nfunc main() {\n var s string\n for {\n _, err := fmt.Scan(&s)\n if err != nil { break }\n\n n := toNum(s)\n t := 0\n for {\n if isPalindrome(n) {\n break\n }\n t++\n n = (n + 1) % (24 * 60)\n }\n fmt.Println(t)\n }\n}\n\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tfor {\n\t\tvar hh, mm int\n\t\texitCode, err := fmt.Scanf(\"%d:%d\", &hh, &mm)\n\t\tif exitCode == -1 || err != nil {\n\t\t\tbreak\n\t\t}\n\n\t\ttt := hh*60 + mm\n\t\tfor i := 0; ; i++ {\n\t\t\tif tt%60%10 == tt/60/10 && tt%60/10 == tt/60%10 {\n\t\t\t\tfmt.Printf(\"%d\\n\", i)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\ttt = (tt + 1) % (24 * 60)\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar hh, mm int\n\tfor {\n\t\texitCode, err := fmt.Scanf(\"%d:%d\", &hh, &mm)\n\t\tif exitCode == -1 || err != nil {\n\t\t\tbreak\n\t\t}\n\n\t\ttt := hh*60 + mm\n\t\tfor i := 0; ; i++ {\n\t\t\tif tt%60%10 == tt/60/10 && tt%60/10 == tt/60%10 {\n\t\t\t\tfmt.Printf(\"%d\\n\", i)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\ttt = (tt + 1) % (24 * 60)\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc isPalindrome(tt int) bool {\n\treturn tt%60%10 == tt/60/10 && tt%60/10 == tt/60%10\n}\n\nfunc main() {\n\tvar hh, mm int\n\tfor {\n\t\texitCode, err := fmt.Scanf(\"%d:%d\", &hh, &mm)\n\t\tif exitCode == -1 || err != nil {\n\t\t\tbreak\n\t\t}\n\t\ttt := hh*60 + mm\n\t\tfor i := 0; ; i++ {\n\t\t\tif isPalindrome(tt) {\n\t\t\t\tfmt.Printf(\"%d\\n\", i)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\ttt = (tt + 1) % (24 * 60)\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\nfunc check(hour int, min int) bool {\n\tvar hourstr, minstr string\n\tif hour/10 == 0 {\n\t\thourstr = \"0\" + strconv.Itoa(hour)\n\t} else {\n\t\thourstr = strconv.Itoa(hour)\n\t}\n\tif min/10 == 0 {\n\t\tminstr = \"0\" + strconv.Itoa(min)\n\t} else {\n\t\tminstr = strconv.Itoa(min)\n\t}\n\tif hourstr[0] == minstr[1] && hourstr[1] == minstr[0] {\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc main() {\n\tvar hour, min, count int\n\tfmt.Scanf(\"%d:%d\", &hour, &min)\n\tfor {\n\t\tif check(hour, min) {\n\t\t\tfmt.Println(count)\n\t\t\tbreak\n\t\t}\n\t\tmin++\n\t\tcount++\n\t\tif min == 60 {\n\t\t\tmin = 0\n\t\t\thour++\n\t\t}\n\t\tif hour == 24 {\n\t\t\thour = 0\n\t\t}\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\nfunc check(hour int, min int) bool {\n\tvar hourstr, minstr string\n\tif hour/10 == 0 {\n\t\thourstr = \"0\" + strconv.Itoa(hour)\n\t} else {\n\t\thourstr = strconv.Itoa(hour)\n\t}\n\tif min/10 == 0 {\n\t\tminstr = \"0\" + strconv.Itoa(min)\n\t} else {\n\t\tminstr = strconv.Itoa(min)\n\t}\n\tif hourstr[0] == minstr[1] && hourstr[1] == minstr[0] {\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc main() {\n\tvar hour, min, count int\n\tfmt.Scanf(\"%d:%d\", &hour, &min)\n\tfor {\n\t\tif check(hour, min) {\n\t\t\tfmt.Println(count)\n\t\t\tbreak\n\t\t}\n\t\tmin++\n\t\tcount++\n\t\tif min == 60 {\n\t\t\tmin = 0\n\t\t\thour++\n\t\t\tif hour == 24 {\n\t\t\t\thour = 0\n\t\t\t}\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar H, M int\n\tfmt.Scanf(\"%d:%d %d\", &H, &M)\n\tcount := 0\n\tfor {\n\t\ts := fmt.Sprintf(\"%02d%02d\", H, M)\n\t\tsame := true\n\t\tfor i := 0; i <= len(s)/2; i++ {\n\t\t\tif s[i] != s[len(s)-i-1] {\n\t\t\t\tsame = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif same {\n\t\t\tbreak\n\t\t}\n\t\tcount++\n\t\tM++\n\t\tif M == 60 {\n\t\t\tM = 0\n\t\t\tH++\n\t\t\tif H == 24 {\n\t\t\t\tH = 0\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(count)\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc Reverse(s string) string {\n\trunes := []rune(s)\n\tfor i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {\n\t\trunes[i], runes[j] = runes[j], runes[i]\n\t}\n\treturn string(runes)\n}\nfunc solve(s string) string {\n\treturn s\n}\n\nfunc output(i int, ans string) {\n\tfmt.Printf(\"Case #%d: %s\\n\", i, ans)\n}\n\nfunc strTime(x int) string {\n\treturn fmt.Sprintf(\"%02d:%02d\", x/60, x%60)\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Buffer(make([]byte, 1000000), 1000000)\n\t//var numTests int\n\tscanner.Scan()\n\tc := strings.Split(scanner.Text(), \":\")\n\ta, _ := strconv.Atoi(c[0])\n\tb, _ := strconv.Atoi(c[1])\n\tcount := 0\n\tx := a*60 + b\n\tfor true {\n\t\ts := strTime(x)\n\t\t//fmt.Println(s)\n\t\tif s == Reverse(s) {\n\t\t\tbreak\n\t\t}\n\t\tx++\n\t\tif x == 24*60 {\n\t\t\tx = 0\n\t\t}\n\t\tcount++\n\t}\n\tfmt.Println(count)\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar hh, mm, counter int\n\t\n\thh = 23\n\tmm = 59\n\tfmt.Scanf(\"%d:%d\", &hh, &mm)\n\t\n\tcounter = 0\n\tfor (isPalindrom(hh,mm) == false) {\n\t\tmm += 1\n\t\tif (mm == 60) {\n\t\t\tmm = 0\n\t\t\thh += 1\n\t\t}\n\t\tif (hh == 24) {hh = 0}\n\t\tcounter += 1\n\t}\n\t\n\tfmt.Printf(\"%d\\n\", counter)\n}\n\nfunc isPalindrom(hh int, mm int) bool {\n\treturn (hh%10 == mm/10) && (hh/10 == mm%10)\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc toNum(s string) int {\n h := (int(s[0]) - int('0')) * 10 + (int(s[1]) - int('0'))\n m := (int(s[3]) - int('0')) * 10 + (int(s[4]) - int('0'))\n return h * 60 + m\n}\n\nfunc isPalindrome(n int) bool {\n h := n / 60\n m := n % 60\n\n a := fmt.Sprintf(\"%02d:%02d\", h, m)\n for i := 0; i < len(a); i++ {\n if a[i] != a[len(a) - 1 - i] {\n return false\n }\n }\n return true\n}\n\nfunc main() {\n var s string\n for {\n _, err := fmt.Scan(&s)\n if err != nil { break }\n\n n := toNum(s)\n t := 0\n for {\n if isPalindrome(n) {\n break\n }\n t++\n n = (n + 1) % (24 * 60)\n if (t > 10) { break }\n }\n fmt.Println(t)\n }\n}\n\n"}], "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5"} {"nl": {"description": "You are given names of two days of the week.Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to the second day of the week you are given. Both months should belong to one year.In this problem, we consider the Gregorian calendar to be used. The number of months in this calendar is equal to 12. The number of days in months during any non-leap year is: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31.Names of the days of the week are given with lowercase English letters: \"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\".", "input_spec": "The input consists of two lines, each of them containing the name of exactly one day of the week. It's guaranteed that each string in the input is from the set \"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\".", "output_spec": "Print \"YES\" (without quotes) if such situation is possible during some non-leap year. Otherwise, print \"NO\" (without quotes).", "sample_inputs": ["monday\ntuesday", "sunday\nsunday", "saturday\ntuesday"], "sample_outputs": ["NO", "YES", "YES"], "notes": "NoteIn the second sample, one can consider February 1 and March 1 of year 2015. Both these days were Sundays.In the third sample, one can consider July 1 and August 1 of year 2017. First of these two days is Saturday, while the second one is Tuesday."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(t interface{}, delim string) {\n\tfmt.Fscanf(r, \"%v\"+delim, t)\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar r *bufio.Reader\nvar w *bufio.Writer\n\nvar months []int\nvar days []string\n\nfunc getDayByMonth(month, start int) string {\n\td := start\n\tfor i := 0; i < month; i++ {\n\t\td += months[i]\n\t}\n\tday := days[d%7]\n\treturn day\n}\n\nfunc main() {\n\tr = bufio.NewReader(os.Stdin)\n\tw = bufio.NewWriter(os.Stdout)\n\tdefer w.Flush()\n\n\tmonths = []int{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}\n\tdays = []string{\"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\"}\n\n\tvar first, second string\n\tI(&first, \"\\n\")\n\tI(&second, \"\\n\")\n\tfor m := 0; m < 11; m++ {\n\t\tfor d := 0; d < 7; d++ {\n\t\t\tif getDayByMonth(m, d) == first && getDayByMonth(m+1, d) == second {\n\t\t\t\tO(\"YES\", \"\\n\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tO(\"NO\", \"\\n\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"fmt\"\n)\n\nfunc Assert(b bool) {\n\tif !b {\n\t\tpanic(\"Assertion error\")\n\t}\n}\n\nfunc GetLine(scanner *bufio.Scanner) string {\n\tAssert(scanner.Scan() && scanner.Err() == nil)\n\treturn scanner.Text()\n}\n\nfunc SliceIndex(limit int, predicate func(i int) bool) int {\n\tfor i := 0; i < limit; i++ {\n\t\tif predicate(i) {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}\n\nfunc Ternary(c bool, a, b interface{}) interface{} {\n\tif c { return a }\n\treturn b\n}\n\nfunc main() {\n\tf := os.Stdin\n\n\tsc := bufio.NewScanner(f)\n\n\tdays := []string{\"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\"}\n\tReadDay := func() int {\n\t\ts := GetLine(sc)\n\t\tidx := SliceIndex(len(days), func(i int) bool { return days[i] == s })\n\t\tAssert(idx != -1)\n\t\treturn idx\n\t}\n\n\tfirst := ReadDay()\n\tsecond := ReadDay()\n\tdiff := second - first\n\tif diff < 0 {\n\t\tdiff += 7\n\t}\n\n\tpossibles := []int{0, 2, 3}\n\tres := SliceIndex(len(possibles), func(i int) bool { return possibles[i] == diff })\n\n\tfmt.Println(Ternary(res == -1, \"NO\", \"YES\"))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"os\"\n\t\"strings\"\n\t\"bufio\"\n\t\"fmt\"\n\t\"strconv\"\n)\n\nfunc OpenFile(fpath string) *os.File {\n\tf, err := os.Open(fpath)\n\tAssert(err == nil)\n\treturn f\n}\n\nfunc Assert(b bool) {\n\tif !b {\n\t\tpanic(\"Assertion error\")\n\t}\n}\n\nfunc GetLine(scanner *bufio.Scanner) string {\n\tAssert(scanner.Scan() && scanner.Err() == nil)\n\treturn scanner.Text()\n}\n\nfunc ReadIntLine(scanner *bufio.Scanner) []int {\n\tlst := make([]int, 0)\n\tfor _, s := range strings.Fields(GetLine(scanner)) {\n\t\ti, err := strconv.Atoi(s)\n\t\tAssert(err == nil)\n\t\tlst = append(lst, i)\n\t}\n\treturn lst\n}\n\nfunc SliceIndex(limit int, predicate func(i int) bool) int {\n\tfor i := 0; i < limit; i++ {\n\t\tif predicate(i) {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}\n\nfunc Ternary(c bool, a, b interface{}) interface{} {\n\tif c { return a }\n\treturn b\n}\n\nfunc main() {\n\tf := os.Stdin\n\t//f := strings.NewReader(\"Now is the winter of our discontent,\\n1 3 4\\n\")\n\t//f = OpenFile(\"/home/ilya/opt/programming/tasks/724A.txt\")\n\n\tsc := bufio.NewScanner(f)\n\n\tdays := []string{\"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\"}\n\tReadDay := func() int {\n\t\ts := GetLine(sc)\n\t\tidx := SliceIndex(len(days), func(i int) bool { return days[i] == s })\n\t\tAssert(idx != -1)\n\t\treturn idx\n\t}\n\n\tfirst := ReadDay()\n\tsecond := ReadDay()\n\tdiff := second - first\n\tif diff < 0 {\n\t\tdiff += 7\n\t}\n\n\tpossibles := []int{0, 2, 3}\n\tres := SliceIndex(len(possibles), func(i int) bool { return possibles[i] == diff })\n\n\tfmt.Println(Ternary(res == -1, \"NO\", \"YES\"))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\nvar days [12]int = [12]int{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}\nvar weekDays [7]string = [7]string{\"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\"}\n\nfunc getWeekDayId(wd string) int {\n\tfor i := 0; i < 7; i++ {\n\t\tif weekDays[i] == wd {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}\n\nfunc yes(d1 int, d2 int) bool {\n\tfor i := 0; i < 11; i++ {\n\t\tif (d1+days[i])%7 == d2 {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc main() {\n\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\n\tvar wd1, wd2 string\n\tfmt.Fscanf(bufin, \"%s\\n\", &wd1)\n\tfmt.Fscanf(bufin, \"%s\\n\", &wd2)\n\n\tvar d1, d2 int\n\td1 = getWeekDayId(wd1)\n\td2 = getWeekDayId(wd2)\n\n\tif yes(d1, d2) {\n\t\tfmt.Fprintf(bufout, \"YES\\n\")\n\t} else {\n\t\tfmt.Fprintf(bufout, \"NO\\n\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc readInt(num int) []int {\n\tin := make([]int, 0, num)\n\tfor i := 0; i < num; i++ {\n\t\tvar d int\n\t\tfmt.Scan(&d)\n\t\tin = append(in, d)\n\t}\n\treturn in\n}\n\nfunc readStr() string {\n\tvar in string\n\tfmt.Scan(&in)\n\treturn in\n}\n\nvar day = map[string]int{\n\t\"monday\": 0,\n\t\"tuesday\": 1,\n\t\"wednesday\": 2,\n\t\"thursday\": 3,\n\t\"friday\": 4,\n\t\"saturday\": 5,\n\t\"sunday\": 6,\n}\n\nfunc main() {\n\tp := day[readStr()]\n\tc := day[readStr()]\n\tdiff := p - c\n\tif (diff == -3) || (diff == -2) || (diff == 0) || (diff == 4) || (diff == 5) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "// http://acm.timus.ru/problem.aspx?space=1&num=1741\npackage main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n)\n\n// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)\n\nconst (\n\tMOD = 1e9 + 7\n)\n\ntype (\n\n)\n\nvar\n\tdays = [...]string{\"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\"}\n\nfunc main () {\n\tvar (\n\t\ts1, s2 string\n\t)\n\n\t//f, _ := os.Open(\"input.txt\")\n\t//input := bufio.NewReader(f)\n\tinput := bufio.NewReader(os.Stdin)\n\n\tfmt.Fscanln(input, &s1)\n\tfmt.Fscanln(input, &s2)\n\n\tp1, p2 := 0, 0\n\tfor i := 0; i < len(days); i++ {\n\t\tif days[i] == s1 {\n\t\t\tp1 = i\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfor i := 0; i < len(days); i++ {\n\t\tif days[i] == s2 {\n\t\t\tp2 = i + 7\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// Solve\n\tdiff := (p2 - p1) % 7\n\tif 31 % 7 == diff || 28 % 7 == diff || 30 % 7 == diff {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\n\tfmt.Println(\"NO\")\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar date_1, date_2 string\n\tdates := [7]string{\"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\"}\n\tfsc := NewFastScanner()\n\n\tvar d1, d2 int\n\tdate_1 = fsc.Next()\n\tdate_2 = fsc.Next()\n\tfor i := 1; i < 7; i++ {\n\t\tif date_1 == dates[i] {\n\t\t\td1 = i\n\t\t}\n\t\tif date_2 == dates[i] {\n\t\t\td2 = i\n\t\t}\n\t}\n\tif d2 < d1 {\n\t\td2 += 7\n\t}\n\tret := d2 - d1\n\tif ret == 0 || ret == 2 || ret == 3 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\n//template\ntype FastScanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewFastScanner() *FastScanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 2028)\n\treturn &FastScanner{r: rdr}\n}\n\nfunc (s *FastScanner) Next() string {\n\ts.Pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\n\nfunc (s *FastScanner) NextInt() int {\n\tval, err := strconv.Atoi(s.Next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn val\n}\nfunc (s *FastScanner) NextInt64() int64 {\n\tval, err := strconv.ParseInt(s.Next(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn val\n}\nfunc (s *FastScanner) Pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.ReadLine()\n\t\ts.p = 0\n\t}\n}\n\nfunc (s *FastScanner) ReadLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, err := s.r.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err.Error())\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"strconv\"\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\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, 0)\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\nfunc main() {\n\tsc := NewScanner()\n\tA := sc.NextLine()\n\tB := sc.NextLine()\n\n\tdays := []string{\"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\"}\n\n\tc := 0\n\tfor ; c < 7; c++ {\n\t\tif days[c] == A {\n\t\t\tbreak\n\t\t}\n\t}\n\n\td := 0\n\tfor ; d < 7; d++ {\n\t\tif days[d] == B {\n\t\t\tbreak\n\t\t}\n\t}\n\tday := []int{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}\n\tdiff := abs((d - c + 7) % 7)\n\tfor i := 0; i < 12; i++ {\n\t\tif diff == day[i] % 7 {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n\treturn\n\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\ntype scanner struct {\n\tsc *bufio.Scanner\n}\n\nfunc (sc *scanner) next() string {\n\tsc.sc.Scan()\n\treturn sc.sc.Text()\n}\n\nfunc (sc *scanner) nextInt() int {\n\ti, err := strconv.Atoi(sc.next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn i\n}\n\nfunc newScanner(r io.Reader, split bufio.SplitFunc) *scanner {\n\tsc := bufio.NewScanner(r)\n\tsc.Split(split)\n\treturn &scanner{\n\t\tsc: sc,\n\t}\n}\n\nvar wsc = newScanner(os.Stdin, bufio.ScanWords)\nvar lsc = newScanner(os.Stdin, bufio.ScanLines)\n\nfunc next() string {\n\treturn wsc.next()\n}\n\nfunc nextInt() int {\n\treturn wsc.nextInt()\n}\n\nfunc nextLine() string {\n\treturn lsc.next()\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}\nfunc joinInts(a []int, sep string) string {\n\tb := make([]string, len(a))\n\tfor i, v := range a {\n\t\tb[i] = strconv.Itoa(v)\n\t}\n\treturn strings.Join(b, sep)\n}\n\nvar weekdays = map[string]int{\n\t\"sunday\": 1,\n\t\"monday\": 2,\n\t\"tuesday\": 3,\n\t\"wednesday\": 4,\n\t\"thursday\": 5,\n\t\"friday\": 6,\n\t\"saturday\": 7,\n}\n\nfunc main() {\n\td1, d2 := weekdays[next()], weekdays[next()]\n\tif d1-d2 == 4 || d2-d1 == 3 || d1-d2 == 5 || d2-d1 == 2 || d1 == d2 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}], "negative_code": [{"source_code": "// http://acm.timus.ru/problem.aspx?space=1&num=1741\npackage main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n)\n\n// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)\n\nconst (\n\tMOD = 1e9 + 7\n)\n\ntype (\n\n)\n\nvar\n\tdays = [...]string{\"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\"}\n\nfunc main () {\n\tvar (\n\t\ts1, s2 string\n\t)\n\n\t//f, _ := os.Open(\"input.txt\")\n\t//input := bufio.NewReader(f)\n\tinput := bufio.NewReader(os.Stdin)\n\n\tfmt.Fscanln(input, &s1)\n\tfmt.Fscanln(input, &s2)\n\n\tp1, p2 := 0, 0\n\tfor i := 0; i < len(days); i++ {\n\t\tif days[i] == s1 {\n\t\t\tp1 = i\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfor i := 0; i < len(days); i++ {\n\t\tif days[i] == s2 {\n\t\t\tp2 = i + 7\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// Solve\n\tdiff := (p2 - p1)\n\tif 31 % 7 == diff || 28 % 7 == diff || 30 % 7 == diff {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\n\tfmt.Println(\"NO\")\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\ntype scanner struct {\n\tsc *bufio.Scanner\n}\n\nfunc (sc *scanner) next() string {\n\tsc.sc.Scan()\n\treturn sc.sc.Text()\n}\n\nfunc (sc *scanner) nextInt() int {\n\ti, err := strconv.Atoi(sc.next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn i\n}\n\nfunc newScanner(r io.Reader, split bufio.SplitFunc) *scanner {\n\tsc := bufio.NewScanner(r)\n\tsc.Split(split)\n\treturn &scanner{\n\t\tsc: sc,\n\t}\n}\n\nvar wsc = newScanner(os.Stdin, bufio.ScanWords)\nvar lsc = newScanner(os.Stdin, bufio.ScanLines)\n\nfunc next() string {\n\treturn wsc.next()\n}\n\nfunc nextInt() int {\n\treturn wsc.nextInt()\n}\n\nfunc nextLine() string {\n\treturn lsc.next()\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}\nfunc joinInts(a []int, sep string) string {\n\tb := make([]string, len(a))\n\tfor i, v := range a {\n\t\tb[i] = strconv.Itoa(v)\n\t}\n\treturn strings.Join(b, sep)\n}\n\nvar weekdays = map[string]int{\n\t\"sunday\": 1,\n\t\"monday\": 2,\n\t\"tuesday\": 3,\n\t\"wednesday\": 4,\n\t\"thursday\": 5,\n\t\"friday\": 6,\n\t\"saturday\": 7,\n}\n\nfunc main() {\n\td1, d2 := weekdays[next()], weekdays[next()]\n\tif d1-d2 == 4 || d2-d1 == 3 || d1-d2 == 3 || d2-d1 == 2 || d1 == d2 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}], "src_uid": "2a75f68a7374b90b80bb362c6ead9a35"} {"nl": {"description": "One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems.But there are too many problems, to do it manually. Alex asks you to write a program, which will determine if a problem is from this contest by its name.It is known, that problem is from this contest if and only if its name contains one of Alex's friends' name exactly once. His friends' names are \"Danil\", \"Olya\", \"Slava\", \"Ann\" and \"Nikita\".Names are case sensitive.", "input_spec": "The only line contains string from lowercase and uppercase letters and \"_\" symbols of length, not more than 100 — the name of the problem.", "output_spec": "Print \"YES\", if problem is from this contest, and \"NO\" otherwise.", "sample_inputs": ["Alex_and_broken_contest", "NikitaAndString", "Danil_and_Olya"], "sample_outputs": ["NO", "YES", "NO"], "notes": null}, "positive_code": [{"source_code": "package main\nimport (\n\t\"fmt\"\n)\n\nfunc main(){\n\tvar str string\n\tfmt.Scanf(\"%s\\n\", &str)\n\tvar dest = [5]string {\"Danil\", \"Olya\", \"Slava\", \"Ann\" ,\"Nikita\"}\n\tsum := 0\n\tfor i := 0; i < 5; i++{\n\t\tsum += matchStr(str, dest[i])\n\t}\n\tif sum == 1{\n\t\tfmt.Println(\"YES\")\n\t}else{\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nfunc matchStr(src string, dest string) int{\n\tsum := 0\n\tfor i := 0; i + len(dest) - 1 < len(src); i++{\n\t\tflag := true\n\t\tfor j := 0; j < len(dest); j++{\n\t\t\tif src[i + j] != dest[j]{\n\t\t\t\tflag = false\n\t\t\t}\n\t\t}\n\t\tif flag {\n\t\t\tsum++\n\t\t}\n\t}\n\treturn sum\n}"}, {"source_code": "// Try Codeforces\n// author: Leonardone @ NEETSDKASU\npackage main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tnames := []string{\"Danil\", \"Olya\", \"Slava\", \"Ann\", \"Nikita\"}\n\tcnt := 0\n\tfor _, x := range names {\n\t\tt := s[:]\n\t\tfor i := 0; i < 10; i++ {\n\t\t\tp := strings.Index(t, x)\n\t\t\tif p < 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tt = t[p+len(x):]\n\t\t\tcnt++\n\t\t}\n\t}\n\tif cnt == 1 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n //\"strconv\"\n \"strings\"\n)\n\nfunc main() {\n //io\n scanner := bufio.NewReader(os.Stdin)\n writer := bufio.NewWriter(os.Stdout)\n //---\n var s string\n fmt.Fscan(scanner, &s)\n \n cnt := strings.Count(s, \"Danil\") + strings.Count(s, \"Olya\")\n cnt += strings.Count(s, \"Slava\") + strings.Count(s, \"Ann\") + strings.Count(s, \"Nikita\")\n if(cnt == 1) {\n writer.WriteString(\"YES\")\n } else {\n writer.WriteString(\"NO\")\n }\n writer.Flush()\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strings\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF877A(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tvar s string\n\tFscan(in, &s)\n\tc := 0\n\tfor _, name := range []string{\"Danil\", \"Olya\", \"Slava\", \"Ann\", \"Nikita\"} {\n\t\tc += strings.Count(s, name)\n\t}\n\tif c == 1 {\n\t\tFprintln(out, \"YES\")\n\t} else {\n\t\tFprintln(out, \"NO\")\n\t}\n}\n\nfunc main() { CF877A(os.Stdin, os.Stdout) }\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar friends = []string{\"Danil\", \"Olya\", \"Slava\", \"Ann\", \"Nikita\"}\n\tvar (\n\t\tproblems string\n\t\tcount int\n\t)\n\tfmt.Scan(&problems)\n\n\tfor _, friend := range friends {\n\t\tcount += strings.Count(problems, friend)\n\n\t\tif count > 1 {\n\t\t\tfmt.Print(\"NO\\n\")\n\t\t\treturn\n\t\t}\n\t}\n\tif count == 0 {\n\t\tfmt.Print(\"NO\\n\")\n\t\treturn\n\t}\n\tfmt.Print(\"YES\\n\")\n}\n"}], "negative_code": [{"source_code": "package main\nimport (\n\t\"fmt\"\n)\n\nfunc main(){\n\tvar str string\n\tfmt.Scanf(\"%s\\n\", &str)\n\tvar dest = [5]string {\"Danil\", \"Olya\", \"Slava\", \"Ann\" ,\"Nikita\"}\n\tsum := 0\n\tfor i := 0; i < 5; i++{\n\t\tif matchStr(str, dest[i]){\n\t\t\tsum++\n\t\t}\n\t}\n\tif sum == 1{\n\t\tfmt.Println(\"YES\")\n\t}else{\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nfunc matchStr(src string, dest string) bool{\n\tfor i := 0; i + len(dest) - 1 < len(src); i++{\n\t\tflag := true\n\t\tfor j := 0; j < len(dest); j++{\n\t\t\tif src[i + j] != dest[j]{\n\t\t\t\tflag = false\n\t\t\t}\n\t\t}\n\t\tif flag {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strings\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF877A(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tvar s string\n\tFscan(in, &s)\n\tc := 0\n\tfor _, name := range []string{\"Danil\", \"Olya\", \"Slava\", \"Ann\", \"Nikita\"} {\n\t\tif strings.Index(s, name) >= 0 {\n\t\t\tc++\n\t\t}\n\t}\n\tif c == 1 {\n\t\tFprintln(out, \"YES\")\n\t} else {\n\t\tFprintln(out, \"NO\")\n\t}\n}\n\nfunc main() { CF877A(os.Stdin, os.Stdout) }\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar friends = []string{\"Danil\", \"Olya\", \"Slava\", \"Ann\", \"Nikita\"}\n\tvar (\n\t\tproblems string\n\t\tcount int\n\t)\n\tfmt.Scan(&problems)\n\n\tfor _, friend := range friends {\n\t\tif has := strings.Contains(problems, friend); has {\n\t\t\tcount++\n\t\t}\n\t\tif count > 1 {\n\t\t\tfmt.Print(\"NO\\n\")\n\t\t\treturn\n\t\t}\n\t}\n\tif count == 0 {\n\t\tfmt.Print(\"NO\\n\")\n\t\treturn\n\t}\n\tfmt.Print(\"YES\\n\")\n}\n"}], "src_uid": "db2dc7500ff4d84dcc1a37aebd2b3710"} {"nl": {"description": "You are locked in a room with a door that has a keypad with 10 keys corresponding to digits from 0 to 9. To escape from the room, you need to enter a correct code. You also have a sequence of digits.Some keys on the keypad have fingerprints. You believe the correct code is the longest not necessarily contiguous subsequence of the sequence you have that only contains digits with fingerprints on the corresponding keys. Find such code.", "input_spec": "The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\le n, m \\le 10$$$) representing the number of digits in the sequence you have and the number of keys on the keypad that have fingerprints. The next line contains $$$n$$$ distinct space-separated integers $$$x_1, x_2, \\ldots, x_n$$$ ($$$0 \\le x_i \\le 9$$$) representing the sequence. The next line contains $$$m$$$ distinct space-separated integers $$$y_1, y_2, \\ldots, y_m$$$ ($$$0 \\le y_i \\le 9$$$) — the keys with fingerprints.", "output_spec": "In a single line print a space-separated sequence of integers representing the code. If the resulting sequence is empty, both printing nothing and printing a single line break is acceptable.", "sample_inputs": ["7 3\n3 5 7 1 6 2 8\n1 2 7", "4 4\n3 4 1 0\n0 1 7 9"], "sample_outputs": ["7 1 2", "1 0"], "notes": "NoteIn the first example, the only digits with fingerprints are $$$1$$$, $$$2$$$ and $$$7$$$. All three of them appear in the sequence you know, $$$7$$$ first, then $$$1$$$ and then $$$2$$$. Therefore the output is 7 1 2. Note that the order is important, and shall be the same as the order in the original sequence.In the second example digits $$$0$$$, $$$1$$$, $$$7$$$ and $$$9$$$ have fingerprints, however only $$$0$$$ and $$$1$$$ appear in the original sequence. $$$1$$$ appears earlier, so the output is 1 0. Again, the order is important."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m, in int\n\tfmt.Scan(&n, &m)\n\ta, b := make([]int, n), make([]int, m)\n\tfor i := range a {\n\t\tfmt.Scan(&in)\n\t\ta[i] = in\n\t}\n\tfor i := range b {\n\t\tfmt.Scan(&in)\n\t\tb[i] = in\n\t}\n\tfor _, c := range a {\n\t\tfor _, c1 := range b {\n\t\t\tif c == c1 {\n\t\t\t\tfmt.Printf(\"%v \", c)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println()\n}"}, {"source_code": "// A. Fingerprints\n/*\nYou are locked in a room with a door that has a keypad with 10 keys corresponding to digits from 0 to 9. To escape from the room, you need to enter a correct code. You also have a sequence of digits.\n\nSome keys on the keypad have fingerprints. You believe the correct code is the longest not necessarily contiguous subsequence of the sequence you have that only contains digits with fingerprints on the corresponding keys. Find such code.\n\nInput\nThe first line contains two integers 𝑛 and 𝑚 (1≤𝑛,𝑚≤10) representing the number of digits in the sequence you have and the number of keys on the keypad that have fingerprints.\n\nThe next line contains 𝑛 distinct space-separated integers 𝑥1,𝑥2,…,𝑥𝑛 (0≤𝑥𝑖≤9) representing the sequence.\n\nThe next line contains 𝑚 distinct space-separated integers 𝑦1,𝑦2,…,𝑦𝑚 (0≤𝑦𝑖≤9) — the keys with fingerprints.\n\nOutput\nIn a single line print a space-separated sequence of integers representing the code. If the resulting sequence is empty, both printing nothing and printing a single line break is acceptable.\n\nExamples\nInput\n7 3\n3 5 7 1 6 2 8\n1 2 7\n\nOutput\n7 1 2\n\nInput\n4 4\n3 4 1 0\n0 1 7 9\n\nOutput\n1 0\n\nNote\nIn the first example, the only digits with fingerprints are 1, 2 and 7. All three of them appear in the sequence you know, 7 first, then 1 and then 2. Therefore the output is 7 1 2. Note that the order is important, and shall be the same as the order in the original sequence.\n\nIn the second example digits 0, 1, 7 and 9 have fingerprints, however only 0 and 1 appear in the original sequence. 1 appears earlier, so the output is 1 0. Again, the order is important.\n*/\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\treader.ReadString('\\n')\n\n\tinput2, _ := reader.ReadString('\\n')\n\tnArr := strings.Split(strings.TrimSpace(input2), \" \")\n\n\tinput3, _ := reader.ReadString('\\n')\n\tmArr := strings.Split(strings.TrimSpace(input3), \" \")\n\n\tfor _, i := range nArr {\n\t\tfor _, j := range mArr {\n\t\t\tif i == j {\n\t\t\t\tfmt.Printf(\"%v \", i)\n\t\t\t}\n\t\t}\n\t}\n}\n"}, {"source_code": "// A. Fingerprints\n/*\nYou are locked in a room with a door that has a keypad with 10 keys corresponding to digits from 0 to 9. To escape from the room, you need to enter a correct code. You also have a sequence of digits.\n\nSome keys on the keypad have fingerprints. You believe the correct code is the longest not necessarily contiguous subsequence of the sequence you have that only contains digits with fingerprints on the corresponding keys. Find such code.\n\nInput\nThe first line contains two integers 𝑛 and 𝑚 (1≤𝑛,𝑚≤10) representing the number of digits in the sequence you have and the number of keys on the keypad that have fingerprints.\n\nThe next line contains 𝑛 distinct space-separated integers 𝑥1,𝑥2,…,𝑥𝑛 (0≤𝑥𝑖≤9) representing the sequence.\n\nThe next line contains 𝑚 distinct space-separated integers 𝑦1,𝑦2,…,𝑦𝑚 (0≤𝑦𝑖≤9) — the keys with fingerprints.\n\nOutput\nIn a single line print a space-separated sequence of integers representing the code. If the resulting sequence is empty, both printing nothing and printing a single line break is acceptable.\n\nExamples\nInput\n7 3\n3 5 7 1 6 2 8\n1 2 7\n\nOutput\n7 1 2\n\nInput\n4 4\n3 4 1 0\n0 1 7 9\n\nOutput\n1 0\n\nNote\nIn the first example, the only digits with fingerprints are 1, 2 and 7. All three of them appear in the sequence you know, 7 first, then 1 and then 2. Therefore the output is 7 1 2. Note that the order is important, and shall be the same as the order in the original sequence.\n\nIn the second example digits 0, 1, 7 and 9 have fingerprints, however only 0 and 1 appear in the original sequence. 1 appears earlier, so the output is 1 0. Again, the order is important.\n*/\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput1, _ := reader.ReadString('\\n')\n\tarr1 := strings.Split(strings.TrimSpace(input1), \" \")\n\n\t_, _ = strconv.Atoi(arr1[0])\n\t_, _ = strconv.Atoi(arr1[1])\n\n\tinput2, _ := reader.ReadString('\\n')\n\tnArr := strings.Split(strings.TrimSpace(input2), \" \")\n\n\tinput3, _ := reader.ReadString('\\n')\n\tmArr := strings.Split(strings.TrimSpace(input3), \" \")\n\n\tfor _, i := range nArr {\n\t\tfor _, j := range mArr {\n\t\t\tif i == j {\n\t\t\t\tfmt.Printf(\"%v \", i)\n\t\t\t}\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scan(&n)\n\tfmt.Scan(&m)\n\n\tsec := make([]int, n)\n\tfinger_print := make([]int, m)\n\tfor i, _ := range sec {\n\t\tfmt.Scan(&sec[i])\n\t}\n\n\tfor i, _ := range finger_print {\n\t\tfmt.Scan(&finger_print[i])\n\t}\n\n\tfor _, i := range sec {\n\t\t//fmt.Println(\"valor de i \", i)\n\t\tfor _, j := range finger_print {\n\t\t\t//fmt.Println(\"valor de jjj \", j)\n\n\t\t\tif i == j {\n\t\t\t\tfmt.Print(strconv.Itoa(i))\n\t\t\t\tfmt.Print(\" \")\n\t\t\t}\n\n\t\t}\n\n\t}\n\tfmt.Println()\n\n}\n"}, {"source_code": "// test\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, m, t int\n\tfmt.Scan(&n, &m)\n\tvar digit [10]int\n\tvar is [10]bool\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&digit[i])\n\t}\n\tfor i := 0; i < m; i++ {\n\t\tfmt.Scan(&t)\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif digit[j] == t {\n\t\t\t\tis[j] = true\n\t\t\t}\n\t\t}\n\t}\n\tfor j := 0; j < n; j++ {\n\t\tif is[j] == true {\n\t\t\tfmt.Printf(\"%d \", digit[j])\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc solve(x, y []int) (res []int) {\n\tn := make(map[int]bool)\n\tfor _, v := range y {\n\t\tn[v] = true\n\t}\n\n\tfor _, v := range x {\n\t\t_, ok := n[v]\n\t\tif ok {\n\t\t\tres = append(res, v)\n\t\t}\n\t}\n\n\treturn\n}\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\n\tx := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&x[i])\n\t}\n\n\ty := make([]int, m)\n\tfor i := 0; i < m; i++ {\n\t\tfmt.Scan(&y[i])\n\t}\n\n\tres := solve(x, y)\n\tfor _, v := range res {\n\t\tfmt.Printf(\"%d \", v)\n\t}\n\n\t// {\n\t// \tx := []int{3, 5, 7, 1, 6, 2, 8}\n\t// \ty := []int{1, 2, 7}\n\t// \tfmt.Println(solve(x, y))\n\t// }\n\n\t// {\n\t// \tx := []int{3, 4, 1, 0}\n\t// \ty := []int{0, 1, 7, 9}\n\t// \tfmt.Println(solve(x, y))\n\t// }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n \"fmt\"\n \"sort\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\n\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\n\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n n,m := ReadInt64(), ReadInt64()\n\n x:=make([]int64,n)\n for i:=0;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\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"}, {"source_code": "package main\n\nimport (\"fmt\")\n\ntype boolean bool\n\nfunc main() {\n\tn := nextInt()\n\tk := nextInt()\n\tvar a []int = make([]int, n)\n\tset := Set{make(map[int]boolean)}\n\tfor i := 0; i < n; i++{\n\t\ta[i] = nextInt()\n\t}\n\tfor i := 0; i < k; i++{\t\n\t\tset.add(nextInt())\n\t}\n\tfor i := 0; i < n; i++{\n\t\tif set.contains(a[i]){\n\t\t\tsout(a[i])\n\t\t\tset.remove(a[i])\n\t\t}\n\t}\n}\n\nfunc next() string{\n\tvar ss string\n\tfmt.Scan(&ss)\n\treturn ss\n}\nfunc nextInt() int{\n\tvar ss int;\n\tfmt.Scan(&ss)\n\treturn ss\n}\nfunc sout(obj ... interface{}){\n\tfor _, k := range obj{\n\t\tfmt.Print(k, \" \")\n\t}\n\tfmt.Println()\n}\n\ntype Set struct{mp map[int]boolean}\n\nfunc (self Set) add (key int){self.mp[key] = true}\n\nfunc (self Set) remove(key int){delete(self.mp, key)}\n\nfunc (self Set) contains(key int) boolean{return self.mp[key] == true}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar n, m, i, y int\n\tfmt.Scanf(\"%d %d\\n\", &n, &m)\n\n\txList := make([]int, n)\n\tfor i = 0; i < n; i++ {\n\t\tfmt.Scan(&xList[i])\n\t}\n\n\tyList := make(map[int]bool)\n\tfor i = 0; i < m; i++ {\n\t\tfmt.Scan(&y)\n\t\tyList[y] = true\n\t}\n\n\tresult := make([]string, 0)\n\tfor i = 0; i < n; i++ {\n\t\tif yList[xList[i]] {\n\t\t\tresult = append(result, strconv.Itoa(xList[i]))\n\t\t}\n\t}\n\n\tfmt.Println(strings.Join(result, \" \"))\n}"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc solve(x, y []int) (res []int) {\n\tn := make(map[int]bool)\n\tfor _, v := range y {\n\t\tn[v] = true\n\t}\n\n\tfor _, v := range x {\n\t\t_, ok := n[v]\n\t\tif ok {\n\t\t\tres = append(res, v)\n\t\t}\n\t}\n\n\treturn\n}\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\n\tx := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &x[i])\n\t}\n\n\ty := make([]int, n)\n\tfor i := 0; i < m; i++ {\n\t\tfmt.Scanf(\"%d\", &y[i])\n\t}\n\n\tres := solve(x, y)\n\tfor _, v := range res {\n\t\tfmt.Printf(\"%d \", v)\n\t}\n\n\t// {\n\t// \tx := []int{3, 5, 7, 1, 6, 2, 8}\n\t// \ty := []int{1, 2, 7}\n\t// \tfmt.Println(solve(x, y))\n\t// }\n\n\t// {\n\t// \tx := []int{3, 4, 1, 0}\n\t// \ty := []int{0, 1, 7, 9}\n\t// \tfmt.Println(solve(x, y))\n\t// }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc solve(x, y []int) (res []int) {\n\tn := make(map[int]bool)\n\tfor _, v := range y {\n\t\tn[v] = true\n\t}\n\n\tfor _, v := range x {\n\t\t_, ok := n[v]\n\t\tif ok {\n\t\t\tres = append(res, v)\n\t\t}\n\t}\n\n\treturn\n}\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\n\tx := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &x[i])\n\t}\n\n\ty := make([]int, m)\n\tfor i := 0; i < m; i++ {\n\t\tfmt.Scanf(\"%d\", &y[i])\n\t}\n\n\tres := solve(x, y)\n\tfor _, v := range res {\n\t\tfmt.Printf(\"%d \", v)\n\t}\n\n\t// {\n\t// \tx := []int{3, 5, 7, 1, 6, 2, 8}\n\t// \ty := []int{1, 2, 7}\n\t// \tfmt.Println(solve(x, y))\n\t// }\n\n\t// {\n\t// \tx := []int{3, 4, 1, 0}\n\t// \ty := []int{0, 1, 7, 9}\n\t// \tfmt.Println(solve(x, y))\n\t// }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n n := 0\n m := 0\n\n fmt.Scanf(\"%d%d\", &n, &m)\n\n ns := make([]int, n)\n ms := make([]int, 10)\n\n for i := 0; i < n; i++ { \n fmt.Scanf(\"%d\", &ns[i])\n }\n\n for i := 0; i < m; i++ {\n x := 0\n fmt.Scanf(\"%d\", &x)\n ms[x] = 1\n }\n\n for i := 0; i < n; i++ {\n if (ms[ns[i]] != 0) {\n fmt.Printf(\"%d \", ns[i])\n }\n }\n\n fmt.Println(\"\")\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n n := 0\n m := 0\n\n fmt.Scanf(\"%d%d\", &n, &m)\n\n ns := make([]int, n)\n ms := make([]int, 10)\n\n for i := 0; i < n; i++ {\n fmt.Scanf(\"%d\", &ns[i])\n }\n\n for i := 0; i < m; i++ {\n x := 0\n fmt.Scanf(\"%d\", &x)\n ms[x] = 1\n }\n\n for i := 0; i < n; i++ {\n if (ms[ns[i]] != 0) {\n fmt.Printf(\"%d \", ns[i])\n }\n }\n\n fmt.Println(\"\")\n}"}], "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72"} {"nl": {"description": "Nicholas has an array a that contains n distinct integers from 1 to n. In other words, Nicholas has a permutation of size n.Nicholas want the minimum element (integer 1) and the maximum element (integer n) to be as far as possible from each other. He wants to perform exactly one swap in order to maximize the distance between the minimum and the maximum elements. The distance between two elements is considered to be equal to the absolute difference between their positions.", "input_spec": "The first line of the input contains a single integer n (2 ≤ n ≤ 100) — the size of the permutation. The second line of the input contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ n), where ai is equal to the element at the i-th position.", "output_spec": "Print a single integer — the maximum possible distance between the minimum and the maximum elements Nicholas can achieve by performing exactly one swap.", "sample_inputs": ["5\n4 5 1 3 2", "7\n1 6 5 3 4 7 2", "6\n6 5 4 3 2 1"], "sample_outputs": ["3", "6", "5"], "notes": "NoteIn the first sample, one may obtain the optimal answer by swapping elements 1 and 2.In the second sample, the minimum and the maximum elements will be located in the opposite ends of the array if we swap 7 and 2.In the third sample, the distance between the minimum and the maximum elements is already maximum possible, so we just perform some unnecessary swap, for example, one can swap 5 and 2."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\ta := make([]int, 105)\n\tvar tmp int\n\tfmt.Scanf(\"%d\", &tmp)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &a[i])\n\t}\n\tans := 0\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif i < j {\n\t\t\t\ttmp := a[i]\n\t\t\t\ta[i] = a[j]\n\t\t\t\ta[j] = tmp\n\t\t\t\tmn := -1\n\t\t\t\tmx := -1\n\t\t\t\tfor k := 0; k < n; k++ {\n\t\t\t\t\tif a[k] == 1 {\n\t\t\t\t\t\tmn = k\n\t\t\t\t\t}\n\t\t\t\t\tif a[k] == n {\n\t\t\t\t\t\tmx = k\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tc := mx - mn\n\t\t\t\tif c < 0 {\n\t\t\t\t\tc = -c\n\t\t\t\t}\n\t\t\t\tif ans < c {\n\t\t\t\t\tans = c\n\t\t\t\t}\n\t\t\t\ttmp = a[i]\n\t\t\t\ta[i] = a[j]\n\t\t\t\ta[j] = tmp\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n\n\n\n"}, {"source_code": "// Codeforces 676 A\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\t\"strconv\"\n)\nvar in *bufio.Reader\n\nfunc readFive() (int,int,int,int,int) {\n var a [5]int\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"first read failure\", err)\n\t\tpanic(err)\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n for i:=0; i d2 {\n\t\tfmt.Print(d1)\n\t} else {\n\t\tfmt.Print(d2)\n\t}\n}\n\ntype StdReader struct {\n\tbuf *bufio.Reader\n}\n\nfunc NewStdReader(reader io.Reader) *StdReader {\n\treturn &StdReader{bufio.NewReaderSize(reader, 2*1024*1024)}\n}\n\nfunc (std *StdReader) ReadInt() int {\n\n\tr := 0\n\tsign := 1\n\tok := false\n\n\tfor {\n\t\tb, e := std.buf.ReadByte()\n\n\t\tif e != nil {\n\t\t\tbreak\n\t\t}\n\t\tif b >= '0' && b <= '9' {\n\t\t\tr = r*10 + int(b-'0')\n\t\t\tok = true\n\t\t} else {\n\t\t\tif ok {\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\tif b == '-' {\n\t\t\t\t\tsign = -sign\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn sign * r\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc solve(a []int) int {\n\tn := len(a)\n\tif n == 2 {\n\t\treturn 1\n\t}\n\tif n == 3 {\n\t\treturn 2\n\t}\n\t// n >= 4\n\ti1, in := -1, -1\n\tfor i := 0; i < n; i++ {\n\t\tif a[i] == 1 {\n\t\t\ti1 = i\n\t\t}\n\t\tif a[i] == n {\n\t\t\tin = i\n\t\t}\n\t}\n\td1b := (i1 + 1) - 1\n\td1e := n - (i1 + 1)\n\tdnb := (in + 1) - 1\n\tdne := n - (in + 1)\n\n\tmax := d1b\n\tif d1e > max {\n\t\tmax = d1e\n\t}\n\tif dnb > max {\n\t\tmax = dnb\n\t}\n\tif dne > max {\n\t\tmax = dne\n\t}\n\treturn max\n}\n\nfunc main() {\n\tvar n int\n\tnr, err := fmt.Fscanln(os.Stdin, &n)\n\tif nr != 1 || err != nil {\n\t\tpanic(err)\n\t}\n\ta := make([]int, n)\n\tpa := make([]interface{}, n)\n\tfor i := 0; i < n; i++ {\n\t\tpa[i] = &a[i]\n\t}\n\tnr, err = fmt.Fscanln(os.Stdin, pa...)\n\tif nr != n || err != nil {\n\t\tpanic(err)\n\t}\n\tres := solve(a)\n\tfmt.Println(res)\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\tvar a[105]int\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &a[i])\n\t}\n\tans := 0\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif i < j {\n\t\t\t\ttmp := a[i]\n\t\t\t\ta[i] = a[j]\n\t\t\t\ta[j] = tmp\n\t\t\t\tmn := -1\n\t\t\t\tmx := -1\n\t\t\t\tfor k := 0; k < n; k++ {\n\t\t\t\t\tif a[k] == 1 {\n\t\t\t\t\t\tmn = k\n\t\t\t\t\t}\n\t\t\t\t\tif a[k] == n {\n\t\t\t\t\t\tmx = k\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tc := mx - mn\n\t\t\t\tif c < 0 {\n\t\t\t\t\tc = -c\n\t\t\t\t}\n\t\t\t\tif ans < c {\n\t\t\t\t\tans = c\n\t\t\t\t}\n\t\t\t\ttmp = a[i]\n\t\t\t\ta[i] = a[j]\n\t\t\t\ta[j] = tmp\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n\n\n\n\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\ta := make([]int, 105)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &a[i])\n\t\tif n == 6 {\n\t\t\tfmt.Println(a[i])\n\t\t}\n\t}\n\tans := 0\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif i < j {\n\t\t\t\ttmp := a[i]\n\t\t\t\ta[i] = a[j]\n\t\t\t\ta[j] = tmp\n\t\t\t\tmn := -1\n\t\t\t\tmx := -1\n\t\t\t\tfor k := 0; k < n; k++ {\n\t\t\t\t\tif a[k] == 1 {\n\t\t\t\t\t\tmn = k\n\t\t\t\t\t}\n\t\t\t\t\tif a[k] == n {\n\t\t\t\t\t\tmx = k\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tc := mx - mn\n\t\t\t\tif c < 0 {\n\t\t\t\t\tc = -c\n\t\t\t\t}\n\t\t\t\tif ans < c {\n\t\t\t\t\tans = c\n\t\t\t\t}\n\t\t\t\ttmp = a[i]\n\t\t\t\ta[i] = a[j]\n\t\t\t\ta[j] = tmp\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n\n\n\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\ta := make([]int, 105)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &a[i])\n\t}\n\tans := 0\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif i < j {\n\t\t\t\ttmp := a[i]\n\t\t\t\ta[i] = a[j]\n\t\t\t\ta[j] = tmp\n\t\t\t\tmn := -1\n\t\t\t\tmx := -1\n\t\t\t\tfor k := 0; k < n; k++ {\n\t\t\t\t\tif a[k] == 1 {\n\t\t\t\t\t\tmn = k\n\t\t\t\t\t}\n\t\t\t\t\tif a[k] == n {\n\t\t\t\t\t\tmx = k\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tc := mx - mn\n\t\t\t\tif c < 0 {\n\t\t\t\t\tc = -c\n\t\t\t\t}\n\t\t\t\tif ans < c {\n\t\t\t\t\tans = c\n\t\t\t\t}\n\t\t\t\ttmp = a[i]\n\t\t\t\ta[i] = a[j]\n\t\t\t\ta[j] = tmp\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n\n\n\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\tvar a[105]int\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &a[i])\n\t\tif n == 6 {\n\t\t\tfmt.Println(a[i])\n\t\t}\n\t}\n\tans := 0\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif i < j {\n\t\t\t\ttmp := a[i]\n\t\t\t\ta[i] = a[j]\n\t\t\t\ta[j] = tmp\n\t\t\t\tmn := -1\n\t\t\t\tmx := -1\n\t\t\t\tfor k := 0; k < n; k++ {\n\t\t\t\t\tif a[k] == 1 {\n\t\t\t\t\t\tmn = k\n\t\t\t\t\t}\n\t\t\t\t\tif a[k] == n {\n\t\t\t\t\t\tmx = k\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tc := mx - mn\n\t\t\t\tif c < 0 {\n\t\t\t\t\tc = -c\n\t\t\t\t}\n\t\t\t\tif ans < c {\n\t\t\t\t\tans = c\n\t\t\t\t}\n\t\t\t\ttmp = a[i]\n\t\t\t\ta[i] = a[j]\n\t\t\t\ta[j] = tmp\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n\n\n\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\ta := make([]int, 105)\n\tvar tmp int\n\tfmt.Scanf(\"%d\", &tmp)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &a[i])\n\t\tif n == 6 {\n\t\t\tfmt.Println(a[i])\n\t\t}\n\t}\n\tans := 0\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif i < j {\n\t\t\t\ttmp := a[i]\n\t\t\t\ta[i] = a[j]\n\t\t\t\ta[j] = tmp\n\t\t\t\tmn := -1\n\t\t\t\tmx := -1\n\t\t\t\tfor k := 0; k < n; k++ {\n\t\t\t\t\tif a[k] == 1 {\n\t\t\t\t\t\tmn = k\n\t\t\t\t\t}\n\t\t\t\t\tif a[k] == n {\n\t\t\t\t\t\tmx = k\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tc := mx - mn\n\t\t\t\tif c < 0 {\n\t\t\t\t\tc = -c\n\t\t\t\t}\n\t\t\t\tif ans < c {\n\t\t\t\t\tans = c\n\t\t\t\t}\n\t\t\t\ttmp = a[i]\n\t\t\t\ta[i] = a[j]\n\t\t\t\ta[j] = tmp\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n\n\n\n"}], "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4"} {"nl": {"description": "The 9-th grade student Gabriel noticed a caterpillar on a tree when walking around in a forest after the classes. The caterpillar was on the height h1 cm from the ground. On the height h2 cm (h2 > h1) on the same tree hung an apple and the caterpillar was crawling to the apple.Gabriel is interested when the caterpillar gets the apple. He noted that the caterpillar goes up by a cm per hour by day and slips down by b cm per hour by night.In how many days Gabriel should return to the forest to see the caterpillar get the apple. You can consider that the day starts at 10 am and finishes at 10 pm. Gabriel's classes finish at 2 pm. You can consider that Gabriel noticed the caterpillar just after the classes at 2 pm.Note that the forest is magic so the caterpillar can slip down under the ground and then lift to the apple.", "input_spec": "The first line contains two integers h1, h2 (1 ≤ h1 < h2 ≤ 105) — the heights of the position of the caterpillar and the apple in centimeters. The second line contains two integers a, b (1 ≤ a, b ≤ 105) — the distance the caterpillar goes up by day and slips down by night, in centimeters per hour.", "output_spec": "Print the only integer k — the number of days Gabriel should wait to return to the forest and see the caterpillar getting the apple. If the caterpillar can't get the apple print the only integer  - 1.", "sample_inputs": ["10 30\n2 1", "10 13\n1 1", "10 19\n1 2", "1 50\n5 4"], "sample_outputs": ["1", "0", "-1", "1"], "notes": "NoteIn the first example at 10 pm of the first day the caterpillar gets the height 26. At 10 am of the next day it slips down to the height 14. And finally at 6 pm of the same day the caterpillar gets the apple.Note that in the last example the caterpillar was slipping down under the ground and getting the apple on the next day."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t// \"sort\"\n\t// \"strings\"\n)\n\nvar (\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\th1, h2 := nextInt(), nextInt()\n\ta, b := nextInt(), nextInt()\n\n\th1 += a * 8\n\n\tif a <= b {\n\t\tif h1 < h2 {\n\t\t\tprintln(-1)\n\t\t\treturn\n\t\t}\n\t}\n\n\tday := 0\n\n\tfor h1 < h2 {\n\t\th1 += (a - b) * 12\n\t\tday++\n\t}\n\n\tprintln(day)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tinit := scanner.Text()\n\theights := strings.Split(init, \" \")\n\n\tcater, _ := strconv.Atoi(heights[0])\n\tapple, _ := strconv.Atoi(heights[1])\n\n\tscanner.Scan()\n\tinput := scanner.Text()\n\tins := strings.Split(input, \" \")\n\n\tupS, _ := strconv.Atoi(ins[0])\n\tdS, _ := strconv.Atoi(ins[1])\n\n\tdiffDay := (upS - dS) * 12\n\tdays := 0\n\t// lets move for day1 first\n\tcater = (cater + 8*upS)\n\tif cater >= apple {\n\t\tfmt.Println(days)\n\t\treturn\n\t}\n\tif dS >= upS {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\tfor {\n\t\tif cater >= apple {\n\t\t\tfmt.Println(days)\n\t\t\treturn\n\t\t}\n\n\t\tdays++\n\t\tcater += diffDay\n\t}\n\n}\n"}], "negative_code": [], "src_uid": "2c39638f07c3d789ba4c323a205487d7"} {"nl": {"description": "There is a field of size $$$2 \\times 2$$$. Each cell of this field can either contain grass or be empty. The value $$$a_{i, j}$$$ is $$$1$$$ if the cell $$$(i, j)$$$ contains grass, or $$$0$$$ otherwise.In one move, you can choose one row and one column and cut all the grass in this row and this column. In other words, you choose the row $$$x$$$ and the column $$$y$$$, then you cut the grass in all cells $$$a_{x, i}$$$ and all cells $$$a_{i, y}$$$ for all $$$i$$$ from $$$1$$$ to $$$2$$$. After you cut the grass from a cell, it becomes empty (i. e. its value is replaced by $$$0$$$).Your task is to find the minimum number of moves required to cut the grass in all non-empty cells of the field (i. e. make all $$$a_{i, j}$$$ zeros).You have to answer $$$t$$$ independent test cases.", "input_spec": "The first line of the input contains one integer $$$t$$$ ($$$1 \\le t \\le 16$$$) — the number of test cases. Then $$$t$$$ test cases follow. The test case consists of two lines, each of these lines contains two integers. The $$$j$$$-th integer in the $$$i$$$-th row is $$$a_{i, j}$$$. If $$$a_{i, j} = 0$$$ then the cell $$$(i, j)$$$ is empty, and if $$$a_{i, j} = 1$$$ the cell $$$(i, j)$$$ contains grass.", "output_spec": "For each test case, print one integer — the minimum number of moves required to cut the grass in all non-empty cells of the field (i. e. make all $$$a_{i, j}$$$ zeros) in the corresponding test case.", "sample_inputs": ["3\n\n0 0\n\n0 0\n\n1 0\n\n0 1\n\n1 1\n\n1 1"], "sample_outputs": ["0\n1\n2"], "notes": null}, "positive_code": [{"source_code": "package main\r\n\r\nimport(\r\n\t\"fmt\"\r\n)\r\n\r\nfunc main() {\r\n\tvar t int\r\n\t_, err := fmt.Scan(&t)\r\n\tif err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n\r\n\tfor i := 0; t > i; i++ {\r\n\t\tvar a []int\r\n\t\tfor j := 0; 2 > j; j++ {\r\n\t\t\tvar v1 int\r\n\t\t\tvar v2 int\r\n\t\t\t_, err := fmt.Scan(&v1)\r\n\t\t\tif err != nil {\r\n\t\t\t\tpanic(err)\r\n\t\t\t}\r\n\t\t\t_, err2 := fmt.Scan(&v2)\r\n\t\t\tif err2 != nil {\r\n\t\t\t\tpanic(err)\r\n\t\t\t}\r\n\t\t\ta = append(a, v1, v2)\r\n\t\t}\r\n\r\n\t\tif a[0] + a[1] + a[2] + a[3] == 4 {\r\n\t\t\tfmt.Println(\"2\")\r\n\t\t} else if a[0] + a[1] + a[2] + a[3] == 0 {\r\n\t\t\tfmt.Println(\"0\")\r\n\t\t} else {\r\n\t\t\tfmt.Println(\"1\")\r\n\t\t}\r\n\t}\r\n\r\n}\r\n"}, {"source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"os\"\r\n\t\"strconv\"\r\n\t\"strings\"\r\n)\r\n\r\ntype CF1701A 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 *CF1701A) 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 *CF1701A) 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 *CF1701A) 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 *CF1701A) 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 *CF1701A) NextString() string {\r\n\tin.load()\r\n\tval := strings.TrimSpace(in.split[in.index])\r\n\tin.index++\r\n\treturn val\r\n}\r\n\r\n/**\r\nRun solve the problem CF1701A\r\nDate: 17/07/22\r\nUser: pepradere\r\nURL: https://codeforces.com/problemset/problem/1701/A\r\nProblem: CF1701A\r\n**/\r\nfunc (in *CF1701A) Run() {\r\n\tfor t := in.NextInt(); t > 0; t-- {\r\n\t\ta := in.NextString()+\" \"+in.NextString()\r\n\t\tb := in.NextString()+\" \"+in.NextString()\r\n\r\n\t\tans := 0\r\n\t\tif a == \"0 0\" && b == \"0 0\" {\r\n\t\t\tans = 0\r\n\t\t}else if a == \"1 1\" && b == \"1 1\" {\r\n\t\t\tans = 2\r\n\t\t}else {\r\n\t\t\tans = 1\r\n\t\t}\r\n\t\tfmt.Println(ans)\r\n\t}\r\n}\r\n\r\nfunc NewCF1701A(r *bufio.Reader) *CF1701A {\r\n\treturn &CF1701A{\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\tNewCF1701A(bufio.NewReader(os.Stdin)).Run()\r\n}\r\n"}, {"source_code": "package main\r\n\r\nimport (\r\n\t.\"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n)\r\n\r\n// github.com/EndlessCheng/codeforces-go\r\nfunc CF1701A(in io.Reader, out io.Writer) {\r\n\tvar T, v int\r\n\tfor Fscan(in, &T); T > 0; T-- {\r\n\t\tc := 0\r\n\t\tfor i := 0; i < 4; i++ {\r\n\t\t\tFscan(in, &v)\r\n\t\t\tc += v\r\n\t\t}\r\n\t\tif c == 0 {\r\n\t\t\tFprintln(out, 0)\r\n\t\t} else if c < 4 {\r\n\t\t\tFprintln(out, 1)\r\n\t\t} else {\r\n\t\t\tFprintln(out, 2)\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunc main() { CF1701A(os.Stdin, os.Stdout) }\r\n"}, {"source_code": "package main\r\n\r\nimport (\r\n\t. \"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n)\r\n\r\n// github.com/EndlessCheng/codeforces-go\r\nfunc CF1701A(in io.Reader, out io.Writer) {\r\n\tvar T, v int\r\n\tfor Fscan(in, &T); T > 0; T-- {\r\n\t\tc := 0\r\n\t\tfor i := 0; i < 4; i++ {\r\n\t\t\tFscan(in, &v)\r\n\t\t\tc += v\r\n\t\t}\r\n\t\tif c == 0 {\r\n\t\t\tFprintln(out, 0)\r\n\t\t} else if c < 4 {\r\n\t\t\tFprintln(out, 1)\r\n\t\t} else {\r\n\t\t\tFprintln(out, 2)\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunc main() { CF1701A(os.Stdin, os.Stdout) }\r\n"}, {"source_code": " // You can edit this code!\r\n // Click here and start typing.\r\n package main\r\n \r\n import \"fmt\"\r\n \r\n func main() {\r\n \tvar t int\r\n \tfmt.Scanf(\"%d\", &t)\r\n \tfor j := 0; j < t; j++ {\r\n \t\tcnt := 0\r\n \t\tfor i := 0; i < 4; i++ {\r\n \t\t\t\tvar x,y int\r\n \t\t\t\tfmt.Scanf(\"%d %d\", &x,&y)\r\n \t\t\t\t//fmt.Printf(\"x==> %v and y ==> %v \\n\",x,y)\r\n \t\t\t\tif x == 1 {\r\n \t\t\t\t\tcnt++\r\n \t\t\t\t}\r\n \t\t\t\tif y == 1 {\r\n \t\t\t\t cnt++\r\n \t\t\t\t}\r\n \t\t}\r\n \t\t//fmt.Printf(\"cnt==> %v\\n\",cnt)\r\n \t\tif cnt == 4 {\r\n \t\t\tfmt.Printf(\"2\\n\")\r\n \t\t} else if cnt == 0 {\r\n \t\t\tfmt.Printf(\"0\\n\")\r\n \t\t} else {\r\n \t\t\tfmt.Printf(\"1\\n\")\r\n \t\t}\r\n \t}\r\n }"}, {"source_code": "package main\r\nimport \"fmt\"\r\n\r\nfunc main() {\r\n var testCase int;\r\n fmt.Scanf(\"%d \", &testCase);\r\n for testCase > 0 {\r\n v := 0\r\n for i:=0; i<2; i++ {\r\n var x, y int\r\n fmt.Scanf(\"%d %d \", &x, &y)\r\n v += x\r\n v += y\r\n }\r\n if (v == 0) {\r\n fmt.Println(0);\r\n } else if (v == 1 || v == 3 || v == 2) {\r\n fmt.Println(1);\r\n } else {\r\n fmt.Println(2);\r\n }\r\n testCase--;\r\n }\r\n \r\n}"}, {"source_code": "package main\r\nimport( \r\n \"fmt\"\r\n \"bufio\"\r\n \"os\"\r\n)\r\nfunc main() {\r\n\tin:= bufio.NewReader(os.Stdin)\r\n\tout:= bufio.NewWriter(os.Stdout)\r\n\tdefer out.Flush()\r\n\tvar t int\r\n\tfmt.Fscan(in,&t)\r\n\tfor i:=0;i 0; t-- {\r\n\t\tcnt = 0\r\n\t\tfor i := 0; i < 4; i++ {\r\n\t\t\tfmt.Fscan(in, &a)\r\n\t\t\tif a > 0 {\r\n\t\t\t\tcnt++\r\n\t\t\t}\r\n\t\t}\r\n\t\tif cnt == 0 {\r\n\t\t\tans = 0\r\n\t\t} else if cnt < 4 {\r\n\t\t\tans = 1\r\n\t\t} else {\r\n\t\t\tans = 2\r\n\t\t}\r\n\t\tfmt.Fprintln(out, ans)\r\n\t}\r\n}\r\n"}, {"source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"os\"\r\n)\r\n\r\nvar (\r\n\treader = bufio.NewReader(os.Stdin)\r\n\tt int\r\n\ta []int\r\n)\r\n\r\nfunc solve(a []int) int {\r\n\tvar c int\r\n\tfor _, x := range a {\r\n\t\tc += x\r\n\t}\r\n\tif c == 0 {\r\n\t\treturn 0\r\n\t}\r\n\tif c == 4 {\r\n\t\treturn 2\r\n\t}\r\n\treturn 1\r\n}\r\n\r\nfunc main() {\r\n\tfmt.Fscan(reader, &t)\r\n\tfor ; t > 0; t-- {\r\n\t\ta = make([]int, 4)\r\n\t\tfor i := 0; i < 4; i++ {\r\n\t\t\tfmt.Fscan(reader, &a[i])\r\n\t\t}\r\n\t\tfmt.Println(solve(a))\r\n\t}\r\n}\r\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar t, a, b, c, d int\n\n\tfmt.Scanln(&t)\n\n\tfor i := 0; i < t; i++ {\n\n\t\tfmt.Scanln(&a, &b)\n\t\tfmt.Scanln(&c, &d)\n\t\tif a+b+c+d == 4 {\n\t\t\tfmt.Println(\"2\")\n\t\t} else if a+b+c+d == 0 {\n\t\t\tfmt.Println(\"0\")\n\t\t} else {\n\t\t\tfmt.Println(\"1\")\n\t\t}\n\t}\n}\n"}, {"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 Solve(testCaseIdx int, reader io.Reader, writer io.Writer) {\r\n\tsum := 0\r\n\tfor k := 0; k < 4; k++ {\r\n\t\tvar ak int\r\n\t\tfmt.Fscan(reader, &ak)\r\n\t\tsum += ak\r\n\t}\r\n\tswitch {\r\n\tcase sum == 0:\r\n\t\tfmt.Fprintln(writer, \"0\")\r\n\tcase sum == 4:\r\n\t\tfmt.Fprintln(writer, \"2\")\r\n\tdefault:\r\n\t\tfmt.Fprintln(writer, \"1\")\r\n\t}\r\n}\r\n\r\nfunc main() {\r\n\treader := bufio.NewReader(os.Stdin)\r\n\twriter := bufio.NewWriter(os.Stdout)\r\n\tdefer writer.Flush()\r\n\r\n\tvar testCaseCount int\r\n\tfmt.Fscan(reader, &testCaseCount)\r\n\tfor t := 0; t < testCaseCount; t++ {\r\n\t\tSolve(t, reader, writer)\r\n\t}\r\n}\r\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar rr = bufio.NewReader(os.Stdin)\nvar ww = bufio.NewWriter(os.Stdout)\n\nfunc slove() {\n\tvar a, b, c, d int\n\tfmt.Fscan(rr, &a, &b, &c, &d)\n\tif a + b + c + d ==0 {\n\t\tfmt.Fprintln(ww, 0)\n\t} else if a + b + c + d == 4 {\n\t\tfmt.Fprintln(ww, 2)\n\t} else {\n\t\tfmt.Fprintln(ww, 1)\n\t}\n}\n\nfunc main() {\n\tdefer ww.Flush()\n\tvar n int\n\tfmt.Fscan(rr, &n)\n\tfor i:=1;i<=n;i++ {\n\t\tslove()\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\n\tvar T int\n\tfmt.Fscan(in, &T)\n\tfor t := 0; t < T; t++ {\n\t\tvar tot int\n\t\tfor i := 0; i < 4; i++ {\n\t\t\tvar v int\n\t\t\tfmt.Fscan(in, &v)\n\t\t\ttot += v\n\t\t}\n\n\t\tif tot == 0 {\n\t\t\tfmt.Fprintln(out, 0)\n\t\t} else if tot == 4 {\n\t\t\tfmt.Fprintln(out, 2)\n\t\t} else {\n\t\t\tfmt.Fprintln(out, 1)\n\t\t}\n\t}\n}\n"}, {"source_code": "// 1701A. Grass Field\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar T int\n\tfmt.Scan(&T)\n\tfor t := 0; t < T; t++ {\n\t\tsum := 0\n\t\tcurr := 0\n\t\tfor i := 0; i < 4; i++ {\n\t\t\tfmt.Scan(&curr)\n\t\t\tsum += curr\n\t\t}\n\t\tif sum == 4 {\n\t\t\tfmt.Println(2)\n\t\t} else if sum == 0 {\n\t\t\tfmt.Println(0)\n\t\t} else {\n\t\t\tfmt.Println(1)\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc solve(one, two, three, four int) int {\n\tsum := one + two + three + four\n\n\tif sum == 0 {\n\t\treturn 0\n\t}\n\tif sum == 4 {\n\t\treturn 2\n\t}\n\n\treturn 1\n}\n\nfunc main() {\n\tvar test int\n\tfmt.Scanln(&test)\n\n\tfor test > 0 {\n\t\ttest--\n\t\tvar one, two, three, four int\n\t\tfmt.Scanln(&one, &two)\n\t\tfmt.Scanln(&three, &four)\n\n\t\tfmt.Println(solve(one, two, three, four))\n\t}\n}\n"}, {"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 main() {\r\n\ta1700(os.Stdin, os.Stdout)\r\n}\r\n\r\nfunc a1700(_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\tvar T int\r\n\tvar x int\r\n\r\n\tfor Fscan(in, &T); T > 0; T-- {\r\n\t\ta := []int{}\r\n\t\ts := 0\r\n\t\tfor i := 0; i < 4; i++ {\r\n\t\t\tFscan(in, &x)\r\n\t\t\ts += x\r\n\t\t\ta = append(a, x)\r\n\t\t}\r\n\r\n\t\tans := 0\r\n\t\tif s == 4 {\r\n\t\t\tans = 2\r\n\t\t} else if s != 0 {\r\n\t\t\tans = 1\r\n\t\t}\r\n\r\n\t\tFprintln(out, ans)\r\n\t}\r\n}\r\n"}, {"source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"os\"\r\n)\r\n\r\nvar (\r\n\twriter = bufio.NewWriter(os.Stdout)\r\n\tscanner = bufio.NewScanner(os.Stdin)\r\n)\r\n\r\nfunc init() {\r\n\tscanner.Split(bufio.ScanWords)\r\n\tscanner.Buffer(make([]byte, 4096), 1e9)\r\n}\r\n\r\nfunc printf(f string, a ...interface{}) {\r\n\tfmt.Fprintf(writer, f, a...)\r\n}\r\n\r\nfunc _int() int {\r\n\ts := _string()\r\n\ti := 0\r\n\tif s[0] == '-' {\r\n\t\tfor _, r := range s[1:] {\r\n\t\t\ti *= 10\r\n\t\t\ti -= int(r - '0')\r\n\t\t}\r\n\t\treturn i\r\n\t}\r\n\tfor _, r := range s {\r\n\t\ti *= 10\r\n\t\ti += int(r - '0')\r\n\t}\r\n\treturn i\r\n}\r\n\r\nfunc _int64() int64 {\r\n\ts := _string()\r\n\ti := int64(0)\r\n\tif s[0] == '-' {\r\n\t\tfor _, r := range s[1:] {\r\n\t\t\ti *= 10\r\n\t\t\ti -= int64(r - '0')\r\n\t\t}\r\n\t\treturn i\r\n\t}\r\n\tfor _, r := range s {\r\n\t\ti *= 10\r\n\t\ti += int64(r - '0')\r\n\t}\r\n\treturn i\r\n}\r\n\r\nfunc _string() string {\r\n\tif !scanner.Scan() {\r\n\t\tpanic(scanner.Err())\r\n\t}\r\n\treturn scanner.Text()\r\n}\r\n\r\nfunc main() {\r\n\tdefer writer.Flush()\r\n\tfor t := _int(); t > 0; t-- {\r\n\t\ta := _int()\r\n\t\tb := _int()\r\n\t\tc := _int()\r\n\t\td := _int()\r\n\t\tprintf(\"%d\\n\", solve(a, b, c, d))\r\n\t}\r\n}\r\n\r\nfunc solve(a, b, c, d int) int {\r\n\tif a == 1 && b == 1 && c == 1 && d == 1 {\r\n\t\treturn 2\r\n\t}\r\n\tif a == 1 || b == 1 || c == 1 || d == 1 {\r\n\t\treturn 1\r\n\t}\r\n\treturn 0\r\n}\r\n"}], "negative_code": [{"source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"os\"\r\n\t\"strconv\"\r\n\t\"strings\"\r\n)\r\n\r\ntype CF1701A 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 *CF1701A) 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 *CF1701A) 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 *CF1701A) 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 *CF1701A) 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 *CF1701A) NextString() string {\r\n\tin.load()\r\n\tval := strings.TrimSpace(in.split[in.index])\r\n\tin.index++\r\n\treturn val\r\n}\r\n\r\n/**\r\nRun solve the problem CF1701A\r\nDate: 17/07/22\r\nUser: pepradere\r\nURL: https://codeforces.com/problemset/problem/1701/A\r\nProblem: CF1701A\r\n**/\r\nfunc (in *CF1701A) Run() {\r\n\tfor t := in.NextInt(); t > 0; t-- {\r\n\t\ta := in.NextString()+\" \"+in.NextString()\r\n\t\tb := in.NextString()+\" \"+in.NextString()\r\n\r\n\t\tans := 0\r\n\t\tif a == \"0 0\" && b == \"0 0\" {\r\n\t\t\tans = 0\r\n\t\t}else if a == \"0 1\" && b == \"0 1\" {\r\n\t\t\tans = 1\r\n\t\t}else if a == \"1 0\" && b == \"0 1\" {\r\n\t\t\tans = 1\r\n\t\t} else if a == \"0 1\" && b == \"1 0\" {\r\n\t\t\tans = 1\r\n\t\t}else if a == \"1 0\" && b == \"1 0\" {\r\n\t\t\tans = 1\r\n\t\t}else if a == \"1 1\" && b == \"1 1\" {\r\n\t\t\tans = 2\r\n\t\t}\r\n\t\tfmt.Println(ans)\r\n\t}\r\n}\r\n\r\nfunc NewCF1701A(r *bufio.Reader) *CF1701A {\r\n\treturn &CF1701A{\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\tNewCF1701A(bufio.NewReader(os.Stdin)).Run()\r\n}\r\n"}, {"source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"os\"\r\n\t\"strconv\"\r\n\t\"strings\"\r\n)\r\n\r\ntype CF1701A 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 *CF1701A) 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 *CF1701A) 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 *CF1701A) 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 *CF1701A) 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 *CF1701A) NextString() string {\r\n\tin.load()\r\n\tval := strings.TrimSpace(in.split[in.index])\r\n\tin.index++\r\n\treturn val\r\n}\r\n\r\n/**\r\nRun solve the problem CF1701A\r\nDate: 17/07/22\r\nUser: pepradere\r\nURL: https://codeforces.com/problemset/problem/1701/A\r\nProblem: CF1701A\r\n**/\r\nfunc (in *CF1701A) Run() {\r\n\tfor t := in.NextInt(); t > 0; t-- {\r\n\t\ta := in.GetLine()\r\n\t\ta = a[0:len(a)-1]\r\n\t\tb := in.GetLine()\r\n\t\tb = b[0:len(b)-1]\r\n\r\n\t\tans := 0\r\n\t\tif a == \"0 0\" && b == \"0 0\" {\r\n\t\t\tans = 0\r\n\t\t}else if a == \"0 1\" && b == \"0 1\" {\r\n\t\t\tans = 1\r\n\t\t}else if a == \"1 0\" && b == \"0 1\" {\r\n\t\t\tans = 1\r\n\t\t} else if a == \"0 1\" && b == \"1 0\" {\r\n\t\t\tans = 1\r\n\t\t}else if a == \"1 0\" && b == \"1 0\" {\r\n\t\t\tans = 1\r\n\t\t}else if a == \"1 1\" && b == \"1 1\" {\r\n\t\t\tans = 2\r\n\t\t}\r\n\t\tfmt.Println(ans)\r\n\t}\r\n}\r\n\r\nfunc NewCF1701A(r *bufio.Reader) *CF1701A {\r\n\treturn &CF1701A{\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\tNewCF1701A(bufio.NewReader(os.Stdin)).Run()\r\n}\r\n"}, {"source_code": "// You can edit this code!\n// Click here and start typing.\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar t int\n\tfmt.Scanf(\"%d\", &t)\n\tfor j := 0; j < t; j++ {\n\t\tcnt := 0\n\t\tfor i := 0; i < 2; i++ {\n\t\t\tfor j := 0; j < 2; j++ {\n\t\t\t\tvar x int\n\t\t\t\tfmt.Scanf(\"%d\", &x)\n\t\t\t\tif x == 1 {\n\t\t\t\t\tcnt++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif cnt == 4 {\n\t\t\tfmt.Printf(\"2\\n\")\n\t\t} else if cnt == 0 {\n\t\t\tfmt.Printf(\"0\\n\")\n\t\t} else {\n\t\t\tfmt.Printf(\"1\\n\")\n\t\t}\n\t}\n}\n"}, {"source_code": "/******************************************************************************\r\n\r\n Online Go Lang Compiler.\r\n Code, Compile, Run and Debug Go Lang program online.\r\nWrite your code in this editor and press \"Run\" button to execute it.\r\n\r\n*******************************************************************************/\r\n\r\n\r\npackage main\r\nimport \"fmt\"\r\n\r\nfunc main() {\r\n var testCase int;\r\n fmt.Scanf(\"%d \", &testCase);\r\n for testCase > 0 {\r\n v := 0\r\n for i:=0; i<4; i++ {\r\n var x int\r\n fmt.Scanf(\"%d \", &x)\r\n v += x\r\n }\r\n if (v == 0) {\r\n fmt.Println(0);\r\n } else if (v == 1 || v == 3) {\r\n fmt.Println(1);\r\n } else {\r\n fmt.Println(2);\r\n }\r\n testCase--;\r\n }\r\n \r\n}\r\n"}], "src_uid": "7336b8becd2438f0439240ee8f9610ec"} {"nl": {"description": "Vasya started working in a machine vision company of IT City. Vasya's team creates software and hardware for identification of people by their face.One of the project's know-how is a camera rotating around its optical axis on shooting. People see an eye-catching gadget — a rotating camera — come up to it to see it better, look into it. And the camera takes their photo at that time. What could be better for high quality identification?But not everything is so simple. The pictures from camera appear rotated too (on clockwise camera rotation frame the content becomes rotated counter-clockwise). But the identification algorithm can work only with faces that are just slightly deviated from vertical.Vasya was entrusted to correct the situation — to rotate a captured image so that image would be minimally deviated from vertical. Requirements were severe. Firstly, the picture should be rotated only on angle divisible by 90 degrees to not lose a bit of information about the image. Secondly, the frames from the camera are so huge and FPS is so big that adequate rotation speed is provided by hardware FPGA solution only. And this solution can rotate only by 90 degrees clockwise. Of course, one can apply 90 degrees turn several times but for the sake of performance the number of turns should be minimized.Help Vasya implement the program that by the given rotation angle of the camera can determine the minimum number of 90 degrees clockwise turns necessary to get a picture in which up direction deviation from vertical is minimum.The next figure contains frames taken from an unrotated camera, then from rotated 90 degrees clockwise, then from rotated 90 degrees counter-clockwise. Arrows show direction to \"true up\". The next figure shows 90 degrees clockwise turn by FPGA hardware. ", "input_spec": "The only line of the input contains one integer x ( - 1018 ≤ x ≤ 1018) — camera angle in degrees. Positive value denotes clockwise camera rotation, negative — counter-clockwise.", "output_spec": "Output one integer — the minimum required number of 90 degrees clockwise turns.", "sample_inputs": ["60", "-60"], "sample_outputs": ["1", "3"], "notes": "NoteWhen the camera is rotated 60 degrees counter-clockwise (the second example), an image from it is rotated 60 degrees clockwise. One 90 degrees clockwise turn of the image result in 150 degrees clockwise total rotation and deviation from \"true up\" for one turn is 150 degrees. Two 90 degrees clockwise turns of the image result in 240 degrees clockwise total rotation and deviation from \"true up\" for two turns is 120 degrees because 240 degrees clockwise equal to 120 degrees counter-clockwise. Three 90 degrees clockwise turns of the image result in 330 degrees clockwise total rotation and deviation from \"true up\" for three turns is 30 degrees because 330 degrees clockwise equal to 30 degrees counter-clockwise.From 60, 150, 120 and 30 degrees deviations the smallest is 30, and it it achieved in three 90 degrees clockwise turns."}, "positive_code": [{"source_code": "// Codeforces 635 E, with podskazki, done\npackage main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"strconv\"\n \"strings\"\n \"os\"\n)\n\nfunc miconv(s string) int64 {\n iret,err := strconv.ParseInt(s, 10, 64)\n if err != nil {\n fmt.Println(\"error in converting \" + s)\n }\n return iret\n}\n\nvar x int64\nvar pov int64\n\n\n\nfunc main() {\n // reading n\n in := bufio.NewReader(os.Stdin)\n s,err := in.ReadString('\\n')\n if err != nil {\n fmt.Println(\"first read failure\", err)\n }\n ss := strings.Split(strings.Trim(s,\" \\n\\r\"),\" \")\n x = miconv(ss[0])\n \n if x > 0 {\n x = x % 360\n } else {\n x = -(-x % 360)\n x = (x + 360) % 360\n }\n // fmt.Printf(\"converted x = %d\\n\", x)\n \n if x<=45 {\n pov = 0\n } else if x<=135 {\n pov = 1\n } else if x<=225 {\n pov = 2\n } else if x>=315 {\n pov = 0\n } else {\n pov = 3\n } \n\t\n\t// print result\n\tfmt.Printf(\"%d\\n\", pov)\n}\n"}], "negative_code": [{"source_code": "// Codeforces 635 E, with podskazki, done\npackage main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"strconv\"\n \"strings\"\n \"os\"\n)\n\nfunc miconv(s string) int64 {\n i,err := strconv.Atoi(s)\n if err != nil {\n fmt.Println(\"error in converting \" + s)\n }\n iret := int64(i)\n return iret\n}\n\nvar x int64\nvar pov int64\n\n\n\nfunc main() {\n // reading n\n in := bufio.NewReader(os.Stdin)\n s,err := in.ReadString('\\n')\n if err != nil {\n fmt.Println(\"first read failure\", err)\n }\n ss := strings.Split(strings.Trim(s,\" \\n\\r\"),\" \")\n x = miconv(ss[0])\n \n if x > 0 {\n x = x % 360\n } else {\n x = -(-x % 360)\n x = (x + 360) % 360\n }\n // fmt.Printf(\"converted x = %d\\n\", x)\n \n if x<=45 {\n pov = 0\n } else if x<=135 {\n pov = 1\n } else if x<=225 {\n pov = 2\n } else if x>=315 {\n pov = 0\n } else {\n pov = 3\n } \n\t\n\t// print result\n\tfmt.Printf(\"%d\\n\", pov)\n}\n"}], "src_uid": "509db9cb6156b692557ba874a09f150e"} {"nl": {"description": "Little Petya loves playing with squares. Mum bought him a square 2n × 2n in size. Petya marked a cell inside the square and now he is solving the following task.The task is to draw a broken line that would go along the grid lines and that would cut the square into two equal parts. The cutting line should not have any common points with the marked cell and the resulting two parts should be equal up to rotation.Petya wants to determine whether it is possible to cut the square in the required manner given the sizes of the square side and the coordinates of the marked cell. Help him.", "input_spec": "The first line contains three space-separated integers 2n, x and y (2 ≤ 2n ≤ 100, 1 ≤ x, y ≤ 2n), representing the length of a square's side and the coordinates of the marked cell. It is guaranteed that 2n is even. The coordinates of the marked cell are represented by a pair of numbers x y, where x represents the number of the row and y represents the number of the column. The rows and columns are numbered by consecutive integers from 1 to 2n. The rows are numbered from top to bottom and the columns are numbered from the left to the right.", "output_spec": "If the square is possible to cut, print \"YES\", otherwise print \"NO\" (without the quotes).", "sample_inputs": ["4 1 1", "2 2 2"], "sample_outputs": ["YES", "NO"], "notes": "NoteA sample test from the statement and one of the possible ways of cutting the square are shown in the picture: "}, "positive_code": [{"source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n)\n\nfunc scanInt(scanner *bufio.Scanner) int {\n scanner.Scan()\n x, _ := strconv.Atoi(scanner.Text())\n return x\n}\n\nfunc main() {\n scanner := bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n side, x, y := scanInt(scanner), scanInt(scanner), scanInt(scanner)\n a, b := side/2, side/2+1\n if (x == a || x == b) && (y == a || y == b) {\n writer.WriteString(\"NO\\n\")\n } else {\n writer.WriteString(\"YES\\n\")\n }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var nn,x,y int\n fmt.Scan(&nn,&x,&y)\n n := nn/2\n if ((x == n) || (x == (n+1))) && ((y == n) || (y == (n+1))) {\n fmt.Println(\"NO\")\n } else {\n fmt.Println(\"YES\")\n }\n}\n"}, {"source_code": "//112B\npackage main\nimport \"fmt\"\n\nfunc main() {\n\tvar nn, xx, yy int\n\tfmt.Scan(&nn, &xx, &yy)\n\tnn/=2\n\tif (nn==xx || (nn+1)==xx) && (nn==yy || nn+1==yy){\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n\n"}, {"source_code": "package main\nimport \"fmt\"\n\nfunc main() {\n\tvar nn, xx, yy int\n\tfmt.Scan(&nn, &xx, &yy)\n\tnn/=2\n\tif (nn==xx || (nn+1)==xx) && (nn==yy || nn+1==yy){\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}"}, {"source_code": "package main\nimport \"fmt\"\n\nfunc main() {\n\tvar nn, xx, yy int\n\tfmt.Scan(&nn, &xx, &yy)\n\tnn/=2\n\tif (nn==xx || (nn+1)==xx) && (nn==yy || nn+1==yy){\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var nn,x,y int\n fmt.Scan(&nn,&x,&y)\n n := nn/2\n if ((x == n) || (x == (n+1))) && ((y == n) || (y == (n+1))) {\n fmt.Println(\"NO\")\n } else {\n fmt.Println(\"YES\")\n }\n}\n"}, {"source_code": "// 112B-Andre,Dikai,Eric\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var n,x,y int\n fmt.Scan(&n,&x,&y)\n if n==2{\n fmt.Println(\"NO\")\n }else{\n if ((x == (n / 2) || x == (n / 2 + 1)) && (y == (n / 2) || y == (n / 2 + 1))){\n fmt.Println(\"NO\")\n }else\n {fmt.Println(\"YES\")}\n }\n \n}\n"}, {"source_code": "// 112B\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, x, y int\n\tfmt.Scan(&n, &x, &y)\n\tif (x == n/2 || x == n/2+1) && (y == n/2 || y == n/2+1) {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n"}, {"source_code": "// 112B-mic\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n,x,y int\n\tfmt.Scan(&n, &x, &y)\n if n==2 {\n\t\tfmt.Println(\"NO\")\n return\n }else if n==4 && (y==2 || y==3) {\n fmt.Println(\"NO\")\n\t\treturn\n }else if (y==n/2 || y==(n/2)+1) && (x==n/2 || x==(n/2)+1) {\n fmt.Println(\"NO\")\n\t\treturn\n\t}\n\tfmt.Println(\"YES\")\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n)\n\nfunc scanInt(scanner *bufio.Scanner) int {\n scanner.Scan()\n x, _ := strconv.Atoi(scanner.Text())\n return x\n}\n\nfunc main() {\n scanner := bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n side, x, y := scanInt(scanner), scanInt(scanner), scanInt(scanner)\n a, b := side/2, side/2+1\n if x == a || x == b || y == a || y == b {\n writer.WriteString(\"NO\\n\")\n } else {\n writer.WriteString(\"YES\\n\")\n }\n}\n"}, {"source_code": "// 112B-Andre,Dikai,Eric\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var n,x,y int\n fmt.Scan(&n,&x,&y)\n if n==2{\n fmt.Println(\"NO\")\n }else\n {if x == n/2 || x == (n/2)+1 && y == n/2 || y == (n/2)+1{\n fmt.Println(\"NO\")\n }else\n {fmt.Println(\"YES\")}\n }\n \n}\n"}, {"source_code": "// 112B-Andre,Dikai,Eric\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n,x,y int\n\tfmt.Scan(&n,&x,&y)\n\tif n==2{\n\t\tfmt.Println(\"NO\")\n\t}else\n\t{if x == n/2 || x == n/2+1 && y == n/2 || y == n/2+1{\n\t\tfmt.Println(\"NO\")\n\t}else\n\t{fmt.Println(\"YES\")}\n\t}\n\t\n}\n"}], "src_uid": "dc891d57bcdad3108dcb4ccf9c798789"} {"nl": {"description": "This morning, Roman woke up and opened the browser with $$$n$$$ opened tabs numbered from $$$1$$$ to $$$n$$$. There are two kinds of tabs: those with the information required for the test and those with social network sites. Roman decided that there are too many tabs open so he wants to close some of them.He decided to accomplish this by closing every $$$k$$$-th ($$$2 \\leq k \\leq n - 1$$$) tab. Only then he will decide whether he wants to study for the test or to chat on the social networks. Formally, Roman will choose one tab (let its number be $$$b$$$) and then close all tabs with numbers $$$c = b + i \\cdot k$$$ that satisfy the following condition: $$$1 \\leq c \\leq n$$$ and $$$i$$$ is an integer (it may be positive, negative or zero).For example, if $$$k = 3$$$, $$$n = 14$$$ and Roman chooses $$$b = 8$$$, then he will close tabs with numbers $$$2$$$, $$$5$$$, $$$8$$$, $$$11$$$ and $$$14$$$.After closing the tabs Roman will calculate the amount of remaining tabs with the information for the test (let's denote it $$$e$$$) and the amount of remaining social network tabs ($$$s$$$). Help Roman to calculate the maximal absolute value of the difference of those values $$$|e - s|$$$ so that it would be easy to decide what to do next.", "input_spec": "The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \\leq k < n \\leq 100$$$) — the amount of tabs opened currently and the distance between the tabs closed. The second line consists of $$$n$$$ integers, each of them equal either to $$$1$$$ or to $$$-1$$$. The $$$i$$$-th integer denotes the type of the $$$i$$$-th tab: if it is equal to $$$1$$$, this tab contains information for the test, and if it is equal to $$$-1$$$, it's a social network tab.", "output_spec": "Output a single integer — the maximum absolute difference between the amounts of remaining tabs of different types $$$|e - s|$$$.", "sample_inputs": ["4 2\n1 1 -1 1", "14 3\n-1 1 -1 -1 1 -1 -1 1 -1 -1 1 -1 -1 1"], "sample_outputs": ["2", "9"], "notes": "NoteIn the first example we can choose $$$b = 1$$$ or $$$b = 3$$$. We will delete then one tab of each type and the remaining tabs are then all contain test information. Thus, $$$e = 2$$$ and $$$s = 0$$$ and $$$|e - s| = 2$$$.In the second example, on the contrary, we can leave opened only tabs that have social networks opened in them."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc main() {\n\tvar n, k int\n\tfmt.Scan(&n, &k)\n\ttabs := make([]int, n)\n\tsum := 0\n\tfor i := range tabs {\n\t\tfmt.Scan(&tabs[i])\n\t\tsum += tabs[i]\n\t}\n\tans := 0\n\tfor b := 0; b < k; b++ {\n\t\tcur := 0\n\t\tfor i := b; i < n; i += k {\n\t\t\tcur += tabs[i]\n\t\t}\n\t\tif x := abs(sum - cur); ans < x {\n\t\t\tans = x\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\ntype CaseInput struct {\n\tK int64\n\tTabs []int64\n}\n\nfunc readCaseInput(scanner *bufio.Scanner) CaseInput {\n\tsize := readInt64(scanner)\n\tk := readInt64(scanner)\n\ttabs := make([]int64, size)\n\tfor i := range tabs {\n\t\ttabs[i] = readInt64(scanner)\n\t}\n\treturn CaseInput{k, tabs}\n}\n\ntype CaseOutput struct {\n\tMaxDiff int64\n}\n\nfunc writeCaseOutput(writer *bufio.Writer, out CaseOutput) {\n\twritef(writer, \"%d\\n\", abs64(out.MaxDiff))\n}\n\nfunc solveCase(in CaseInput) CaseOutput {\n\tdiffs := make([]int64, in.K)\n\tdiffsTotal := int64(0)\n\tfor i, t := range in.Tabs {\n\t\tdiffs[int64(i) % in.K] += t\n\t\tdiffsTotal += t\n\t}\n\n\tmaxDiff := abs64(diffsTotal - diffs[0])\n\tfor b := int64(1); b < in.K; b++ {\n\t\tmaxDiff = max64(abs64(diffsTotal - diffs[b]), maxDiff)\n\t}\n\treturn CaseOutput{maxDiff}\n}\n\nfunc solveSequential(scanner *bufio.Scanner, writer *bufio.Writer) {\n\twriteCaseOutput(writer, solveCase(readCaseInput(scanner)))\n}\n\nfunc main() {\n\tvar scanner *bufio.Scanner\n\tif len(os.Args) > 1 {\n\t\treader, err := os.Open(os.Args[1])\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tdefer reader.Close()\n\t\tscanner = bufio.NewScanner(reader)\n\t} else {\n\t\tscanner = bufio.NewScanner(os.Stdin)\n\t}\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Buffer(make([]byte, 0, 1024*1024), 1024*1024)\n\n\tvar writer = bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tsolveSequential(scanner, writer)\n}\n\nfunc readInt64(sc *bufio.Scanner) int64 {\n\tif !sc.Scan() {\n\t\tpanic(\"failed to scan next token\")\n\t}\n\n\tres, err := strconv.ParseInt(sc.Text(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn res\n}\n\nfunc writef(writer *bufio.Writer, formatStr string, values ...interface{}) {\n\tout := fmt.Sprintf(formatStr, values...)\n\t_, err := writer.WriteString(out)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc max64(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc abs64(a int64) int64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc solve(mat []int, t1, t2, n, b, k int) int {\n\tfor b < n {\n\t\tif mat[b] == 1 {\n\t\t\tt1--\n\t\t} else {\n\t\t\tt2--\n\t\t}\n\t\tb += k\n\t}\n\tans := t1 - t2\n\tif ans < 0 {\n\t\tans = 0 - ans\n\t}\n\treturn ans\n}\nfunc main() {\n\tbuf := bufio.NewReader(os.Stdin)\n\tvar n, k int\n\tfmt.Fscanf(buf, \"%d %d\\n\", &n, &k)\n\tmat := make([]int, n+1)\n\tvar t1 int = 0\n\tvar t2 int = 0\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(buf, \"%d\", &mat[i])\n\t\tif mat[i] == 1 {\n\t\t\tt1++\n\t\t} else {\n\t\t\tt2++\n\t\t}\n\t}\n\tmax := -1\n\tfor b := 0; b < k; b++ {\n\t\ttmp := solve(mat, t1, t2, n, b, k)\n\t\tif max == -1 || max < tmp {\n\t\t\tmax = tmp\n\t\t}\n\t}\n\tfmt.Printf(\"%d\\n\", max)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nconst maxn = 105\n\nvar a [maxn] int\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 main() {\n\tvar k, n int\n\tfmt.Scan(&n, &k)\n\tcnta, cntb := 0, 0\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a[i])\n\t\tif a[i] == 1 {\n\t\t\tcnta++\n\t\t} else {\n\t\t\tcntb++\n\t\t}\n\t}\n\tbest := 0\n\tfor i := 0; i < k; i++ {\n\t\ttcnta, tcntb := cnta, cntb\n\t\tfor j := i; j < n; j += k {\n\t\t\tif a[j] == 1 {\n\t\t\t\ttcnta--\n\t\t\t} else {\n\t\t\t\ttcntb--\n\t\t\t}\n\t\t}\n\t\tbest = max(best, int(math.Abs(float64(tcnta-tcntb))))\n\t}\n\tfmt.Println(best)\n}\n"}, {"source_code": "// Codeforces 1101 B Accordion train done 3 attempts\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"strings\"\n\t\"strconv\"\n\t\"os\"\n)\nvar in *bufio.Reader\n\nfunc readFive() (int,int,int,int,int) {\n\tvar a [5]int\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"first read failure\", err)\n\t\tpanic(err)\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n\tfor i:=0; i0 {\n\t\t\tge++\n\t\t} else {\n\t\t\tgs++\n\t\t}\n\t}\n\tea := make([]int,k)\n\tsa := make([]int,k)\n\tfor b:=0; b0 {\n\t\t\t\tea[b]++\n\t\t\t} else {\n\t\t\t\tsa[b]++\n\t\t\t}\n\t\t}\n\t}\n\tmaxdif = -1\n\tfor b:=0; b maxdif {\n\t\t\tmaxdif = d\n\t\t}\n\t}\n}\n\nfunc printRes() {\n\tfmt.Println(maxdif)\n}\n\nfunc main() {\n\treadData()\n\tsolve()\n\tprintRes()\n}\n\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\ntype in struct {\n\tScanner *bufio.Scanner\n}\n\nfunc (in *in) s() string {\n\tin.Scanner.Scan()\n\treturn in.Scanner.Text()\n}\nfunc (in *in) i() int {\n\tret, _ := strconv.ParseInt(in.s(), 10, 32)\n\treturn int(ret)\n}\nfunc (in *in) i64() int64 {\n\tret, _ := strconv.ParseInt(in.s(), 10, 64)\n\treturn ret\n}\nfunc (in *in) f() float64 {\n\tret, _ := strconv.ParseFloat(in.s(), 64)\n\treturn ret\n}\nfunc (in *in) ss(n int) []string {\n\ta := make([]string, n)\n\tfor i := range a {\n\t\ta[i] = in.s()\n\t}\n\treturn a\n}\nfunc (in *in) is(n int) []int {\n\ta := make([]int, n)\n\tfor i := range a {\n\t\ta[i] = in.i()\n\t}\n\treturn a\n}\nfunc (in *in) is64(n int) []int64 {\n\ta := make([]int64, n)\n\tfor i := range a {\n\t\ta[i] = in.i64()\n\t}\n\treturn a\n}\nfunc (in *in) fs(n int) []float64 {\n\ta := make([]float64, n)\n\tfor i := range a {\n\t\ta[i] = in.f()\n\t}\n\treturn a\n}\nfunc (in *in) imat(h int, w int) [][]int64 {\n\ta := make([][]int64, h)\n\tfor y := range a {\n\t\ta[y] = make([]int64, w)\n\t\tfor x := range a[y] {\n\t\t\ta[y][x] = in.i64()\n\t\t}\n\t}\n\treturn a\n}\n\nfunc stdin() in {\n\tscn := bufio.NewScanner(os.Stdin)\n\tscn.Split(bufio.ScanWords)\n\tmax := 1048576\n\tbuf := make([]byte, max)\n\tscn.Buffer(buf, max)\n\treturn in{Scanner: scn}\n}\n\nfunc abs(v int) int {\n\tif v < 0 {\n\t\treturn -v\n\t}\n\treturn v\n}\n\nconst maxn = 2e5 + 7\nconst inf = 0x3f3f3f3f\n\nfunc main() {\n\tin := stdin()\n\tn, k := in.i(), in.i()\n\tre := make([]int, k)\n\tsum := 0\n\tfor i := 0; i < n; i++ {\n\t\tx := in.i()\n\t\tre[i%k] += x\n\t\tsum += x\n\t}\n\tans := 0\n\tfor _, v := range re {\n\t\ttp := abs(sum - v)\n\t\tif tp > ans {\n\t\t\tans = tp\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t//\"strings\"\n\t//\"sort\"\n)\n\nfunc main() {\n\tvar n, k int\n\tfmt.Scan(&n, &k)\n\n\tvar browse []int\n\tvar e, s int\n\n\tfor i := 0; i < n; i++ {\n\t\tvar each int\n\t\tfmt.Scan(&each)\n\n\t\tif each > 0 {\n\t\t\te ++\n\t\t} else {\n\t\t\ts ++\n\t\t}\n\n\t\tbrowse = append(browse, each)\n\t}\n\n\tmax := -1\n\n\tfor i := 0; i < k; i++ {\n\t\tvar e1, s1 int\n\t\tvar j int = i\n\n\t\tfor j < n {\n\t\t\tif browse[j] > 0 {\n\t\t\t\te1 ++\n\t\t\t} else {\n\t\t\t\ts1 ++\n\t\t\t}\n\n\t\t\tj += k\n\t\t}\n\n\t\tresult := ((e - e1) - (s - s1))\n\t\tif result < 0 {\n\t\t\tresult = -result\n\t\t}\n\n\t\tmax = int(math.Max(float64(max), float64(result)))\n\t}\n\n\tfmt.Println(max)\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\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, k, t1, t2 int\n\tscanf(\"%d %d\\n\", &n, &k)\n\tvar arr []int\n\tarr = []int{}\n\n\tfor i := 0; i < n; i++ {\n\t\tscanf(\"%d\", &t1)\n\t\tarr = append(arr, t1)\n\t}\n\n\tans := 0\n\n\tfor i := 0; i < k; i++ {\n\t\tt1, t2 = 0, 0\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif (j-i)%k != 0 {\n\t\t\t\tif arr[j] == 1 {\n\t\t\t\t\tt1++\n\t\t\t\t} else {\n\t\t\t\t\tt2++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif abs(t1-t2) > ans {\n\t\t\tans = abs(t1 - t2)\n\t\t}\n\t}\n\n\tprintf(\"%d\", ans)\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nvar ns [200]int\n\nfunc main() {\n\tvar n, k int\n\tfmt.Scanf(\"%d %d\\n\", &n, &k)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &ns[i])\n\t}\n\tvar allE, allS int\n\tfor idx := 0; idx < n; idx++ {\n\t\tif ns[idx] > 0 {\n\t\t\tallE++\n\t\t} else {\n\t\t\tallS++\n\t\t}\n\t}\n\tmaxDist := float64(-1)\n\tfor b := 0; b < n; b++ {\n\t\tcurrE := float64(allE)\n\t\tcurrS := float64(allS)\n\t\tfor i := -100; i < 100; i++ {\n\t\t\tc := b + i*k\n\t\t\tif c >= 0 && c < n {\n\t\t\t\tif ns[c] > 0 {\n\t\t\t\t\tcurrE--\n\t\t\t\t} else {\n\t\t\t\t\tcurrS--\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tmaxDist = math.Max(maxDist, math.Abs(currE-currS))\n\t}\n\tfmt.Printf(\"%0.f\\n\", maxDist)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n, k int\n\tvar types []int\n\n\tfmt.Scan(&n, &k)\n\tfor i := 0; i < n; i++ {\n\t\tvar t int\n\t\tfmt.Scan(&t)\n\t\ttypes = append(types, t)\n\t}\n\n\tmaxDiff := 0\n\tfor i := 0; i < k; i++ {\n\t\tcountTest := 0\n\t\tcountSocialNetwork := 0\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif (j-i)%k != 0 {\n\t\t\t\tif types[j] == 1 {\n\t\t\t\t\tcountTest++\n\t\t\t\t} else {\n\t\t\t\t\tcountSocialNetwork++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdiff := int(math.Abs(float64(countSocialNetwork - countTest)))\n\t\tif maxDiff < diff {\n\t\t\tmaxDiff = diff\n\t\t}\n\t}\n\tfmt.Println(maxDiff)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner = bufio.NewScanner(os.Stdin)\n\nfunc init() {\n\tscanner.Split(bufio.ScanWords)\n}\n\nfunc scanString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc scanBytes() []byte {\n\tscanner.Scan()\n\treturn scanner.Bytes()\n}\n\nfunc scanInt64() int64 {\n\tscanner.Scan()\n\tv, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\treturn v\n}\n\nfunc scanInt() int {\n\tscanner.Scan()\n\tv, _ := strconv.Atoi(scanner.Text())\n\treturn v\n}\n\nfunc scanInts(n int) []int {\n\tl := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tscanner.Scan()\n\t\tl[i], _ = strconv.Atoi(scanner.Text())\n\t}\n\n\treturn l\n}\n\nfunc scanInts64(n int64) []int64 {\n\tl := make([]int64, n)\n\tfor i := int64(0); i < n; i++ {\n\t\tscanner.Scan()\n\t\tl[i], _ = strconv.ParseInt(scanner.Text(), 10, 64)\n\t}\n\n\treturn l\n}\n\nfunc scanBool() bool {\n\tscanner.Scan()\n\tv, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\treturn v == 1\n}\n\nfunc scanBools(n int64) []bool {\n\tl := make([]bool, n)\n\tfor i := int64(0); i < n; i++ {\n\t\tscanner.Scan()\n\t\tv, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\t\tl[i] = v == 1\n\t}\n\n\treturn l\n}\n\nfunc scanUint64() uint64 {\n\tscanner.Scan()\n\tv, _ := strconv.ParseUint(scanner.Text(), 10, 64)\n\treturn v\n}\n\ntype ByAge []uint64\n\nfunc (a ByAge) Len() int { return len(a) }\nfunc (a ByAge) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a ByAge) Less(i, j int) bool { return a[i] < a[j] }\n\nfunc main() {\n\tn, k := scanInt(), scanInt()\n\n\ta := make([]int, n+1)\n\tfor i := 0; i < n; i++ {\n\t\tscanner.Scan()\n\t\ta[i+1], _ = strconv.Atoi(scanner.Text())\n\t}\n\n\t// fmt.Println(a)\n\n\tbest := 0\n\tfor b := 1; b <= n; b++ {\n\t\ttmp := make([]int, len(a))\n\t\tcopy(tmp, a)\n\n\t\t// fmt.Println(\"b = \", b)\n\t\tfor i := -100; i < 100; i++ {\n\t\t\tc := b + i*k\n\t\t\tif c < 1 || c > n {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// fmt.Println(\"remove = \", c)\n\t\t\ttmp[c] = 0\n\t\t}\n\n\t\t// fmt.Println(tmp)\n\n\t\te, s := 0, 0 // e - экзамен (1), s - социалки (-1)\n\t\tfor i := 1; i <= n; i++ {\n\t\t\tif tmp[i] == 1 {\n\t\t\t\te++\n\t\t\t}\n\n\t\t\tif tmp[i] == -1 {\n\t\t\t\ts++\n\t\t\t}\n\t\t}\n\t\t// fmt.Println(\"e=\", e, \"s=\", s, \"abs(e-s)=\", abs(e-s))\n\t\tbest = max(best, abs(e-s))\n\t}\n\n\tfmt.Println(best)\n}\n\nfunc skipZero(a []uint64) []uint64 {\n\tfor len(a) > 0 && a[0] == 0 {\n\t\ta = a[1:]\n\t}\n\n\treturn a\n}\n\nfunc abs(a int) int {\n\tif a >= 0 {\n\t\treturn a\n\t}\n\n\treturn -a\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nvar ns [200]int\n\nfunc main() {\n\tvar n, k int\n\tfmt.Scanf(\"%d %d\", &n, &k)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &ns[i])\n\t}\n\tvar allE, allS int\n\tfor idx := 0; idx < n; idx++ {\n\t\tif ns[idx] > 0 {\n\t\t\tallE++\n\t\t} else {\n\t\t\tallS++\n\t\t}\n\t}\n\tmaxDist := float64(-1)\n\tfor b := 0; b < n; b++ {\n\t\tcurrE := float64(allE)\n\t\tcurrS := float64(allS)\n\t\tfor i := -100; i < 100; i++ {\n\t\t\tc := b + i*k\n\t\t\tif c >= 0 && c < n {\n\t\t\t\tif ns[c] > 0 {\n\t\t\t\t\tcurrE--\n\t\t\t\t} else {\n\t\t\t\t\tcurrS--\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tmaxDist = math.Max(maxDist, math.Abs(currE-currS))\n\t}\n\tfmt.Printf(\"%0.f\\n\", maxDist)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n, k int\n\tvar types []int\n\n\tfmt.Scan(&n, &k)\n\tfor i := 0; i < n; i++ {\n\t\tvar t int\n\t\tfmt.Scan(&t)\n\t\ttypes = append(types, t)\n\t}\n\n\tmaxDiff := 0\n\tfor i := 0; i < k; i++ {\n\t\tcountTest := 0\n\t\tcountSocialNetwork := 0\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif (j-i)%k != 0 {\n\t\t\t\tif types[j] == 1 {\n\t\t\t\t\tcountTest++\n\t\t\t\t} else {\n\t\t\t\t\tcountSocialNetwork++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdiff := int(math.Abs(float64(countSocialNetwork - countTest)))\n\t\tfmt.Println(i)\n\t\tfmt.Println(diff)\n\t\tif maxDiff < diff {\n\t\t\tmaxDiff = diff\n\t\t}\n\t}\n\tfmt.Println(maxDiff)\n}\n"}], "src_uid": "6119258322e06fa6146e592c63313df3"} {"nl": {"description": "Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully submitted it at the first attempt. Misha solved the problem that costs a points and Vasya solved the problem that costs b points. Besides, Misha submitted the problem c minutes after the contest started and Vasya submitted the problem d minutes after the contest started. As you know, on Codeforces the cost of a problem reduces as a round continues. That is, if you submit a problem that costs p points t minutes after the contest started, you get points. Misha and Vasya are having an argument trying to find out who got more points. Help them to find out the truth.", "input_spec": "The first line contains four integers a, b, c, d (250 ≤ a, b ≤ 3500, 0 ≤ c, d ≤ 180). It is guaranteed that numbers a and b are divisible by 250 (just like on any real Codeforces round).", "output_spec": "Output on a single line: \"Misha\" (without the quotes), if Misha got more points than Vasya. \"Vasya\" (without the quotes), if Vasya got more points than Misha. \"Tie\" (without the quotes), if both of them got the same number of points.", "sample_inputs": ["500 1000 20 30", "1000 1000 1 1", "1500 1000 176 177"], "sample_outputs": ["Vasya", "Tie", "Misha"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc max(x int, y int) int {\n\tif x > y {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc score(p int, t int) int {\n\treturn max(3 * p / 10, p - p * t / 250)\n}\n\nfunc main() {\n\tvar a, b, c, d int\n fmt.Scanf(\"%d %d %d %d\", &a, &b, &c, &d)\n\n\tscore1 := score(a, c)\n\tscore2 := score(b, d)\n\tswitch {\n\tcase score1 > score2:\n\t\tfmt.Printf(\"Misha\\n\")\n\tcase score1 < score2:\n\t\tfmt.Printf(\"Vasya\\n\")\n\tdefault:\n\t\tfmt.Printf(\"Tie\\n\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner = bufio.NewScanner(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\ta, b, c, d := nextInt(), nextInt(), nextInt(), nextInt()\n\tmPoint, vPoint := max(a * 3 / 10, a - a * c / 250), max(b * 3 / 10, b - b * d / 250)\n\n\tif mPoint == vPoint {\n\t\tprintln(\"Tie\")\n\t} else if mPoint > vPoint {\n\t\tprintln(\"Misha\")\n\t} else {\n\t\tprintln(\"Vasya\")\n\t}\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 next() string {\n\tif !scanner.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc score(p, t int) int {\n\treturn max(3*p/10, p-p/250*t)\n}\n\nfunc main() {\n\tvar a, b, c, d int\n\tfmt.Scan(&a, &b, &c, &d)\n\tm := score(a, c)\n\tv := score(b, d)\n\tif m > v {\n\t\tfmt.Println(\"Misha\")\n\t} else if m < v {\n\t\tfmt.Println(\"Vasya\")\n\t} else {\n\t\tfmt.Println(\"Tie\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n)\n\nfunc scanInt(scanner *bufio.Scanner) int {\n scanner.Scan()\n x, _ := strconv.Atoi(scanner.Text())\n return x\n}\n\nfunc score(p, t int) int {\n x, y := 3*p, 10*p - p/25*t\n if x > y {\n return x\n } else {\n return y\n }\n}\n\nfunc main() {\n scanner := bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n a := scanInt(scanner)\n b := scanInt(scanner)\n c := scanInt(scanner)\n d := scanInt(scanner)\n misha, vasya := score(a, c), score(b, d)\n if misha > vasya {\n writer.WriteString(\"Misha\\n\")\n } else if misha < vasya {\n writer.WriteString(\"Vasya\\n\")\n } else {\n writer.WriteString(\"Tie\\n\")\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strings\"\n\t\"strconv\"\n)\n\nfunc reader(a []string) func() int {\n\tvar ptr int = -1\n\treturn func() int {\n\t\tptr += 1\n\t\tret, _ := strconv.Atoi(a[ptr])\n\t\treturn ret\n\t}\n}\n\nfunc getPoint(p, t int) int {\n\ta, b := 3 * p / 10, p - p * t / 250\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\ts, _ := in.ReadString('\\n')\n\tstr := strings.Fields(s)\n\tnextInt := reader(str)\n\ta, b, c, d := nextInt(), nextInt(), nextInt(), nextInt()\n\n\tp1, p2 := getPoint(a, c), getPoint(b, d)\n\tif p1 > p2 {\n\t\tfmt.Println(\"Misha\")\n\t}else if p1 < p2 {\n\t\tfmt.Println(\"Vasya\")\n\t}else {\n\t\tfmt.Println(\"Tie\")\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar a, b, c, d float64\n\tfmt.Scanf(\"%f %f %f %f\", &a, &b, &c, &d)\n\tmishaPoints := math.Max(3*a/10, a-c*a/250)\n\tvasyaPoints := math.Max(3*b/10, b-d*b/250)\n\n\tif mishaPoints > vasyaPoints {\n\t\tfmt.Print(\"Misha\")\n\t} else if vasyaPoints > mishaPoints {\n\t\tfmt.Print(\"Vasya\")\n\t} else {\n\t\tfmt.Print(\"Tie\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc main() {\n\tvar a, b, c, d int\n\n\tfmt.Scan(&a, &b, &c, &d)\n\n\tm := max(3*a/10, a-a/250*c)\n\tv := max(3*b/10, b-b/250*d)\n\n\tvar res string\n\n\tif m > v {\n\t\tres = \"Misha\"\n\t} else if m < v {\n\t\tres = \"Vasya\"\n\t} else {\n\t\tres = \"Tie\"\n\t}\n\n\tfmt.Println(res)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar a, b, c, d int\n\tfmt.Scan(&a, &b, &c, &d)\n\n\tmisha := max(3*a/10, a-a/250*c)\n\tvasya := max(3*b/10, b-b/250*d)\n\n\tif misha > vasya {\n\t\tfmt.Println(\"Misha\")\n\t} else if misha < vasya {\n\t\tfmt.Println(\"Vasya\")\n\t} else {\n\t\tfmt.Println(\"Tie\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\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 score(p int, t int) int {\n\treturn max(3*p/10, p-p/250*t)\n}\n\nfunc main() {\n\tfor {\n\t\tvar a,b,c,d int\n\t\tnum, _ := fmt.Scanf(\"%d%d%d%d\", &a, &b, &c, &d)\n\t\tif num != 4 {\n\t\t\tbreak\n\t\t}\n\t\ts1 := score(a,c)\n\t\ts2 := score(b,d)\n\t\tif s1 > s2 {\n\t\t\tfmt.Println(\"Misha\")\n\t\t} else if s1 < s2 {\n\t\t\tfmt.Println(\"Vasya\")\n\t\t} else {\n\t\t\tfmt.Println(\"Tie\")\n\t\t}\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc main() {\n\tvar a, b, c, d int\n\n\tfmt.Scan(&a, &b, &c, &d)\n\n\tm := max(3*a/10, a/250*c)\n\tv := max(3*b/10, b/250*d)\n\n\tvar res string\n\n\tif m > v {\n\t\tres = \"Misha\"\n\t} else if m < v {\n\t\tres = \"Vasya\"\n\t} else {\n\t\tres = \"Tie\"\n\t}\n\n\tfmt.Println(res)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar a, b, c, d int\n\tfmt.Scan(&a, &b, &c, &d)\n\n\tmisha := max(3*a/10, a/250*c)\n\tvasya := max(3*b/10, b/250*d)\n\n\tif misha > vasya {\n\t\tfmt.Println(\"Misha\")\n\t} else if misha < vasya {\n\t\tfmt.Println(\"Vasya\")\n\t} else {\n\t\tfmt.Println(\"Tie\")\n\t}\n}\n"}], "src_uid": "95b19d7569d6b70bd97d46a8541060d0"} {"nl": {"description": "There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th child wants to get at least ai candies.Jzzhu asks children to line up. Initially, the i-th child stands at the i-th place of the line. Then Jzzhu start distribution of the candies. He follows the algorithm: Give m candies to the first child of the line. If this child still haven't got enough candies, then the child goes to the end of the line, else the child go home. Repeat the first two steps while the line is not empty. Consider all the children in the order they go home. Jzzhu wants to know, which child will be the last in this order?", "input_spec": "The first line contains two integers n, m (1 ≤ n ≤ 100; 1 ≤ m ≤ 100). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 100).", "output_spec": "Output a single integer, representing the number of the last child.", "sample_inputs": ["5 2\n1 3 1 4 2", "6 4\n1 1 2 2 3 3"], "sample_outputs": ["4", "6"], "notes": "NoteLet's consider the first sample. Firstly child 1 gets 2 candies and go home. Then child 2 gets 2 candies and go to the end of the line. Currently the line looks like [3, 4, 5, 2] (indices of the children in order of the line). Then child 3 gets 2 candies and go home, and then child 4 gets 2 candies and goes to the end of the line. Currently the line looks like [5, 2, 4]. Then child 5 gets 2 candies and goes home. Then child 2 gets two candies and goes home, and finally child 4 gets 2 candies and goes home.Child 4 is the last one who goes home."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner = bufio.NewScanner(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tn, m := nextInt(), nextInt()\n\n\tmaxline, line, pos, a := 0, 0, 0, 0\n\n\tfor i := 0; i < n; i++ {\n\t\ta = nextInt()\n\n\t\tline = a / m\n\n\t\tif a % m > 0 {\n\t\t\tline++\n\t\t}\n\n\t\tif line >= maxline {\n\t\t\tmaxline = line\n\t\t\tpos = i\n\t\t}\n\t}\n\n\tprintln(pos + 1)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt() int {\n\tn, err := strconv.Atoi(next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, err := strconv.ParseFloat(next(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc println(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}\n\nfunc print(a ...interface{}) {\n\tfmt.Fprint(writer, a...)\n}\n\nfunc printf(format string, a ...interface{}) {\n\tfmt.Fprintf(writer, format, a...)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\tn, m := 0, 0\n\tif scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tfmt.Sscanf(line, \"%d %d\", &n, &m)\n\t}\n\n\tif scanner.Scan() {\n\t\tline := scanner.Text()\n\t\ttokens := strings.Fields(line)\n\t\tchildRequirement := make([]int, n)\n\n\t\tfor i := 0; i < n; i++ {\n\t\t\tchildRequirement[i], _ = strconv.Atoi(tokens[i])\n\t\t}\n\n\t\tchildGet := make([]int, n)\n\n\t\tlastChild := 0\n\t\tfor {\n\t\t\tfinishes := true\n\t\t\tfor i := 0; i < n; i++ {\n\t\t\t\tif childGet[i] < childRequirement[i] {\n\t\t\t\t\tchildGet[i] = childGet[i] + m\n\t\t\t\t\tlastChild = i\n\t\t\t\t}\n\n\t\t\t\tif childGet[i] < childRequirement[i] {\n\t\t\t\t\tfinishes = false\n\t\t\t\t}\n\t\t\t}\n\t\t\tif finishes {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfmt.Println(lastChild + 1)\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar a, n, m, num int\n\n\tfmt.Scan(&n)\n\tfmt.Scan(&m)\n\n\tmax := 0\n\tfor i := 1; i <= n; i++ {\n\t\tfmt.Scan(&a)\n\n\t\tif ((a + m - 1) / m) >= max {\n\t\t\tmax = (a + m - 1) / m\n\t\t\tnum = i\n\t\t}\n\n\t}\n\tfmt.Println(num)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, m, a int\n\tfmt.Scan(&n)\n\tfmt.Scan(&m)\n\tvar z, t int\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a)\n\t\tx := (a + m - 1) / m\n\t\tif x >= t {\n\t\t\tt = x\n\t\t\tz = i\n\t\t}\n\t}\n\tfmt.Println(z + 1)\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n )\n\ntype child struct {\n index int\n left int\n}\n\nfunc main() {\n var n, m int\n fmt.Scan(&n, &m)\n\n an := make([]child, 2*n, 2*n)\n for i := 0; i < n; i++ {\n var a int\n fmt.Scan(&a)\n an[i].left = a\n an[i].index = i+1\n }\n\n left := n\n ans := n\n for left > 0 {\n tmp := left\n left = 0\n for i := 0; i < tmp; i++ {\n if an[i].left > m {\n an[n+left].index, an[n+left].left = an[i].index, an[i].left-m\n left++\n }\n }\n if left == 0 {\n ans = an[tmp-1].index\n break\n }\n for i := n; i < left+n; i++ {\n an[i-n].index, an[i-n].left = an[i].index, an[i].left\n }\n }\n\n fmt.Println(ans)\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\tn, m := 0, 0\n\tif scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tfmt.Sscanf(line, \"%d %d\", &n, &m)\n\t}\n\n\tif scanner.Scan() {\n\t\tline := scanner.Text()\n\t\ttokens := strings.Fields(line)\n\t\tchildRequirement := make([]int, n)\n\n\t\tfor i := 0; i < n; i++ {\n\t\t\tchildRequirement[i], _ = strconv.Atoi(tokens[i])\n\t\t}\n\n\t\tchildGet := make([]int, n)\n\n\t\tlastChild := 0\n\t\tfor {\n\t\t\tfinishes := true\n\t\t\tfor i := 0; i < n; i++ {\n\t\t\t\tif childGet[i] < childRequirement[i] {\n\t\t\t\t\tchildGet[i] = childGet[i] + m\n\t\t\t\t\tlastChild = i\n\t\t\t\t}\n\n\t\t\t\tif childGet[i] < childRequirement[i] {\n\t\t\t\t\tfinishes = false\n\t\t\t\t}\n\t\t\t}\n\t\t\tif finishes {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfmt.Println(childGet)\n\t\tfmt.Println(lastChild + 1)\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b, year int\n\n\tfmt.Scan(&a)\n\tfmt.Scan(&b)\n\n\tfor i := 1; a <= b; i++ {\n\t\ta = a * 3\n\t\tb = b * 2\n\t\tyear = i\n\t}\n\tfmt.Println(year)\n}\n"}], "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c"} {"nl": {"description": "ZS the Coder loves to read the dictionary. He thinks that a word is nice if there exists a substring (contiguous segment of letters) of it of length 26 where each letter of English alphabet appears exactly once. In particular, if the string has length strictly less than 26, no such substring exists and thus it is not nice.Now, ZS the Coder tells you a word, where some of its letters are missing as he forgot them. He wants to determine if it is possible to fill in the missing letters so that the resulting word is nice. If it is possible, he needs you to find an example of such a word as well. Can you help him?", "input_spec": "The first and only line of the input contains a single string s (1 ≤ |s| ≤ 50 000), the word that ZS the Coder remembers. Each character of the string is the uppercase letter of English alphabet ('A'-'Z') or is a question mark ('?'), where the question marks denotes the letters that ZS the Coder can't remember.", "output_spec": "If there is no way to replace all the question marks with uppercase letters such that the resulting word is nice, then print  - 1 in the only line. Otherwise, print a string which denotes a possible nice word that ZS the Coder learned. This string should match the string from the input, except for the question marks replaced with uppercase English letters. If there are multiple solutions, you may print any of them.", "sample_inputs": ["ABC??FGHIJK???OPQR?TUVWXY?", "WELCOMETOCODEFORCESROUNDTHREEHUNDREDANDSEVENTYTWO", "??????????????????????????", "AABCDEFGHIJKLMNOPQRSTUVW??M"], "sample_outputs": ["ABCDEFGHIJKLMNOPQRZTUVWXYS", "-1", "MNBVCXZLKJHGFDSAQPWOEIRUYT", "-1"], "notes": "NoteIn the first sample case, ABCDEFGHIJKLMNOPQRZTUVWXYS is a valid answer beacuse it contains a substring of length 26 (the whole string in this case) which contains all the letters of the English alphabet exactly once. Note that there are many possible solutions, such as ABCDEFGHIJKLMNOPQRSTUVWXYZ or ABCEDFGHIJKLMNOPQRZTUVWXYS.In the second sample case, there are no missing letters. In addition, the given string does not have a substring of length 26 that contains all the letters of the alphabet, so the answer is  - 1.In the third sample case, any string of length 26 that contains all letters of the English alphabet fits as an answer."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\nimport \"bufio\"\nimport \"os\"\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\nfunc good(a []byte, n int, pos int) bool {\n\tvar has [26]bool\n\tfor c := 0; c < 26; c++ {\n\t\thas[c] = false\n\t}\n\n\tfor i := 0; i < 26; i++ {\n\t\tx := a[pos+i]\n\t\tif x != '?' {\n\t\t\tc := x - 'A'\n\t\t\tif has[c] {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\thas[c] = true\n\t\t}\n\t}\n\n\tc := 0\n\tfor i := 0; i < 26; i++ {\n\t\tif a[pos+i] == '?' {\n\t\t\tfor has[c] {\n\t\t\t\tc++\n\t\t\t}\n\t\t\thas[c] = true\n\t\t\ta[pos+i] = byte(c + 'A')\n\t\t}\n\t}\n\n\tfor i := 0; i < n; i++ {\n\t\tif a[i] == '?' {\n\t\t\ta[i] = 'A'\n\t\t}\n\t}\n\n\treturn true\n}\n\nfunc main() {\n\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\n\tvar s string\n\tfmt.Fscanf(bufin, \"%s\\n\", &s)\n\n\ta := []byte(s)\n\tn := len(a)\n\n\tfound := false\n\tfor i := 0; i+26 <= n; i++ {\n\t\tif good(a, n, i) {\n\t\t\tfound = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif found {\n\t\tfmt.Fprintf(bufout, \"%s\\n\", a)\n\t} else {\n\t\tfmt.Fprintf(bufout, \"%d\\n\", -1)\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nvar all = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\nfunc main() {\n\tin := ScanLine()\n\tneeda := make(map[byte]int)\n\tnoyou := make(map[byte]int)\n\tfor idx := range all {\n\t\tnoyou[all[idx]]++\n\t}\n\tleftlen := len(in)\n\tbase := 0\n\tf := 0\n\tb := 0\n\tif leftlen < 26 {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\n\t// once\n\tfor {\n\t\tif in[b] == '?' {\n\t\t\tbase++\n\t\t} else {\n\t\t\tdelete(noyou, in[b])\n\t\t\tneeda[in[b]]++\n\t\t\tif needa[in[b]] == 1 {\n\t\t\t\tbase++\n\t\t\t}\n\t\t}\n\t\tif b == 25 {\n\t\t\tbreak\n\t\t}\n\t\tb++\n\t}\n\tfor {\n\t\tif base == 26 {\n\t\t\tfor idx := 0; idx != f; idx++ {\n\t\t\t\tif in[idx] == '?' {\n\t\t\t\t\tfmt.Print(\"A\")\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Print(string(in[idx]))\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor idx := f; idx != b+1; idx++ {\n\t\t\t\tif in[idx] == '?' {\n\t\t\t\t\tfor k := range noyou {\n\t\t\t\t\t\tfmt.Print(string(k))\n\t\t\t\t\t\tdelete(noyou, k)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Print(string(in[idx]))\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor idx := b + 1; idx != len(in); idx++ {\n\t\t\t\tif in[idx] == '?' {\n\t\t\t\t\tfmt.Print(\"A\")\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Print(string(in[idx]))\n\t\t\t\t}\n\t\t\t}\n\t\t\tfmt.Println()\n\t\t\tbreak\n\t\t}\n\t\tf++\n\t\tb++\n\t\tleftlen--\n\t\tif leftlen < 26 {\n\t\t\tfmt.Println(-1)\n\t\t\tbreak\n\t\t}\n\t\tif in[f-1] == '?' {\n\t\t\tbase--\n\t\t} else {\n\t\t\tneeda[in[f-1]]--\n\t\t\tif needa[in[f-1]] == 0 {\n\t\t\t\tnoyou[in[f-1]] = 1\n\t\t\t\tbase--\n\t\t\t}\n\t\t}\n\n\t\tif in[b] == '?' {\n\t\t\tbase++\n\t\t} else {\n\t\t\tif needa[in[b]] == 0 {\n\t\t\t\tbase++\n\t\t\t\tdelete(noyou, in[b])\n\t\t\t}\n\t\t\tneeda[in[b]]++\n\t\t}\n\t}\n}\n\nfunc ScanLine() string {\n\tvar c byte\n\tvar err error\n\tvar b []byte\n\tfor err == nil {\n\t\t_, err = fmt.Scanf(\"%c\", &c)\n\n\t\tif c != '\\n' && c != byte(13) {\n\t\t\tb = append(b, c)\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn string(b)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nvar all = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\nfunc main() {\n\tin := ScanLine()\n\tvar needa [26]int\n\tleftlen := len(in)\n\tbase := 0\n\tf := 0\n\tb := 0\n\tif leftlen < 26 {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\n\t// once\n\tfor {\n\t\tif in[b] == '?' {\n\t\t\tbase++\n\t\t} else {\n\t\t\tneeda[in[b]-'A']++\n\t\t\tif needa[in[b]-'A'] == 1 {\n\t\t\t\tbase++\n\t\t\t}\n\t\t}\n\t\tif b == 25 {\n\t\t\tbreak\n\t\t}\n\t\tb++\n\t}\n\tfor {\n\t\tvar empty int\n\t\tif base == 26 {\n\t\t\tfor idx := 0; idx != f; idx++ {\n\t\t\t\tif in[idx] == '?' {\n\t\t\t\t\tfmt.Print(\"A\")\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Print(string(in[idx]))\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor idx := f; idx != b+1; idx++ {\n\t\t\t\tif in[idx] == '?' {\n\t\t\t\t\tfor k := empty; ; k++ {\n\t\t\t\t\t\tif needa[k] == 0 {\n\t\t\t\t\t\t\tfmt.Print(string(all[k]))\n\t\t\t\t\t\t\tempty = k + 1\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} else {\n\t\t\t\t\tfmt.Print(string(in[idx]))\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor idx := b + 1; idx != len(in); idx++ {\n\t\t\t\tif in[idx] == '?' {\n\t\t\t\t\tfmt.Print(\"A\")\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Print(string(in[idx]))\n\t\t\t\t}\n\t\t\t}\n\t\t\tfmt.Println()\n\t\t\tbreak\n\t\t}\n\t\tf++\n\t\tb++\n\t\tleftlen--\n\t\tif leftlen < 26 {\n\t\t\tfmt.Println(-1)\n\t\t\tbreak\n\t\t}\n\t\tif in[f-1] == '?' {\n\t\t\tbase--\n\t\t} else {\n\t\t\tneeda[in[f-1]-'A']--\n\t\t\tif needa[in[f-1]-'A'] == 0 {\n\t\t\t\tbase--\n\t\t\t}\n\t\t}\n\n\t\tif in[b] == '?' {\n\t\t\tbase++\n\t\t} else {\n\t\t\tif needa[in[b]-'A'] == 0 {\n\t\t\t\tbase++\n\t\t\t}\n\t\t\tneeda[in[b]-'A']++\n\t\t}\n\t}\n}\n\nfunc ScanLine() string {\n\tvar c byte\n\tvar err error\n\tvar b []byte\n\tfor err == nil {\n\t\t_, err = fmt.Scanf(\"%c\", &c)\n\n\t\tif c != '\\n' && c != byte(13) {\n\t\t\tb = append(b, c)\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn string(b)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar all = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\nfunc main() {\n\tbufin := bufio.NewReader(os.Stdin)\n\tbufout := bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\n\tvar strin string\n\tfmt.Fscanf(bufin, \"%s\\n\", &strin)\n\tin := []byte(strin)\n\tvar needa [26]int\n\tleftlen := len(in)\n\tbase := 0\n\tf := 0\n\tb := 0\n\tif leftlen < 26 {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\n\t// once\n\tfor {\n\t\tif in[b] == '?' {\n\t\t\tbase++\n\t\t} else {\n\t\t\tneeda[in[b]-'A']++\n\t\t\tif needa[in[b]-'A'] == 1 {\n\t\t\t\tbase++\n\t\t\t}\n\t\t}\n\t\tif b == 25 {\n\t\t\tbreak\n\t\t}\n\t\tb++\n\t}\n\tvar ok bool\n\tfor {\n\t\tvar empty int\n\t\tif base == 26 {\n\t\t\tok = true\n\t\t\t// for idx := 0; idx != f; idx++ {\n\t\t\t// \tif in[idx] == '?' {\n\t\t\t// \t\tfmt.Print(\"A\")\n\t\t\t// \t} else {\n\t\t\t// \t\tfmt.Print(string(in[idx]))\n\t\t\t// \t}\n\t\t\t// }\n\t\t\tfor idx := f; idx != b+1; idx++ {\n\t\t\t\tif in[idx] == '?' {\n\t\t\t\t\tfor k := empty; ; k++ {\n\t\t\t\t\t\tif needa[k] == 0 {\n\t\t\t\t\t\t\tin[idx] = all[k]\n\t\t\t\t\t\t\tempty = k + 1\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor idx := b + 1; idx != len(in); idx++ {\n\t\t\t\tif in[idx] == '?' {\n\t\t\t\t\tin[idx] = 'A'\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tf++\n\t\tb++\n\t\tleftlen--\n\t\tif leftlen < 26 {\n\t\t\tfmt.Println(-1)\n\t\t\tbreak\n\t\t}\n\t\tif in[f-1] == '?' {\n\t\t\tin[f-1] = 'A'\n\t\t\tbase--\n\t\t} else {\n\t\t\tneeda[in[f-1]-'A']--\n\t\t\tif needa[in[f-1]-'A'] == 0 {\n\t\t\t\tbase--\n\t\t\t}\n\t\t}\n\n\t\tif in[b] == '?' {\n\t\t\tbase++\n\t\t} else {\n\t\t\tif needa[in[b]-'A'] == 0 {\n\t\t\t\tbase++\n\t\t\t}\n\t\t\tneeda[in[b]-'A']++\n\t\t}\n\t}\n\tif ok {\n\t\tfmt.Fprintf(bufout, \"%s\\n\", in)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"regexp\"\n)\n\nfunc main() {\n\tmarks := make([]bool, 26)\n\tletter := 0\n\tquestion := 0\n\tok := false\n\n\treader := bufio.NewReader(os.Stdin)\n\tre := regexp.MustCompile(`\\r?\\n`)\n\tif _in, err := reader.ReadString('\\n'); err != nil {\n\t\tif err != io.EOF {\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tin := re.ReplaceAllString(_in, \"\")\n\n\t\tif len(in) < 26 {\n\t\t\tfmt.Println(-1)\n\t\t\treturn\n\t\t}\n\n\t\ts := 0\n\t\tp := 0\n\t\tfor s <= len(in)-25 {\n\t\t\tif in[s] == '?' {\n\t\t\t\tletter = 0\n\t\t\t\tquestion = 1\n\t\t\t} else {\n\t\t\t\tmarks[in[s]-'A'] = true\n\t\t\t\tletter = 1\n\t\t\t\tquestion = 0\n\t\t\t}\n\t\t\tp = s + 1\n\t\t\tfor p < len(in) && p-s < 26 {\n\t\t\t\tif in[p] == '?' {\n\t\t\t\t\tquestion++\n\t\t\t\t} else if marks[in[p]-'A'] {\n\t\t\t\t\tfor i := 0; i < 26; i++ {\n\t\t\t\t\t\tmarks[i] = false\n\t\t\t\t\t}\n\t\t\t\t\tj := p - 1\n\t\t\t\t\tfor j > s && j < len(in) && (in[j] == '?' || in[j] != in[p]) {\n\t\t\t\t\t\tj--\n\t\t\t\t\t}\n\t\t\t\t\ts = j + 1\n\t\t\t\t\tbreak\n\t\t\t\t} else {\n\t\t\t\t\tmarks[in[p]-'A'] = true\n\t\t\t\t\tletter++\n\t\t\t\t}\n\t\t\t\tp++\n\t\t\t}\n\t\t\tif letter+question == 26 {\n\t\t\t\tok = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif ok {\n\t\t\ti := 0\n\t\t\tfor ; i < s; i++ {\n\t\t\t\tif in[i] == '?' {\n\t\t\t\t\tfmt.Printf(\"A\")\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Printf(\"%c\", in[i])\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor ; i < p; i++ {\n\t\t\t\tif in[i] == '?' {\n\t\t\t\t\tfor j := 0; j < 26; j++ {\n\t\t\t\t\t\tif !marks[j] {\n\t\t\t\t\t\t\tmarks[j] = true\n\t\t\t\t\t\t\tfmt.Printf(\"%c\", 'A'+j)\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} else {\n\t\t\t\t\tfmt.Printf(\"%c\", in[i])\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor ; i < len(in); i++ {\n\t\t\t\tif in[i] == '?' {\n\t\t\t\t\tfmt.Printf(\"A\")\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Printf(\"%c\", in[i])\n\t\t\t\t}\n\t\t\t}\n\t\t\tfmt.Printf(\"\\n\")\n\t\t} else {\n\t\t\tfmt.Println(-1)\n\t\t}\n\t}\n}\n"}, {"source_code": "// Codeforces 716 B Complete the Word\n// int - 32 bit type !!!!\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\t\"strconv\"\n)\nvar in *bufio.Reader\n\nfunc readFive() (int,int,int,int,int) {\n var a [5]int\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"first read failure\", err)\n\t\tpanic(err)\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n for i:=0; i=26 {\n fmt.Println(\"Error, ich,i = \",ich,i)\n }\n nch[ich] ++\n //fmt.Println(\"++ich,nch=\",nch,ich)\n if nch[ich] == 2 {\n n2++\n } \n }\n if i>=26 {\n if s[i-26] != '?' {\n ich = int(s[i-26] - 'A')\n nch[ich]--\n //fmt.Println(\"--ich,nch=\",nch,ich)\n if nch[ich]==1 {\n n2--\n }\n }\n }\n //fmt.Println(\"i,n2=\",i,n2)\n if i>=25 && n2==0 {\n // we found solution, copy to aout\n aout = make([]byte, n)\n for ii:=0; ii 0 {\n iich ++\n }\n aout[ii] = byte(iich+'A')\n iich++\n } \n }\n for ii:=i+1; ii= amount {\n\t\tab[people] -= amount\n\t\tpeople = (people + 1) % 2\n\t\tamount++\n\t}\n\n\tif people == 0 {\n\t\tfmt.Println(\"Vladik\")\n\t} else {\n\t\tfmt.Println(\"Valera\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n var vladik, valera int\n fmt.Scanf(\"%d %d\", &vladik, &valera)\n\n var i int = 1\n for vladik >= 0 && valera >= 0 {\n if i % 2 == 1 {\n vladik -= i\n } else {\n valera -= i\n }\n i += 1\n }\n\n if vladik < 0 {\n fmt.Println(\"Vladik\")\n } else {\n fmt.Println(\"Valera\")\n }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\n/*\n Hmm..., if we analyze the worst case problem: 10^9 if we use naive method\n using sum of quadratic formula, we could get n = ~31622, since vladik & valera\n taking turns to give each other, then the n for naive method would be\n 2 * ~31622 = ~63244, which is still within feasible number of looping I guess,\n so let's try using naive approach :D!! --> but really this is unreliable approach\n*/\n\nfunc main(){\n var vladik, valera int\n fmt.Scanf(\"%d %d\", &vladik, &valera)\n\n var i int = 1\n for vladik >= 0 && valera >= 0 {\n if i % 2 == 1 {\n vladik -= i\n } else {\n valera -= i\n }\n i += 1\n }\n\n // fmt.Printf(\"i: %d\\n\", i)\n // fmt.Printf(\"Vladik: %d, Valera: %d\\n\", vladik, valera)\n\n if vladik < 0 {\n fmt.Println(\"Vladik\")\n } else {\n fmt.Println(\"Valera\")\n }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scanf(\"%d %d\", &a, &b)\n\ti := 1\n\tfor {\n\t\tif a-i < 0 {\n\t\t\tfmt.Println(\"Vladik\")\n\t\t\treturn\n\t\t}\n\t\ta = a - i\n\t\tif b-i-1 < 0 {\n\t\t\tfmt.Println(\"Valera\")\n\t\t\treturn\n\t\t}\n\t\tb = b - i - 1\n\t\ti += 2\n\t}\n}\n"}, {"source_code": "// Codeforces helper functions\n// 20 Jan 18\n// samadhi\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n\t\"unicode\"\n)\n\nconst debug = true\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tin := gsli(reader)\n\ta := in[0]\n\tb := in[1]\n\n\ti := 1\n\n\tfor true {\n\t\ta -= i\n\t\tif a < 0 {\n\t\t\tfmt.Println(\"Vladik\")\n\t\t\treturn\n\t\t}\n\t\ti++\n\t\tb -= i\n\t\tif b < 0 {\n\t\t\tfmt.Println(\"Valera\")\n\t\t\treturn\n\t\t}\n\t\ti++\n\t}\n\n}\n\n// Input helpers\n\n// If you don't pass in a reference to the reader, and just instantiate a new\n// one every time, it will work locally, with IO typed at human-speed, but not\n// on Codeforces.\n\n// Get Space-separated Line as Strings\n//\n// Example input:\n// 1 test 382.0\n// Example output:\n// [\"1\", \"test\", \"382.0\"]\n\nfunc gsls(reader *bufio.Reader) (arr []string) {\n\t// Get a full line\n\tinput, _ := reader.ReadString('\\n')\n\n\t//Strip newline and return chars, if any\n\tinput = strings.TrimSuffix(input, \"\\n\")\n\tinput = strings.TrimSuffix(input, \"\\r\")\n\n\t// Split at the spaces into an array\n\tarr = strings.Split(input, \" \")\n\n\treturn\n}\n\n// Get Space-separated Line as Integers\n// Any non-valid integers will be 0\n//\n// Example input:\n// test 1 12.3 -117\n// Example output:\n// [0, 1, 0, -117]\n\nfunc gsli(reader *bufio.Reader) (arr []int) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.Atoi(e)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Get Space-separated Line as 64-bit Floats\n// Any non-valid floats will be 0\n//\n// Example input:\n// test 128.328 12 -11.0\n// Example output:\n// [0, 128.328, 12, -11]\n\nfunc gslf(reader *bufio.Reader) (arr []float64) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.ParseFloat(e, 64)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// String helpers\n\n// Is Lowercase\n// Given some string[i], return whether it is lower case or not.\n\nfunc isl(b byte) bool {\n\tvar r rune\n\tr = rune(b)\n\treturn unicode.IsLower(r)\n}\n\n// Math helpers\n\n// Positve Modulo\n// Returns x mod y, but always positive\n\nfunc posMod(x, y int) int {\n\treturn (x%y + y) % y\n}\n\n// Max Int\n// Returns the max of two ints\n\nfunc maxInt(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\n// Distance formule\n// Calculates the distance to the origin\n\nfunc dist(x, y float64) float64 {\n\treturn math.Sqrt(math.Pow(x, 2) + math.Pow(y, 2))\n}\n\n// Output helpers\n\nfunc yes() {\n\tfmt.Println(\"Yes\")\n}\n\nfunc no() {\n\tfmt.Println(\"No\")\n}\n\n// Debug helpers\n\n// From https://groups.google.com/forum/#!topic/golang-nuts/Qlxs3V77nss\n\nfunc dbg(s string, a ...interface{}) {\n\tif debug {\n\t\tfmt.Printf(s, a...)\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\tp := 1\n\tfor {\n\t\tif n < p {\n\t\t\tfmt.Printf(\"Vladik\\n\")\n\t\t\tbreak\n\t\t}\n\t\tn -= p\n\t\tp++\n\t\tif m < p {\n\t\t\tfmt.Printf(\"Valera\\n\")\n\t\t\tbreak\n\t\t}\n\t\tm -= p\n\t\tp++\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc getLooser(vladik int64, valera int64) {\n\tmaxStep := 1000000000\n\tfor index := 0; index < maxStep; index++ {\n\t\tif vladik < 0 {\n\t\t\tfmt.Println(\"Vladik\")\n\t\t\tbreak\n\t\t} else if valera < 0 {\n\t\t\tfmt.Println(\"Valera\")\n\t\t\tbreak\n\t\t}\n\t\tif index != 0 {\n\t\t\tif index%2 == 0 {\n\t\t\t\tvalera = valera - int64(index)\n\t\t\t} else {\n\t\t\t\ttemp := vladik - int64(index)\n\t\t\t\tvladik = temp\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _ := reader.ReadString('\\n')\n\tnumbers := strings.Fields(text)\n\t// fmt.Println(numbers)\n\tvladik, _ := strconv.ParseInt(numbers[0], 10, 64)\n\tvalera, _ := strconv.ParseInt(numbers[1], 10, 64)\n\tgetLooser(vladik, valera)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar vladik, valera int\n\tvar k int\n\tk = 1\n\tfmt.Scanf(\"%d %d\\n\", &vladik, &valera)\n\tfor {\n\t\tif vladik-k < 0 {\n\t\t\tfmt.Println(\"Vladik\")\n\t\t\tbreak\n\t\t} else {\n\t\t\tvladik = vladik - k\n\t\t}\n\t\tk++\n\t\tif valera-k < 0 {\n\t\t\tfmt.Println(\"Valera\")\n\t\t\tbreak\n\t\t} else {\n\t\t\tvalera = valera - k\n\t\t}\n\t\tk++\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc solve(s string) string {\n\treturn s\n}\n\nfunc output(i int, ans string) {\n\tfmt.Printf(\"Case #%d: %s\\n\", i, ans)\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Buffer(make([]byte, 1000000), 1000000)\n\n\tscanner.Scan()\n\tx := strings.Split(scanner.Text(), \" \")\n\ta, _ := strconv.Atoi(x[0])\n\tb, _ := strconv.Atoi(x[1])\n\tda := 1\n\tfor a >= 0 && b >= 0 {\n\t\ta -= da\n\t\tb -= (da + 1)\n\t\tda += 2\n\t}\n\n\tif a < 0 {\n\t\tfmt.Println(\"Vladik\")\n\t} else {\n\t\tfmt.Println(\"Valera\")\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\n//func calc(t int) string {\n//\tvar a int\n//\tvar b int\n//\tfmt.Scanln(&a,&b)\n//\tvar prev int = a\n//\tvar sum1 int = a\n//\tvar sum2 int = b\n//\tvar flag bool = false\n//\n//\tif a!=b{\n//\t\treturn \"rated\"\n//\t}\n//\tfor i:=1;i= 0; i-- {\n\t\tif _, exist := m[a[i]]; !exist {\n\t\t\tr = append([]int64{a[i]}, r...)\n\t\t}\n\n\t\tm[a[i]] = true\n\t}\n\n\treturn int64(len(r)), r\n}\n\nfunc main() {\n\tvar n int64\n\n\tfmt.Scanln(&n)\n\n\tvar a, _ = ScanN(n)\n\n\tvar r1, r2 = Process(a)\n\n\tfmt.Println(r1)\n\n\tPrintSlice(r2)\n}\n\nfunc ScanN(n int64) ([]int64, error) {\n\tin := make([]int64, n)\n\tfor i := range in {\n\t\t_, err := fmt.Scan(&in[i])\n\t\tif err != nil {\n\t\t\treturn in[:i], err\n\t\t}\n\t}\n\treturn in, nil\n}\n\nfunc PrintSlice(a []int64) {\n\tfor i := 0; i < len(a); i++ {\n\t\tif i == len(a)-1 {\n\t\t\tfmt.Print(a[i])\n\t\t} else {\n\t\t\tfmt.Print(a[i], \" \")\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Buffer(make([]byte, 2048*2048), 2048*2048)\n\tscanner.Split(bufio.ScanWords)\n\n\tscanner.Scan()\n\tn, _ := strconv.Atoi(scanner.Text())\n\n\ta := make([]int, n)\n\n\tfor i := 0; i < n; i++ {\n\t\tscanner.Scan()\n\t\ta[i], _ = strconv.Atoi(scanner.Text())\n\t}\n\n\ttotal := 0\n\tset := make([]int, 1001)\n\n\tfor i := 0; i < 1001; i++ {\n\t\tset[i] = -1\n\t}\n\n\tfor i, el := range a {\n\t\tif set[el] == -1 {\n\t\t\ttotal++\n\t\t} else {\n\t\t\ta[set[el]] = -1\n\t\t}\n\t\tset[el] = i\n\t}\n\tfmt.Println(total)\n\n\tfor _, el := range a {\n\t\tif el == -1 {\n\t\t\tcontinue\n\t\t}\n\t\tif set[el] == -1 {\n\t\t\tcontinue\n\t\t}\n\t\tfmt.Printf(\"%d \", el)\n\t}\n\tfmt.Printf(\"\\n\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a[i])\n\t}\n\tans := make([]int, 0)\n\tmp := make(map[int]bool)\n\tfor i := n-1; i >= 0; i-- {\n\t\tif _, ok := mp[a[i]]; ok {\n\t\t\tcontinue\n\t\t}\n\t\tmp[a[i]] = true\n\t\tans = append(ans, a[i])\n\t}\n\tfmt.Printf(\"%d\\n%d\", len(ans), ans[len(ans)-1])\n\tfor i := len(ans)-2; i >= 0; i-- {\n\t\tfmt.Printf(\" %d\", ans[i])\n\t}\n\tfmt.Println()\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nconst (\n\tmaxn = 55\n)\n\nvar (\n\tn int\n\ta [maxn]int\n\tm map[int]bool\n\tans []int\n)\n\nfunc main() {\n\tfmt.Scan(&n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a[i])\n\t}\n\n\tm = make(map[int]bool)\n\tfor i := n - 1; i >= 0; i-- {\n\t\t_, inMap := m[a[i]]\n\t\tif !inMap {\n\t\t\tans = append(ans, a[i])\n\t\t\tm[a[i]] = true\n\t\t}\n\t}\n\n\tfmt.Println(len(ans))\n\tfor i := len(ans) - 1; i >= 0; i-- {\n\t\tfmt.Printf(\"%v \", ans[i])\n\t}\n}\n"}, {"source_code": "package main\n\nimport . \"fmt\"\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tvar n int\n\tScan(&n)\n\ta := make([]int, n)\n\tfor i := range a {\n\t\tScan(&a[i])\n\t}\n\tu := []int{}\n\tvis := [1001]bool{}\n\tfor i := n - 1; i >= 0; i-- {\n\t\tif !vis[a[i]] {\n\t\t\tvis[a[i]] = true\n\t\t\tu = append(u, a[i])\n\t\t}\n\t}\n\tPrintln(len(u))\n\tfor i := len(u) - 1; i >= 0; i-- {\n\t\tPrint(u[i], \" \")\n\t}\n}\n"}, {"source_code": "package main \nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nvar set, no []int\nfunc check(f int) int{\n\t var r int\n\t for i, a := range no {\n\t \t if a == f { \n\t \t \t r = i\n\t \t }\n\t }\n\n\t return r\n}\nfunc main() {\n\t var n int \n\t var used = make(map[int]bool)\n\t fmt.Scanf(\"%d\", &n)\n\n\t for i:=0; i= 0; i-- {\n\t\ttmp, _ := strconv.Atoi(arrStartStrings[i])\n\t\tif m[tmp] == false {\n\t\t\tstart = append(start, tmp)\n\t\t\tm[tmp] = true\n\t\t}\n\t}\n\tfor i, j := 0, len(start)-1; i < j; i, j = i+1, j-1 {\n\t\tstart[i], start[j] = start[j], start[i]\n\t}\n\tfmt.Println(len(start))\n\tfor i := 0; i < len(start); i++ {\n\t\tif i == 0 {\n\t\t\tfmt.Printf(\"%d\", start[i])\n\t\t} else {\n\t\t\tfmt.Printf(\" %d\", start[i])\n\t\t}\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Init() {\n}\n\nfunc Solve(io *FastIO) {\n\tN := io.NextInt()\n\tA := io.NextIntArray(N)\n\t\n\tcnt := 0\n\tseen := make(map[int]bool)\n\tgood := make([]bool, N)\n\tfor i := N - 1; i >= 0; i-- {\n\t\tif !seen[A[i]] {\n\t\t\tcnt++\n\t\t\tseen[A[i]] = true\n\t\t\tgood[i] = true\n\t\t}\n\t}\n\t\n\tio.Println(cnt)\n\tfor i, v := range A {\n\t\tif good[i] {\n\t\t\tio.Printf(\"%d \", v)\n\t\t}\n\t}\n\tio.Println()\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tInit()\n\tSolve(&io)\n\tio.FlushOutput()\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tm := make(map[int]bool)\n\tk := make([]int,n)\n\tvar l []int\n\tfor i:=0;i=0;i-- {\n\t\t_,ok := m[k[i]]\n\t\tif !ok {\n\t\t\tl = append(l,k[i])\n\t\t\tm[k[i]] = true\n\t\t}\n\t}\n\tfor i :=0;i= 0; i-- {\n\t\tv, _ := m[a[i]]\n\t\tif v {\n\t\t\ta[i] = -1\n\t\t} else {\n\t\t\tm[a[i]] = true\n\t\t\tcnt++\n\t\t}\n\t}\n\n\tfmt.Println(cnt)\n\tfor i := 0; i < n; i++ {\n\t\tif a[i] != -1 {\n\t\t\tfmt.Print(a[i], \" \")\n\t\t\t//fmt.Printf(\"%d \", a[i])\n\t\t}\n\t}\n\n\tfmt.Println()\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc Process(a []int64) (int64, []int64) {\n\tvar m = map[int64]bool{}\n\tvar r = make([]int64, 0)\n\n\tfor i := len(a) - 1; i >= 0; i-- {\n\t\tif _, exist := m[a[i]]; !exist {\n\t\t\tr = append([]int64{a[i]}, r...)\n\t\t}\n\n\t\tm[a[i]] = true\n\t}\n\n\treturn int64(len(r)), r\n}\n\nfunc main() {\n\tvar n int64\n\n\tfmt.Scanln(&n)\n\n\tvar a, _ = ScanN(n)\n\n\tvar r1, r2 = Process(a)\n\n\tfmt.Println(r1)\n\tPrintSlice(r2)\n}\n\nfunc ScanN(n int64) ([]int64, error) {\n\tin := make([]int64, n)\n\tfor i := range in {\n\t\t_, err := fmt.Scan(&in[i])\n\t\tif err != nil {\n\t\t\treturn in[:i], err\n\t\t}\n\t}\n\treturn in, nil\n}\n\nfunc PrintSlice(a []int64) {\n\tfor i := 0; i < len(a); i++ {\n\t\tif i == len(a)-1 {\n\t\t\tfmt.Print(a[i])\n\t\t} else {\n\t\t\tfmt.Print(a, \" \")\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Init() {\n}\n\nfunc Solve(io *FastIO) {\n\tN := io.NextInt()\n\tA := io.NextIntArray(N)\n\t\n\tseen := make(map[int]bool)\n\tgood := make([]bool, N)\n\tfor i := N - 1; i >= 0; i-- {\n\t\tif !seen[A[i]] {\n\t\t\tseen[A[i]] = true\n\t\t\tgood[i] = true\n\t\t}\n\t}\n\t\n\tfor i, v := range A {\n\t\tif good[i] {\n\t\t\tio.Printf(\"%d \", v)\n\t\t}\n\t}\n\tio.Println()\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tInit()\n\tSolve(&io)\n\tio.FlushOutput()\n}"}], "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a"} {"nl": {"description": "This is an easier version of the problem. In this version, $$$n \\le 500$$$.Vasya is an experienced developer of programming competitions' problems. As all great minds at some time, Vasya faced a creative crisis. To improve the situation, Petya gifted him a string consisting of opening and closing brackets only. Petya believes, that the beauty of the bracket string is a number of its cyclical shifts, which form a correct bracket sequence.To digress from his problems, Vasya decided to select two positions of the string (not necessarily distinct) and swap characters located at this positions with each other. Vasya will apply this operation exactly once. He is curious what is the maximum possible beauty he can achieve this way. Please help him.We remind that bracket sequence $$$s$$$ is called correct if: $$$s$$$ is empty; $$$s$$$ is equal to \"($$$t$$$)\", where $$$t$$$ is correct bracket sequence; $$$s$$$ is equal to $$$t_1 t_2$$$, i.e. concatenation of $$$t_1$$$ and $$$t_2$$$, where $$$t_1$$$ and $$$t_2$$$ are correct bracket sequences. For example, \"(()())\", \"()\" are correct, while \")(\" and \"())\" are not.The cyclical shift of the string $$$s$$$ of length $$$n$$$ by $$$k$$$ ($$$0 \\leq k < n$$$) is a string formed by a concatenation of the last $$$k$$$ symbols of the string $$$s$$$ with the first $$$n - k$$$ symbols of string $$$s$$$. For example, the cyclical shift of string \"(())()\" by $$$2$$$ equals \"()(())\".Cyclical shifts $$$i$$$ and $$$j$$$ are considered different, if $$$i \\ne j$$$.", "input_spec": "The first line contains an integer $$$n$$$ ($$$1 \\le n \\le 500$$$), the length of the string. The second line contains a string, consisting of exactly $$$n$$$ characters, where each of the characters is either \"(\" or \")\".", "output_spec": "The first line should contain a single integer — the largest beauty of the string, which can be achieved by swapping some two characters. The second line should contain integers $$$l$$$ and $$$r$$$ ($$$1 \\leq l, r \\leq n$$$) — the indices of two characters, which should be swapped in order to maximize the string's beauty. In case there are several possible swaps, print any of them.", "sample_inputs": ["10\n()()())(()", "12\n)(()(()())()", "6\n)))(()"], "sample_outputs": ["5\n8 7", "4\n5 10", "0\n1 1"], "notes": "NoteIn the first example, we can swap $$$7$$$-th and $$$8$$$-th character, obtaining a string \"()()()()()\". The cyclical shifts by $$$0, 2, 4, 6, 8$$$ of this string form a correct bracket sequence.In the second example, after swapping $$$5$$$-th and $$$10$$$-th character, we obtain a string \")(())()()(()\". The cyclical shifts by $$$11, 7, 5, 3$$$ of this string form a correct bracket sequence.In the third example, swap of any two brackets results in $$$0$$$ cyclical shifts being correct bracket sequences. "}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc init() {\n\tReadString = newReadString(os.Stdin)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc newReadString(ior io.Reader) func() string {\n\tr := bufio.NewScanner(ior)\n\t// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\t// Split sets the split function for the Scanner. The default split function is ScanLines.\n\t// Split panics if it is called after scanning has started.\n\tr.Split(bufio.ScanWords)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n/*********** DP sub-functions ***********/\n\n// ChMin accepts a pointer of integer and a target value.\n// If target value is SMALLER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMin(updatedValue *int, target int) bool {\n\tif *updatedValue > target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// ChMax accepts a pointer of integer and a target value.\n// If target value is LARGER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMax(updatedValue *int, target int) bool {\n\tif *updatedValue < target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// NthBit returns nth bit value of an argument.\n// n starts from 0.\nfunc NthBit(num, nth int) int {\n\treturn num >> uint(nth) & 1\n}\n\n// OnBit returns the integer that has nth ON bit.\n// If an argument has nth ON bit, OnBit returns the argument.\nfunc OnBit(num, nth int) int {\n\treturn num | (1 << uint(nth))\n}\n\n// OffBit returns the integer that has nth OFF bit.\n// If an argument has nth OFF bit, OffBit returns the argument.\nfunc OffBit(num, nth int) int {\n\treturn num & ^(1 << uint(nth))\n}\n\n// PopCount returns the number of ON bit of an argument.\nfunc PopCount(num int) int {\n\tres := 0\n\n\tfor i := 0; i < 70; i++ {\n\t\tif ((num >> uint(i)) & 1) == 1 {\n\t\t\tres++\n\t\t}\n\t}\n\n\treturn res\n}\n\n/*********** Arithmetic ***********/\n\n// Max returns the max integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Max(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m < integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// Min returns the min integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Min(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// Sum returns multiple integers sum.\nfunc Sum(integers ...int) int {\n\ts := 0\n\n\tfor _, i := range integers {\n\t\ts += i\n\t}\n\n\treturn s\n}\n\n// PowInt is integer version of math.Pow\n// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).\nfunc PowInt(a, e int) int {\n\tif a < 0 || e < 0 {\n\t\tpanic(errors.New(\"[argument error]: PowInt does not accept negative integers\"))\n\t}\n\n\tif e == 0 {\n\t\treturn 1\n\t}\n\n\tif e%2 == 0 {\n\t\thalfE := e / 2\n\t\thalf := PowInt(a, halfE)\n\t\treturn half * half\n\t}\n\n\treturn a * PowInt(a, e-1)\n}\n\n// AbsInt is integer version of math.Abs\nfunc AbsInt(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// Gcd returns the Greatest Common Divisor of two natural numbers.\n// Gcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Gcd uses the Euclidean Algorithm.\nfunc Gcd(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\tif a < b {\n\t\ta, b = b, a\n\t}\n\n\t// Euclidean Algorithm\n\tfor b > 0 {\n\t\tdiv := a % b\n\t\ta, b = b, div\n\t}\n\n\treturn a\n}\n\n// Lcm returns the Least Common Multiple of two natural numbers.\n// Lcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Lcd uses the Euclidean Algorithm indirectly.\nfunc Lcm(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\n\t// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2\n\t// a' and b' are relatively prime numbers\n\t// gcd consists of prime numbers, that are included in a and b\n\tgcd := Gcd(a, b)\n\n\t// not (a * b / gcd), because of reducing a probability of overflow\n\treturn (a / gcd) * b\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\t// str := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst MOD = 1000000000 + 7\nconst ALPHABET_NUM = 26\nconst INF_INT64 = math.MaxInt64\nconst INF_BIT60 = 1 << 60\n\nvar n int\nvar S []rune\n\nfunc main() {\n\tn = ReadInt()\n\tS = ReadRuneSlice()\n\n\t// S[4], S[9] = S[9], S[4]\n\t// sub()\n\n\tans := 0\n\tl, r := 0, 0\n\tfor i := 0; i < n; i++ {\n\t\tfor j := i; j < n; j++ {\n\t\t\t// 入れ替える\n\t\t\tS[i], S[j] = S[j], S[i]\n\n\t\t\ttmp := sub()\n\t\t\tif ans < tmp {\n\t\t\t\tans = tmp\n\t\t\t\tl, r = i, j\n\t\t\t}\n\n\t\t\t// もとに戻す\n\t\t\tS[i], S[j] = S[j], S[i]\n\t\t}\n\t}\n\tfmt.Println(ans)\n\tfmt.Println(l+1, r+1)\n}\n\ntype Char struct {\n\tidx int\n\tc rune\n}\n\nfunc sub() int {\n\t// スタックで字句解析する\n\ts := make([]Char, 0, 1000)\n\tmemo := []int{}\n\tfor i := 0; i < n; i++ {\n\t\tr := S[i]\n\t\tchar := Char{idx: i, c: r}\n\n\t\tif len(s) == 0 || r == '(' {\n\t\t\ts = append(s, char)\n\t\t\tcontinue\n\t\t}\n\n\t\tif r == ')' && s[len(s)-1].c == '(' {\n\t\t\tpopped := s[len(s)-1]\n\t\t\ts = s[:len(s)-1]\n\t\t\tif len(s) == 0 || s[len(s)-1].c == ')' {\n\t\t\t\tmemo = append(memo, popped.idx)\n\t\t\t}\n\t\t} else {\n\t\t\ts = append(s, char)\n\t\t}\n\t}\n\n\t// スタックに何も残っていないときはmemoの長さ\n\tif len(s) == 0 {\n\t\treturn len(memo)\n\t}\n\n\t// 残ったカッコの数をチェック\n\top, cl := 0, 0\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i].c == '(' {\n\t\t\top++\n\t\t} else {\n\t\t\tcl++\n\t\t}\n\t}\n\t// 数が一致しないとダメ\n\tif op != cl {\n\t\treturn 0\n\t}\n\n\tl, r := 0, 0\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i].c == '(' {\n\t\t\tr = s[i].idx\n\t\t\tbreak\n\t\t}\n\t}\n\tfor i := len(s) - 1; i >= 0; i-- {\n\t\tif s[i].c == ')' {\n\t\t\tl = s[i].idx\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// fmt.Println(memo)\n\t// for i := 0; i < len(s); i++ {\n\t// \tfmt.Printf(\"%d: %c\\n\", s[i].idx, s[i].c)\n\t// }\n\t// fmt.Printf(\"lidx: %d, ridx: %d\\n\", l, r)\n\n\tans := 0\n\tfor i := 0; i < len(memo); i++ {\n\t\tif l < memo[i] && memo[i] <= r {\n\t\t\tans++\n\t\t}\n\t}\n\n\treturn ans + 1\n}\n\n// MODはとったか?\n// 遷移だけじゃなくて最後の最後でちゃんと取れよ?\n\n/*******************************************************************/\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvar n int\n\tvar s string\n\tfmt.Fscanf(reader, \"%d\\n%s\\n\", &n, &s)\n\tsum := make([]int, n+1)\n\tfor i := n - 1; i >= 0; i-- {\n\t\tif s[i] == ')' {\n\t\t\tsum[i] = sum[i+1] + 1\n\t\t} else {\n\t\t\tsum[i] = sum[i+1] - 1\n\t\t}\n\t}\n\n\tif sum[0] != 0 {\n\t\tfmt.Printf(\"0\\n1 1\\n\")\n\t\treturn\n\t}\n\n\tmin := 2 * n\n\ttotal := 0\n\ta := 1\n\tb := 1\n\n\tfor i := 0; i < n; i++ {\n\t\tif sum[i] < min {\n\t\t\tmin = sum[i]\n\t\t\ttotal = 1\n\t\t} else if sum[i] == min {\n\t\t\ttotal++\n\t\t}\n\t}\n\n\t//fmt.Printf(\"%d %d\\n%d %d\\n\", min, total, a, b)\n\n\tfor i := 0; i < n; i++ {\n\t\tsub := 0\n\t\tif s[i] == ')' {\n\t\t\tsub = 2\n\t\t} else {\n\t\t\tsub = -2\n\t\t}\n\n\t\tfor j := i + 1; j < n; j++ {\n\t\t\tif s[i] == s[j] {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tcha := 0\n\t\t\ttmin := 2 * n\n\t\t\tttotal := 0\n\n\t\t\tfor k := 0; k < n; k++ {\n\t\t\t\tif k > i && k <= j {\n\t\t\t\t\tcha = sub\n\t\t\t\t} else {\n\t\t\t\t\tcha = 0\n\t\t\t\t}\n\n\t\t\t\tif sum[k]+cha < tmin {\n\t\t\t\t\ttmin = sum[k] + cha\n\t\t\t\t\tttotal = 1\n\t\t\t\t} else if sum[k]+cha == tmin {\n\t\t\t\t\tttotal++\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ttotal > total {\n\t\t\t\ttotal = ttotal\n\t\t\t\ta = i + 1\n\t\t\t\tb = j + 1\n\t\t\t}\n\n\t\t\t//fmt.Println(ttotal, tmin, i+1, j+1)\n\t\t}\n\t}\n\n\tfmt.Printf(\"%d\\n%d %d\\n\", total, a, b)\n}\n\n// ((()))(()()()()()()()()())\n// +++++++-+-+-+-+-+-++++++++\n// 01232101212121212121212121\n\n// ((())))()()()()()()()()()(\n// +++++++-+-+-+-+-+-+-+-+-+-\n// 01232101010101010101010101\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvar n int\n\tvar s string\n\tfmt.Fscanf(reader, \"%d\\n%s\\n\", &n, &s)\n\tsum := make([]int, n+1)\n\tfor i := n - 1; i >= 0; i-- {\n\t\tif s[i] == ')' {\n\t\t\tsum[i] = sum[i+1] + 1\n\t\t} else {\n\t\t\tsum[i] = sum[i+1] - 1\n\t\t}\n\t}\n\n\tif sum[0] != 0 {\n\t\tfmt.Printf(\"0\\n1 1\\n\")\n\t\treturn\n\t}\n\n\tmin := 2 * n\n\ttotal := 0\n\ta := 1\n\tb := 1\n\n\tfor i := 0; i < n; i++ {\n\t\tif sum[i] < min {\n\t\t\tmin = sum[i]\n\t\t\ttotal = 1\n\t\t} else if sum[i] == min {\n\t\t\ttotal++\n\t\t}\n\t}\n\n\t//fmt.Printf(\"%d %d\\n%d %d\\n\", min, total, a, b)\n\n\tfor i := 0; i < n; i++ {\n\t\tfor j := i + 1; j < n; j++ {\n\t\t\tif s[i] == s[j] {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tsub := 0\n\t\t\tif s[i] == ')' {\n\t\t\t\tsub = 2\n\t\t\t} else {\n\t\t\t\tsub = -2\n\t\t\t}\n\t\t\tcha := 0\n\t\t\ttmin := 2 * n\n\t\t\tttotal := 0\n\n\t\t\tfor k := 0; k < n; k++ {\n\t\t\t\tif k > i && k <= j {\n\t\t\t\t\tcha = sub\n\t\t\t\t} else {\n\t\t\t\t\tcha = 0\n\t\t\t\t}\n\n\t\t\t\tif sum[k]+cha < tmin {\n\t\t\t\t\ttmin = sum[k]\n\t\t\t\t\tttotal = 1\n\t\t\t\t} else if sum[k]+cha == tmin {\n\t\t\t\t\tttotal++\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ttotal > total {\n\t\t\t\ttotal = ttotal\n\t\t\t\ta = i\n\t\t\t\tb = j\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Printf(\"%d\\n%d %d\\n\", total, a+1, b+1)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvar n int\n\tvar s string\n\tfmt.Fscanf(reader, \"%d\\n%s\\n\", &n, &s)\n\tsum := make([]int, n+1)\n\tfor i := n - 1; i >= 0; i-- {\n\t\tif s[i] == ')' {\n\t\t\tsum[i] = sum[i+1] + 1\n\t\t} else {\n\t\t\tsum[i] = sum[i+1] - 1\n\t\t}\n\t}\n\n\tif sum[0] != 0 {\n\t\tfmt.Printf(\"0\\n1 1\\n\")\n\t\treturn\n\t}\n\n\tmin := 2 * n\n\ttotal := 0\n\ta := 1\n\tb := 1\n\n\tfor i := 0; i < n; i++ {\n\t\tif sum[i] < min {\n\t\t\tmin = sum[i]\n\t\t\ttotal = 1\n\t\t} else if sum[i] == min {\n\t\t\ttotal++\n\t\t}\n\t}\n\n\t//fmt.Printf(\"%d %d\\n%d %d\\n\", min, total, a, b)\n\n\tfor i := 0; i < n; i++ {\n\t\tfor j := i + 1; j < n; j++ {\n\t\t\tif s[i] == s[j] {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tsub := 0\n\t\t\tif s[i] == ')' {\n\t\t\t\tsub = 2\n\t\t\t} else {\n\t\t\t\tsub = -2\n\t\t\t}\n\t\t\tcha := 0\n\t\t\ttmin := 2 * n\n\t\t\tttotal := 0\n\n\t\t\tfor k := 0; k < n; k++ {\n\t\t\t\tif k > i && k <= j {\n\t\t\t\t\tcha = sub\n\t\t\t\t} else {\n\t\t\t\t\tcha = 0\n\t\t\t\t}\n\n\t\t\t\tif sum[i]+cha < tmin {\n\t\t\t\t\ttmin = sum[k]\n\t\t\t\t\tttotal = 1\n\t\t\t\t} else if sum[k]+cha == tmin {\n\t\t\t\t\tttotal++\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ttotal > total {\n\t\t\t\ttotal = ttotal\n\t\t\t\ta = i\n\t\t\t\tb = j\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Printf(\"%d\\n%d %d\\n\", total, a+1, b+1)\n}\n"}], "src_uid": "2d10668fcc2d8e90e102b043f5e0578d"} {"nl": {"description": "You're given a string of lower-case Latin letters. Your task is to find the length of its longest substring that can be met in the string at least twice. These occurrences can overlap (see sample test 2).", "input_spec": "The first input line contains the string. It's guaranteed, that the string is non-empty, consists of lower-case Latin letters, and its length doesn't exceed 100.", "output_spec": "Output one number — length of the longest substring that can be met in the string at least twice.", "sample_inputs": ["abcd", "ababa", "zzz"], "sample_outputs": ["0", "3", "2"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n s := getS()\n n := len(s)\n max := 0\n seen := map[string]bool{}\n for i := 0; i < n; i++ {\n for j := i+1; j <= n; j++ {\n if seen[s[i:j]] && j-i > max {\n max = j-i\n }\n seen[s[i:j]] = true\n }\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", max))\n}\n"}], "negative_code": [], "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7"} {"nl": {"description": "Ilya is an experienced player in tic-tac-toe on the 4 × 4 field. He always starts and plays with Xs. He played a lot of games today with his friend Arseny. The friends became tired and didn't finish the last game. It was Ilya's turn in the game when they left it. Determine whether Ilya could have won the game by making single turn or not. The rules of tic-tac-toe on the 4 × 4 field are as follows. Before the first turn all the field cells are empty. The two players take turns placing their signs into empty cells (the first player places Xs, the second player places Os). The player who places Xs goes first, the another one goes second. The winner is the player who first gets three of his signs in a row next to each other (horizontal, vertical or diagonal).", "input_spec": "The tic-tac-toe position is given in four lines. Each of these lines contains four characters. Each character is '.' (empty cell), 'x' (lowercase English letter x), or 'o' (lowercase English letter o). It is guaranteed that the position is reachable playing tic-tac-toe, and it is Ilya's turn now (in particular, it means that the game is not finished). It is possible that all the cells are empty, it means that the friends left without making single turn.", "output_spec": "Print single line: \"YES\" in case Ilya could have won by making single turn, and \"NO\" otherwise.", "sample_inputs": ["xx..\n.oo.\nx...\noox.", "x.ox\nox..\nx.o.\noo.x", "x..x\n..oo\no...\nx.xo", "o.x.\no...\n.x..\nooxx"], "sample_outputs": ["YES", "NO", "YES", "NO"], "notes": "NoteIn the first example Ilya had two winning moves: to the empty cell in the left column and to the leftmost empty cell in the first row.In the second example it wasn't possible to win by making single turn.In the third example Ilya could have won by placing X in the last row between two existing Xs.In the fourth example it wasn't possible to win by making single turn."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc I(i interface{}, delim string) {\n\tfmt.Fscanf(r, \"%v\"+delim, i)\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nvar in [4]string\n\nfunc check() bool {\n\tfor i := 0; i < 4; i++ {\n\t\tfor j := 0; j < 4; j++ {\n\t\t\tif in[i][j] == 'x' {\n\t\t\t\tif strings.Contains(in[i], \"xxx\") ||\n\t\t\t\t\t(i+2 < 4 && ((in[i+1][j] == 'x' && in[i+2][j] == 'x') ||\n\t\t\t\t\t\t(j+2 < 4 && in[i+1][j+1] == 'x' && in[i+2][j+2] == 'x') ||\n\t\t\t\t\t\t(j-2 >= 0 && in[i+1][j-1] == 'x' && in[i+2][j-2] == 'x'))) {\n\t\t\t\t\tO(\"YES\", \"\\n\")\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\nfunc main() {\n\tr = bufio.NewReader(os.Stdin)\n\tw = bufio.NewWriter(os.Stdout)\n\tdefer w.Flush()\n\tfor i := 0; i < 4; i++ {\n\t\tI(&in[i], \"\\n\")\n\t}\n\tif check() {\n\t\treturn\n\t}\n\tfor i := 0; i < 4; i++ {\n\t\tfor j := 0; j < 4; j++ {\n\t\t\tif in[i][j] == '.' {\n\t\t\t\ta := []rune(in[i])\n\t\t\t\ta[j] = 'x'\n\t\t\t\tin[i] = string(a)\n\t\t\t\tif check() {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\ta[j] = '.'\n\t\t\t\tin[i] = string(a)\n\t\t\t}\n\t\t}\n\t}\n\tO(\"NO\", \"\\n\")\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc getField() [4][4]rune {\n\tvar field [4][4]rune\n\tvar c rune\n\tfor i := range field {\n\t\tfor j := range field[i] {\n\t\t\tfor {\n\t\t\t\t_, err := fmt.Scanf(\"%c\", &c)\n\t\t\t\tif err != nil {\n\t\t\t\t\tpanic(err)\n\t\t\t\t}\n\t\t\t\tif c == 'x' || c == 'o' || c == '.' {\n\t\t\t\t\tfield[i][j] = c\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn field\n}\n\nvar patterns [][]rune = [][]rune{\n\t{'.', 'x', 'x'},\n\t{'x', '.', 'x'},\n\t{'x', 'x', '.'},\n}\n\nfunc inPatterns3(x1, x2, x3 rune) bool {\n\tfor i := range patterns {\n\t\tpattern := patterns[i]\n\t\tif x1 == pattern[0] && x2 == pattern[1] && x3 == pattern[2] {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc inPatterns4(x1, x2, x3, x4 rune) bool {\n\treturn inPatterns3(x1, x2, x3) || inPatterns3(x2, x3, x4)\n}\n\nfunc canWin(field [4][4]rune) bool {\n\tfor _, f := range field {\n\t\tif inPatterns4(f[0], f[1], f[2], f[3]) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\tfor i := range field {\n\t\tif inPatterns4(field[0][i], field[1][i], field[2][i], field[3][i]) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\tif inPatterns4(field[0][0], field[1][1], field[2][2], field[3][3]) ||\n\t\tinPatterns4(field[0][3], field[1][2], field[2][1], field[3][0]) {\n\t\treturn true\n\t}\n\tif inPatterns3(field[1][0], field[2][1], field[3][2]) ||\n\t\tinPatterns3(field[0][1], field[1][2], field[2][3]) ||\n\t\tinPatterns3(field[2][0], field[1][1], field[0][2]) ||\n\t\tinPatterns3(field[3][1], field[2][2], field[1][3]) {\n\t\treturn true\n\t}\n\n\treturn false\n}\n\nfunc main() {\n\tif canWin(getField()) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n \"strings\"\n)\n\nfunc max(a, b int) int {\n if a > b {\n return a\n }\n return b\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 // your code here\n rows := make([]string, 4)\n for i := 0; i < 4; i++ {\n fmt.Fscanf(in, \"%s\\n\", &rows[i])\n }\n lines := []string{}\n for r := 0; r < 4; r++ {\n lines = append(lines, rows[r])\n }\n for c := 0; c < 4; c++ {\n line := \"\"\n for r := 0; r < 4; r++ {\n line += rows[r][c:c+1]\n }\n lines = append(lines, line)\n }\n for r := 0; r < 2; r++ {\n for c := 0; c < 2; c++ {\n if r == 1 && c == 1 {\n break\n }\n line := \"\"\n for i := 0; r + i < 4 && c + i < 4; i++ {\n line += string(rows[r+i][c + i])\n }\n lines = append(lines, line)\n line = \"\"\n cc := 3 - c\n for i := 0; r + i < 4 && cc - i >= 0; i++ {\n line += string(rows[r+i][cc-i])\n }\n lines = append(lines, line)\n }\n }\n for _, line := range lines {\n for i := range line {\n if line[i:i+1] == \".\" && strings.Contains(line[0:i]+\"x\"+line[i+1:], \"xxx\") {\n fmt.Println(\"YES\")\n return\n }\n }\n }\n fmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"regexp\"\n)\n\nfunc main() {\n\tconst b_size int = 4\n\n\treader := bufio.NewReader(os.Stdin)\n\tre := regexp.MustCompile(`\\r?\\n`)\n\n\tboard := [b_size]string{}\n\n\tfor i := 0; i < b_size; i++ {\n\t\tif s, err := reader.ReadString('\\n'); err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\ts = re.ReplaceAllString(s, \"\")\n\t\t\tboard[i] = s\n\t\t}\n\t}\n\n\tok := false\n\tcandidate := make([]rune, b_size)\n\tn := 0\n\n\tfor i := 0; i < b_size; i++ {\n\t\t// Horizontally\n\t\tfor j := 0; j < b_size; j++ {\n\t\t\tcandidate[j] = rune(board[i][j])\n\t\t}\n\t\tif is_ok(candidate, b_size) {\n\t\t\tok = true\n\t\t\tbreak\n\t\t}\n\n\t\t// Vertically\n\t\tfor j := 0; j < b_size; j++ {\n\t\t\tcandidate[j] = rune(board[j][i])\n\t\t}\n\t\tif is_ok(candidate, b_size) {\n\t\t\tok = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif ok {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\n\tdia_array := make([][b_size]rune, (b_size*2-1)*2)\n\tfor j := 0; j < b_size; j++ {\n\t\toff0 := j\n\t\toff1 := (b_size*2 - 1) + (b_size - j - 1)\n\t\tfor i := 0; i < b_size; i++ {\n\t\t\tdia_array[i+off0][j] = rune(board[i][j])\n\t\t\tdia_array[i+off1][j] = rune(board[i][j])\n\t\t}\n\t}\n\n\tfor i := 0; i < (b_size*2-1)*2; i++ {\n\t\tn = 0\n\t\tfor j := 0; j < b_size; j++ {\n\t\t\tif dia_array[i][j] != dia_array[0][b_size-1] {\n\t\t\t\tcandidate[n] = dia_array[i][j]\n\t\t\t\tn++\n\t\t\t}\n\t\t}\n\t\tif is_ok(candidate, n) {\n\t\t\tok = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif ok {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nfunc is_ok(candidate []rune, n int) bool {\n\tif n < 3 {\n\t\treturn false\n\t} else {\n\t\tfor e := 3; e <= n; e++ {\n\t\t\txs := 0\n\t\t\tdots := 0\n\t\t\tfor i := e - 3; i < e; i++ {\n\t\t\t\tif candidate[i] == 'x' {\n\t\t\t\t\txs++\n\t\t\t\t} else if candidate[i] == '.' {\n\t\t\t\t\tdots++\n\t\t\t\t} else { // 'o'\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\tif xs == 2 && dots == 1 {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tfield := make([][]int, 4)\n\tfor i := 0; i < 4; i++ {\n\t\tfield[i] = make([]int, 4)\n\t\tfor j, ch := range readString() {\n\t\t\tswitch ch {\n\t\t\tcase 'x':\n\t\t\t\tfield[i][j] = 1\n\t\t\tcase 'o':\n\t\t\t\tfield[i][j] = 2\n\t\t\t}\n\t\t}\n\t}\n\tfor i := 0; i < 4; i++ {\n\t\tfor j := 0; j < 4; j++ {\n\t\t\tif field[i][j] == 0 {\n\t\t\t\tfield[i][j] = 1\n\t\t\t\tif win(field) {\n\t\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tfield[i][j] = 0\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n\nfunc win(field [][]int) bool {\n\tfor j := 0; j < 4; j++ {\n\t\tfor i := 0; i < 2; i++ {\n\t\t\tif field[j][i] == 1 && field[j][i+1] == 1 && field[j][i+2] == 1 {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\tfor j := 0; j < 4; j++ {\n\t\tfor i := 0; i < 2; i++ {\n\t\t\tif field[i][j] == 1 && field[i+1][j] == 1 && field[i+2][j] == 1 {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\tfor i := 0; i < 2; i++ {\n\t\tfor j := 0; j < 2; j++ {\n\t\t\tif field[i][j] == 1 && field[i+1][j+1] == 1 && field[i+2][j+2] == 1 {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\tfor i := 0; i < 2; i++ {\n\t\tfor j := 0; j < 2; j++ {\n\t\t\tif field[i][3-j] == 1 && field[i+1][3-j-1] == 1 && field[i+2][3-j-2] == 1 {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}, {"source_code": "// Codeforces 754 B IlyaTicTacToe,\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\t\"strconv\"\n)\nvar in *bufio.Reader\n\nfunc readFive() (int,int,int,int,int) {\n\tvar a [5]int\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"first read failure\", err)\n\t\tpanic(err)\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n\tfor i:=0; i=4 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor x0:=0; x0<4; x0++ {\n\t\t\t\tx1 := x0+2*dx[dir]\n\t\t\t\tif x1<0 || x1>=4 {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tcntX := 0\n\t\t\t\tcntO := 0\n\t\t\t\tfor k:=0; k<3; k++ {\n\t\t\t\t\txx := x0 + k*dx[dir]\n\t\t\t\t\tyy := y0 + k*dy[dir]\n\t\t\t\t\tif field[yy][xx]=='x' {\n\t\t\t\t\t\tcntX++\n\t\t\t\t\t} else if field[yy][xx]=='o' {\n\t\t\t\t\t\tcntO++\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif cntX>=2 && cntO==0 {\n\t\t\t\t\tcanWin = \"YES\"\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc printRes() {\n\tfmt.Println(canWin)\n}\n\nfunc main() {\n\treadData()\n\tsolve()\n\tprintRes()\n}\n"}, {"source_code": "package main\nimport \"fmt\"\n\nconst size int = 4;\nfunc solve(T []string,x int,y int) bool{\n //fmt.Println(x,y);\n T[x]=T[x][:y]+string('x')+T[x][y+1:];\n possible:=false;\n for i:=0;i=0&&nx=0&&ny= 0 && table[i][j] == x && table[i+1][j-1] == x && table[i+2][j-2] == x {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc main() {\n\ttable := make([][]rune, size)\n\n\tfor i := 0; i < size; i++ {\n\t\ttable[i] = make([]rune, size)\n\n\t\tvar row string\n\t\tfmt.Scanf(\"%s\\n\", &row)\n\n\t\tfor p, s := range row {\n\t\t\ttable[i][p] = s\n\t\t}\n\t}\n\n\tfor i := 0; i < size; i++ {\n\t\tfor j := 0; j < size; j++ {\n\t\t\tif table[i][j] == dot {\n\t\t\t\ttable[i][j] = x\n\t\t\t\tif checkHorizontal(table) || checkVertical(table) || checkDiagonal(table) {\n\t\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\ttable[i][j] = dot\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(\"NO\")\n}"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc I(i interface{}, delim string) {\n\tfmt.Fscanf(r, \"%v\"+delim, i)\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nvar in [4]string\n\nfunc check() bool {\n\tfor i := 0; i < 4; i++ {\n\t\tfor j := 0; j < 4; j++ {\n\t\t\tif in[i][j] == 'x' {\n\t\t\t\tif strings.Contains(in[i], \"xxx\") ||\n\t\t\t\t\t(i+2 < 4 && ((in[i+1][j] == 'x' && in[i+2][j] == 'x') ||\n\t\t\t\t\t\t(j+2 < 4 && in[i+1][j+1] == 'x' && in[i+2][j+2] == 'x') ||\n\t\t\t\t\t\t(i-2 >= 0 && in[i+1][j-1] == 'x' && in[i+2][j-2] == 'x'))) {\n\t\t\t\t\tO(\"YES\", \"\\n\")\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\nfunc main() {\n\tr = bufio.NewReader(os.Stdin)\n\tw = bufio.NewWriter(os.Stdout)\n\tdefer w.Flush()\n\tfor i := 0; i < 4; i++ {\n\t\tI(&in[i], \"\\n\")\n\t}\n\tif check() {\n\t\treturn\n\t}\n\tfor i := 0; i < 4; i++ {\n\t\tfor j := 0; j < 4; j++ {\n\t\t\tif in[i][j] == '.' {\n\t\t\t\ta := []rune(in[i])\n\t\t\t\ta[j] = 'x'\n\t\t\t\tin[i] = string(a)\n\t\t\t\tif check() {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\ta[j] = '.'\n\t\t\t\tin[i] = string(a)\n\t\t\t}\n\t\t}\n\t}\n\tO(\"NO\", \"\\n\")\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nconst size = 4\nconst x = 'x'\nconst dot = '.'\n\nfunc checkVertical(table [][]rune) bool {\n\tfor i := 0; i < size; i++ {\n\t\tif table[i][0] == x && table[i][1] == x && table[i][2] == x {\n\t\t\treturn true\n\t\t}\n\n\t\tif table[i][1] == x && table[i][2] == x && table[i][3] == x {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc checkHorizontal(table [][]rune) bool {\n\tfor j := 0; j < size; j++ {\n\t\tif table[j][0] == x && table[j][1] == x && table[j][2] == x {\n\t\t\treturn true\n\t\t}\n\n\t\tif table[j][1] == x && table[j][2] == x && table[j][3] == x {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc checkDiagonal(table [][]rune) bool {\n\tfor i := 0; i < size; i++ {\n\t\tfor j := 0; j < size; j++ {\n\t\t\tvar ii, jj int\n\n\t\t\tii = i + 2\n\t\t\tjj = j + 2\n\n\t\t\tif ii < size && jj < size && table[i][j] == x && table[i+1][j+1] == x && table[i+2][j+2] == x {\n\t\t\t\treturn true\n\t\t\t}\n\n\t\t\tii = i + 2\n\t\t\tjj = j - 2\n\n\t\t\tif ii < size && jj >= 0 && table[i][j] == x && table[i+1][j-1] == x && table[i+2][j-2] == x {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc main() {\n\ttable := make([][]rune, size)\n\n\tfor i := 0; i < size; i++ {\n\t\ttable[i] = make([]rune, size)\n\n\t\tvar row string\n\t\tfmt.Scanf(\"%s\\n\", &row)\n\n\t\tfor p, s := range row {\n\t\t\ttable[i][p] = s\n\t\t}\n\t}\n\n\tfor i := 0; i < size; i++ {\n\t\tfor j := 0; j < size; j++ {\n\t\t\tif table[i][j] == dot {\n\t\t\t\ttable[i][j] = x\n\t\t\t\tif checkHorizontal(table) || checkVertical(table) || checkDiagonal(table) {\n\t\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\ttable[i][j] = dot\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(\"NO\")\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nconst size = 4\nconst x = 'x'\nconst dot = '.'\n\nfunc checkVertical(table [][]rune) bool {\n\tfor i := 0; i < size; i++ {\n\t\tif table[i][0] == x && table[i][1] == x && table[i][2] == x {\n\t\t\treturn true\n\t\t}\n\n\t\tif table[i][1] == x && table[i][2] == x && table[i][3] == x {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc checkHorizontal(table [][]rune) bool {\n\tfor j := 0; j < size; j++ {\n\t\tif table[j][0] == x && table[j][1] == x && table[j][2] == x {\n\t\t\treturn true\n\t\t}\n\n\t\tif table[j][1] == x && table[j][2] == x && table[j][3] == x {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc checkDiagonal(table [][]rune) bool {\n\tif table[0][0] == x && table[1][1] == x && table[2][2] == x {\n\t\treturn true\n\t}\n\n\tif table[1][1] == x && table[2][2] == x && table[3][3] == x {\n\t\treturn true\n\t}\n\n\tif table[0][3] == x && table[1][2] == x && table[2][1] == x {\n\t\treturn true\n\t}\n\n\tif table[3][0] == x && table[2][1] == x && table[1][2] == x {\n\t\treturn true\n\t}\n\n\treturn false\n}\n\nfunc main() {\n\ttable := make([][]rune, size)\n\n\tfor i := 0; i < size; i++ {\n\t\ttable[i] = make([]rune, size)\n\n\t\tvar row string\n\t\tfmt.Scanf(\"%s\\n\", &row)\n\n\t\tfor p, s := range row {\n\t\t\ttable[i][p] = s\n\t\t}\n\t}\n\n\tfor i := 0; i < size; i++ {\n\t\tfor j := 0; j < size; j++ {\n\t\t\tif table[i][j] == dot {\n\t\t\t\ttable[i][j] = x\n\t\t\t\tif checkHorizontal(table) || checkVertical(table) || checkDiagonal(table) {\n\t\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\ttable[i][j] = dot\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(\"NO\")\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nconst size = 4\n\nfunc checkVertical(table [][]rune) bool {\n\tfor i := 0; i < size; i++ {\n\t\tif table[i][0] == 'X' && table[i][1] == 'X' && table[i][2] == 'X' {\n\t\t\treturn true\n\t\t}\n\n\t\tif table[i][1] == 'X' && table[i][2] == 'X' && table[i][3] == 'X' {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc checkHorizontal(table [][]rune) bool {\n\tfor j := 0; j < size; j++ {\n\t\tif table[j][0] == 'X' && table[j][1] == 'X' && table[j][2] == 'X' {\n\t\t\treturn true\n\t\t}\n\n\t\tif table[j][1] == 'X' && table[j][2] == 'X' && table[j][3] == 'X' {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc checkDiagonal(table [][]rune) bool {\n\tif table[0][0] == 'X' && table[1][1] == 'X' && table[2][2] == 'X' {\n\t\treturn true\n\t}\n\n\tif table[1][1] == 'X' && table[2][2] == 'X' && table[3][3] == 'X' {\n\t\treturn true\n\t}\n\n\tif table[0][3] == 'X' && table[1][2] == 'X' && table[2][1] == 'X' {\n\t\treturn true\n\t}\n\n\tif table[3][0] == 'X' && table[2][1] == 'X' && table[1][2] == 'X' {\n\t\treturn true\n\t}\n\n\treturn false\n}\n\nfunc main() {\n\ttable := make([][]rune, size)\n\n\tfor i := 0; i < size; i++ {\n\t\ttable[i] = make([]rune, size)\n\n\t\tvar row string\n\t\tfmt.Scanf(\"%s\\n\", &row)\n\n\t\tfor p, s := range row {\n\t\t\ttable[i][p] = s\n\t\t}\n\t}\n\n\tfor i := 0; i < size; i++ {\n\t\tfor j := 0; j < size; j++ {\n\t\t\tif table[i][j] == '.' {\n\t\t\t\ttable[i][j] = 'X'\n\t\t\t\tif checkHorizontal(table) || checkVertical(table) || checkDiagonal(table) {\n\t\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\ttable[i][j] = '.'\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(\"NO\")\n}"}], "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917"} {"nl": {"description": "Yura is a mathematician, and his cognition of the world is so absolute as if he have been solving formal problems a hundred of trillions of billions of years. This problem is just that!Consider all non-negative integers from the interval $$$[0, 10^{n})$$$. For convenience we complement all numbers with leading zeros in such way that each number from the given interval consists of exactly $$$n$$$ decimal digits.You are given a set of pairs $$$(u_i, v_i)$$$, where $$$u_i$$$ and $$$v_i$$$ are distinct decimal digits from $$$0$$$ to $$$9$$$.Consider a number $$$x$$$ consisting of $$$n$$$ digits. We will enumerate all digits from left to right and denote them as $$$d_1, d_2, \\ldots, d_n$$$. In one operation you can swap digits $$$d_i$$$ and $$$d_{i + 1}$$$ if and only if there is a pair $$$(u_j, v_j)$$$ in the set such that at least one of the following conditions is satisfied: $$$d_i = u_j$$$ and $$$d_{i + 1} = v_j$$$, $$$d_i = v_j$$$ and $$$d_{i + 1} = u_j$$$. We will call the numbers $$$x$$$ and $$$y$$$, consisting of $$$n$$$ digits, equivalent if the number $$$x$$$ can be transformed into the number $$$y$$$ using some number of operations described above. In particular, every number is considered equivalent to itself.You are given an integer $$$n$$$ and a set of $$$m$$$ pairs of digits $$$(u_i, v_i)$$$. You have to find the maximum integer $$$k$$$ such that there exists a set of integers $$$x_1, x_2, \\ldots, x_k$$$ ($$$0 \\le x_i < 10^{n}$$$) such that for each $$$1 \\le i < j \\le k$$$ the number $$$x_i$$$ is not equivalent to the number $$$x_j$$$.", "input_spec": "The first line contains an integer $$$n$$$ ($$$1 \\le n \\le 50\\,000$$$) — the number of digits in considered numbers. The second line contains an integer $$$m$$$ ($$$0 \\le m \\le 45$$$) — the number of pairs of digits in the set. Each of the following $$$m$$$ lines contains two digits $$$u_i$$$ and $$$v_i$$$, separated with a space ($$$0 \\le u_i < v_i \\le 9$$$). It's guaranteed that all described pairs are pairwise distinct.", "output_spec": "Print one integer — the maximum value $$$k$$$ such that there exists a set of integers $$$x_1, x_2, \\ldots, x_k$$$ ($$$0 \\le x_i < 10^{n}$$$) such that for each $$$1 \\le i < j \\le k$$$ the number $$$x_i$$$ is not equivalent to the number $$$x_j$$$. As the answer can be big enough, print the number $$$k$$$ modulo $$$998\\,244\\,353$$$.", "sample_inputs": ["1\n0", "2\n1\n0 1", "2\n9\n0 1\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9"], "sample_outputs": ["10", "99", "91"], "notes": "NoteIn the first example we can construct a set that contains all integers from $$$0$$$ to $$$9$$$. It's easy to see that there are no two equivalent numbers in the set.In the second example there exists a unique pair of equivalent numbers: $$$01$$$ and $$$10$$$. We can construct a set that contains all integers from $$$0$$$ to $$$99$$$ despite number $$$1$$$."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\nvar wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)\nvar rdr = bufio.NewScanner(os.Stdin)\nfunc gs() string { rdr.Scan(); return rdr.Text() }\nfunc gi() int { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }\nfunc gis(n int) []int { res := make([]int,n); for i:=0;i 1 {\tinfn = os.Args[1] }\n\tif infn != \"\" {\tf, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }\n\trdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)\n\t// PROGRAM STARTS HERE\n\tN,M := gi(),gi(); mask := ia(10); for i:=0;i> uint(k)) & 1 == 0 {\n\t\t\t\t\t\tg[(j | ((1<> 1\n\t}\n\tconA := big.NewInt(0)\n\tcofA, cofD := big.NewInt(0), uint(0)\n\tfor d, c, p := uint(1), int64(2), big.NewInt(2);n != 1; d, c = d + 1, c << 1{\n\t\t\tif c == n + 1 {\n\t\t\t\t// conA/conB += (c * d) / p\n\t\t\t\tconA.Lsh(conA, d - cofD)\n\t\t\t\tconA.Add(big.NewInt(c * int64(d)), conA)\n\t\t\t\tcofD = d\n\n\t\t\t\t// cofA/cofB += 1 / p\n\t\t\t\tcofA.Sub(p, big.NewInt(1))\n\t\t\t\tbreak\n\t\t\t} else if c > n + 1 {\n\n\t\t\t\tconA.Lsh(conA, d - cofD)\n\t\t\t\tconA.Add(big.NewInt(n * int64(d)), conA)\n\t\t\t\tcofD = d\n\n\t\t\t\tc = c - n\n\t\t\t}\n\t\tp.Lsh(p, 1)\n\t}\n\tif n == 1 {\n\t\tfmt.Printf(\"%d/1\", count)\n\t\treturn\n\t}\n\n\trat := &big.Rat{}\n\trat.SetFrac(conA, cofA)\n\trat.Add(rat, big.NewRat(count, 1))\n\tfmt.Printf(\"%s\\n\", rat.String())\n}"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math/big\"\n)\n\nvar con, cof *big.Rat\n\nfunc main() {\n\tvar n int64\n\tfmt.Scanf(\"%d\", &n)\n\tvar count int64\n\tfor n % 2 == 0 {\n\t\tcount, n = count + 1, n >> 1\n\t}\n\tcon, cof = big.NewRat(count, 1), big.NewRat(1, 1)\n\thalf := big.NewRat(1, 2)\n\tfor d, c, p := int64(1), int64(2), big.NewRat(1, 2);n != 1; d, c = d + 1, c << 1{\n\t\tif c >= n {\n\t\t\ttmp := &big.Rat{}\n\t\t\tif c == n + 1 {\n\t\t\t\ttmp.Mul(big.NewRat(c * d, 1), p)\n\t\t\t\tcon.Add(con, tmp)\n\t\t\t\tcof.Sub(cof, p)\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\ttmp.Mul(big.NewRat(n * d, 1), p)\n\t\t\t\tcon.Add(con, tmp)\n\t\t\t\tc = c - n\n\t\t\t}\n\t\t} \n\t\tp.Mul(p, half)\n\t}\n\n\tcof.Inv(cof)\n\tcon.Mul(con, cof)\n\tfmt.Printf(\"%s\\n\", con.String())\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math/big\"\n)\n\nvar con, cof *big.Rat\nvar n, depth uint\n\nfunc search(d uint, value uint) {\n\tif d == depth {\n\t\tcon.Add(con, big.NewRat(int64(depth), 1 << depth))\n\t\tif value >= n {\n\t\t\tcof.Add(cof, big.NewRat(1, 1 << depth))\n\t\t}\n\t\treturn\n\t} else if value < n {\n\t\tsearch(d + 1, value)\n\t\tsearch(d + 1, value | (1 << (depth - d - 1)))\n\t} else {\n\t\tcon.Add(con, big.NewRat(int64(d), 1 << (depth - d)))\n\t\tcof.Add(cof, big.NewRat(1, 1 << (depth - d)))\n\t}\n}\n\nfunc main() {\n\tcon, cof = big.NewRat(0, 1), big.NewRat(0, 1)\n\tfmt.Scanf(\"%d\", &n)\n\tfor depth = 0;(1 << depth) < n;depth ++ {\n\n\t}\n\tsearch(0, 0)\n\tcof.Sub(big.NewRat(1,1), cof)\n\tcof.Inv(cof)\n\tcon.Mul(con, cof)\n\tfmt.Printf(\"%s\", con.String())\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math/big\"\n)\n\nvar con, cof *big.Rat\nvar n, depth uint\n\nfunc search(d uint, value uint) {\n\tif d == depth {\n\t\tcon.Add(con, big.NewRat(int64(depth), 1 << depth))\n\t\tif value >= n {\n\t\t\tcof.Add(cof, big.NewRat(1, 1 << depth))\n\n\t\t}\n\t\treturn\n\t} else if value < n {\n\t\tsearch(d + 1, value)\n\t\tsearch(d + 1, value | (1 << (depth - d - 1)))\n\t} else {\n\t\tcon.Add(con, big.NewRat(int64(d), 1 << d))\n\t\tcof.Add(cof, big.NewRat(1, 1 << d))\n\t}\n}\n\nfunc main() {\n\tcon, cof = big.NewRat(0, 1), big.NewRat(0, 1)\n\tfmt.Scanf(\"%d\", &n)\n\tfor depth = 0;(1 << depth) < n;depth ++ {\n\n\t}\n\tsearch(0, 0)\n\tcof.Sub(big.NewRat(1,1), cof)\n\tcof.Inv(cof)\n\tcon.Mul(con, cof)\n\tfmt.Printf(\"%s\", con.String())\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math/big\"\n)\n\nvar con, cof *big.Rat\nvar n, depth uint\n\nfunc search(d uint, value uint) {\n\tif d == depth {\n\t\tcon.Add(con, big.NewRat(int64(depth), 1 << depth))\n\t\tif value >= n {\n\t\t\tcof.Add(cof, big.NewRat(1, 1 << depth))\n\t\t}\n\t\treturn\n\t} else if value < n {\n\t\tsearch(d + 1, value)\n\t\tsearch(d + 1, value | (1 << (depth - d - 1)))\n\t} else {\n\t\tcon.Add(con, big.NewRat(int64(d), 1 << (depth - d + 1)))\n\t\tcof.Add(cof, big.NewRat(1, 1 << (depth - d + 1)))\n\t}\n}\n\nfunc main() {\n\tcon, cof = big.NewRat(0, 1), big.NewRat(0, 1)\n\tfmt.Scanf(\"%d\", &n)\n\tfor depth = 0;(1 << depth) < n;depth ++ {\n\n\t}\n\tsearch(0, 0)\n\tcof.Sub(big.NewRat(1,1), cof)\n\tcof.Inv(cof)\n\tcon.Mul(con, cof)\n\tfmt.Printf(\"%s\", con.String())\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math/big\"\n)\n\nvar con, cof *big.Rat\nvar n, depth uint\n\nfunc search(d uint, value uint) {\n\tif d == depth {\n\t\tcon.Add(con, big.NewRat(int64(depth), 1 << depth))\n\t\tif value >= n {\n\t\t\tcof.Add(cof, big.NewRat(1, 1 << depth))\n\n\t\t}\n\t\treturn\n\t} else if value < n {\n\t\tsearch(d + 1, value)\n\t\tsearch(d + 1, value | (1 << (depth - d - 1)))\n\t} else {\n\t\tcon.Add(con, big.NewRat(int64(d), 1 << d))\n\t\tcof.Add(cof, big.NewRat(1, 1 << d))\n\t}\n}\n\nfunc main() {\n\tcon, cof = big.NewRat(0, 1), big.NewRat(0, 1)\n\tfmt.Scanf(\"%d\", &n)\n\tfor depth = 0;(1 << depth) < n;depth ++ {\n\n\t}\n\tsearch(0, 0)\n\tcof.Sub(big.NewRat(1,1), cof)\n\tcof.Inv(cof)\n\tcon.Mul(con, cof)\n\tfmt.Printf(\"%s\\n\", con.String())\n}"}], "src_uid": "5491b4a27991153a61ac4a2618b2cd0e"} {"nl": {"description": "One spring day on his way to university Lesha found an array A. Lesha likes to split arrays into several parts. This time Lesha decided to split the array A into several, possibly one, new arrays so that the sum of elements in each of the new arrays is not zero. One more condition is that if we place the new arrays one after another they will form the old array A.Lesha is tired now so he asked you to split the array. Help Lesha!", "input_spec": "The first line contains single integer n (1 ≤ n ≤ 100) — the number of elements in the array A. The next line contains n integers a1, a2, ..., an ( - 103 ≤ ai ≤ 103) — the elements of the array A.", "output_spec": "If it is not possible to split the array A and satisfy all the constraints, print single line containing \"NO\" (without quotes). Otherwise in the first line print \"YES\" (without quotes). In the next line print single integer k — the number of new arrays. In each of the next k lines print two integers li and ri which denote the subarray A[li... ri] of the initial array A being the i-th new array. Integers li, ri should satisfy the following conditions: l1 = 1 rk = n ri + 1 = li + 1 for each 1 ≤ i < k. If there are multiple answers, print any of them.", "sample_inputs": ["3\n1 2 -3", "8\n9 -12 3 4 -4 -10 7 3", "1\n0", "4\n1 2 3 -5"], "sample_outputs": ["YES\n2\n1 2\n3 3", "YES\n2\n1 2\n3 8", "NO", "YES\n4\n1 1\n2 2\n3 3\n4 4"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i interface{}, delim string) {\n\tfmt.Fscanf(r, \"%v\"+delim, i)\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc main() {\n\tr = bufio.NewReader(os.Stdin)\n\tw = bufio.NewWriter(os.Stdout)\n\tdefer w.Flush()\n\tvar n int\n\tI(&n, \"\\n\")\n\tin := make([]int, n)\n\tsum := 0\n\tstart := 1\n\tend := 1\n\tvar out [][2]int\n\tfor i, _ := range in {\n\t\tI(&in[i], \" \")\n\t\tsum += in[i]\n\t\tif sum != 0 {\n\t\t\tend = i + 1\n\t\t\tout = append(out, [2]int{start, end})\n\t\t\tstart = i + 2\n\t\t\tif i != n-1 {\n\t\t\t\tsum = 0\n\t\t\t}\n\t\t}\n\t}\n\tif sum == 0 && len(out) == 0 {\n\t\tO(\"NO\", \"\\n\")\n\t\treturn\n\t}\n\tif sum == 0 {\n\t\tout[len(out)-1][1] = n\n\t}\n\tO(\"YES\", \"\\n\")\n\tO(len(out), \"\\n\")\n\tfor _, o := range out {\n\t\tO(o[0], \" \")\n\t\tO(o[1], \"\\n\")\n\t}\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc getArr() []int {\n\tvar (\n\t\tn int\n\t\tarr []int\n\t)\n\tif _, err := fmt.Scan(&n); err != nil {\n\t\tpanic(err)\n\t}\n\tarr = make([]int, n)\n\tfor i := range arr {\n\t\tif _, err := fmt.Scan(&arr[i]); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\treturn arr\n}\n\ntype Split struct {\n\tStart, End int\n\tNext, Prev *Split\n}\n\nfunc (split *Split) CalcSum() int {\n\tvar sum int\n\tfor i := split.Start; i < split.End; i++ {\n\t\tsum += arr[i]\n\t}\n\treturn sum\n}\n\nfunc (split *Split) Process() bool {\n\tfullSum := split.CalcSum()\n\tsaveEnd := split.End\n\tif fullSum == 0 {\n\t\tcurSum := 0\n\t\tfor i := split.Start; i < saveEnd; i++ {\n\t\t\tcurSum += arr[i]\n\t\t\tif curSum != 0 && (fullSum-curSum) != 0 {\n\t\t\t\tsplit.End = i + 1\n\t\t\t\trs := &Split{Start: i + 1, End: saveEnd}\n\t\t\t\trs.Next = split.Next\n\t\t\t\trs.Prev = split\n\t\t\t\tsplit.Next = rs\n\t\t\t\tif split.Process() && rs.Process() {\n\t\t\t\t\treturn true\n\t\t\t\t} else {\n\t\t\t\t\tsplit.Next = rs.Next\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false\n\t} else {\n\t\treturn true\n\t}\n}\n\nfunc (split *Split) FirstSplit() *Split {\n\tfor split.Prev != nil {\n\t\tsplit = split.Prev\n\t}\n\treturn split\n}\n\nfunc (split *Split) Len() int {\n\tvar n int\n\tfor split != nil {\n\t\tsplit = split.Next\n\t\tn += 1\n\t}\n\treturn n\n}\n\nvar arr []int\n\nfunc main() {\n\tarr = getArr()\n\n\tspl := &Split{Start: 0, End: len(arr)}\n\n\tif spl.Process() {\n\t\tfmt.Println(\"YES\")\n\t\tfspl := spl.FirstSplit()\n\t\tfmt.Println(fspl.Len())\n\t\tfor fspl != nil {\n\t\t\tfmt.Println(fspl.Start+1, fspl.End)\n\t\t\tfspl = fspl.Next\n\t\t}\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "//http://codeforces.com/contest/754/problem/A\npackage main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\nfunc main() {\n\n\tvar (\n\t\tn int\n\t)\n\n\t//f, _ := os.Open(\"input.txt\")\n\t//input := bufio.NewReader(f)\n\tinput := bufio.NewReader(os.Stdin)\n\n\tfmt.Fscanln(input, &n)\n\ta := make([]int, n)\n\n\tzeroes := true\n\tsum := 0\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscan(input, &a[i])\n\n\t\tzeroes = zeroes && (a[i] == 0)\n\t\tsum += a[i]\n\t}\n\n\tif zeroes {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\n\tfmt.Println(\"YES\")\n\n\tif sum != 0 {\n\t\tfmt.Println(1)\n\t\tfmt.Println(1, n)\n\t\treturn\n\t}\n\n\tfmt.Println(\"2\")\n\tsum = 0\n\ti := 0\n\tfor sum == 0 {\n\t\tsum += a[i]\n\t\ti++\n\t}\n\n\tfmt.Println(1, i)\n\tfmt.Println(i + 1, n)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar n int\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\tsum := 0\n\thas_non_zero := false\n\n\tarray := make([]int, n)\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tfor i := 0; i < n && scanner.Scan(); i++ {\n\t\ta, err := strconv.Atoi(scanner.Text())\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tarray[i] = a\n\t\tsum += a\n\t\tif a != 0 {\n\t\t\thas_non_zero = true\n\t\t}\n\t}\n\n\tif !has_non_zero {\n\t\tfmt.Println(\"NO\")\n\t} else if sum != 0 {\n\t\tfmt.Println(\"YES\")\n\t\tfmt.Println(\"1\\n1\", n)\n\t} else {\n\t\ts := 0\n\t\tbound := -1\n\t\tfor i := 0; i < n; i++ {\n\t\t\ts += array[i]\n\t\t\tif s != 0 {\n\t\t\t\tbound = i\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfmt.Println(\"YES\")\n\t\tfmt.Println(2)\n\t\tfmt.Println(1, bound+1)\n\t\tfmt.Println(bound+2, n)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt()\n\ta := make([]int, n)\n\ttotal := 0\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = readInt()\n\t\tif a[i] == 0 {\n\t\t\ttotal++\n\t\t}\n\t}\n\tif total == n {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tres := make([][]int, 0)\n\tfor i := 0; i < n; i++ {\n\t\tstart := i\n\t\tsum := a[i]\n\t\tfor sum == 0 && i+1 < n {\n\t\t\ti++\n\t\t\tsum += a[i]\n\t\t}\n\t\tfor i+1 < n && a[i+1] == 0 {\n\t\t\ti++\n\t\t\tsum += a[i]\n\t\t}\n\t\tif sum == 0 {\n\t\t\tfmt.Println(\"NO\")\n\t\t\treturn\n\t\t}\n\t\tres = append(res, []int{start + 1, i + 1})\n\t}\n\tfmt.Println(\"YES\")\n\tfmt.Println(len(res))\n\tfor _, v := range res {\n\t\tfmt.Println(v[0], v[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\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"}, {"source_code": "package main\nimport \"fmt\"\nfunc main(){\n for true{\n var n int;\n if items,_:=fmt.Scan(&n);items==0{\n break;\n }\n var myVec []int;\n for i:=0;i 1 {\n\t\tfmt.Println(\"YES\")\n\t\tfmt.Println(len(res))\n\t\tfor _, v := range res {\n\t\t\tfmt.Println(v[0], v[1])\n\t\t}\n\t} else {\n\t\tfmt.Println(\"NO\")\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"}], "src_uid": "3a9258070ff179daf33a4515def9897a"} {"nl": {"description": "You are given n k-digit integers. You have to rearrange the digits in the integers so that the difference between the largest and the smallest number was minimum. Digits should be rearranged by the same rule in all integers.", "input_spec": "The first line contains integers n and k — the number and digit capacity of numbers correspondingly (1 ≤ n, k ≤ 8). Next n lines contain k-digit positive integers. Leading zeroes are allowed both in the initial integers and the integers resulting from the rearranging of digits.", "output_spec": "Print a single number: the minimally possible difference between the largest and the smallest number after the digits are rearranged in all integers by the same rule.", "sample_inputs": ["6 4\n5237\n2753\n7523\n5723\n5327\n2537", "3 3\n010\n909\n012", "7 5\n50808\n36603\n37198\n44911\n29994\n42543\n50156"], "sample_outputs": ["2700", "3", "20522"], "notes": "NoteIn the first sample, if we rearrange the digits in numbers as (3,1,4,2), then the 2-nd and the 4-th numbers will equal 5237 and 2537 correspondingly (they will be maximum and minimum for such order of digits).In the second sample, if we swap the second digits and the first ones, we get integers 100, 99 and 102."}, "positive_code": [{"source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n \"sort\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nvar writer *bufio.Writer\nvar best int = -1\nvar g [][]int\nvar numRows, numCols int\n\nfunc permute(i int) {\n if i == numCols {\n xs := make([]int, numRows)\n for i := range g {\n x := 0\n for _, d := range g[i] {\n x = 10*x + d\n }\n xs[i] = x\n }\n sort.Ints(xs)\n diff := xs[numRows-1] - xs[0]\n if best == -1 || diff < best {\n best = diff\n }\n } else {\n permute(i+1)\n for j := i+1; j < numCols; j++ {\n for k := range g {\n g[k][i], g[k][j] = g[k][j], g[k][i]\n }\n permute(i+1)\n for k := range g {\n g[k][i], g[k][j] = g[k][j], g[k][i]\n }\n }\n }\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer = bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n numRows, numCols = getI(), getI()\n g = make([][]int, numRows)\n for i := range g {\n s := getS()\n g[i] = make([]int, numCols)\n for j := range g[i] {\n g[i][j] = int(s[j]-'0')\n }\n }\n permute(0)\n\n writer.WriteString(fmt.Sprintf(\"%d\\n\", best))\n}\n"}], "negative_code": [], "src_uid": "08f85cd4ffbd135f0b630235209273a4"} {"nl": {"description": "Polycarp urgently needs a shovel! He comes to the shop and chooses an appropriate one. The shovel that Policarp chooses is sold for k burles. Assume that there is an unlimited number of such shovels in the shop.In his pocket Polycarp has an unlimited number of \"10-burle coins\" and exactly one coin of r burles (1 ≤ r ≤ 9).What is the minimum number of shovels Polycarp has to buy so that he can pay for the purchase without any change? It is obvious that he can pay for 10 shovels without any change (by paying the requied amount of 10-burle coins and not using the coin of r burles). But perhaps he can buy fewer shovels and pay without any change. Note that Polycarp should buy at least one shovel.", "input_spec": "The single line of input contains two integers k and r (1 ≤ k ≤ 1000, 1 ≤ r ≤ 9) — the price of one shovel and the denomination of the coin in Polycarp's pocket that is different from \"10-burle coins\". Remember that he has an unlimited number of coins in the denomination of 10, that is, Polycarp has enough money to buy any number of shovels.", "output_spec": "Print the required minimum number of shovels Polycarp has to buy so that he can pay for them without any change. ", "sample_inputs": ["117 3", "237 7", "15 2"], "sample_outputs": ["9", "1", "2"], "notes": "NoteIn the first example Polycarp can buy 9 shovels and pay 9·117 = 1053 burles. Indeed, he can pay this sum by using 10-burle coins and one 3-burle coin. He can't buy fewer shovels without any change.In the second example it is enough for Polycarp to buy one shovel.In the third example Polycarp should buy two shovels and pay 2·15 = 30 burles. It is obvious that he can pay this sum without any change. "}, "positive_code": [{"source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\n\nfunc main() {\n\tvar k, r int\n\tvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\n\t\n\tscanner.Scan()\n\tfmt.Sscanf(scanner.Text(), \"%d %d\", &k, &r)\n\t\n\tn := 1\n\tfor m := k % 10; m != 0 && m != r; m = (m + k) % 10 {\n\t\tn++\n\t}\n\t\n\tfmt.Print(n)\n}"}, {"source_code": "package main\n\n\nimport \"fmt\"\n\nfunc main() {\n\tvar k,r int;\n\tfmt.Scan(&k, &r)\n\tfor i:=1; i<=10; i++ {\n\t\tsum := k * i\n\t\tif sum % 10 == 0 || sum % 10 == r {\n\t\t\tfmt.Println(i)\n\t\t\tbreak\n\t\t}\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i interface{}, delim string) error {\n\t_, err := fmt.Fscanf(r, \"%v\"+delim, i)\n\treturn err\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc main() {\n\tif f, err := os.Open(\"in.txt\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n\tdefer w.Flush()\n\tvar k int\n\tfor I(&k, \" \") == nil {\n\t\tsolve(k)\n\t}\n}\nfunc solve(k int) {\n\tvar r int\n\tI(&r, \"\\n\")\n\ti := 1\n\tfor k*i%10 != r && k*i%10 != 0 {\n\t\ti++\n\t}\n\tO(i, \"\\n\")\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n k, r := readInt(), readInt()\n for i := 1; i < 11; i++ {\n res := i*k % 10\n if res == r || res == 0 {\n fmt.Println(i)\n break\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"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar k, r int\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &k, &r)\n\tfor i := 1; i <= 10; i++ {\n\t\tif k*i%10 == 0 || (k*i-r)%10 == 0 {\n\t\t\tfmt.Println(i)\n\t\t\tbreak\n\t\t}\n\t}\n}\n"}, {"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 solution(k int, r int) int {\n\tfor x := 1; x <= 20; x++ {\n\t\tp := x * k\n\t\tif (p%10 == 0) || (p%10 == r) {\n\t\t\treturn x\n\t\t}\n\t}\n\treturn 10\n}\n\nfunc main() {\n\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\n\tvar k, r int\n\tfmt.Fscanf(bufin, \"%d %d\\n\", &k, &r)\n\n\tfmt.Fprintf(bufout, \"%d\\n\", solution(k, r))\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var k, r int\n fmt.Scanf(\"%d %d\", &k, &r)\n for n := 1; ; n++ {\n a := n * k\n b := a - r\n if a % 10 == 0 || b % 10 == 0 {\n fmt.Printf(\"%d\\n\", n)\n return\n }\n }\n}\n"}, {"source_code": "// codeforces project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nvar (\n\tk, r int\n)\n\nfunc main() {\n\tfmt.Scan(&k, &r)\n\tvar i int = 1\n\ttmp := k\n\tfor ; (k-r)%10 != 0; i++ {\n\t\tif k%10 == 0 {\n\t\t\tbreak\n\t\t}\n\t\tk += tmp\n\t}\n\tfmt.Println(i)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar k, r int16\n\tfmt.Scan(&k, &r)\n\tvar i int16\n\tfor i = 1; i <= 10; i++ {\n\t\tif i * k % 10 == r || i * k % 10 == 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(i)\n}\n"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\n\nfunc max(a, b int) int {\n if a > b {\n return a\n }\n return b\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 // your code here\n var k, r int\n fmt.Fscanf(in, \"%d %d\\n\", &k, &r)\n amount := k\n for amount % 10 != 0 && amount % 10 != r {\n amount += k\n }\n fmt.Println(amount / k)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar k, r int\n\tfmt.Scanf(\"%d %d \\n\", &k, &r)\n\tsol := 1\n\tfor (sol*k)%10 != 0 && (sol*k)%10 != r {\n\t\tsol++\n\t}\n\tfmt.Print(sol)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar k string\n\tvar r int\n\tfmt.Scanf(\"%s %d\\n\", &k, &r)\n\tunitDigit, _ := strconv.Atoi(string(k[len(k)-1]))\n\tfor i := 1; i <= 9; i++ {\n\t\tx := strconv.Itoa(unitDigit * i)\n\t\tnewUnitDigit, _ := strconv.Atoi(string(x[len(x)-1]))\n\t\t// fmt.Println(unitDigit, i, x, newUnitDigit, r)\n\t\tif newUnitDigit == r || newUnitDigit == 0 {\n\t\t\tfmt.Println(i)\n\t\t\tbreak\n\t\t}\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\n\t\"strings\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\nfunc getString() string {\n\tsc := bufio.NewScanner(os.Stdin)\n\tfor sc.Scan() {\n\t\treturn sc.Text()\n\t}\n\treturn sc.Text()\n}\n\nfunc main() {\n\tstr := getString()\n\tar := strings.Split(str, \" \")\n\tk, _ := strconv.Atoi(ar[0])\n\tr, _ := strconv.Atoi(ar[1])\n\ti := 1\n\tif dec := k%10; dec != 0 {\n\t\ttmp := dec\n\t\tfor {\n\t\t\tif tmp%10 == 0 {\n\t\t\t\tfmt.Println(i)\n\t\t\t\treturn \n\t\t\t}\n\t\t\tif tmp-r == 0 {\n\t\t\t\tfmt.Println(i)\n\t\t\t\treturn\n\t\t\t} else {\n\t\t\t\ti++\n\t\t\t\ttmp = dec * i\n\t\t\t\tif tmp > 10 {\n\t\t\t\t\ttmp = tmp % 10\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfmt.Println(i)\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar k int\n\tvar r int\n\tfmt.Scanf(\"%d %d\", &k, &r)\n\n\tfor i := 1; i < 10; i++ {\n\t\tif (k*i)%10 == r || (k*i)%10 == 0 {\n\t\t\tfmt.Printf(\"%d\\n\", i)\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Printf(\"%d\\n\", 10)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar k, r int\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &k, &r)\n\tsum := 0\n\ti := 0\n\tfor ; ; i++ {\n\t\tsum += k\n\t\tif sum%10 == 0 || sum%10 == r {\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(i + 1)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar k, r int\n\tfmt.Scan(&k, &r)\n\tvar cnt = 1\n\tvar remain = k % 10\n\tfor remain != r && remain != 0 {\n\t\tremain = (k + remain) % 10\n\t\tcnt++\n\t}\n\tfmt.Print(cnt)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar k, r int\n\treader := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(reader, &k)\n\tfmt.Fscan(reader, &r)\n\tbuyNumber := 1\n\tfor {\n\t\tif (buyNumber*k)%10 == 0 {\n\t\t\tbreak\n\t\t} else if (((buyNumber * k) % 10) - r) == 0 {\n\t\t\tbreak\n\t\t}\n\t\tbuyNumber++\n\t}\n\tfmt.Println(buyNumber)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar k, r int\n\tfmt.Scanf(\"%d %d\", &k, &r)\n\n\ti := 1\n\tfor {\n\t\ttmp := i * k\n\t\tif tmp%10 == 0 || tmp%10 == r {\n\t\t\tfmt.Println(i)\n\t\t\treturn\n\t\t}\n\t\ti++\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"strconv\"\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\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, 0)\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}\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tsc := NewScanner()\n\tk, r := sc.NextInt(), sc.NextInt()\n\tfor l := 1; l <= 10; l++ {\n\t\tg := k * l\n\t\tif g % 10 == 0 || g % 10 == r {\n\t\t\tfmt.Println(l)\n\t\t\treturn\n\t\t}\n\t}\n\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar k, r, mod uint\n\tfmt.Scan(&k, &r)\n\tmod = k % 10\n\tfor i := uint(1); i <= 9; i++ {\n\t\tif (i*mod%10) == r || (i*mod%10) == 0 {\n\t\t\tfmt.Println(i)\n\t\t\treturn\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\n// https://codeforces.com/problemset/problem/732/A\n// A. Buy a Shovel\n// time limit per test\n// 1 second\n// memory limit per test\n// 256 megabytes\n// input\n// standard input\n// output\n// standard output\n\n// Polycarp urgently needs a shovel! He comes to the shop and chooses an appropriate one. The shovel that Policarp chooses is sold for k burles. Assume that there is an unlimited number of such shovels in the shop.\n\n// In his pocket Polycarp has an unlimited number of \"10-burle coins\" and exactly one coin of r burles (1 ≤ r ≤ 9).\n\n// What is the minimum number of shovels Polycarp has to buy so that he can pay for the purchase without any change? It is obvious that he can pay for 10 shovels without any change (by paying the requied amount of 10-burle coins and not using the coin of r burles). But perhaps he can buy fewer shovels and pay without any change. Note that Polycarp should buy at least one shovel.\n// Input\n\n// The single line of input contains two integers k and r (1 ≤ k ≤ 1000, 1 ≤ r ≤ 9) — the price of one shovel and the denomination of the coin in Polycarp's pocket that is different from \"10-burle coins\".\n\n// Remember that he has an unlimited number of coins in the denomination of 10, that is, Polycarp has enough money to buy any number of shovels.\n// Output\n\n// Print the required minimum number of shovels Polycarp has to buy so that he can pay for them without any change.\n\nfunc main() {\n\tvar k, r int\n\t_, _ = fmt.Scan(&k, &r)\n\n\tnShovles := 1\n\tfor {\n\t\tprice := nShovles * k\n\n\t\tmod := price % 10\n\t\tif mod == 0 || mod == r {\n\t\t\tbreak\n\t\t}\n\t\tnShovles++\n\t}\n\n\tfmt.Print(nShovles)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\n// https://codeforces.com/problemset/problem/732/A\n// комментарии к решению\n// Десятичных монет неограниченное количество, поэтому нас интересует\n// строго десятичный остаток стоимости, что приводит к конечному кол-ву\n// решений. Перебираем все на листочке и выписываем двумерный массив решений\nfunc taskSolution(k int, r int) int {\n\tcounts := [][]int{\n\t\t{1, 1, 1, 1, 1, 1, 1, 1, 1}, // k%10 = 0\n\t\t{1, 2, 3, 4, 5, 6, 7, 8, 9}, // k%10 = 1\n\t\t{5, 1, 5, 2, 5, 3, 5, 4, 5}, // k%10 = 2\n\t\t{7, 4, 1, 8, 5, 2, 9, 6, 3}, // k%10 = 3\n\t\t{5, 3, 5, 1, 5, 4, 5, 2, 5}, // k%10 = 4\n\t\t{2, 2, 2, 2, 1, 2, 2, 2, 2}, // k%10 = 5\n\t\t{10, 2, 5, 4, 5, 1, 5, 3, 5}, // k%10 = 6\n\t\t{3, 6, 9, 2, 5, 8, 1, 4, 7}, // k%10 = 7\n\t\t{5, 4, 5, 3, 5, 2, 5, 1, 5}, // k%10 = 8\n\t\t{9, 8, 7, 6, 5, 4, 3, 2, 1}, // k%10 = 9\n\t}\n\n\treturn counts[k%10][r-1]\n}\n\nfunc main() {\n\tvar k, r int\n\tif _, err := fmt.Scan(&k, &r); err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(taskSolution(k, r))\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar priceOfShovel int\n\tfmt.Scan(&priceOfShovel)\n\tvar change int\n\tfmt.Scan(&change)\n\tsumOfShovels := 1\n\tshovelPrice := 0\n\tactualPrice := 0\n\tcount := 1\n\tfor index := 0; index < count; index++ {\n\t\tshovelPrice = priceOfShovel * count\n\t\tactualPrice = shovelPrice % 10\n\n\t\tif actualPrice == change || actualPrice == 0 {\n\t\t\tbreak\n\t\t}\n\n\t\tsumOfShovels = sumOfShovels + 1\n\t\tcount++\n\t}\n\tfmt.Print(count)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar k, r int\n\tfmt.Scanf(\"%d %d\", &k, &r)\n\tfor i := 1; i <= 9; i++ {\n\t\tif k*i%10 == 0 || k*i%10 == r {\n\t\t\tfmt.Println(i)\n\t\t\tbreak\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n\tscanner.Scan()\n\tans, _ := strconv.Atoi(scanner.Text())\n\treturn ans\n}\n\nfunc PrintInts(ints ...int) {\n\tfor _, value := range ints {\n\t\twriter.WriteString(strconv.Itoa(value))\n\t\twriter.WriteByte(' ')\n\t}\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tvar k, r int = ReadInt32(), ReadInt32()\n\n\tfor i := 1; i <= 10; i++ {\n\t\tif k*i%10 == r || k*i%10 == 0 {\n\t\t\tPrintInts(i)\n\t\t\tbreak\n\t\t}\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar (\n\tk, r int\n)\n\nfunc main() {\n\tfmt.Scan(&k, &r)\n\n\tif (k-r)%10 == 0 {\n\t\tprintln(1)\n\t} else {\n\t\tvar i int\n\t\ttmp := k\n\t\tm := (k - r) % 10\n\t\tfor i = 1; m != 0; i++ {\n\t\t\tk += tmp\n\t\t\tm = (k - r) % 10\n\t\t}\n\t\tprintln(i)\n\t}\n}\n"}, {"source_code": "// codeforces project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nvar (\n\tk, r int\n)\n\nfunc main() {\n\tfmt.Scan(&k, &r)\n\tvar i int = 1\n\ttmp := k\n\tfor ; (k-r)%10 != 0; i++ {\n\t\tif k%10 == 0 {\n\t\t\tbreak\n\t\t}\n\t\tk += tmp\n\t}\n\tprintln(i)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar k string\n\tvar r int\n\tfmt.Scanf(\"%s %d\\n\", &k, &r)\n\tunitDigit, _ := strconv.Atoi(string(k[len(k)-1]))\n\tflag := false\n\tfor i := 0; i <= 9; i++ {\n\t\tx := strconv.Itoa(unitDigit * i)\n\t\tnewUnitDigit, _ := strconv.Atoi(string(x[len(x)-1]))\n\t\t// fmt.Println(unitDigit, i, x, newUnitDigit, r)\n\t\tif newUnitDigit == r {\n\t\t\tfmt.Println(i)\n\t\t\tflag = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif !flag {\n\t\tfmt.Println(r)\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\n\t\"strings\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\nfunc getString() string {\n\tsc := bufio.NewScanner(os.Stdin)\n\tfor sc.Scan() {\n\t\treturn sc.Text()\n\t}\n\treturn sc.Text()\n}\n\nfunc main() {\n\tstr := getString()\n\tar := strings.Split(str, \" \")\n\tk, _ := strconv.Atoi(ar[0])\n\tr, _ := strconv.Atoi(ar[1])\n\tif dec := k%10; dec != 0 {\n\t\ti := 1\n\t\tfor {\n\t\t\tif dec%r == 0 {\n\t\t\t\tfmt.Println(i)\n\t\t\t\treturn \n\t\t\t} else {\n\t\t\t\ti++\n\t\t\t\tdec = dec * i\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfmt.Println(1)\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar k, r int\n\tfmt.Scan(&k, &r)\n\tvar cnt = 1\n\tvar remain = k % 10\n\tfor remain != r && remain == 0 {\n\t\tremain = (k + remain) % 10\n\t\tcnt++\n\t}\n\tfmt.Print(cnt)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\n// https://codeforces.com/problemset/problem/732/A\n// комментарии к решению\n// Десятичных монет неограниченное количество, поэтому нас интересует\n// строго десятичный остаток стоимости, что приводит к конечному кол-ву\n// решений. Перебираем все на листочке и выписываем двумерный массив решений\nfunc taskSolution(k int, r int) int {\n\tcounts := [][]int{\n\t\t// r = 1 2 3 4 5 6 7 8 9\n\t\t{1, 1, 1, 1, 1, 1, 1, 1, 1}, // k%10 = 0\n\t\t{1, 2, 3, 4, 5, 6, 7, 8, 9}, // k%10 = 1\n\t\t{5, 1, 5, 2, 5, 3, 5, 4, 5}, // k%10 = 2\n\t\t{7, 4, 1, 8, 5, 2, 9, 6, 3}, // k%10 = 3\n\t\t{5, 3, 5, 1, 5, 4, 5, 2, 5}, // k%10 = 4\n\t\t{2, 2, 2, 2, 2, 2, 2, 2, 2}, // k%10 = 5\n\t\t{10, 2, 5, 4, 5, 1, 5, 3, 5}, // k%10 = 6\n\t\t{3, 6, 9, 2, 5, 8, 1, 4, 7}, // k%10 = 7\n\t\t{5, 4, 5, 3, 5, 2, 5, 1, 5}, // k%10 = 8\n\t\t{9, 8, 7, 6, 5, 4, 3, 2, 1}, // k%10 = 9\n\t}\n\n\treturn counts[k%10][r-1]\n}\n\nfunc main() {\n\tvar k, r int\n\tif _, err := fmt.Scan(&k, &r); err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(taskSolution(k, r))\n}\n"}], "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3"} {"nl": {"description": "Carl is a beginner magician. He has a blue, b violet and c orange magic spheres. In one move he can transform two spheres of the same color into one sphere of any other color. To make a spell that has never been seen before, he needs at least x blue, y violet and z orange spheres. Can he get them (possible, in multiple actions)?", "input_spec": "The first line of the input contains three integers a, b and c (0 ≤ a, b, c ≤ 1 000 000) — the number of blue, violet and orange spheres that are in the magician's disposal. The second line of the input contains three integers, x, y and z (0 ≤ x, y, z ≤ 1 000 000) — the number of blue, violet and orange spheres that he needs to get.", "output_spec": "If the wizard is able to obtain the required numbers of spheres, print \"Yes\". Otherwise, print \"No\".", "sample_inputs": ["4 4 0\n2 1 2", "5 6 1\n2 7 2", "3 3 3\n2 2 2"], "sample_outputs": ["Yes", "No", "Yes"], "notes": "NoteIn the first sample the wizard has 4 blue and 4 violet spheres. In his first action he can turn two blue spheres into one violet one. After that he will have 2 blue and 5 violet spheres. Then he turns 4 violet spheres into 2 orange spheres and he ends up with 2 blue, 1 violet and 2 orange spheres, which is exactly what he needs."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc max(a, b int) int {\n if a > b {\n return a \n }\n return b\n}\n\nfunc available(a, b int) int {\n if a > b {\n dif := a - b\n if dif%2 == 0 {\n return dif/2\n } else {\n return (dif - 1)/2\n }\n }\n return 0\n}\n\nfunc main() {\n var a, b, c, x, y, z int\n fmt.Scan(&a, &b, &c, &x, &y, &z)\n\n needed := max(0, x-a) + max(0, y-b) + max(0, z-c)\n ava := available(a, x) + available(b, y) + available(c, z)\n\n if needed > ava {\n fmt.Println(\"No\")\n } else {\n fmt.Println(\"Yes\") \n }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar (\n\t\ta int\n\t\tb int\n\t\tc int\n\t\tx int\n\t\ty int\n\t\tz int\n\t)\n\tfmt.Scanf(\"%d %d %d \",&a,&b,&c)\n\tfmt.Scanf(\"%d %d %d \",&x,&y,&z)\n\tif (x > a){\n\t\tx -= a\n\t\ta = 0\n\t}else {\n\t\ta -= x\n\t\tx = 0\n\t}\n\tif (y > b){\n\t\ty -= b\n\t\tb = 0\n\t}else {\n\t\tb -= y\n\t\ty = 0\n\t}\n\tif (z > c){\n\t\tz -= c\n\t\tc = 0\n\t}else {\n\t\tc -= z\n\t\tz = 0\n\t}\n\tif (x + y + z) <= (a/2 + b/2 + c/2){\n\t\tfmt.Print(\"Yes\")\n\t}else {\n\t\tfmt.Print(\"No\")\n\t}\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var a, b [3]int\n // fmt.Println(i)\n fmt.Scanf(\"%d %d %d\\n\", &a[0], &a[1], &a[2])\n fmt.Scanf(\"%d %d %d\\n\", &b[0], &b[1], &b[2])\n acnt, bcnt := 0, 0\n for i := 0; i < 3; i++ {\n if a[i]-b[i] > 0 {\n acnt += (((a[i] - b[i]) / 2) * 2)\n } else {\n bcnt += (b[i] - a[i])\n }\n }\n //fmt.Println(acnt)\n //fmt.Println(bcnt)\n if acnt/2 >= bcnt {\n fmt.Println(\"Yes\")\n } else {\n fmt.Println(\"No\")\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a [3]int\n\tif _, err := fmt.Scanf(\"%d %d %d\\n\", &a[0], &a[1], &a[2]); err != nil {\n\t\treturn\n\t}\n\tvar x [3]int\n\tif _, err := fmt.Scanf(\"%d %d %d\\n\", &x[0], &x[1], &x[2]); err != nil {\n\t\treturn\n\t}\n\n\tvar d [3]int\n\tneg := 0\n\tfor i := 0; i < 3; i++ {\n\t\td[i] = a[i] - x[i]\n\t\tif d[i] < 0 {\n\t\t\tneg += d[i]\n\t\t}\n\t}\n\n\tfor neg < 0 {\n\t\tok := false\n\t\tfor i := 0; i < 3; i++ {\n\t\t\tif d[i] >= 2 {\n\t\t\t\tneg++\n\t\t\t\td[i] -= 2\n\t\t\t\tok = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !ok {\n\t\t\tfmt.Println(\"No\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Println(\"Yes\")\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var a, b, c, x, y, z int\n fmt.Scanf(\"%d%d%d\\n\",&a,&b,&c);\n fmt.Scanf(\"%d%d%d\\n\",&x,&y,&z);\n aa := a - x\n if (aa > 0) {\n aa /= 2\n }\n bb := b - y\n if (bb > 0) {\n bb /= 2\n }\n cc := c - z\n if (cc > 0) {\n cc /= 2\n }\n\n ans := aa + bb + cc\n\n if ans >= 0 {\n fmt.Println(\"Yes\")\n } else {\n fmt.Println(\"No\")\n }\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, c int\n\tfmt.Scan(&a, &b, &c)\n\tvar x, y, z int\n\tfmt.Scan(&x, &y, &z)\n\tvar addA = a - x\n\tvar addB = b - y\n\tvar addC = c - z\n\tvar add int\n\tvar minus int\n\tif addA > 0 {\n\t\tadd += addA / 2\n\t} else {\n\t\tminus += addA\n\t}\n\tif addB > 0 {\n\t\tadd += addB / 2\n\t} else {\n\t\tminus += addB\n\t}\n\tif addC > 0 {\n\t\tadd += addC / 2\n\t} else {\n\t\tminus += addC\n\t}\n\tif add+minus >= 0 {\n\t\tfmt.Print(\"Yes\")\n\t} else {\n\t\tfmt.Print(\"No\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tstdin := bufio.NewReader(os.Stdin)\n\n\tvar a, b, c int\n\tvar tA, tB, tC int\n\t\n\tfmt.Fscanf(stdin, \"%d%d%d\\n\", &a, &b, &c)\n\tfmt.Fscanf(stdin, \"%d%d%d\\n\", &tA, &tB, &tC)\n\n\ta = a - tA\n\tb = b - tB\n\tc = c - tC\n\n\t// fmt.Println(a, b, c)\n\n\tif a < 0 {\n\t\ta = a * 2\n\t} else {\n\t\ta = a / 2 * 2\n\t}\n\tif b < 0 {\n\t\tb = b * 2\n\t} else {\n\t\tb = b / 2 * 2\n\t}\n\tif c < 0 {\n\t\tc = c * 2\n\t} else {\n\t\tc = c / 2 * 2\n\t}\n\n\tif a + b + c >= 0 {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar (\n\t\ta int\n\t\tb int\n\t\tc int\n\t\tx int\n\t\ty int\n\t\tz int\n\t)\n\tfmt.Scanf(\"%d%d%d\",&a,&b,&c)\n\tfmt.Scanf(\"%d%d%d\",&x,&y,&z)\n\tif (x > a){\n\t\tx -= a\n\t\ta = 0\n\t}else {\n\t\ta -= x\n\t\tx = 0\n\t}\n\tif (y > b){\n\t\ty -= b\n\t\tb = 0\n\t}else {\n\t\tb -= y\n\t\ty = 0\n\t}\n\tif (z > c){\n\t\tz -= c\n\t\tc = 0\n\t}else {\n\t\tc -= z\n\t\tz = 0\n\t}\n\tif (x + y + z) <= (a/2 + b/2 + c/2){\n\t\tfmt.Println(\"Yes\")\n\t}else {\n\t\tfmt.Println(\"No\")\n\t}\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar (\n\t\ta int\n\t\tb int\n\t\tc int\n\t\tx int\n\t\ty int\n\t\tz int\n\t)\n\tfmt.Scanf(\"%d%d%d\",&a,&b,&c)\n\tfmt.Scanf(\"%d%d%d\",&x,&y,&z)\n\tif (x > a){\n\t\tx -= a\n\t\ta = 0\n\t}else {\n\t\ta -= x\n\t\tx = 0\n\t}\n\tif (y > b){\n\t\ty -= b\n\t\tb = 0\n\t}else {\n\t\tb -= y\n\t\ty = 0\n\t}\n\tif (z > c){\n\t\tz -= c\n\t\tc = 0\n\t}else {\n\t\tc -= z\n\t\tz = 0\n\t}\n\tif (x + y + z) <= (a/2 + b/2 + c/2){\n\t\tfmt.Print(\"Yes\")\n\t}else {\n\t\tfmt.Print(\"No\")\n\t}\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var a, b [3]int\n for i := 0; i < 3; i++ {\n // fmt.Println(i)\n fmt.Scanf(\"%d\", &a[i])\n }\n for i := 0; i < 3; i++ {\n fmt.Scanf(\"%d\", &b[i])\n }\n acnt, bcnt := 0, 0\n for i := 0; i < 3; i++ {\n if a[i]-b[i] > 0 {\n acnt += (((a[i] - b[i]) / 2) * 2)\n } else {\n bcnt += (b[i] - a[i])\n }\n }\n //fmt.Println(acnt)\n //fmt.Println(bcnt)\n if acnt/2 >= bcnt {\n fmt.Println(\"Yes\")\n } else {\n fmt.Println(\"No\")\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tstdin := bufio.NewReader(os.Stdin)\n\n\tvar a, b, c int\n\tvar tA, tB, tC int\n\t\n\tfmt.Fscanf(stdin, \"%d%d%d\\n\", &a, &b, &c)\n\tfmt.Fscanf(stdin, \"%d%d%d\\n\", &tA, &tB, &tC)\n\n\ta = a - tA\n\tb = b - tB\n\tc = c - tC\n\n\t// fmt.Println(a, b, c)\n\n\tif a < 0 {\n\t\ta = a * 2\n\t}\n\tif b < 0 {\n\t\tb = b * 2\n\t}\n\tif c < 0 {\n\t\tc = c * 2\n\t}\n\n\tif a + b + c >= 0 {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n"}], "src_uid": "1db4ba9dc1000e26532bb73336cf12c3"} {"nl": {"description": "Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, the traffic moves only from west to east or only from east to west. Also, traffic moves only from north to south or only from south to north in each vertical street. It is possible to enter a horizontal street from a vertical street, or vice versa, at their intersection. The mayor has received some street direction patterns. Your task is to check whether it is possible to reach any junction from any other junction in the proposed street direction pattern.", "input_spec": "The first line of input contains two integers n and m, (2 ≤ n, m ≤ 20), denoting the number of horizontal streets and the number of vertical streets. The second line contains a string of length n, made of characters '<' and '>', denoting direction of each horizontal street. If the i-th character is equal to '<', the street is directed from east to west otherwise, the street is directed from west to east. Streets are listed in order from north to south. The third line contains a string of length m, made of characters '^' and 'v', denoting direction of each vertical street. If the i-th character is equal to '^', the street is directed from south to north, otherwise the street is directed from north to south. Streets are listed in order from west to east.", "output_spec": "If the given pattern meets the mayor's criteria, print a single line containing \"YES\", otherwise print a single line containing \"NO\".", "sample_inputs": ["3 3\n><>\nv^v", "4 6\n<><>\nv^v^v^"], "sample_outputs": ["NO", "YES"], "notes": "NoteThe figure above shows street directions in the second sample test case."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\ntype Vertex struct {\n\tneighbors []*Vertex\n}\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scanf(\"%d %d\\n\", &n, &m)\n\tg1 := make([][]*Vertex, n)\n\tg2 := make([][]*Vertex, n)\n\tfor i := range g1 {\n\t\tg1[i] = make([]*Vertex, m)\n\t\tg2[i] = make([]*Vertex, m)\n\t\tfor j := range g1[i] {\n\t\t\tg1[i][j] = &Vertex{neighbors: make([]*Vertex, 2)}\n\t\t\tg2[i][j] = &Vertex{neighbors: make([]*Vertex, 2)}\n\t\t}\n\t}\n\tvar horizon, vertical string\n\tfmt.Scanf(\"%s\\n\", &horizon)\n\tfmt.Scanf(\"%s\\n\", &vertical)\n\tfor i, c := range horizon {\n\t\tif c == '>' {\n\t\t\tfor j := 0; j < m-1; j++ {\n\t\t\t\tg1[i][j].neighbors[0] = g1[i][j+1]\n\t\t\t}\n\t\t\tfor j := 1; j < m; j++ {\n\t\t\t\tg2[i][j].neighbors[0] = g2[i][j-1]\n\t\t\t}\n\t\t} else {\n\t\t\tfor j := 1; j < m; j++ {\n\t\t\t\tg1[i][j].neighbors[0] = g1[i][j-1]\n\t\t\t}\n\t\t\tfor j := 0; j < m-1; j++ {\n\t\t\t\tg2[i][j].neighbors[0] = g2[i][j+1]\n\t\t\t}\n\t\t}\n\t}\n\tfor j, c := range vertical {\n\t\tif c == 'v' {\n\t\t\tfor i := 0; i < n-1; i++ {\n\t\t\t\tg1[i][j].neighbors[1] = g1[i+1][j]\n\t\t\t}\n\t\t\tfor i := 1; i < n; i++ {\n\t\t\t\tg2[i][j].neighbors[1] = g2[i-1][j]\n\t\t\t}\n\t\t} else {\n\t\t\tfor i := 1; i < n; i++ {\n\t\t\t\tg1[i][j].neighbors[1] = g1[i-1][j]\n\t\t\t}\n\t\t\tfor i := 0; i < n-1; i++ {\n\t\t\t\tg2[i][j].neighbors[1] = g2[i+1][j]\n\t\t\t}\n\n\t\t}\n\t}\n\tif dfs(g1) && dfs(g2) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nfunc dfs(g [][]*Vertex) bool {\n\tvisited := make(map[*Vertex]struct{})\n\tv := g[0][0]\n\tdfsRecurse(v, visited)\n\treturn len(visited) == len(g) * len(g[0])\n\n}\n\nfunc dfsRecurse(v *Vertex, visited map[*Vertex]struct{}) {\n\tvisited[v] = struct{}{}\n\tfor _, n := range v.neighbors {\n\t\tif n == nil {\n\t\t\tcontinue\n\t\t}\n\t\tif _, ok := visited[n]; !ok {\n\t\t\tdfsRecurse(n, visited)\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n scanner.Scan()\n ans, _ := strconv.Atoi(scanner.Text())\n return ans\n}\n\nfunc ReadString() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nvar (\n n, m, count int\n row, col string\n visited []bool\n)\n\nfunc dfs(i, j int) {\n index := i*m + j\n if i < 0 || j < 0 || i >= n || j >= m || visited[index] {\n return\n }\n\n visited[index] = true\n\n if row[i] == '>' {\n dfs(i, j+1)\n } else {\n dfs(i, j-1)\n }\n\n if col[j] == 'v' {\n dfs(i+1, j)\n } else {\n dfs(i-1, j)\n }\n}\n\nfunc main() {\n defer writer.Flush()\n scanner.Split(bufio.ScanWords)\n\n n = ReadInt32()\n m = ReadInt32()\n row = ReadString()\n col = ReadString()\n count = n * m\n f := true\n\n for i := 0; (i < n) && (f); i++ {\n for j := 0; (j < m) && (f); j++ {\n visited = make([]bool, count)\n dfs(i, j)\n for k := 0; (k < count) && (f); k++ {\n f = visited[k]\n }\n }\n }\n\n if f {\n writer.WriteString(\"YES\\n\")\n } else {\n writer.WriteString(\"NO\\n\")\n }\n}\n"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n scanner.Scan()\n ans, _ := strconv.Atoi(scanner.Text())\n return ans\n}\n\nfunc ReadString() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n defer writer.Flush()\n scanner.Split(bufio.ScanWords)\n\n n := ReadInt32()\n m := ReadInt32()\n s1 := ReadString()\n s2 := ReadString()\n count := n * m\n a := make([][]int, count)\n for i := 0; i < count; i++ {\n a[i] = make([]int, count)\n a[i][i] = 1\n }\n\n for i := 0; i < m; i++ {\n if s2[i] == 'v' {\n for j := 0; j < n-1; j++ {\n for k := j + 1; k < n; k++ {\n a[j*m+i][k*m+i] = 1\n }\n }\n } else {\n for j := n - 1; j > 0; j-- {\n for k := j - 1; k >= 0; k-- {\n a[j*m+i][k*m+i] = 1\n }\n }\n }\n }\n\n for i := 0; i < n; i++ {\n if s1[i] == '>' {\n for j := 0; j < m-1; j++ {\n for k := j + 1; k < m; k++ {\n a[i*m+j][i*m+k] = 1\n }\n }\n } else {\n for j := m - 1; j > 0; j-- {\n for k := j - 1; k >= 0; k-- {\n a[i*m+j][i*m+k] = 1\n }\n }\n }\n }\n\n for k := 0; k < count; k++ {\n for i := 0; i < count; i++ {\n for j := 0; j < count; j++ {\n if a[i][k] == 1 && a[k][j] == 1 {\n a[i][j] = 1\n }\n }\n }\n }\n\n f := true\n\n for i := 0; (i < count) && (f); i++ {\n for j := 0; (j < count) && (f); j++ {\n f = a[i][j] != 0\n }\n }\n\n if f {\n writer.WriteString(\"YES\\n\")\n } else {\n writer.WriteString(\"NO\\n\")\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scan(&n)\n\tfmt.Scan(&m)\n\tvar rows, cols string\n\tfmt.Scan(&rows)\n\tfmt.Scan(&cols)\n\tvar tl, tr, bl, br bool\n\n\tfor i := 0; i < n; i++ {\n\t\tvar direction = rows[i]\n\t\tif i == 0 {\n\t\t\tswitch direction {\n\t\t\tcase '>':\n\t\t\t\ttr = true\n\t\t\tcase '<':\n\t\t\t\ttl = true\n\t\t\t}\n\t\t}\n\t\tif i == n-1 {\n\t\t\tswitch direction {\n\t\t\tcase '>':\n\t\t\t\tbr = true\n\t\t\tcase '<':\n\t\t\t\tbl = true\n\t\t\t}\n\t\t}\n\t}\n\n\tfor i := 0; i < m; i++ {\n\t\tvar direction = cols[i]\n\t\tif i == 0 {\n\t\t\tswitch direction {\n\t\t\tcase 'v':\n\t\t\t\tbl = true\n\t\t\tcase '^':\n\t\t\t\ttl = true\n\t\t\t}\n\t\t}\n\t\tif i == m-1 {\n\t\t\tswitch direction {\n\t\t\tcase 'v':\n\t\t\t\tbr = true\n\t\t\tcase '^':\n\t\t\t\ttr = true\n\t\t\t}\n\t\t}\n\t}\n\tif tl && tr && bl && br {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\ntype Vertex struct {\n\tneighbors []*Vertex\n}\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\tg1 := make([][]*Vertex, n)\n\tg2 := make([][]*Vertex, n)\n\tfor i := range g1 {\n\t\tg1[i] = make([]*Vertex, m)\n\t\tg2[i] = make([]*Vertex, m)\n\t\tfor j := range g1[i] {\n\t\t\tg1[i][j] = &Vertex{neighbors: make([]*Vertex, 2)}\n\t\t\tg2[i][j] = &Vertex{neighbors: make([]*Vertex, 2)}\n\t\t}\n\t}\n\n\tvar horizon, vertical string\n\tfmt.Scanf(\"%s %s\", &horizon, &vertical)\n\tfor i, c := range horizon {\n\t\tif c == '>' {\n\t\t\tfor j := 0; j < m-1; j++ {\n\t\t\t\tg1[i][j].neighbors[0] = g1[i][j+1]\n\t\t\t}\n\t\t\tfor j := 1; j < m; j++ {\n\t\t\t\tg2[i][j].neighbors[0] = g2[i][j-1]\n\t\t\t}\n\t\t} else {\n\t\t\tfor j := 1; j < m; j++ {\n\t\t\t\tg1[i][j].neighbors[0] = g1[i][j-1]\n\t\t\t}\n\t\t\tfor j := 0; j < m-1; j++ {\n\t\t\t\tg2[i][j].neighbors[0] = g2[i][j+1]\n\t\t\t}\n\t\t}\n\t}\n\tfor j, c := range vertical {\n\t\tif c == 'v' {\n\t\t\tfor i := 0; i < n-1; i++ {\n\t\t\t\tg1[i][j].neighbors[1] = g1[i+1][j]\n\t\t\t}\n\t\t\tfor i := 1; i < n; i++ {\n\t\t\t\tg2[i][j].neighbors[1] = g2[i-1][j]\n\t\t\t}\n\t\t} else {\n\t\t\tfor i := 1; i < n; i++ {\n\t\t\t\tg1[i][j].neighbors[1] = g1[i-1][j]\n\t\t\t}\n\t\t\tfor i := 0; i < n-1; i++ {\n\t\t\t\tg2[i][j].neighbors[1] = g2[i+1][j]\n\t\t\t}\n\n\t\t}\n\t}\n\tif dfs(g1) && dfs(g2) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nfunc dfs(g [][]*Vertex) bool {\n\tvisited := make(map[*Vertex]struct{})\n\tv := g[0][0]\n\tdfsRecurse(v, visited)\n\treturn len(visited) == len(g) * len(g[0])\n\n}\n\nfunc dfsRecurse(v *Vertex, visited map[*Vertex]struct{}) {\n\tvisited[v] = struct{}{}\n\tfor _, n := range v.neighbors {\n\t\tif n == nil {\n\t\t\tcontinue\n\t\t}\n\t\tif _, ok := visited[n]; !ok {\n\t\t\tdfsRecurse(n, visited)\n\t\t}\n\t}\n}\n"}], "src_uid": "eab5c84c9658eb32f5614cd2497541cf"} {"nl": {"description": "Your security guard friend recently got a new job at a new security company. The company requires him to patrol an area of the city encompassing exactly N city blocks, but they let him choose which blocks. That is, your friend must walk the perimeter of a region whose area is exactly N blocks. Your friend is quite lazy and would like your help to find the shortest possible route that meets the requirements. The city is laid out in a square grid pattern, and is large enough that for the sake of the problem it can be considered infinite.", "input_spec": "Input will consist of a single integer N (1 ≤ N ≤ 106), the number of city blocks that must be enclosed by the route.", "output_spec": "Print the minimum perimeter that can be achieved.", "sample_inputs": ["4", "11", "22"], "sample_outputs": ["8", "14", "20"], "notes": "NoteHere are some possible shapes for the examples:"}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tfor i := 1; ; i++ {\n\t\tif i*i >= n {\n\t\t\tfmt.Println(4 * i)\n\t\t\treturn\n\t\t}\n\t\tif i*(i+1) >= n {\n\t\t\tfmt.Println(4*i + 2)\n\t\t\treturn\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nvar n int\n\nfunc main() {\n fmt.Scan(&n)\n sqt := math.Sqrt(float64(n))\n hight := int(sqt)\n width := 0\n if hight*hight == n {\n width = hight\n } else {\n width = hight + 1\n if hight*width < n {\n hight += 1\n }\n }\n fmt.Println(hight*2 + width*2)\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc roundUp(x float64) int {\n\treturn int(math.Floor(x + 1))\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\\n\", &n)\n\tif sqrt := math.Sqrt(float64(n)); int(sqrt)*int(sqrt) == n {\n\t\tfmt.Println(int(sqrt) * 4)\n\t\tos.Exit(0)\n\t} else {\n\t\tx := roundUp(sqrt)\n\t\ty := x\n\t\tfor {\n\t\t\tif x*y == n {\n\t\t\t\tbreak\n\t\t\t} else if x*y < n {\n\t\t\t\tx++\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tx--\n\t\t}\n\t\tfmt.Println(x*2 + y*2)\n\t\tos.Exit(0)\n\t}\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nvar (\n n, a, b int\n)\n\nfunc main() {\n fmt.Scan(&n)\n a , b = 1, 1\n for a * b < n {\n a++\n if a > b {\n a, b = b, a\n }\n }\n fmt.Println(2*(a+b))\n}\n"}], "negative_code": [], "src_uid": "414cc57550e31d98c1a6a56be6722a12"} {"nl": {"description": "Recently Adaltik discovered japanese crosswords. Japanese crossword is a picture, represented as a table sized a × b squares, and each square is colored white or black. There are integers to the left of the rows and to the top of the columns, encrypting the corresponding row or column. The number of integers represents how many groups of black squares there are in corresponding row or column, and the integers themselves represents the number of consecutive black squares in corresponding group (you can find more detailed explanation in Wikipedia https://en.wikipedia.org/wiki/Japanese_crossword).Adaltik decided that the general case of japanese crossword is too complicated and drew a row consisting of n squares (e.g. japanese crossword sized 1 × n), which he wants to encrypt in the same way as in japanese crossword. The example of encrypting of a single row of japanese crossword. Help Adaltik find the numbers encrypting the row he drew.", "input_spec": "The first line of the input contains a single integer n (1 ≤ n ≤ 100) — the length of the row. The second line of the input contains a single string consisting of n characters 'B' or 'W', ('B' corresponds to black square, 'W' — to white square in the row that Adaltik drew).", "output_spec": "The first line should contain a single integer k — the number of integers encrypting the row, e.g. the number of groups of black squares in the row. The second line should contain k integers, encrypting the row, e.g. corresponding to sizes of groups of consecutive black squares in the order from left to right.", "sample_inputs": ["3\nBBW", "5\nBWBWB", "4\nWWWW", "4\nBBBB", "13\nWBBBBWWBWBBBW"], "sample_outputs": ["1\n2", "3\n1 1 1", "0", "1\n4", "3\n4 1 3"], "notes": "NoteThe last sample case correspond to the picture in the statement."}, "positive_code": [{"source_code": "package main\n\nimport (\n \"fmt\"\n \"regexp\"\n \"strings\"\n)\n\nfunc main() {\n var n int\n fmt.Scanln(&n)\n \n var str string\n fmt.Scanln(&str)\n re := regexp.MustCompile(\"(W)*\")\n\tstr = re.ReplaceAllString(str, \"$1\")\n\t\n\tblocks := strings.Split(str, \"W\")\n if len(blocks) > 0 {\n if len(blocks[0]) == 0 {\n blocks = append(blocks[1:])\n }\n if len(blocks[len(blocks) - 1]) == 0 {\n blocks = append(blocks[:len(blocks)-1])\n }\n }\n fmt.Println(len(blocks))\n for _, block := range blocks {\n fmt.Printf(\"%v \", len(block))\n }\n}"}, {"source_code": "// A. One-dimensional Japanese Crossword\n/*\nRecently Adaltik discovered japanese crosswords. Japanese crossword is a picture, represented as a table sized a × b squares, and each square is colored white or black. There are integers to the left of the rows and to the top of the columns, encrypting the corresponding row or column. The number of integers represents how many groups of black squares there are in corresponding row or column, and the integers themselves represents the number of consecutive black squares in corresponding group (you can find more detailed explanation in Wikipedia https://en.wikipedia.org/wiki/Japanese_crossword).\n\nAdaltik decided that the general case of japanese crossword is too complicated and drew a row consisting of n squares (e.g. japanese crossword sized 1 × n), which he wants to encrypt in the same way as in japanese crossword.\n\nHelp Adaltik find the numbers encrypting the row he drew.\n\nInput\nThe first line of the input contains a single integer n (1 ≤ n ≤ 100) — the length of the row. The second line of the input contains a single string consisting of n characters 'B' or 'W', ('B' corresponds to black square, 'W' — to white square in the row that Adaltik drew).\n\nOutput\nThe first line should contain a single integer k — the number of integers encrypting the row, e.g. the number of groups of black squares in the row.\n\nThe second line should contain k integers, encrypting the row, e.g. corresponding to sizes of groups of consecutive black squares in the order from left to right.\nExamples\n\nInput\n3\nBBW\n\nOutput\n1\n2\n\nInput\n5\nBWBWB\n\nOutput\n3\n1 1 1\n\nInput\n4\nWWWW\n\nOutput\n0\n\nInput\n4\nBBBB\n\nOutput\n1\n4\n\nInput\n13\nWBBBBWWBWBBBW\n\nOutput\n3\n4 1 3\n\nNote\nThe last sample case correspond to the picture in the statement.\n*/\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput1, _ := reader.ReadString('\\n')\n\tn, _ := strconv.Atoi(strings.TrimSpace(input1))\n\n\tinput2, _ := reader.ReadString('\\n')\n\ta := strings.TrimSpace(input2)\n\n\tk, g := 0, 0\n\tarrK := []int{}\n\tfor i := 0; i < n; i++ {\n\t\tif a[i] == 'B' {\n\t\t\tk++\n\t\t} else if k > 0 {\n\t\t\tg++\n\t\t\tarrK = append(arrK, k)\n\t\t\tk = 0\n\t\t}\n\t}\n\n\tif k > 0 {\n\t\tg++\n\t\tarrK = append(arrK, k)\n\t\tk = 0\n\t}\n\n\tfmt.Println(g)\n\n\tfor _, v := range arrK {\n\t\tfmt.Printf(\"%v \", v)\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"bufio\"\nimport \"os\"\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\nfunc main() {\n\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\n\tvar n int\n\tvar s string\n\n\tfmt.Fscanf(bufin, \"%d\\n\", &n)\n\tfmt.Fscanf(bufin, \"%s\\n\", &s)\n\n\tvar res []int\n\tfor i := 0; i < n; i++ {\n\t\tif s[i] == 'B' {\n\t\t\tj := i\n\t\t\tfor (j < n) && (s[j] == 'B') {\n\t\t\t\tj++\n\t\t\t}\n\t\t\tres = append(res, j-i)\n\t\t\ti = j - 1\n\t\t}\n\t}\n\n\tfmt.Fprintf(bufout, \"%d\\n\", len(res))\n\tfor _, v := range res {\n\t\tfmt.Fprintf(bufout, \"%d \", v)\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar (\n\t\tn int\n\t\ts string\n\t)\n\tfmt.Scan(&n, &s)\n\n\tseq := []int{}\n\tfor i, v := range s {\n\t\tif v == 'B' {\n\t\t\tif i == 0 || s[i-1] == 'W' {\n\t\t\t\tseq = append(seq, 0)\n\t\t\t}\n\t\t\tseq[len(seq)-1]++\n\t\t}\n\t}\n\n\tfmt.Println(len(seq))\n\tif len(seq) == 0 {\n\t\treturn\n\t}\n\tfor i, v := range seq {\n\t\tif i != 0 {\n\t\t\tfmt.Print(\" \")\n\t\t}\n\t\tfmt.Print(v)\n\t}\n\tfmt.Println()\n}\n"}, {"source_code": "// http://acm.timus.ru/problem.aspx?space=1&num=1741\npackage main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n)\n\n// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)\n\nconst MOD = 1e9 + 7\n\nfunc main () {\n\tvar n int\n\tvar str string\n\n\t//f, _ := os.Open(\"input.txt\")\n\t//input := bufio.NewReader(f)\n\tinput := bufio.NewReader(os.Stdin)\n\n\tfmt.Fscanln(input, &n)\n\tfmt.Fscanln(input, &str)\n\n\n\n\tcnt := 0\n\tans := make([]int, 0)\n\tfor i := 0; i < len(str); i++ {\n\t\tif str[i] == 'W' {\n\t\t\tif cnt > 0 {\n\t\t\t\tans = append(ans, cnt)\n\t\t\t\tcnt = 0\n\t\t\t}\n\t\t} else {\n\t\t\tcnt++\n\t\t}\n\t}\n\n\tif cnt > 0 {\n\t\tans = append(ans, cnt)\n\t}\n\n\n\tfmt.Println(len(ans))\n\tfor i := 0; i < len(ans); i++ {\n\t\tif i != 0 {\n\t\t\tfmt.Print(\" \", ans[i])\n\t\t} else {\n\t\t\tfmt.Print(ans[i])\n\t\t}\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strings\"\n\t\"fmt\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\treader.ReadString('\\n')\n\tcs, _ := reader.ReadString('\\n')\n\n\tcodes := []string{}\n\tb := 0\n\tfor _, c := range strings.TrimSpace(cs) {\n\t\tif c == 'B' {\n\t\t\tb++\n\t\t} else {\n\t\t\tif b > 0 {\n\t\t\t\tcodes = append(codes, fmt.Sprintf(\"%d\", b))\n\t\t\t\tb = 0\n\t\t\t}\n\t\t}\n\t}\n\tif b > 0 {\n\t\tcodes = append(codes, fmt.Sprintf(\"%d\", b))\n\t}\n\n\tif len(codes) > 0 {\n\t\tfmt.Fprintln(os.Stdout, len(codes))\n\t\tfmt.Fprintln(os.Stdout, strings.Join(codes, \" \"))\n\t} else {\n\t\tfmt.Fprintln(os.Stdout, 0)\n\t}\n\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tvar str string\n\tfmt.Scanf(\"%d\\n%s\", &n, &str)\n\n\tvar counter int\n\tvar answer []int\n\tfor i := 0; i <= n; i++ {\n\t\tif (i == n || (i != 0 && str[i-1] != str[i])) && counter != 0 {\n\t\t\tanswer = append(answer, counter)\n\t\t\tcounter = 0\n\t\t}\n\t\tif i < n && str[i] == 'B' {\n\t\t\tcounter++\n\t\t}\n\t}\n\n\tfmt.Println(len(answer))\n\tfor _, a := range answer {\n\t\tfmt.Printf(\"%d \", a)\n\t}\n\tfmt.Println()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tvar str string\n\tfmt.Scanf(\"%d\\n%s\", &n, &str)\n\n\tvar counter int\n\tvar answer []int\n\tfor i := 0; i <= n; i++ {\n\t\tif (i == n || (i != 0 && str[i-1] != str[i])) && counter != 0 {\n\t\t\tanswer = append(answer, counter)\n\t\t\tcounter = 0\n\t\t}\n\t\tif i < n && str[i] == 'B' {\n\t\t\tcounter++\n\t\t}\n\t}\n\n\tfmt.Println(len(answer))\n\tfor _, a := range answer {\n\t\tfmt.Printf(\"%d \", a)\n\t}\n\tfmt.Println()\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n fmt.Scan(&n)\n groups := make([]int, n)\n var s string\n fmt.Scan(&s)\n s += \"W\"\n var lastRune rune = 'W'\n var groupCnt int\n var curGroup int\n for _, r := range s {\n if r == 'B' {\n curGroup++\n if lastRune == 'W' {\n groupCnt++\n }\n lastRune = 'B'\n } else if r == 'W' {\n if lastRune == 'B' {\n groups[groupCnt-1] = curGroup\n }\n lastRune = 'W'\n curGroup = 0\n }\n }\n fmt.Print(groupCnt, \"\\n\")\n for i:=0; i < groupCnt; i++ {\n fmt.Print(groups[i], \" \")\n }\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tfsc := NewFastScanner()\n\tN := fsc.NextInt()\n\t_ = N\n\tstr := fsc.Next()\n\tvar ans []int\n\tvar res int\n\n\tfor i := 0; i < len(str); i++ {\n\t\tif str[i] == 'B' {\n\t\t\tres++\n\t\t} else {\n\t\t\tif res > 0 {\n\t\t\t\tans = append(ans, res)\n\t\t\t}\n\t\t\tres = 0\n\t\t}\n\t}\n\tif res > 0 {\n\t\tans = append(ans, res)\n\t}\n\tfmt.Println(len(ans))\n\tfor i := 0; i < len(ans); i++ {\n\t\tfmt.Print(ans[i], \" \")\n\t}\n}\n\n//template\ntype FastScanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewFastScanner() *FastScanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 2028)\n\treturn &FastScanner{r: rdr}\n}\n\nfunc (s *FastScanner) Next() string {\n\ts.Pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\n\nfunc (s *FastScanner) NextInt() int {\n\tval, err := strconv.Atoi(s.Next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn val\n}\nfunc (s *FastScanner) NextInt64() int64 {\n\tval, err := strconv.ParseInt(s.Next(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn val\n}\nfunc (s *FastScanner) Pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.ReadLine()\n\t\ts.p = 0\n\t}\n}\n\nfunc (s *FastScanner) ReadLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, err := s.r.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err.Error())\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strings\"\n\t\"fmt\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\treader.ReadString('\\n')\n\tcs, _ := reader.ReadString('\\n')\n\n\tcodes := []string{}\n\tb := 0\n\tfor _, c := range strings.TrimSpace(cs) {\n\t\tif c == 'B' {\n\t\t\tb++\n\t\t} else {\n\t\t\tif b > 0 {\n\t\t\t\tcodes = append(codes, fmt.Sprintf(\"%d\", b))\n\t\t\t\tb = 0\n\t\t\t}\n\t\t}\n\t}\n\tif b > 0 {\n\t\tcodes = append(codes, fmt.Sprintf(\"%d\", b))\n\t}\n\n\tif len(codes) > 0 {\n\t\tfmt.Println(strings.Join(codes, \" \"))\n\t} else {\n\t\tfmt.Println(0)\n\t}\n\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strings\"\n\t\"fmt\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\treader.ReadString('\\n')\n\tcs, _ := reader.ReadString('\\n')\n\n\tcodes := []string{}\n\tb := 0\n\tfor _, c := range strings.TrimSpace(cs) {\n\t\tif c == 'B' {\n\t\t\tb++\n\t\t} else {\n\t\t\tif b > 0 {\n\t\t\t\tcodes = append(codes, fmt.Sprintf(\"%d\", b))\n\t\t\t\tb = 0\n\t\t\t}\n\t\t}\n\t}\n\tif b > 0 {\n\t\tcodes = append(codes, fmt.Sprintf(\"%d\", b))\n\t}\n\n\tif len(codes) > 0 {\n\t\tfmt.Fprintln(os.Stdout, strings.Join(codes, \" \"))\n\t} else {\n\t\tfmt.Fprintln(os.Stdout, 0)\n\t}\n\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tvar str string\n\tfmt.Scanf(\"%d\\n%s\", &n, &str)\n\n\tvar counter int\n\tfor i := 0; i <= n; i++ {\n\t\tif (i == n || (i != 0 && str[i-1] != str[i])) && counter != 0 {\n\t\t\tfmt.Printf(\"%d \", counter)\n\t\t\tcounter = 0\n\t\t}\n\t\tif i < n && str[i] == 'B' {\n\t\t\tcounter++\n\t\t}\n\t}\n\tfmt.Println()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n\tscanner.Scan()\n\tans, _ := strconv.Atoi(scanner.Text())\n\treturn ans\n}\n\nfunc PrintInts(ints ...int) {\n\tfor _, value := range ints {\n\t\twriter.WriteString(strconv.Itoa(value))\n\t\twriter.WriteByte(' ')\n\t}\n}\n\nfunc main() {\n\t//fmt.Scanf(\"%d%d\",&n, &k)\n\tscanner.Split(bufio.ScanWords)\n\tvar row string\n\tvar length, index int\n\tvar arr [100]int\n\t_ = ReadInt32()\n\tfmt.Scanf(\"%s\", &row)\n\tfor i := 0; i < len(row); i++ {\n\t\tif row[i] == 'B' {\n\t\t\tlength++\n\t\t} else if row[i] != 'B' && length > 0 {\n\t\t\tarr[index] = length\n\t\t\tindex++\n\t\t\tlength = 0\n\t\t}\n\t}\n\tif length != 0 {\n\t\tarr[index] = length\n\t\tindex++\n\t}\n\tfmt.Printf(\"%d\", index)\n\tif index > 0 {\n\t\tfmt.Printf(\"\\n%d\", arr[0])\n\t}\n\tfor i := 1; i < index; i++ {\n\t\tfmt.Printf(\" %d\", arr[i])\n\t}\n\tfmt.Printf(\"\\n\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n\tscanner.Scan()\n\tans, _ := strconv.Atoi(scanner.Text())\n\treturn ans\n}\n\nfunc PrintInts(ints ...int) {\n\tfor _, value := range ints {\n\t\twriter.WriteString(strconv.Itoa(value))\n\t\twriter.WriteByte(' ')\n\t}\n}\n\nfunc main() {\n\t//fmt.Scanf(\"%d%d\",&n, &k)\n\tscanner.Split(bufio.ScanWords)\n\tvar row string\n\tvar length, index int\n\tvar arr [100]int\n\t_ = ReadInt32()\n\tfmt.Scanf(\"%s\", &row)\n\tfor i := 0; i < len(row); i++ {\n\t\tif row[i] == 'B' {\n\t\t\tlength++\n\t\t} else if row[i] != 'B' && length > 0 {\n\t\t\tarr[index] = length\n\t\t\tindex++\n\t\t\tlength = 0\n\t\t}\n\t}\n\tif length != 0 {\n\t\tarr[index] = length\n\t\tindex++\n\t}\n\tfmt.Printf(\"%d\", index)\n\tif index > 0 {\n\t\tfmt.Printf(\"\\n%d\", arr[0])\n\t}\n\tfor i := 1; i < index; i++ {\n\t\tfmt.Printf(\" %d\", arr[i])\n\t}\n\tfmt.Printf(\"\\n\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n\tscanner.Scan()\n\tans, _ := strconv.Atoi(scanner.Text())\n\treturn ans\n}\n\nfunc PrintInts(ints ...int) {\n\tfor _, value := range ints {\n\t\twriter.WriteString(strconv.Itoa(value))\n\t\twriter.WriteByte(' ')\n\t}\n}\n\nfunc main() {\n\t//fmt.Scanf(\"%d%d\",&n, &k)\n\tscanner.Split(bufio.ScanWords)\n\tvar row string\n\tvar length, index int\n\tvar arr [100]int\n\t_ = ReadInt32()\n\tfmt.Scanf(\"%s\", &row)\n\tfor i := 0; i < len(row); i++ {\n\t\tif row[i] == 'B' {\n\t\t\tlength++\n\t\t} else if row[i] != 'B' && length > 0 {\n\t\t\tarr[index] = length\n\t\t\tindex++\n\t\t\tlength = 0\n\t\t}\n\t}\n\tif length != 0 {\n\t\tarr[index] = length\n\t\tindex++\n\t}\n\tfmt.Println(index)\n\tfor i := 0; i < index; i++ {\n\t\tfmt.Println(arr[i], \" \")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tfsc := NewFastScanner()\n\tN := fsc.NextInt()\n\t_ = N\n\tstr := fsc.Next()\n\tvar ans []int\n\tvar res int\n\n\tfor i := 0; i < len(str); i++ {\n\t\tif str[i] == 'B' {\n\t\t\tres++\n\t\t} else {\n\t\t\tif res > 0 {\n\t\t\t\tans = append(ans, res)\n\t\t\t}\n\t\t\tres = 0\n\t\t}\n\t}\n\tfmt.Println(len(ans))\n\tfor i := 0; i < len(ans); i++ {\n\t\tfmt.Print(ans[i], \" \")\n\t}\n}\n\n//template\ntype FastScanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewFastScanner() *FastScanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 2028)\n\treturn &FastScanner{r: rdr}\n}\n\nfunc (s *FastScanner) Next() string {\n\ts.Pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\n\nfunc (s *FastScanner) NextInt() int {\n\tval, err := strconv.Atoi(s.Next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn val\n}\nfunc (s *FastScanner) NextInt64() int64 {\n\tval, err := strconv.ParseInt(s.Next(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn val\n}\nfunc (s *FastScanner) Pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.ReadLine()\n\t\ts.p = 0\n\t}\n}\n\nfunc (s *FastScanner) ReadLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, err := s.r.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err.Error())\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n"}], "src_uid": "e4b3a2707ba080b93a152f4e6e983973"} {"nl": {"description": "Little Petya has recently started attending a programming club. Naturally he is facing the problem of choosing a programming language. After long considerations he realized that Java is the best choice. The main argument in favor of choosing Java was that it has a very large integer data type, called BigInteger.But having attended several classes of the club, Petya realized that not all tasks require using the BigInteger type. It turned out that in some tasks it is much easier to use small data types. That's why a question arises: \"Which integer type to use if one wants to store a positive integer n?\"Petya knows only 5 integer types:1) byte occupies 1 byte and allows you to store numbers from  - 128 to 1272) short occupies 2 bytes and allows you to store numbers from  - 32768 to 327673) int occupies 4 bytes and allows you to store numbers from  - 2147483648 to 21474836474) long occupies 8 bytes and allows you to store numbers from  - 9223372036854775808 to 92233720368547758075) BigInteger can store any integer number, but at that it is not a primitive type, and operations with it are much slower.For all the types given above the boundary values are included in the value range.From this list, Petya wants to choose the smallest type that can store a positive integer n. Since BigInteger works much slower, Peter regards it last. Help him.", "input_spec": "The first line contains a positive number n. It consists of no more than 100 digits and doesn't contain any leading zeros. The number n can't be represented as an empty string. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).", "output_spec": "Print the first type from the list \"byte, short, int, long, BigInteger\", that can store the natural number n, in accordance with the data given above.", "sample_inputs": ["127", "130", "123456789101112131415161718192021222324"], "sample_outputs": ["byte", "short", "BigInteger"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\n//import \"strconv\"\n\nfunc main(){\n\tvar n string\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tn = r.Text()\n\tl := len(n)\n\tif l < 3 || (l == 3 && n < \"128\") {\n\t\tw.WriteString(\"byte\")\n\t} else if l < 5 || (l == 5 && n < \"32768\") {\n\t\tw.WriteString(\"short\")\n\t} else if l < 10 || (l == 10 && n < \"2147483648\") {\n\t\tw.WriteString(\"int\")\n\t} else if l < 19 || (l == 19 && n < \"9223372036854775808\") {\n\t\tw.WriteString(\"long\")\n\t} else {\n\t\tw.WriteString(\"BigInteger\")\n\t}\n\tw.WriteString(\"\\n\")\n\tw.Flush()\n}\n"}, {"source_code": "// 66A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x string\n\tfmt.Scan(&x)\n\tif len(x) < 3 || (len(x) == 3 && x <= \"127\") {\n\t\tfmt.Print(\"byte\")\n\t} else if len(x) < 5 || (len(x) == 5 && x <= \"32767\") {\n\t\tfmt.Print(\"short\")\n\t} else if len(x) < 10 || (len(x) == 10 && x <= \"2147483647\") {\n\t\tfmt.Print(\"int\")\n\t} else if len(x) < 19 || (len(x) == 19 && x <= \"9223372036854775807\") {\n\t\tfmt.Print(\"long\")\n\t} else {\n\t\tfmt.Print(\"BigInteger\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x string\n\tfmt.Scan(&x)\n\tif len(x) < 3 || (len(x) == 3 && x <= \"127\") {\n\t\tfmt.Print(\"byte\")\n\t} else if len(x) < 5 || (len(x) == 5 && x <= \"32767\") {\n\t\tfmt.Print(\"short\")\n\t} else if len(x) < 10 || (len(x) == 10 && x <= \"2147483647\") {\n\t\tfmt.Print(\"int\")\n\t} else if len(x) < 19 || (len(x) == 19 && x <= \"9223372036854775807\") {\n\t\tfmt.Print(\"long\")\n\t} else {\n\t\tfmt.Print(\"BigInteger\")\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\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\tif n <= 127 {\n\t\tw.WriteString(\"byte\")\n\t} else if n <= 32767 {\n\t\tw.WriteString(\"short\")\n\t} else if n <= 2147483647 {\n\t\tw.WriteString(\"int\")\n\t} else if n <= 9223372036854775807 {\n\t\tw.WriteString(\"long\")\n\t} else {\n\t\tw.WriteString(\"BigInteger\")\n\t}\n\tw.WriteString(\"\\n\")\n\tw.Flush()\n}\n"}, {"source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\n\nfunc main(){\n\tvar n float64\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tn, _ = strconv.ParseFloat(r.Text(), 64)\n\tif n >=0 {\n\t\tw.WriteString(\"byte\")\n\t} else if n >= 128 {\n\t\tw.WriteString(\"short\")\n\t} else if n >= 32768 {\n\t\tw.WriteString(\"int\")\n\t} else if n >= 2147483648 {\n\t\tw.WriteString(\"long\")\n\t} else if n >= 9223372036854775808 {\n\t\tw.WriteString(\"BigInteger\")\n\t}\n\tw.WriteString(\"\\n\")\n\tw.Flush()\n}\n"}, {"source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\n//import \"strconv\"\n\nfunc main(){\n\tvar n string\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tn = r.Text()\n\tl := len(n)\n\tif n >= \"0\" && n < \"128\" && l <= 3 {\n\t\tw.WriteString(\"byte\")\n\t} else if n >= \"128\" && n < \"32768\" && l <= 5 {\n\t\tw.WriteString(\"short\")\n\t} else if n >= \"32768\" && n < \"2147483648\" && l <= 10 {\n\t\tw.WriteString(\"int\")\n\t} else if n >= \"2147483648\" && n < \"9223372036854775808\" && l <= 19 {\n\t\tw.WriteString(\"long\")\n\t} else {\n\t\tw.WriteString(\"BigInteger\")\n\t}\n\tw.WriteString(\"\\n\")\n\tw.Flush()\n}\n"}, {"source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\n\nfunc main(){\n\tvar n float64\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tn, _ = strconv.ParseFloat(r.Text(), 64)\n\tif n <= 127 {\n\t\tw.WriteString(\"byte\")\n\t} else if n <= 32767 {\n\t\tw.WriteString(\"short\")\n\t} else if n <= 2147483647 {\n\t\tw.WriteString(\"int\")\n\t} else if n <= 9223372036854775807 {\n\t\tw.WriteString(\"long\")\n\t} else {\n\t\tw.WriteString(\"BigInteger\")\n\t}\n\tw.WriteString(\"\\n\")\n\tw.Flush()\n}\n"}, {"source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\n//import \"strconv\"\n\nfunc main(){\n\tvar n string\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tn = r.Text()\n\tl := len(n)\n\tif n >= \"0\" && n < \"128\" && l <= 3 {\n\t\tw.WriteString(\"byte\")\n\t} else if n >= \"128\" && n < \"32768\" && l <= 5 {\n\t\tw.WriteString(\"short\")\n\t} else if n >= \"32768\" && n < \"2147483648\" && l <= 10 {\n\t\tw.WriteString(\"int\")\n\t} else if n >= \"2147483648\" && n < \"9223372036854775808\" && l <= 19 {\n\t\tw.WriteString(\"long\")\n\t} else {\n\t\tw.WriteString(\"BigInteger\")\n\t}\n\tw.WriteString(\"\\n\")\n\tw.Flush()\n}\n"}, {"source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\n\nfunc main(){\n\tvar n float64\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tn, _ = strconv.ParseFloat(r.Text(), 64)\n\tif n == 9223372036854775808 {\n\t\tw.WriteString(\"BigInteger\")\n\t} else if n <= 127 {\n\t\tw.WriteString(\"byte\")\n\t} else if n <= 32767 {\n\t\tw.WriteString(\"short\")\n\t} else if n <= 2147483647 {\n\t\tw.WriteString(\"int\")\n\t} else if n <= 9223372036854775807 {\n\t\tw.WriteString(\"long\")\n\t} else {\n\t\tw.WriteString(\"BigInteger\")\n\t}\n\tw.WriteString(\"\\n\")\n\tw.Flush()\n}\n"}, {"source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\n\nfunc main(){\n\tvar n string\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tn = r.Text()\n\tif n <= \"127\" {\n\t\tw.WriteString(\"byte\")\n\t} else if n <= \"32767\" {\n\t\tw.WriteString(\"short\")\n\t} else if n <= \"2147483647\" {\n\t\tw.WriteString(\"int\")\n\t} else if n <= \"9223372036854775807\" {\n\t\tw.WriteString(\"long\")\n\t} else {\n\t\tw.WriteString(\"BigInteger\")\n\t}\n\tw.WriteString(\"\\n\")\n\tw.Flush()\n}\n"}], "src_uid": "33041f1832fa7f641e37c4c638ab08a1"} {"nl": {"description": "Petya is a big fan of mathematics, especially its part related to fractions. Recently he learned that a fraction is called proper iff its numerator is smaller than its denominator (a < b) and that the fraction is called irreducible if its numerator and its denominator are coprime (they do not have positive common divisors except 1).During his free time, Petya thinks about proper irreducible fractions and converts them to decimals using the calculator. One day he mistakenly pressed addition button ( + ) instead of division button (÷) and got sum of numerator and denominator that was equal to n instead of the expected decimal notation. Petya wanted to restore the original fraction, but soon he realized that it might not be done uniquely. That's why he decided to determine maximum possible proper irreducible fraction such that sum of its numerator and denominator equals n. Help Petya deal with this problem. ", "input_spec": "In the only line of input there is an integer n (3 ≤ n ≤ 1000), the sum of numerator and denominator of the fraction.", "output_spec": "Output two space-separated positive integers a and b, numerator and denominator of the maximum possible proper irreducible fraction satisfying the given sum.", "sample_inputs": ["3", "4", "12"], "sample_outputs": ["1 2", "1 3", "5 7"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc nod(a, b int) int {\n\tfor b != 0 {\n\t\ta, b = b, a%b\n\t}\n\treturn a\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tfor a := n / 2; a > 0; a-- {\n\t\tb := n - a\n\t\tif nod(a, b) == 1 {\n\t\t\tfmt.Println(a, b)\n\t\t\treturn\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tn int\n\t)\n\tfmt.Scan(&n)\n\ta, b := Calculate854A(n)\n\tfmt.Print(a, b)\n}\n\nfunc Calculate854A(n int) (int, int) {\n\tfor a := n / 2; a > 0; a-- {\n\t\tvar b = n - a\n\t\tif Gcd(a, b) == 1 {\n\t\t\treturn a, b\n\t\t}\n\t}\n\treturn 0, 0\n}\n\nfunc Gcd(a int, b int) (int) {\n\tfor b != 0 {\n\t\ta, b = b, a%b\n\t}\n\treturn a\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tn int\n\t)\n\tfmt.Scan(&n)\n\ta, b := Calculate854A(n)\n\tfmt.Print(a, b)\n}\n\nfunc Calculate854A(n int) (int, int) {\n\tvar maxA = 0\n\tvar maxB = 0\n\tfor i := 1; i < n; i++ {\n\t\tvar a = i\n\t\tvar b = n - i\n\t\tif a >= b {\n\t\t\tbreak\n\t\t}\n\t\tif Gcd(a, b) == 1 {\n\t\t\tmaxA = a\n\t\t\tmaxB = b\n\t\t}\n\t}\n\treturn maxA, maxB\n}\n\nfunc Gcd(a int, b int) (int) {\n\tfor b != 0 {\n\t\ta, b = b, a%b\n\t}\n\treturn a\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc gcd(a, b int) int {\n\tif b == 0 {\n\t\treturn a\n\t}\n\tif a < b {\n\t\treturn gcd(b, a)\n\t} else {\n\t\treturn gcd(b, a%b)\n\t}\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tfor i := n/2; i >= 1; i-- {\n\t\tif gcd(i, n-i) == 1 {\n\t\t\tfmt.Println(i, n-i)\n\t\t\tbreak\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt()\n\tansA := 0\n\tansB := 0\n\tfor i := 1; i <= n; i++ {\n\t\ta := i\n\t\tb := n - i\n\t\tif a < b {\n\t\t\tok := true\n\t\t\tfor j := 2; j <= a; j++ {\n\t\t\t\tif a%j == 0 && b%j == 0 {\n\t\t\t\t\tok = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ok {\n\t\t\t\tansA = a\n\t\t\t\tansB = b\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Printf(\"%d %d\\n\", ansA, ansB)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int;\n\tfmt.Scan(&n);\n\tvar an, bn int = 0, 1;\n\tvar ch bool;\n\tfor i := 1; i <= n / 2; i++ {\n\n\t\tb := n - i;\n\t\tif b < i {\n\t\t\tbreak;\n\t\t}\n\t\tch = true;\n\t\tfor a := 2; a <= i; a++ {\n\t\t\tif (i % a == 0) && (b % a == 0) {\n\t\t\t\tch = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ch && bn * i > an * b {\n\t\t\tan, bn = i, b;\n\t\t}\n\t}\n\tfmt.Print(an,\" \" , bn);\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc gcd(a int, b int) int {\n if b == 0 {\n return a\n }\n if a < b {\n return gcd(b, a)\n } else {\n return gcd(b, a%b)\n }\n}\n\nvar num int\n\nfunc main() {\n fmt.Scan(&num)\n div := num / 2\n for i := div; div >= 1; i-- {\n if gcd(i, num-i) == 1 {\n fmt.Println(i, num-i)\n break\n }\n }\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc gcd(a int32,b int32)(int32){\n\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\tvar n int32\n\tfmt.Scanf(\"%d\",&n)\n\tvalue:=float64(0)\n\tvar x,y int32\n\tfor i:=int32(1);i<=1000;i++{\n\t\tfor j:=int32(i);j<=1000;j++{\n\t\t\tif(i+j==n&&gcd(i,j)==1){\n\t\t\t\tvar a,b float64\n\t\t\t\ta=float64(i)\n\t\t\t\tb=float64(j)\n\t\t\t\ttvalue:=a/b\n\t\t\t\tif(tvalue>value){\n\t\t\t\t\tx=int32(a)\n\t\t\t\t\ty=int32(b)\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\t}\n\n\tfmt.Printf(\"%d %d\",x,y)\n\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc vzaimnoProst(a, b int) bool {\n\treturn gcd(a, b) == 1\n}\n\nfunc gcd(a, b int) int {\n\tfor a != b {\n\t\tif a > b {\n\t\t\ta -= b\n\t\t} else {\n\t\t\tb -= a\n\t\t}\n\t}\n\n\treturn a\n}\n\nfunc main() {\n\tvar a, b, n int\n\tfmt.Scanf(\"%d\", &n)\n\tif n%2 == 0 {\n\t\ta = n/2 - 1\n\t\tb = n/2 + 1\n\t} else {\n\t\ta = n / 2\n\t\tb = n/2 + 1\n\t}\n\tfor !vzaimnoProst(a, b) {\n\t\ta--\n\t\tb++\n\t}\n\tfmt.Println(a, b)\n}"}, {"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\n\tfor a := N / 2; a >= 1; a-- {\n\t\tif gcd(a, N-a) == 1 {\n\t\t\tfmt.Println(a, N-a)\n\t\t\treturn\n\t\t}\n\t}\n}\n\nfunc gcd(a, b int) int {\n\tfor b > 0 {\n\t\ta, b = b, a%b\n\t}\n\treturn a\n}\n\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"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, x, a, b int\n\tfmt.Scan(&n)\n\tfor x = n / 2; x > 0; x-- {\n\t\tfor a, b = n-x, x; b != 0; {\n\t\t\ta, b = b, a%b\n\t\t}\n\t\tif a == 1 {\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(x, n-x)\n}\n"}, {"source_code": "// cf854a project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar a, b int\n\tfor i := n / 2; ; i-- {\n\t\ta = i\n\t\tb = n - a\n\t\tflag := true\n\t\tfor j := a; j > 1; j-- {\n\t\t\tif a%j == 0 && b%j == 0 {\n\t\t\t\tflag = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif flag {\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(a, b)\n}"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tn int\n\t)\n\tfmt.Scan(&n)\n\ta, b := Calculate854A(n)\n\tfmt.Print(a, b)\n}\n\nfunc Calculate854A(n int) (int, int) {\n\tvar maxA = 0\n\tvar maxB = 0\n\tfor i := 1; i < n; i++ {\n\t\tvar a = i\n\t\tvar b = n - i\n\t\tif a >= b {\n\t\t\tbreak\n\t\t}\n\t\tif Gcd(a, b) != 0 {\n\t\t\tmaxA = a\n\t\t\tmaxB = b\n\t\t}\n\t}\n\treturn maxA, maxB\n}\n\nfunc Gcd(a int, b int) (int) {\n\tfor b != 0 {\n\t\ta, b = b, a%b\n\t}\n\treturn a\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar a, b int\n\tif n %2 == 0{\n\t\ta = n/2-1\n\t\tb = n/2+1\n\t} else {\n\t\ta = n/2\n\t\tb = n/2+1\n\t}\n\tfmt.Println(a, \" \", b)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt()\n\tansA := 0\n\tansB := 0\n\tfor i := 1; i <= n; i++ {\n\t\ta := i\n\t\tb := n - i\n\t\tif a < b {\n\t\t\tok := true\n\t\t\tfor j := 2; j < a; j++ {\n\t\t\t\tif a%j == 0 && b%j == 0 {\n\t\t\t\t\tok = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ok {\n\t\t\t\tansA = a\n\t\t\t\tansB = b\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Printf(\"%d %d\\n\", ansA, ansB)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}, {"source_code": "package main\n\nimport ()\n\nfunc main() {\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc vzaimnoProst(a, b int) bool {\n\treturn gcd(a, b) == 1\n}\n\nfunc gcd(a, b int) int {\n\tfor a != b {\n\t\tif a > b {\n\t\t\ta -= b\n\t\t} else {\n\t\t\tb -= a\n\t\t}\n\t}\n\n\treturn a\n}\n\nfunc main() {\n\tvar a, b, n int\n\tfmt.Scanf(\"%d\", &n)\n\tif n%2 == 0 {\n\t\ta = n/2 - 1\n\t\tb = n/2 + 1\n\t} else {\n\t\ta = n / 2\n\t\tb = n/2 + 1\n\t}\n\tfor !vzaimnoProst(a, b) {\n\t\ta++\n\t\tb--\n\t}\n\tfmt.Println(a, b)\n}"}], "src_uid": "0af3515ed98d9d01ce00546333e98e77"} {"nl": {"description": "Vasya has a non-negative integer n. He wants to round it to nearest integer, which ends up with 0. If n already ends up with 0, Vasya considers it already rounded.For example, if n = 4722 answer is 4720. If n = 5 Vasya can round it to 0 or to 10. Both ways are correct.For given n find out to which integer will Vasya round it.", "input_spec": "The first line contains single integer n (0 ≤ n ≤ 109) — number that Vasya has.", "output_spec": "Print result of rounding n. Pay attention that in some cases answer isn't unique. In that case print any correct answer.", "sample_inputs": ["5", "113", "1000000000", "5432359"], "sample_outputs": ["0", "110", "1000000000", "5432360"], "notes": "NoteIn the first example n = 5. Nearest integers, that ends up with zero are 0 and 10. Any of these answers is correct, so you can print 0 or 10."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n fmt.Scan(&n)\n ans := 10 * (n / 10)\n if n % 10 > 5 {\n ans += 10\n }\n fmt.Println(ans)\n}\n\n"}, {"source_code": "package main\nimport \"fmt\"\nfunc main() {\n var n uint64\n fmt.Scan(&n)\n if n%10 > 5 {\n fmt.Print(n+(10-(n%10)))\n } else {\n fmt.Print(n-(n%10))\n }\n}"}, {"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\tv := n % 10\n\tif v > 5 {\n\t\tn += 10 - v\n\t} else {\n\t\tn -= v\n\t}\n\tfmt.Println(n)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}, {"source_code": "\npackage main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\nvar helper SHelper\n\nfunc main() {\n\thelper.Init()\n\tn := helper.ReadInt64()\n\tl := n / 10\n\tr := n % 10\n\tif r == 0 {\n\t\tfmt.Println(n)\n\t} else if r <= 5 {\n\t\tfmt.Println(l * 10)\n\t} else {\n\t\tfmt.Println((l + 1) * 10)\n\t}\n}\n\ntype SHelper struct {\n\tfile *os.File\n\tscanner *bufio.Scanner\n}\n\nfunc (this *SHelper) Init() {\n\tthis.file = os.Stdin\n\tthis.scanner = bufio.NewScanner(this.file)\n\tthis.scanner.Split(bufio.ScanWords)\n}\n\nfunc (this *SHelper) ReadInt64() int64 {\n\tthis.scanner.Scan()\n\tn, err:= strconv.ParseInt(this.scanner.Text(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n uint64\n fmt.Scan(&n)\n last := n%10\n if last <= 5 {\n n = n - last\n } else {\n n = n + (10 - last)\n }\n fmt.Print(n)\n}"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n fmt.Scan(&n)\n n = n - n%10\n fmt.Print(n)\n}"}], "src_uid": "29c4d5fdf1328bbc943fa16d54d97aa9"} {"nl": {"description": "After playing Neo in the legendary \"Matrix\" trilogy, Keanu Reeves started doubting himself: maybe we really live in virtual reality? To find if this is true, he needs to solve the following problem.Let's call a string consisting of only zeroes and ones good if it contains different numbers of zeroes and ones. For example, 1, 101, 0000 are good, while 01, 1001, and 111000 are not good.We are given a string $$$s$$$ of length $$$n$$$ consisting of only zeroes and ones. We need to cut $$$s$$$ into minimal possible number of substrings $$$s_1, s_2, \\ldots, s_k$$$ such that all of them are good. More formally, we have to find minimal by number of strings sequence of good strings $$$s_1, s_2, \\ldots, s_k$$$ such that their concatenation (joining) equals $$$s$$$, i.e. $$$s_1 + s_2 + \\dots + s_k = s$$$.For example, cuttings 110010 into 110 and 010 or into 11 and 0010 are valid, as 110, 010, 11, 0010 are all good, and we can't cut 110010 to the smaller number of substrings as 110010 isn't good itself. At the same time, cutting of 110010 into 1100 and 10 isn't valid as both strings aren't good. Also, cutting of 110010 into 1, 1, 0010 isn't valid, as it isn't minimal, even though all $$$3$$$ strings are good.Can you help Keanu? We can show that the solution always exists. If there are multiple optimal answers, print any.", "input_spec": "The first line of the input contains a single integer $$$n$$$ ($$$1\\le n \\le 100$$$) — the length of the string $$$s$$$. The second line contains the string $$$s$$$ of length $$$n$$$ consisting only from zeros and ones.", "output_spec": "In the first line, output a single integer $$$k$$$ ($$$1\\le k$$$) — a minimal number of strings you have cut $$$s$$$ into. In the second line, output $$$k$$$ strings $$$s_1, s_2, \\ldots, s_k$$$ separated with spaces. The length of each string has to be positive. Their concatenation has to be equal to $$$s$$$ and all of them have to be good. If there are multiple answers, print any.", "sample_inputs": ["1\n1", "2\n10", "6\n100011"], "sample_outputs": ["1\n1", "2\n1 0", "2\n100 011"], "notes": "NoteIn the first example, the string 1 wasn't cut at all. As it is good, the condition is satisfied.In the second example, 1 and 0 both are good. As 10 isn't good, the answer is indeed minimal.In the third example, 100 and 011 both are good. As 100011 isn't good, the answer is indeed minimal."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar read = bufio.NewReader(os.Stdin)\n\tvar write = bufio.NewWriter(os.Stdout)\n\tdefer write.Flush()\n\tvar n int\n\tfmt.Fscan(read, &n)\n\tvar s string\n\tfmt.Fscan(read, &s)\n\tif n%2 == 1 {\n\t\tfmt.Fprintln(write, 1)\n\t\tfmt.Fprint(write, s)\n\t\treturn\n\t}\n\tvar a = strings.Split(s, \"\")\n\tvar n1, n0 int\n\tfor i := 0; i < n; i++ {\n\t\tif a[i] == \"1\" {\n\t\t\tn1++\n\t\t} else {\n\t\t\tn0++\n\t\t}\n\t}\n\tif n1 != n0 {\n\t\tfmt.Fprintln(write, 1)\n\t\tfmt.Fprint(write, s)\n\t\treturn\n\t}\n\tfmt.Fprintln(write, 2)\n\tfor i := 0; i < n-1; i++ {\n\t\tfmt.Fprint(write, a[i])\n\t}\n\tfmt.Fprint(write, \" \", a[n-1])\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a string\n\tvar n, cnt int\n\t// var x float64\n\t// var s string\n\t// scr := bufio.NewReader(os.Stdin)\n\t// ocr := bufio.NewWriter(os.Stdout)\n\n\tfmt.Scanln(&n)\n\tfmt.Scanln(&a)\n\tm := make(map[string]int)\n\n\tm = count(a, m)\n\n\tif m[\"1\"] == m[\"0\"] {\n\t\tcnt = 2\n\t} else {\n\t\tcnt = 1\n\t}\n\n\tfmt.Println(cnt)\n\n\tif cnt == 2 {\n\t\tfor x := range a {\n\t\t\tm2 := make(map[string]int)\n\t\t\tm1 := make(map[string]int)\n\t\t\tif x > 0 {\n\t\t\t\tm2 = count(a[:x], m2)\n\t\t\t\tm1 = count(a[x:], m1)\n\t\t\t\tif (m2[\"1\"] != m2[\"0\"]) && (m1[\"0\"] != m1[\"1\"]) {\n\t\t\t\t\tfmt.Println(a[:x], \" \", a[x:])\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t} else {\n\t\tfmt.Println(a)\n\t}\n}\n\nfunc count(a string, m map[string]int) map[string]int {\n\tfor _, y := range a {\n\t\tm[string(y)]++\n\t}\n\treturn m\n}\n"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\n\nfunc main() {\n scanner := bufio.NewScanner(os.Stdin)\n scanner.Scan()\n scanner.Scan()\n str := scanner.Text()\n\n count := 0\n for _, ch := range str {\n if ch == '1' {\n count++\n } else {\n count--\n }\n }\n if count != 0 {\n fmt.Printf(\"1\\n%v\\n\", str)\n } else {\n fmt.Printf(\"2\\n%c %v\\n\", str[0], str[1:len(str)])\n }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tvar s string\n\tfmt.Scanln(&n)\n\tfmt.Scanln(&s)\n\to := 0\n\tl := 0\n\tfor _, r := range s {\n\t\tif r == '0' {\n\t\t\to++\n\t\t} else {\n\t\t\tl++\n\t\t}\n\t}\n\tif l != o {\n\t\tfmt.Println(1)\n\t\tfmt.Println(s)\n\t\treturn\n\t}\n\tfmt.Println(2)\n\tfmt.Println(string(s[0]), string(s[1:]))\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar n int\n\tvar str string\n\n\tfmt.Scanln(&n)\n\tfmt.Scanln(&str)\n\n\tl:=0\n\tr:=0\n\n\tfor _,s:=range str{\n\t\tif s=='0'{\n\t\t\tl++\n\t\t} else {\n\t\t\tr++;\n\t\t}\n\t}\n\tif l!=r{\n\t\tfmt.Println(1);\n\t\tfmt.Println(str);\n\t\treturn;\n\t}\n\tfmt.Println(2);\n\tfmt.Println(string(str[0]),string(str[1:]))\n\n\n\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanln(&n)\n\tvar x string\n\tfmt.Scanln(&x)\n\tdiff := 0\n\tfor _, c := range x {\n\t\tif c == '0' {\n\t\t\tdiff++\n\t\t} else {\n\t\t\tdiff--\n\t\t}\n\t}\n\tif diff == 0 {\n\t\tfmt.Println(2)\n\t\tfmt.Print(string(x[0]), \" \")\n\t\tfor i, c := range x {\n\t\t\tif i == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfmt.Print(string(c))\n\t\t}\n\t} else {\n\t\tfmt.Println(1)\n\t\tfmt.Println(x)\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar count int\n\tvar number string\n\n\tfmt.Scan(&count, &number)\n\n\tif strings.Count(number, \"0\") == strings.Count(number, \"1\") {\n\t\tfmt.Println(\"2\")\n\t\tfmt.Print(number[:len(number)-1], \" \", string(number[len(number)-1]))\n\t} else {\n\t\tfmt.Println(\"1\")\n\t\tfmt.Print(number)\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, cnt0, cnt1 int32\n\tfmt.Scanf(\"%d\\n\", &n)\n\tvar str string\n\tfmt.Scanf(\"%s\\n\", &str)\n\n\tfor _, c := range(str) {\n\t\tif c == '0' {\n\t\t\tcnt0 ++\n\t\t} else {\n\t\t\tcnt1 ++\n\t\t}\n\t}\n\tif (cnt0 != cnt1) {\n\t\tfmt.Println(1)\n\t\tfmt.Println(str)\n\t} else {\n\t\tfmt.Println(2)\n\t\tfmt.Println(str[0:1], str[1:])\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\n// 800\n//https://codeforces.com/problemset/problem/1189/A\n\nfunc main() {\n\tvar v []byte\n\tfmt.Scanln(&v)\n\tfmt.Scanln(&v)\n\tvar ones, zeros int\n\tfor _, k := range v {\n\t\tif k == '1' {\n\t\t\tones++\n\t\t} else {\n\t\t\tzeros++\n\t\t}\n\t}\n\tif ones != zeros {\n\t\tfmt.Println(\"1\")\n\t\tfmt.Println(string(v))\n\t} else {\n\t\tfmt.Println(\"2\")\n\t\tfmt.Println(string(v[0]), string(v[1:]))\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc retCount(str string) (int, int) {\n\tone := strings.Count(str, \"1\")\n\tzero := strings.Count(str, \"0\")\n\treturn one, zero\n}\n\nfunc check(str string) bool {\n\tone, zero := retCount(str)\n\tif one == zero {\n\t\treturn false\n\t} else {\n\t\treturn true\n\t}\n}\n\nfunc main() {\n\tvar n, i int\n\tvar s string\n\tfmt.Scan(&n)\n\tfmt.Scan(&s)\n\tif check(s) {\n\t\tfmt.Println(1)\n\t\tfmt.Println(s)\n\t\treturn\n\t}\n\tif n == 1 {\n\t\tfmt.Println(n)\n\t\tfmt.Println(s)\n\t\treturn\n\t}\n\tif n%2 == 0 {\n\t\tfmt.Println(2)\n\t\tfmt.Println(s[:n-1] + \" \" + s[n-1:])\n\t} else {\n\t\tfor i = 1; i < n; i++ {\n\t\t\tif check(s[:i]) && check(s[i:]) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif i != n {\n\t\t\tfmt.Println(2)\n\t\t\tfmt.Println(s[:i] + \" \" + s[i:])\n\t\t} else {\n\t\t\tfmt.Println(3)\n\t\t\tfmt.Println(s[:n-2] + \" \" + s[n-2:n-1] + \" \" + s[n-1:n])\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc right(n int, stroka string) int {\n\tvar one int = 0\n\tvar zero int = 0\n\tfor i := 0; i < n; i++ {\n\t\tif stroka[i] == '1' {\n\t\t\tone += 1\n\t\t} else if stroka[i] == '0' {\n\t\t\tzero += 1\n\t\t}\n\t}\n\tif one == zero {\n\t\treturn 2\n\t} else {\n\t\treturn 1\n\t}\n}\n\nfunc main() {\n\tvar n int\n\tvar stroka string\n\tfmt.Scan(&n)\n\tfmt.Scan(&stroka)\n\tif n%2 == 1 {\n\t\tfmt.Println(1)\n\t\tfmt.Println(stroka)\n\t} else {\n\t\tfmt.Println(right(n, stroka))\n\t\tif right(n, stroka) == 1 {\n\t\t\tfmt.Println(stroka)\n\t\t} else {\n\t\t\tfmt.Println(stroka[:1], stroka[1:])\n\t\t}\n\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\n// 6\n// 100011\n\nfunc main() {\n\tvar n int\n\tfmt.Scanln(&n)\n\tsum := 0\n\tvar x string\n\tfmt.Scanln(&x)\n\tfor i := 0; i < n; i++ {\n\t\tif x[i] == '0' {\n\t\t\tsum++\n\t\t} else {\n\t\t\tsum--\n\t\t}\n\t}\n\tif sum == 0 {\n\t\tfmt.Println(2)\n\t\tfmt.Printf(\"%s %c\", x[0:len(x)-1], x[len(x)-1])\n\t} else {\n\t\tfmt.Println(1)\n\t\tfmt.Println(x)\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tvar c int\n\n\tfmt.Scanf(\"%s\\n\", &s)\n\tfmt.Scanf(\"%s\", &s)\n\n\tfor _, v := range s {\n\t\tif v == 49 {\n\t\t\tc++\n\t\t}\n\t}\n\n\tif c*2 == len(s) {\n\t\tfmt.Println(2)\n\t\tfmt.Println(s[:len(s)-1], s[len(s)-1:])\n\t} else {\n\t\tfmt.Println(1)\n\t\tfmt.Println(s)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"strings\"\n)\n\nfunc main() {\n var n int\n var s string\n fmt.Scan(&n)\n fmt.Scan(&s)\n c := strings.Count(s, \"1\")\n if 2 * c != n {\n fmt.Printf(\"1\\n%s\\n\", s)\n } else {\n fmt.Printf(\"2\\n%s %s\\n\", s[:1], s[1:])\n }\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar n int\n\t_,_=fmt.Scanln(&n)\n\tvar s string\n\t_,_=fmt.Scanln(&s)\n\tcnt1,cnt2:=0,0\n\tfor _,v:=range s {\n\t\tif v == '1' {\n\t\t\tcnt1++\n\t\t} else {\n\t\t\tcnt2++\n\t\t}\n\t}\n\tif cnt1 == cnt2 {\n\t\tfmt.Println(2)\n\t\tfmt.Printf(\"%s %c\\n\",s[0:n-1],s[n-1])\n\t}else{\n\t\tfmt.Println(1)\n\t\tfmt.Println(s)\n\t}\n}"}, {"source_code": "// Author: sighduck\n// URL: https://codeforces.com/contest/1189/problem/A\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Solve(n int, s string) []string {\n\tones := 0\n\tzeros := 0\n\tfor _, char := range s {\n\t\tif string(char) == \"1\" {\n\t\t\tones += 1\n\t\t} else {\n\t\t\tzeros += 1\n\t\t}\n\t}\n\tif ones != zeros {\n\t\treturn []string{s}\n\t}\n\treturn []string{string(s[0]), s[1:]}\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n int\n\tvar s string\n\tfmt.Fscanf(reader, \"%d\\n\", &n)\n\tfmt.Fscanf(reader, \"%s\\n\", &s)\n\n\tsolution := Solve(n, s)\n\tfmt.Fprintf(writer, \"%d\\n\", len(solution))\n\tfor i := 0; i < len(solution); i++ {\n\t\tfmt.Fprintf(writer, \"%s \", solution[i])\n\t}\n\tfmt.Fprintf(writer, \"\\n\")\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\n\nfunc main() {\n scanner := bufio.NewScanner(os.Stdin)\n scanner.Scan()\n str := scanner.Text()\n\n count := 0\n for _, ch := range str {\n if ch == '1' {\n count++\n } else {\n count--\n }\n }\n if count != 0 {\n fmt.Printf(\"1\\n%v\\n\", str)\n } else {\n fmt.Printf(\"2\\n%c %v\\n\", str[0], str[1:len(str)])\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tvar s string\n\tfmt.Scan(&n)\n\tfmt.Scan(&s)\n\tif n == 1 {\n\t\tfmt.Println(n)\n\t\tfmt.Println(s)\n\t\treturn\n\t}\n\tif n%2 == 0 {\n\t\tfmt.Println(2)\n\t\tfmt.Println(s[:n/2] + \" \" + s[n/2:])\n\t} else {\n\t\tfmt.Println(3)\n\t\tfmt.Println(s[:n/2] + \" \" + s[n/2:n/2+1] + \" \" + s[n/2+1:])\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc retCount(str string) (int, int) {\n\tone := strings.Count(str, \"1\")\n\tzero := strings.Count(str, \"0\")\n\treturn one, zero\n}\n\nfunc main() {\n\tvar n, i int\n\tvar s string\n\tfmt.Scan(&n)\n\tfmt.Scan(&s)\n\tif n == 1 {\n\t\tfmt.Println(n)\n\t\tfmt.Println(s)\n\t\treturn\n\t}\n\tif n%2 == 0 {\n\t\tfmt.Println(2)\n\t\tfmt.Println(s[:n/2] + \" \" + s[n/2:])\n\t} else {\n\t\tfor i = 1; i < n; i++ {\n\t\t\tone, zero := retCount(s[1:])\n\t\t\tif one != zero {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif i != n {\n\t\t\tfmt.Println(2)\n\t\t\tfmt.Println(s[:i] + \" \" + s[i:])\n\t\t} else {\n\t\t\tfmt.Println(3)\n\t\t\tfmt.Println(s[:n/2] + \" \" + s[n/2:n/2+1] + \" \" + s[n/2+1:])\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc retCount(str string) (int, int) {\n\tone := strings.Count(str, \"1\")\n\tzero := strings.Count(str, \"0\")\n\treturn one, zero\n}\n\nfunc check(str string) bool {\n\tone, zero := retCount(str)\n\tif one == zero {\n\t\treturn false\n\t} else {\n\t\treturn true\n\t}\n}\n\nfunc main() {\n\tvar n, i int\n\tvar s string\n\tfmt.Scan(&n)\n\tfmt.Scan(&s)\n\tif n == 1 {\n\t\tfmt.Println(n)\n\t\tfmt.Println(s)\n\t\treturn\n\t}\n\tif n%2 == 0 {\n\t\tfmt.Println(2)\n\t\tfmt.Println(s[:n-1] + \" \" + s[n-1:])\n\t} else {\n\t\tfor i = 1; i < n; i++ {\n\t\t\tif check(s[:i]) && check(s[i:]) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif i != n {\n\t\t\tfmt.Println(2)\n\t\t\tfmt.Println(s[:i] + \" \" + s[i:])\n\t\t} else {\n\t\t\tfmt.Println(3)\n\t\t\tfmt.Println(s[:n-2] + \" \" + s[n-2:n-1] + \" \" + s[n-1:n])\n\t\t}\n\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc right(n int, stroka string) int {\n\tvar one int = 0\n\tvar zero int = 0\n\tfor i := 0; i < n; i++ {\n\t\tif stroka[i] == '1' {\n\t\t\tone += 1\n\t\t} else if stroka[i] == '0' {\n\t\t\tzero += 1\n\t\t}\n\t}\n\tif one == zero {\n\t\treturn 2\n\t} else {\n\t\treturn 1\n\t}\n}\n\nfunc main() {\n\tvar n int\n\tvar stroka string\n\tfmt.Scan(&n)\n\tfmt.Scan(&stroka)\n\tif n%2 == 1 {\n\t\tfmt.Println(1)\n\t\tfmt.Println(stroka)\n\t} else {\n\t\tfmt.Println(right(n, stroka))\n\t\tfmt.Println(stroka[:1], stroka[1:])\n\t}\n}\n"}], "src_uid": "4ebed264d40a449602a26ceef2e849d1"} {"nl": {"description": "One day Kefa found n baloons. For convenience, we denote color of i-th baloon as si — lowercase letter of the Latin alphabet. Also Kefa has k friends. Friend will be upset, If he get two baloons of the same color. Kefa want to give out all baloons to his friends. Help Kefa to find out, can he give out all his baloons, such that no one of his friens will be upset — print «YES», if he can, and «NO», otherwise. Note, that Kefa's friend will not upset, if he doesn't get baloons at all.", "input_spec": "The first line contains two integers n and k (1 ≤ n, k ≤ 100) — the number of baloons and friends. Next line contains string s — colors of baloons.", "output_spec": "Answer to the task — «YES» or «NO» in a single line. You can choose the case (lower or upper) for each letter arbitrary.", "sample_inputs": ["4 2\naabb", "6 3\naacaab"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first sample Kefa can give 1-st and 3-rd baloon to the first friend, and 2-nd and 4-th to the second.In the second sample Kefa needs to give to all his friends baloons of color a, but one baloon will stay, thats why answer is «NO»."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar balls string\n\tvar n,k int\n\n\tfmt.Scan(&n, &k, &balls)\n\n\tcolors := make(map[rune]int,0)\n\n\tfor _,clr := range balls {\n\t\tcolors[clr]++\n\t}\n\n\tfor _,num := range colors {\n\t\tif num > k {\n\t\t\tfmt.Println(\"NO\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Println(\"YES\")\n}"}, {"source_code": "package main\n\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\treadInt(reader)\n\tk := readInt(reader)\n\tskipLine(reader)\n\n\ta := make(map[byte]int, 26)\n\ts := readLine(reader)\n\n\t//fmt.Printf(\"*s:%v\\n\", *s)\n\n\tfor i := 0; ik {\n\t\t\tok = false\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif ok {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}\n\nfunc readLine(nr *bufio.Reader) *string {\n\tline, _, err := nr.ReadLine()\n\tif err!=nil {\n\t\tpanic(err)\n\t}\n\ts := string(line)\n\treturn &s\n}\n\nfunc skipLine(nr *bufio.Reader) {\n\t_, _, err := nr.ReadLine()\n\tif err!=nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc readInt(nr *bufio.Reader) int {\n\tvar a int\n\tfmt.Fscan(nr, &a)\n\treturn a\n}\n\nfunc readA(n int) *[]int {\n\ta := make([]int, n)\n\n\treader := bufio.NewReader(os.Stdin)\n\n\tfor i := 0; i k {\n isPossible = false\n break\n } \n }\n \n if isPossible {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}"}, {"source_code": "package main\n\n/*\n The idea to solve this problem is by noticing that we need to make sure\n that each friends given baloon by Kefa doesn't get same color more than once. \n Which means the number of baloon of for each color must be the same number\n of Kefa friends or less (because his friends won't be angry if they do not get\n baloon)\n*/\n\nimport (\n \"fmt\"\n \"os\"\n \"bufio\"\n)\n\nfunc main() {\n var n, k int\n var baloons string\n var m = make(map[string]int)\n \n stdin := bufio.NewReader(os.Stdin)\n fmt.Fscanf(stdin, \"%d %d\\n\", &n, &k)\n fmt.Fscanf(stdin, \"%s\\n\", &baloons)\n \n // count number of baloon based on color\n for i := 0; i < n; i++ {\n m[string(baloons[i])]++\n }\n \n isPossible := true\n for _, v := range m {\n if v > k {\n isPossible = false\n break\n } \n }\n \n if isPossible {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nconst maxInputSize = 512 * 1024 //bytes\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Buffer(make([]byte, maxInputSize), maxInputSize)\n\n\tscanner.Scan()\n\tn, _ := strconv.Atoi(scanner.Text())\n\n\tscanner.Scan()\n\tk, _ := strconv.Atoi(scanner.Text())\n\tscanner.Scan()\n\ts := scanner.Text()\n\n\tyes := true\n\tl := make([]int, 26)\n\n\tfor i := 0; i < n; i++ {\n\t\tl[s[i]-97]++\n\t\tif l[s[i]-97] > k {\n\t\t\tyes = false\n\t\t}\n\t}\n\n\tif yes {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\t_ = readInt()\n\tk := readInt()\n\tcnt := map[rune]int{}\n\tfor _, v := range readString() {\n\t\tcnt[v]++\n\t}\n\tfor _, v := range cnt {\n\t\tif v > k {\n\t\t\tfmt.Println(\"NO\")\n\t\t\treturn\n\t\t}\n\n\t}\n\tfmt.Println(\"YES\")\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n, k int\n fmt.Scan(&n, &k)\n ballonByColor := make([]int, 256)\n var str string\n fmt.Scan(&str)\n for _, r := range str {\n ballonByColor[int(r)]++\n }\n for i:=0; i<256; i++ {\n if ballonByColor[i] > k {\n fmt.Print(\"NO\")\n return\n }\n }\n fmt.Print(\"YES\")\n}"}, {"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, A := sc.NextInt(), sc.NextInt()\n\n\tS := sc.NextLine()\n\n\tmp := map[byte]int{}\n\n\tfor i := 0; i < N; i++ {\n\t\tmp[S[i]]++\n\t}\n\n\tfor _, v := range mp {\n\t\tif v > A {\n\t\t\tfmt.Println(\"NO\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"YES\")\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tN, A := sc.NextInt(), sc.NextInt()\n\n\tS := sc.NextLine()\n\n\tmp := map[byte]int{}\n\n\tfor i := 0; i < N; i++ {\n\t\tmp[S[i]]++\n\t}\n\n\tfor _, v := range mp {\n\t\tif v= 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": "ceb3807aaffef60bcdbcc9a17a1391be"} {"nl": {"description": "Two positive integers a and b have a sum of s and a bitwise XOR of x. How many possible values are there for the ordered pair (a, b)?", "input_spec": "The first line of the input contains two integers s and x (2 ≤ s ≤ 1012, 0 ≤ x ≤ 1012), the sum and bitwise xor of the pair of positive integers, respectively.", "output_spec": "Print a single integer, the number of solutions to the given conditions. If no solutions exist, print 0.", "sample_inputs": ["9 5", "3 3", "5 2"], "sample_outputs": ["4", "2", "0"], "notes": "NoteIn the first sample, we have the following solutions: (2, 7), (3, 6), (6, 3), (7, 2).In the second sample, the only solutions are (1, 2) and (2, 1)."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc needs(sum, xor, carry, digit int64) int64 {\n\tif digit < 1 {\n\t\treturn 1 - carry\n\t}\n\n\tif (xor & digit) != 0 {\n\t\tif (sum & digit) != 0 {\n\t\t\treturn (1 - carry) * 2 * needs(sum, xor, 0, digit>>1)\n\t\t}\n\t\treturn carry * 2 * needs(sum, xor, 1, digit>>1)\n\t}\n\n\tif (sum & digit) != 0 {\n\t\treturn needs(sum, xor, 1, digit>>1)\n\t}\n\treturn needs(sum, xor, 0, digit>>1)\n}\n\nfunc main() {\n\tvar sum, xor int64\n\tfmt.Scan(&sum, &xor)\n\n\tif sum != xor {\n\t\tfmt.Println(needs(sum, xor, 0, 1<<62))\n\t} else {\n\t\tfmt.Println(needs(sum, xor, 0, 1<<62) - 2)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar (\n\tin = bufio.NewReader(os.Stdin)\n\tout = bufio.NewWriter(os.Stdout)\n)\n\nconst BITS = 50\n\nvar s, x int64\n\nfunc main() {\n\tdefer out.Flush()\n\tfmt.Fscan(in, &s, &x)\n\tans := solve(0, 0)\n\tif s == x {\n\t\tans -= 2\n\t}\n\tfmt.Fprintln(out, ans)\n}\n\nfunc solve(i, carry int) int64 {\n\tif i == BITS {\n\t\tif carry == 0 {\n\t\t\treturn 1\n\t\t}\n\t\treturn 0\n\t}\n\tkey := Key{i, carry}\n\tif result, ok := cache[key]; ok {\n\t\treturn result\n\t}\n\tresult := int64(0)\n\tfor a := 0; a <= 1; a++ {\n\t\tb := a ^ get(i, x)\n\t\tsum := a + b + carry\n\t\tif sum&1 == get(i, s) {\n\t\t\tresult += solve(i+1, sum>>1)\n\t\t}\n\t}\n\tcache[key] = result\n\treturn result\n}\n\nvar cache = map[Key]int64{}\n\ntype Key struct {\n\ti, carry int\n}\n\nfunc get(i int, x int64) int {\n\treturn int((x >> uint(i)) & 1)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc solve(s, x int64) int64 {\n\tif (s-x)%2 == 1 {\n\t\treturn 0\n\t}\n\tif ((s-x)/2)&x != 0 {\n\t\treturn 0\n\t}\n\tif s < x {\n\t\treturn 0\n\t}\n\tres := int64(1)\n\tfor y := x; y > 0; y &= (y - 1) {\n\t\tres *= 2\n\t}\n\tif s-x == 0 {\n\t\tres -= 2\n\t}\n\treturn res\n}\n\nfunc main() {\n\tvar s, x int64\n\tfmt.Scan(&s, &x)\n\tfmt.Println(solve(s, x))\n}\n"}, {"source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"math/bits\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF627A(in io.Reader, out io.Writer) {\n\tvar s, x, ans int64\n\tFscan(in, &s, &x)\n\tif d := s - x; d >= 0 && d&1 == 0 && d/2|x == d/2+x {\n\t\tans = int64(1) << bits.OnesCount64(uint64(x))\n\t\tif d == 0 {\n\t\t\tans -= 2\n\t\t}\n\t}\n\tFprint(out, ans)\n}\n\nfunc main() { CF627A(os.Stdin, os.Stdout) }\n"}, {"source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"math/bits\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tvar s, x, ans int64\n\tScan(&s, &x)\n\tif d := s - x; d >= 0 && d&1 == 0 && d/2|x == d/2+x {\n\t\tans = int64(1) << bits.OnesCount64(uint64(x))\n\t\tif d == 0 {\n\t\t\tans -= 2\n\t\t}\n\t}\n\tPrint(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc needs(sum, xor, carry, digit int64) int64 {\n\tif digit <= 0 {\n\t\tif carry == 0 {\n\t\t\treturn 1\n\t\t}\n\t\treturn 0\n\t}\n\n\tif (xor & digit) != 0 {\n\t\tif (sum & digit) != 0 {\n\t\t\tif carry != 0 {\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\treturn 2 * needs(sum, xor, 0, digit>>1)\n\t\t}\n\t\tif carry != 0 {\n\t\t\treturn 2 * needs(sum, xor, 1, digit>>1)\n\t\t}\n\t\treturn 0\n\t}\n\n\tif (sum & digit) != 0 {\n\t\treturn needs(sum, xor, 1, digit>>1)\n\t}\n\treturn needs(sum, xor, 0, digit>>1)\n}\n\nfunc main() {\n\tvar sum, xor int64\n\tfmt.Scan(&sum, &xor)\n\n\tif sum != xor {\n\t\tfmt.Println(needs(sum, xor, 0, 1<<62))\n\t} else {\n\t\tfmt.Println(needs(sum, xor, 0, 1<<62) - 2)\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar sum, xor, count, total int\n\tfmt.Scan(&sum, &xor)\n\tvar bits []int\n\tcount = 0\n\n\tfor xor > 0 {\n\t\tcount = (count << 1) | 1\n\t\tbits = append(bits, xor-xor&(xor-1))\n\t\txor = xor & (xor - 1)\n\t}\n\n\tfor ; count >= 0; count-- {\n\t\tleft := 0\n\t\tright := 0\n\n\t\tfor i, val := range bits {\n\t\t\tif (count & (1 << uint(i))) > 0 {\n\t\t\t\tleft += val\n\t\t\t} else {\n\t\t\t\tright += val\n\t\t\t}\n\t\t}\n\n\t\tif left >= sum || right >= sum {\n\t\t\tcontinue\n\t\t}\n\t\tif left == right {\n\t\t\ttotal++\n\t\t\tif (sum-(left+right))%2 != 0 {\n\t\t\t\ttotal++\n\t\t\t}\n\t\t} else {\n\t\t\tif (sum-(left+right))%2 == 0 {\n\t\t\t\ttotal++\n\t\t\t}\n\t\t}\n\t\t// fmt.Println(count, bits, left, right, \"=\", total)\n\t}\n\tfmt.Println(total)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar sum, xor int\n\tfmt.Scan(&sum, &xor)\n\n\tif ((sum - xor) % 2) != 0 {\n\t\tfmt.Println(0)\n\t\treturn\n\t}\n\txorbits := 0\n\tsumbits := 0\n\tmask := 1\n\n\tfor mask <= xor && mask <= sum {\n\t\tif xor&mask > 0 {\n\t\t\txorbits++\n\t\t}\n\t\tif sum&mask > 0 {\n\t\t\tsumbits++\n\t\t}\n\t\tmask <<= 1\n\t}\n\txorbits *= 2\n\n\tif sum&xor == sum {\n\t\txorbits -= sumbits\n\t}\n\tfmt.Println(xorbits)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar sum, xor, count, total int\n\tfmt.Scan(&sum, &xor)\n\tvar bits []int\n\tcount = 0\n\n\tfor xor > 0 {\n\t\tcount = (count << 1) | 1\n\t\tbits = append(bits, xor-xor&(xor-1))\n\t\txor = xor & (xor - 1)\n\t}\n\n\tfor ; count >= 0; count-- {\n\t\tleft := 0\n\t\tright := 0\n\n\t\tfor i, val := range bits {\n\t\t\tif (count & (1 << uint(i))) > 0 {\n\t\t\t\tleft += val\n\t\t\t} else {\n\t\t\t\tright += val\n\t\t\t}\n\t\t}\n\n\t\tif left >= sum || right >= sum {\n\t\t\tcontinue\n\t\t}\n\t\tif left == right {\n\t\t\ttotal++\n\t\t\tif sum-(left+right)%2 != 0 {\n\t\t\t\ttotal++\n\t\t\t}\n\t\t} else {\n\t\t\tif (sum-(left+right))%2 == 0 {\n\t\t\t\ttotal++\n\t\t\t}\n\t\t}\n\t\t// fmt.Println(count, bits, left, right, \"=\", total)\n\t}\n\tfmt.Println(total)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar (\n\tin = bufio.NewReader(os.Stdin)\n\tout = bufio.NewWriter(os.Stdout)\n)\n\nconst BITS = 15\n\nvar s, x int\n\nfunc main() {\n\tdefer out.Flush()\n\tfmt.Fscan(in, &s, &x)\n\n\t//for i := 0; i < BITS; i++ {\n\t//\tfmt.Fprint(out, get(i, s))\n\t//}\n\t//fmt.Fprintln(out)\n\t//for i := 0; i < BITS; i++ {\n\t//\tfmt.Fprint(out, get(i, x))\n\t//}\n\t//fmt.Fprintln(out)\n\n\tans := solve(0, 0)\n\tif s == x {\n\t\tans -= 2\n\t}\n\tfmt.Fprintln(out, ans)\n}\n\nfunc solve(i, carry int) int64 {\n\tif i == BITS {\n\t\tif carry == 0 {\n\t\t\treturn 1\n\t\t}\n\t\treturn 0\n\t}\n\tkey := Key{i, carry}\n\tif result, ok := cache[key]; ok {\n\t\treturn result\n\t}\n\tresult := int64(0)\n\tfor a := 0; a <= 1; a++ {\n\t\tb := a ^ get(i, x)\n\t\tsum := a + b + carry\n\t\tif sum&1 == get(i, s) {\n\t\t\t//fmt.Fprintln(out, i, a, b, carry, \"works\", sum>>1)\n\t\t\tresult += solve(i+1, sum>>1)\n\t\t}\n\t}\n\t//fmt.Fprintln(out, i, carry, \">\", result)\n\tcache[key] = result\n\treturn result\n}\n\nvar cache = map[Key]int64{}\n\ntype Key struct {\n\ti, carry int\n}\n\nfunc get(i, x int) int {\n\treturn (x >> uint(i)) & 1\n}\n"}, {"source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"math/bits\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF627A(in io.Reader, out io.Writer) {\n\tvar s, x, ans int64\n\tFscan(in, &s, &x)\n\tif d := s - x; d >= 0 && d&1 == 0 && d/2|x == d/2+x {\n\t\tif d == 0 {\n\t\t\tx--\n\t\t}\n\t\tans = int64(1) << bits.OnesCount64(uint64(x))\n\t}\n\tFprint(out, ans)\n}\n\nfunc main() { CF627A(os.Stdin, os.Stdout) }\n"}], "src_uid": "18410980789b14c128dd6adfa501aea5"} {"nl": {"description": "The HR manager was disappointed again. The last applicant failed the interview the same way as 24 previous ones. \"Do I give such a hard task?\" — the HR manager thought. \"Just raise number 5 to the power of n and get last two digits of the number. Yes, of course, n can be rather big, and one cannot find the power using a calculator, but we need people who are able to think, not just follow the instructions.\"Could you pass the interview in the machine vision company in IT City?", "input_spec": "The only line of the input contains a single integer n (2 ≤ n ≤ 2·1018) — the power in which you need to raise number 5.", "output_spec": "Output the last two digits of 5n without spaces between them.", "sample_inputs": ["2"], "sample_outputs": ["25"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(25)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\n// Buffered IO for fast I/O.\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\n// Helper function to wrap around the buffered IO.\nfunc printf(f string, a ...interface{}) {\n\tfmt.Fprintf(writer, f, a...)\n}\n\n// Helper function to take an input from the user.\nfunc scanf(f string, a ...interface{}) {\n\tfmt.Fscanf(reader, f, a...)\n}\n\n// Solve\nfunc solve() {\n\t// Solve the problem!\n\tvar numberOfFactors int\n\tscanf(\"%d\", &numberOfFactors)\n\n\t// Any 5 powered by anything will always have '25' as its last two digits.\n\tprintf(\"25\\n\")\n\treturn\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tsolve()\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tfmt.Println(25)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(\"25\")\n}\n"}, {"source_code": "package main\n \nimport (\n\t\"bufio\"\n\t\"fmt\"\n \"os\"\n)\n \nfunc main() {\n\tvar n uint64\n\tin := bufio.NewReader(os.Stdin)\n fmt.Fscanf(in, \"%d \\n\", &n)\n fmt.Println(25)\n // result := int(math.Pow(5, float64(n)))\n // stringresult := strconv.Itoa(result)\n // fmt.Println(stringresult[len(stringresult)-2:len(stringresult)])\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(25)\n}\n"}, {"source_code": "package main\nimport \"fmt\"\nfunc main() {\n fmt.Println(\"25\")\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"math/rand\"\n\t\"os\"\n)\n\nconst INF = 1000000001\n\ntype Pair struct {\n\tfirst, second int\n}\n\nfunc sort(arr []Pair) []Pair {\n\tif len(arr) < 2 {\n\t\treturn arr\n\t}\n\tleft := 0\n\tright := len(arr) - 1\n\tpivot := rand.Int() % len(arr)\n\n\tarr[pivot], arr[right] = arr[right], arr[pivot]\n\n\tfor i := 0; i < len(arr); i++ {\n\t\tif arr[i].first > arr[right].first {\n\t\t\tarr[i], arr[left] = arr[left], arr[i]\n\t\t\tleft++\n\t\t}\n\t}\n\n\tarr[left], arr[right] = arr[right], arr[left]\n\n\tsort(arr[:left])\n\tsort(arr[left+1:])\n\treturn arr\n}\n\nfunc sort2(arr []int) []int {\n\tif len(arr) < 2 {\n\t\treturn arr\n\t}\n\tleft := 0\n\tright := len(arr) - 1\n\tpivot := rand.Int() % len(arr)\n\n\tarr[pivot], arr[right] = arr[right], arr[pivot]\n\n\tfor i := 0; i < len(arr); i++ {\n\t\tif arr[i] < arr[right] {\n\t\t\tarr[i], arr[left] = arr[left], arr[i]\n\t\t\tleft++\n\t\t}\n\t}\n\n\tarr[left], arr[right] = arr[right], arr[left]\n\n\tsort2(arr[:left])\n\tsort2(arr[left+1:])\n\treturn arr\n}\n\nfunc gcd (a, b int64) int64 {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn gcd (b, a % b);\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc solution(reader io.Reader, writer io.Writer) {\n\tfmt.Println(25)\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}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\n\tvar n int64\n\tfmt.Scan(&n)\n\tfmt.Println(25)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tfmt.Fprintln(os.Stdout, 25)\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc pow(a, b int64) int64 {\n\tif b <= 0 {\n\t\treturn 1\n\t}\n\tif b <= 1 {\n\t\treturn a\n\t}\n\treturn pow((a*a)%100, b/2)\n}\n\nfunc main() {\n\tvar b int64\n\tfmt.Scan(&b)\n\tfmt.Println(pow(5, b))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n uint64\n\tfmt.Scanf(\"%d\", &n)\n\n\tswitch n {\n\tcase 0:\n\t\tfmt.Println(\"1\")\n\tcase 1:\n\t\tfmt.Println(\"5\")\n\tdefault:\n\t\tfmt.Println(\"25\")\n\t}\n}"}], "negative_code": [{"source_code": "package main\n \nimport (\n\t\"bufio\"\n\t\"fmt\"\n \"os\"\n \"math\"\n \"strconv\"\n)\n \nfunc main() {\n\tvar n uint64\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(in, \"%d \\n\", &n)\n result := int(math.Pow(5, float64(n)))\n stringresult := strconv.Itoa(result)\n fmt.Println(stringresult[len(stringresult)-2:len(stringresult)])\n}\n"}, {"source_code": "package main\nimport \"fmt\"\nfunc main() {\n fmt.Println(\"hello world\")\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\n\tswitch n {\n\tcase 0:\n\t\tfmt.Println(\"1\")\n\tcase 1:\n\t\tfmt.Println(\"5\")\n\tdefault:\n\t\tfmt.Println(\"25\")\n\t}\n}"}], "src_uid": "dcaff75492eafaf61d598779d6202c9d"} {"nl": {"description": "In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square's cells are painted black and others are painted white. Your task is to repaint at most one cell the other color so that the picture has a 2 × 2 square, completely consisting of cells of the same color. If the initial picture already has such a square, the person should just say so and the test will be completed. Your task is to write a program that determines whether it is possible to pass the test. You cannot pass the test if either repainting any cell or no action doesn't result in a 2 × 2 square, consisting of cells of the same color.", "input_spec": "Four lines contain four characters each: the j-th character of the i-th line equals \".\" if the cell in the i-th row and the j-th column of the square is painted white, and \"#\", if the cell is black.", "output_spec": "Print \"YES\" (without the quotes), if the test can be passed and \"NO\" (without the quotes) otherwise.", "sample_inputs": ["####\n.#..\n####\n....", "####\n....\n####\n...."], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first test sample it is enough to repaint the first cell in the second row. After such repainting the required 2 × 2 square is on the intersection of the 1-st and 2-nd row with the 1-st and 2-nd column."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc check(x [4]string, a int, b int) bool {\n cnt := 0\n for i := a; i < (a+2); i++ {\n for j := b; j < (b+2); j++ {\n if x[i][j] != x[a][b] { cnt++ }\n }\n }\n if cnt == 2 { return false } else { return true }\n}\n\nfunc main() {\n var x [4]string\n for i := 0; i < 4; i++ {\n fmt.Scan(&x[i])\n }\n ans := false\n for i := 0; i < 3; i++ {\n for j := 0; j < 3; j++ {\n if check(x,i,j) {\n ans = true\n break\n }\n }\n }\n if ans { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc check(x [4]string, a int, b int) bool {\n cnt := 0\n for i := a; i < (a+2); i++ {\n for j := b; j < (b+2); j++ {\n if x[i][j] != x[a][b] { cnt++ }\n }\n }\n if cnt == 2 { return false } else { return true }\n}\n\nfunc main() {\n var x [4]string\n for i := 0; i < 4; i++ {\n fmt.Scan(&x[i])\n }\n ans := false\n for i := 0; i < 3; i++ {\n for j := 0; j < 3; j++ {\n if check(x,i,j) {\n ans = true\n break\n }\n }\n }\n if ans { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc check(x [4]string, a int, b int) bool { // mengecek return value fungsi array x elemen ke 4, variabel a dan b dengan jenis int \n cnt := 0 // membuat variabel cnt kemudian diisi dengan 0\n for i := a; i < (a+2); i++ { // looping\n for j := b; j < (b+2); j++ { // looping ke 2\n if x[i][j] != x[a][b] { cnt++ } // jika array x elemen i dan j tidak sama dengan array x elemen a dan b maka cnt ditambah\n }\n }\n if cnt == 2 { return false } else { return true } // jika cnt sama dengan 2 maka return false, lainnya return true\n}\n\nfunc main() {\n var x [4]string // membuat variabel array x elemen ke 4 dengan jenis string\n for i := 0; i < 4; i++ { // looping ke 3\n fmt.Scan(&x[i]) // mengambil input \n }\n ans := false // membuat variabel ans kemudian diisi dengan false\n for i := 0; i < 3; i++ { //looping ke 4\n for j := 0; j < 3; j++ { // looping ke 5\n if check(x,i,j) { // jika check x,i dan j maka ans sama dengan true kemudian keluar dari fungsi\n ans = true\n break\n }\n }\n }\n if ans { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") } // jika ans maka cetak Yes, lainnya cetak NO\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\ts := make([]string, 4)\n\tfor i := range s {\n\t\tfmt.Scanln(&s[i])\n\t}\n\tfor i := 0; i < 3; i++ {\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tcnt := 0\n\t\t\tif s[i][j] == '.' {\n\t\t\t\tcnt++\n\t\t\t}\n\t\t\tif s[i+1][j] == '.' {\n\t\t\t\tcnt++\n\t\t\t}\n\t\t\tif s[i][j+1] == '.' {\n\t\t\t\tcnt++\n\t\t\t}\n\t\t\tif s[i+1][j+1] == '.' {\n\t\t\t\tcnt++\n\t\t\t}\n\t\t\tif cnt != 2 {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "// 287A-mic\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n arr := make([]string, 4)\n for i := 0; i < 4; i++ {\n fmt.Scan(&arr[i])\n }\n\n for i := 0; i < 3; i++ {\n for j := 0; j < 3; j++ {\n if arr[i][j] == arr[i][j+1] && arr[i][j] == arr[i+1][j] && arr[i][j] == arr[i+1][j+1] {\n fmt.Println(\"YES\")\n return\n } else if arr[i][j] == arr[i][j+1] && arr[i][j] == arr[i+1][j] {\n fmt.Println(\"YES\")\n return\n } else if arr[i][j] == arr[i][j+1] && arr[i][j] == arr[i+1][j+1] {\n fmt.Println(\"YES\")\n return\n } else if arr[i+1][j] == arr[i+1][j+1] && arr[i+1][j] == arr[i][j+1] {\n fmt.Println(\"YES\")\n return\n } else if arr[i+1][j] == arr[i+1][j+1] && arr[i+1][j] == arr[i][j] {\n fmt.Println(\"YES\")\n return\n }\n }\n }\n fmt.Println(\"NO\")\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc check(x [4]string, a int, b int) bool {\n cnt := 0\n for i := a; i < (a+2); i++ {\n for j := b; j < (b+2); j++ {\n if x[i][j] != x[a][b] { cnt++ }\n }\n }\n if cnt == 2 { return false } else { return true }\n}\n\nfunc main() {\n var x [4]string\n for i := 0; i < 4; i++ {\n fmt.Scan(&x[i])\n }\n ans := false\n for i := 0; i < 3; i++ {\n for j := 0; j < 3; j++ {\n if check(x,i,j) {\n ans = true\n break\n }\n }\n }\n if ans { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc check(x [4]string, a int, b int) bool {\n cnt := 0\n for i := a; i < (a+2); i++ {\n for j := b; j < (b+2); j++ {\n if x[i][j] != x[a][b] { cnt++ }\n }\n }\n if cnt <= 1 { return true } else { return false }\n}\n\nfunc main() {\n var x [4]string\n for i := 0; i < 4; i++ {\n fmt.Scan(&x[i])\n }\n ans := false\n for i := 0; i < 3; i++ {\n for j := 0; j < 3; j++ {\n if check(x,i,j) {\n ans = true\n break\n }\n }\n }\n if ans { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\ts := make([]string, 4)\n\tfor i := range s {\n\t\tfmt.Scanln(&s[i])\n\t}\n\tfor i := 0; i < 2; i++ {\n\t\tfor j := 0; j < 2; j++ {\n\t\t\tcnt := 0\n\t\t\tif s[i][j] == '.' {\n\t\t\t\tcnt++\n\t\t\t}\n\t\t\tif s[i+1][j] == '.' {\n\t\t\t\tcnt++\n\t\t\t}\n\t\t\tif s[i][j+1] == '.' {\n\t\t\t\tcnt++\n\t\t\t}\n\t\t\tif s[i+1][j+1] == '.' {\n\t\t\t\tcnt++\n\t\t\t}\n\t\t\tif cnt <= 1 || cnt >= 3 {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}], "src_uid": "01b145e798bbdf0ca2ecc383676d79f3"} {"nl": {"description": "Your friend has n cards.You know that each card has a lowercase English letter on one side and a digit on the other.Currently, your friend has laid out the cards on a table so only one side of each card is visible.You would like to know if the following statement is true for cards that your friend owns: \"If a card has a vowel on one side, then it has an even digit on the other side.\" More specifically, a vowel is one of 'a', 'e', 'i', 'o' or 'u', and even digit is one of '0', '2', '4', '6' or '8'.For example, if a card has 'a' on one side, and '6' on the other side, then this statement is true for it. Also, the statement is true, for example, for a card with 'b' and '4', and for a card with 'b' and '3' (since the letter is not a vowel). The statement is false, for example, for card with 'e' and '5'. You are interested if the statement is true for all cards. In particular, if no card has a vowel, the statement is true.To determine this, you can flip over some cards to reveal the other side. You would like to know what is the minimum number of cards you need to flip in the worst case in order to verify that the statement is true.", "input_spec": "The first and only line of input will contain a string s (1 ≤ |s| ≤ 50), denoting the sides of the cards that you can see on the table currently. Each character of s is either a lowercase English letter or a digit.", "output_spec": "Print a single integer, the minimum number of cards you must turn over to verify your claim.", "sample_inputs": ["ee", "z", "0ay1"], "sample_outputs": ["2", "0", "2"], "notes": "NoteIn the first sample, we must turn over both cards. Note that even though both cards have the same letter, they could possibly have different numbers on the other side.In the second sample, we don't need to turn over any cards. The statement is vacuously true, since you know your friend has no cards with a vowel on them.In the third sample, we need to flip the second and fourth cards."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tans := 0\n\tfor i := range s {\n\t\tswitch s[i] {\n\t\tcase 'a', 'e', 'i', 'o', 'u', '1', '3', '5', '7', '9':\n\t\t\tans++\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\n/*\n\tTo verify whether or not the statement is valid, basically\n\twe just need to check cards with vowel or cards with odd number\n*/\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar str string\n\tstdin := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(stdin, \"%s\", &str)\n\tshouldCheck := 0\n\tfor i := 0; i < len(str); i++ {\n\t\tch := string(str[i])\n\t\tnum, err := strconv.Atoi(ch)\n\t\tif err != nil {\n\t\t\tif ch == \"a\" || ch == \"i\" || ch == \"u\" || ch == \"e\" || ch == \"o\" {\n\t\t\t\tshouldCheck++\n\t\t\t}\n\t\t} else {\n\t\t\tif num%2 != 0 {\n\t\t\t\tshouldCheck++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(shouldCheck)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar str string\n\tstdin := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(stdin, \"%s\", &str)\n\tshouldCheck := 0\n\tfor i := 0; i < len(str); i++ {\n\t\tch := string(str[i])\n\t\tnum, err := strconv.Atoi(ch)\n\t\tif err != nil {\n\t\t\tif ch == \"a\" || ch == \"i\" || ch == \"u\" || ch == \"e\" || ch == \"o\" {\n\t\t\t\tshouldCheck++\n\t\t\t}\n\t\t} else {\n\t\t\tif num%2 != 0 {\n\t\t\t\tshouldCheck++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(shouldCheck)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tvar ans int\n\tvowel := []int32{'a','e','i','o','u','1','3','5','7','9'}\n\tfmt.Scanf(\"%s\",&s)\n\tfor _, ch := range s {\n\t\tfor _, v := range vowel {\n\t\t\tif ch == v {\n\t\t\t\tans++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Print(ans)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc vowel_l(r rune) bool {\n if r == 'a' || r == 'e' || r == 'i' || r == 'o' || r == 'u' {\n return true\n }\n return false\n}\n\nfunc odd(r rune) bool {\n if r == '1' || r == '3' || r == '5' || r == '7' || r == '9' {\n return true\n } \n return false\n}\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n var cnt int\n for _, r := range s {\n if vowel_l(r) || odd(r) {\n cnt++\n }\n }\n fmt.Print(cnt)\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tS := sc.NextLine()\n\tcount := 0\n\tfor _, v := range S {\n\t\tswitch v {\n\t\tcase 'a', 'i', 'u', 'e', 'o', '1', '3', '5', '7', '9':\n\t\t\tcount++\n\n\t\t}\n\t}\n\tfmt.Println(count)\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scanln(&s)\n\tvar ans int\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] >= '0' && s[i] <= '9' {\n\t\t\tif (s[i]-'0')%2 == 1 {\n\t\t\t\tans++\n\t\t\t}\n\t\t} else {\n\t\t\tif strings.IndexByte(\"aeiou\", s[i]) != -1 {\n\t\t\t\tans++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tg := \"aeiou\"\n\tk := 0\n\tfor _,a := range s {\n\t\tif strings.Count(g,string(a)) >0 {\n\t\t\tk++\n\t\t}\n\t\tn,err := strconv.Atoi(string(a))\n\t\tif err==nil && n%2 !=0 {\n\t\t\tk++\n\t\t}\n\t}\n\tfmt.Println(k)\n}"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc vowel_l(r rune) bool {\n if r == 'a' || r == 'e' || r == 'i' || r == 'u' {\n return true\n }\n return false\n}\n\nfunc odd(r rune) bool {\n if r == '1' || r == '3' || r == '5' || r == '7' || r == '9' {\n return true\n } \n return false\n}\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n var cnt int\n for _, r := range s {\n if vowel_l(r) || odd(r) {\n cnt++\n }\n }\n fmt.Print(cnt)\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tS := sc.NextLine()\n\tcount := 0\n\tfor _, v := range S {\n\t\tswitch v {\n\t\tcase 'a', 'i', 'u', 'e', 'o', '0', '2', '4', '6', '8':\n\t\t\tcount++\n\n\t\t}\n\t}\n\tfmt.Println(count)\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scanln(&s)\n\tvar ans int\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] >= '0' && s[i] <= '9' {\n\t\t\tif (s[i]-'0')%2 == 0 {\n\t\t\t\tans++\n\t\t\t}\n\t\t} else {\n\t\t\tif strings.IndexByte(\"aeiou\", s[i]) != -1 {\n\t\t\t\tans++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scanln(&s)\n\tvar ans int\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] >= '0' && s[i] <= '9' {\n\t\t\tif (s[i]-'0')%2 == 0 {\n\t\t\t\tans++\n\t\t\t}\n\t\t} else {\n\t\t\tif strings.IndexByte(\"aeios\", s[i]) != -1 {\n\t\t\t\tans++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n"}], "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223"} {"nl": {"description": "Polycarp invited all his friends to the tea party to celebrate the holiday. He has n cups, one for each of his n friends, with volumes a1, a2, ..., an. His teapot stores w milliliters of tea (w ≤ a1 + a2 + ... + an). Polycarp wants to pour tea in cups in such a way that: Every cup will contain tea for at least half of its volume Every cup will contain integer number of milliliters of tea All the tea from the teapot will be poured into cups All friends will be satisfied. Friend with cup i won't be satisfied, if there exists such cup j that cup i contains less tea than cup j but ai > aj.For each cup output how many milliliters of tea should be poured in it. If it's impossible to pour all the tea and satisfy all conditions then output -1.", "input_spec": "The first line contains two integer numbers n and w (1 ≤ n ≤ 100, ). The second line contains n numbers a1, a2, ..., an (1 ≤ ai ≤ 100).", "output_spec": "Output how many milliliters of tea every cup should contain. If there are multiple answers, print any of them. If it's impossible to pour all the tea and satisfy all conditions then output -1.", "sample_inputs": ["2 10\n8 7", "4 4\n1 1 1 1", "3 10\n9 8 10"], "sample_outputs": ["6 4", "1 1 1 1", "-1"], "notes": "NoteIn the third example you should pour to the first cup at least 5 milliliters, to the second one at least 4, to the third one at least 5. It sums up to 14, which is greater than 10 milliliters available."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t//\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\ntype fs struct {\n\tdata []int\n\tindex []int\n}\n\nfunc (a *fs) Len() int {\n\treturn len(a.data)\n}\n\nfunc (a *fs) Less(i, j int) bool {\n\treturn a.data[a.index[i]] > a.data[a.index[j]]\n}\n\nfunc (a *fs) Swap(i, j int) {\n\tt := a.index[i]\n\ta.index[i] = a.index[j]\n\ta.index[j] = t\n}\n\nfunc main() {\n\tinp := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tis, err := inp.ReadString('\\n')\n\tif err != nil {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tis = strings.TrimRight(is, \"\\n\\r\\t \")\n\tl1 := strings.Split(is, \" \")\n\tif len(l1) != 2 {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tn, err := strconv.Atoi(l1[0])\n\tif err != nil {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tw, err := strconv.Atoi(l1[1])\n\tif err != nil {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tis, err = inp.ReadString('\\n')\n\tif err != nil {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tis = strings.TrimRight(is, \"\\n\\r\\t \")\n\tl2 := strings.Split(is, \" \")\n\tif len(l2) != n {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\n\tavol := make([]int, n)\n\tafact := make([]int, n)\n\tindex := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tavol[i], err = strconv.Atoi(l2[i])\n\t\tif err != nil {\n\t\t\tout.WriteString(\"-1\")\n\t\t\tout.Flush()\n\t\t\treturn\n\t\t}\n\t\tafact[i] = (avol[i] + 1) / 2\n\t\tw -= afact[i]\n\t\tif w < 0 {\n\t\t\tout.WriteString(\"-1\")\n\t\t\tout.Flush()\n\t\t\treturn\n\t\t}\n\t\tindex[i] = i\n\t}\n\n\t//fmt.Printf(\"%v\\n\", afact)\n\tfss := fs{\n\t\tdata: avol,\n\t\tindex: index,\n\t}\n\tsort.Sort(&fss)\n\t//fmt.Printf(\"%v\\n\", fss.index)\n\n\tfor _, idx := range fss.index {\n\t\tadd := avol[idx] - afact[idx]\n\t\tif w < add {\n\t\t\tadd = w\n\t\t}\n\t\tafact[idx] += add\n\t\tw -= add\n\t}\n\n\tif w > 0 {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t} else {\n\t\tfor _, v := range afact {\n\t\t\tout.WriteString(strconv.Itoa(v))\n\t\t\tout.WriteString(\" \")\n\t\t}\n\t}\n\tout.Flush()\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t//\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\ntype fs struct {\n\tdata []int\n\tindex []int\n}\n\nfunc (a *fs) Len() int {\n\treturn len(a.data)\n}\n\nfunc (a *fs) Less(i, j int) bool {\n\treturn a.data[i] > a.data[j]\n}\n\nfunc (a *fs) Swap(i, j int) {\n\tt := a.index[i]\n\ta.index[i] = a.index[j]\n\ta.index[j] = t\n}\n\nfunc main() {\n\tinp := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tis, err := inp.ReadString('\\n')\n\tif err != nil {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tis = strings.TrimRight(is, \"\\n\\r\\t \")\n\tl1 := strings.Split(is, \" \")\n\tif len(l1) != 2 {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tn, err := strconv.Atoi(l1[0])\n\tif err != nil {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tw, err := strconv.Atoi(l1[1])\n\tif err != nil {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tis, err = inp.ReadString('\\n')\n\tif err != nil {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tis = strings.TrimRight(is, \"\\n\\r\\t \")\n\tl2 := strings.Split(is, \" \")\n\tif len(l2) != n {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\n\tavol := make([]int, n)\n\tafact := make([]int, n)\n\tindex := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tavol[i], err = strconv.Atoi(l2[i])\n\t\tif err != nil {\n\t\t\tout.WriteString(\"-1\")\n\t\t\tout.Flush()\n\t\t\treturn\n\t\t}\n\t\tafact[i] = (avol[i] + 1) / 2\n\t\tw -= afact[i]\n\t\tif w < 0 {\n\t\t\tout.WriteString(\"-1\")\n\t\t\tout.Flush()\n\t\t\treturn\n\t\t}\n\t\tindex[i] = i\n\t}\n\n\t//fmt.Printf(\"%v\\n\", afact)\n\tfss := fs{\n\t\tdata: avol,\n\t\tindex: index,\n\t}\n\tsort.Sort(&fss)\n\t//fmt.Printf(\"%v\\n\", fss.index)\n\n\tfor _, idx := range fss.index {\n\t\tadd := avol[idx] - afact[idx]\n\t\tif w < add {\n\t\t\tadd = w\n\t\t}\n\t\tafact[idx] += add\n\t\tw -= add\n\t}\n\n\tif w > 0 {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t} else {\n\t\tfor _, v := range afact {\n\t\t\tout.WriteString(strconv.Itoa(v))\n\t\t\tout.WriteString(\" \")\n\t\t}\n\t}\n\tout.Flush()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t//\t\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tinp := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tis, err := inp.ReadString('\\n')\n\tif err != nil {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tis = strings.TrimRight(is, \"\\n\\r\\t \")\n\tl1 := strings.Split(is, \" \")\n\tif len(l1) != 2 {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tn, err := strconv.Atoi(l1[0])\n\tif err != nil {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tw, err := strconv.Atoi(l1[1])\n\tif err != nil {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tis, err = inp.ReadString('\\n')\n\tif err != nil {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tis = strings.TrimRight(is, \"\\n\\r\\t \")\n\tl2 := strings.Split(is, \" \")\n\tif len(l2) != n {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tavol := make([]int, n)\n\tafact := make([]int, n)\n\tminv := 0\n\tfor i := 0; i < n; i++ {\n\t\tavol[i], err = strconv.Atoi(l2[i])\n\t\tif err != nil {\n\t\t\tout.WriteString(\"-1\")\n\t\t\tout.Flush()\n\t\t\treturn\n\t\t}\n\t\tcv := (avol[i] + 1) / 2\n\t\tif cv < minv {\n\t\t\tcv = minv\n\t\t} else {\n\t\t\tminv = cv\n\t\t}\n\t\tafact[i] = cv\n\t\tw -= cv\n\t\tif w <= 0 {\n\t\t\tout.WriteString(\"-1\")\n\t\t\tout.Flush()\n\t\t\treturn\n\t\t}\n\t}\n\tmaxv := avol[n-1]\n\tfor i := n - 1; i >= 0; i-- {\n\t\tadd := 0\n\t\tif avol[i] > maxv {\n\t\t\tadd = maxv - afact[i]\n\t\t} else {\n\t\t\tadd = avol[i] - afact[i]\n\t\t\tmaxv = avol[i]\n\t\t}\n\t\tif add < w {\n\t\t\tafact[i] += w\n\t\t\tbreak\n\t\t} else {\n\t\t\tafact[i] += add\n\t\t\tw -= add\n\t\t}\n\t}\n\n\tif w > 0 {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t} else {\n\t\tfor _, v := range afact {\n\t\t\tout.WriteString(strconv.Itoa(v))\n\t\t}\n\t}\n\tout.Flush()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t//\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\ntype fs struct {\n\tdata []int\n\tindex []int\n}\n\nfunc (a *fs) Len() int {\n\treturn len(a.data)\n}\n\nfunc (a *fs) Less(i, j int) bool {\n\treturn a.data[i] > a.data[j]\n}\n\nfunc (a *fs) Swap(i, j int) {\n\tt := a.index[i]\n\ta.index[i] = a.index[j]\n\ta.index[j] = t\n}\n\nfunc main() {\n\tinp := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tis, err := inp.ReadString('\\n')\n\tif err != nil {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tis = strings.TrimRight(is, \"\\n\\r\\t \")\n\tl1 := strings.Split(is, \" \")\n\tif len(l1) != 2 {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tn, err := strconv.Atoi(l1[0])\n\tif err != nil {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tw, err := strconv.Atoi(l1[1])\n\tif err != nil {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tis, err = inp.ReadString('\\n')\n\tif err != nil {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tis = strings.TrimRight(is, \"\\n\\r\\t \")\n\tl2 := strings.Split(is, \" \")\n\tif len(l2) != n {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\n\tavol := make([]int, n)\n\tafact := make([]int, n)\n\tindex := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tavol[i], err = strconv.Atoi(l2[i])\n\t\tif err != nil {\n\t\t\tout.WriteString(\"-1\")\n\t\t\tout.Flush()\n\t\t\treturn\n\t\t}\n\t\tafact[i] = (avol[i] + 1) / 2\n\t\tw -= afact[i]\n\t\tif w < 0 {\n\t\t\tout.WriteString(\"-1\")\n\t\t\tout.Flush()\n\t\t\treturn\n\t\t}\n\t\tindex[i] = i\n\t}\n\tfss := fs{\n\t\tdata: avol,\n\t\tindex: index,\n\t}\n\tsort.Sort(&fss)\n\n\tfor _, idx := range fss.index {\n\t\tadd := avol[idx] - afact[idx]\n\t\tif w < add {\n\t\t\tadd = w\n\t\t}\n\t\tafact[idx] += w\n\t\tw -= add\n\t}\n\n\tif w > 0 {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t} else {\n\t\tfor _, v := range afact {\n\t\t\tout.WriteString(strconv.Itoa(v))\n\t\t\tout.WriteString(\" \")\n\t\t}\n\t}\n\tout.Flush()\n}\n"}, {"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\tinp := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tis, err := inp.ReadString('\\n')\n\tif err != nil {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tis = strings.TrimRight(is, \"\\n\\r\\t \")\n\tl1 := strings.Split(is, \" \")\n\tif len(l1) != 2 {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tn, err := strconv.Atoi(l1[0])\n\tif err != nil {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tw, err := strconv.Atoi(l1[1])\n\tif err != nil {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tis, err = inp.ReadString('\\n')\n\tif err != nil {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\tis = strings.TrimRight(is, \"\\n\\r\\t \")\n\tl2 := strings.Split(is, \" \")\n\tif len(l2) != n {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t\treturn\n\t}\n\n\tavol := make([]int, n)\n\tafact := make([]int, n)\n\tminv := 0\n\tfor i := 0; i < n; i++ {\n\t\tavol[i], err = strconv.Atoi(l2[i])\n\t\tif err != nil {\n\t\t\tout.WriteString(\"-1\")\n\t\t\tout.Flush()\n\t\t\treturn\n\t\t}\n\t\tcv := (avol[i] + 1) / 2\n\t\tif cv < minv {\n\t\t\tcv = minv\n\t\t} else {\n\t\t\tminv = cv\n\t\t}\n\t\tafact[i] = cv\n\t\tw -= cv\n\t\tif w <= 0 {\n\t\t\tout.WriteString(\"-1\")\n\t\t\tout.Flush()\n\t\t\treturn\n\t\t}\n\t}\n\tmaxv := avol[n-1]\n\tfor i := n - 1; i >= 0; i-- {\n\t\tadd := 0\n\t\tif avol[i] > maxv {\n\t\t\tadd = maxv - afact[i]\n\t\t} else {\n\t\t\tadd = avol[i] - afact[i]\n\t\t\tmaxv = avol[i]\n\t\t}\n\t\tif add >= w {\n\t\t\tafact[i] += w\n\t\t\tw = 0\n\t\t\tbreak\n\t\t} else {\n\t\t\tafact[i] += add\n\t\t\tw -= add\n\t\t}\n\t\tfmt.Println(i, avol[i], afact[i], w)\n\t}\n\n\tif w > 0 {\n\t\tout.WriteString(\"-1\")\n\t\tout.Flush()\n\t} else {\n\t\tfor _, v := range afact {\n\t\t\tout.WriteString(strconv.Itoa(v))\n\t\t\tout.WriteString(\" \")\n\t\t}\n\t}\n\tout.Flush()\n}\n"}], "src_uid": "5d3bb9e03f4c5c8ecb6233bd5f90f3a3"} {"nl": {"description": "Year 2118. Androids are in mass production for decades now, and they do all the work for humans. But androids have to go to school to be able to solve creative tasks. Just like humans before.It turns out that high school struggles are not gone. If someone is not like others, he is bullied. Vasya-8800 is an economy-class android which is produced by a little-known company. His design is not perfect, his characteristics also could be better. So he is bullied by other androids.One of the popular pranks on Vasya is to force him to compare $$$x^y$$$ with $$$y^x$$$. Other androids can do it in milliseconds while Vasya's memory is too small to store such big numbers.Please help Vasya! Write a fast program to compare $$$x^y$$$ with $$$y^x$$$ for Vasya, maybe then other androids will respect him.", "input_spec": "On the only line of input there are two integers $$$x$$$ and $$$y$$$ ($$$1 \\le x, y \\le 10^{9}$$$).", "output_spec": "If $$$x^y < y^x$$$, then print '<' (without quotes). If $$$x^y > y^x$$$, then print '>' (without quotes). If $$$x^y = y^x$$$, then print '=' (without quotes).", "sample_inputs": ["5 8", "10 3", "6 6"], "sample_outputs": [">", "<", "="], "notes": "NoteIn the first example $$$5^8 = 5 \\cdot 5 \\cdot 5 \\cdot 5 \\cdot 5 \\cdot 5 \\cdot 5 \\cdot 5 = 390625$$$, and $$$8^5 = 8 \\cdot 8 \\cdot 8 \\cdot 8 \\cdot 8 = 32768$$$. So you should print '>'.In the second example $$$10^3 = 1000 < 3^{10} = 59049$$$.In the third example $$$6^6 = 46656 = 6^6$$$."}, "positive_code": [{"source_code": "package main\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc main(){\n\tvar a, b float64\n\tfmt.Scan(&a)\n\tfmt.Scan(&b)\n\tif a == b {\n\t\tfmt.Println(\"=\")\n\t\tos.Exit(0)\n\t}\n\tif a > b {\n\t\tvar x, y float64\n\t\tx = b\n\t\ty = a\n\t\tx = (x * math.Log(a)) / math.Log(b)\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(\"<\")\n\t\t}\n\t} else {\n\t\tvar x, y float64\n\t\tx = b\n\t\ty = a\n\t\ty = (y * math.Log(b)) / math.Log(a)\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(\"<\")\n\t\t}\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvar x, y float64\n\tfmt.Fscan(reader, &x, &y)\n\tx, y = y*math.Log(x), x*math.Log(y)\n\t// fmt.Println(x, y)\n\tif x == y {\n\t\tfmt.Println(\"=\")\n\t\treturn\n\t} else if x > y {\n\t\tfmt.Println(\">\")\n\t} else if x < y {\n\t\tfmt.Println(\"<\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"strconv\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar x1,y1 float64\n\tfmt.Scanf(\"%f %f\\n\", &x1, &y1)\n\tx := (math.Log(x1)*y1)\n\ty := (math.Log(y1)*x1)\n\tif x == y {\n\t\tfmt.Println(\"=\")\n\t} else if x > y {\n\t\tfmt.Println(\">\")\n\t} else {\n\t\tfmt.Println(\"<\")\n\t}\n}\n\nfunc readOneInt64(r *bufio.Reader) (n int64) {\n\tbytes, _ := r.ReadBytes('\\n')\n\tn, _ = strconv.ParseInt(string(bytes[:len(bytes)-2]), 10, 64)\n\treturn\n}\n\nfunc readInt64Slice(r *bufio.Reader, n int) (slice []int64) {\n\tvar bytes []byte\n\tslice = make([]int64, n)\n\tn--\n\tfor i := 0; i < n; i++ {\n\t\tbytes, _ = r.ReadBytes(' ')\n\t\tslice[i], _ = strconv.ParseInt(string(bytes[:len(bytes)-1]), 10, 64)\n\t}\n\tslice[n] = readOneInt64(r)\n\treturn\n}\n\nfunc readOneString(r *bufio.Reader) string {\n\tbytes, _ := r.ReadBytes('\\n')\n\treturn string(bytes[:len(bytes)-2])\n}\n\nfunc abs(i int) int {\n\tif i < 0 {\n\t\treturn i * -1\n\t}\n\treturn i\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"fmt\"\n\t\"math\"\n)\n\nvar sc = bufio.NewScanner(os.Stdin)\nconst EPS = 0.00000001\n\nfunc nextLine() string{\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc nextInt() int {\n\tsc.Scan()\n\ti, e := strconv.Atoi(sc.Text())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n\n\nfunc main(){\n\tsc.Split(bufio.ScanWords)\n\n\tx := float64(nextInt())\n\ty := float64(nextInt())\n\n\tres_xy := y * math.Log2(x)\n\tres_yx := x * math.Log2(y)\n\n\t//fmt.Printf(\"%v, %v, %v\", res_xy, res_yx, res_xy-res_yx)\n\n\tif math.Abs(res_xy - res_yx) < EPS{\n\t\tfmt.Println(\"=\")\n\t}else if res_xy < res_yx {\n\t\tfmt.Println(\"<\")\n\t}else {\n\t\tfmt.Println(\">\")\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x, y int\n\tfmt.Scanf(\"%d %d\\n\", &x, &y)\n\tif x == y {\n\t\tfmt.Println(\"=\")\n\t\treturn\n\t}\n\tif x > y {\n\t\tif y >= 3 {\n\t\t\tfmt.Println(\"<\")\n\t\t\treturn\n\t\t}\n\t\tif y == 2 {\n\t\t\tif x == 4 {\n\t\t\t\tfmt.Println(\"=\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif x == 3 {\n\t\t\t\tfmt.Println(\">\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif x > 4 {\n\t\t\t\tfmt.Println(\"<\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tif y == 1 {\n\t\t\tfmt.Println(\">\")\n\t\t}\n\t}\n\tif x < y {\n\t\tif x >= 3 {\n\t\t\tfmt.Println(\">\")\n\t\t\treturn\n\t\t}\n\t\tif x == 2 {\n\t\t\tif y == 4 {\n\t\t\t\tfmt.Println(\"=\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif y == 3 {\n\t\t\t\tfmt.Println(\"<\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif y > 4 {\n\t\t\t\tfmt.Println(\">\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tif x == 1 {\n\t\t\tfmt.Println(\"<\")\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"math\"\n\t\"fmt\"\n)\n\nfunc main () {\n\tvar a float64\n\tvar b float64\n\n\tfmt.Scanf(\"%f %f\\n\",&a,&b)\n\n\tc := b * math.Log(a)\n\td := a * math.Log(b)\n\n\tif c < d {\n\t\tfmt.Println(\"<\")\n\t} else if c > d {\n\t\tfmt.Println(\">\")\n\t} else {\n\t\tfmt.Println(\"=\")\n\t}\n\n}"}, {"source_code": "package main\n\n/*\n\tThe idea to solve this problem is by using logarithm to solve\n\tthe equation. We apply logarithm to both sides of equation then\n\tcompare them. For details take a look at this reference:\n\thttp://www.montereyinstitute.org/courses/DevelopmentalMath/COURSE_TEXT2_RESOURCE/U18_L4_T1_text_final.html\n*/\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar x, y float64\n\tstdin := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(stdin, \"%f %f\\n\", &x, &y)\n\tx, y = y*math.Log(x), x*math.Log(y)\n\tif x == y {\n\t\tfmt.Println(\"=\")\n\t} else if x < y {\n\t\tfmt.Println(\"<\")\n\t} else {\n\t\tfmt.Println(\">\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar x, y float64\n\tstdin := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(stdin, \"%f %f\\n\", &x, &y)\n\tx, y = y*math.Log(x), x*math.Log(y)\n\tif x == y {\n\t\tfmt.Println(\"=\")\n\t} else if x < y {\n\t\tfmt.Println(\"<\")\n\t} else {\n\t\tfmt.Println(\">\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tx := float64(readInt())\n\ty := float64(readInt())\n\tt0 := y * math.Log(x)\n\tt1 := x * math.Log(y)\n\tif t0 == t1 {\n\t\tfmt.Println(\"=\")\n\t} else if t1 < t0 {\n\t\tfmt.Println(\">\")\n\t} else {\n\t\tfmt.Println(\"<\")\n\t}\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar a, b float64\n\tfmt.Scan(&a, &b)\n\t\n\tvar t float64 = math.Log2(a) / math.Log2(b) * b\n\tif a == b {\n\t\tfmt.Println(\"=\")\n\t} else if t == a {\n\t\tfmt.Println(\"=\")\n\t} else if t > a {\n\t\tfmt.Println(\">\")\n\t} else {\n\t\tfmt.Println(\"<\")\n\t}\n}"}], "negative_code": [{"source_code": "package main\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc main(){\n\tvar a, b float64\n\tfmt.Scan(&a)\n\tfmt.Scan(&b)\n\tif a == b {\n\t\tfmt.Println(\"=\")\n\t\tos.Exit(0)\n\t}\n\tif a > b {\n\t\tvar x, y float64\n\t\tx = b\n\t\ty = a\n\t\tx = (x * math.Log(a)) / math.Log(b)\n\t\tif x > y {\n\t\t\tfmt.Println(\">\")\n\t\t} else{\n\t\t\tfmt.Println(\"<\")\n\t\t}\n\t} else {\n\t\tvar x, y float64\n\t\tx = b\n\t\ty = a\n\t\ty = (y * math.Log(b)) / math.Log(a)\n\t\tif x > y {\n\t\t\tfmt.Println(\">\")\n\t\t} else{\n\t\t\tfmt.Println(\"<\")\n\t\t}\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvar x, y int\n\tfmt.Fscan(reader, &x, &y)\n\txLog, yLog := int(math.Log(float64(x))), int(math.Log(float64(x)))\n\tif y*xLog == yLog*x {\n\t\tfmt.Println(\"=\")\n\t\treturn\n\t} else if y*xLog > yLog*x {\n\t\tfmt.Println(\">\")\n\t} else if y*xLog < yLog*x {\n\t\tfmt.Println(\"<\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvar x, y int\n\tfmt.Fscan(reader, &x, &y)\n\n\tif x == y {\n\t\tfmt.Println(\"=\")\n\t\treturn\n\t} else if x > y {\n\t\tfmt.Println(\"<\")\n\t} else if x < y {\n\t\tfmt.Println(\">\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvar x, y int\n\tfmt.Fscan(reader, &x, &y)\n\txLog, yLog := int(math.Log(float64(x))), int(math.Log(float64(y)))\n\t// fmt.Println(xLog, yLog)\n\tif y*xLog == yLog*x {\n\t\tfmt.Println(\"=\")\n\t\treturn\n\t} else if y*xLog > yLog*x {\n\t\tfmt.Println(\">\")\n\t} else if y*xLog < yLog*x {\n\t\tfmt.Println(\"<\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x, y int\n\tfmt.Scanf(\"%d\", &x)\n\tfmt.Scanf(\"%d\", &y)\n\n\tif x == y {\n\t\tfmt.Print(\"=\")\n\t\treturn\n\t}\n\tif x > y {\n\t\tif y >= 3 {\n\t\t\tfmt.Print(\"<\")\n\t\t\treturn\n\t\t}\n\t\tfmt.Print(\">\")\n\t\treturn\n\t}\n\tif x < y {\n\t\tif x >= 3 {\n\t\t\tfmt.Print(\">\")\n\t\t\treturn\n\t\t}\n\t\tfmt.Print(\"<\")\n\t\treturn\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x, y int\n\tfmt.Scanf(\"%d %d\\n\", &x, &y)\n\tif x == y {\n\t\tfmt.Println(\"=\")\n\t\treturn\n\t}\n\tif x > y {\n\t\tif y >= 3 {\n\t\t\tfmt.Println(\"<\")\n\t\t\treturn\n\t\t}\n\t\tfmt.Println(\">\")\n\t\treturn\n\t}\n\tif x < y {\n\t\tif x >= 3 {\n\t\t\tfmt.Println(\">\")\n\t\t\treturn\n\t\t}\n\t\tfmt.Println(\"<\")\n\t\treturn\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x, y int\n\tfmt.Scanf(\"%d %d\\n\", &x, &y)\n\n\tif x == y {\n\t\tfmt.Print(\"=\")\n\t\treturn\n\t}\n\tif x > y {\n\t\tif y >= 3 {\n\t\t\tfmt.Print(\"<\")\n\t\t\treturn\n\t\t}\n\t\tfmt.Print(\">\")\n\t\treturn\n\t}\n\tif x < y {\n\t\tif x >= 3 {\n\t\t\tfmt.Print(\">\")\n\t\t\treturn\n\t\t}\n\t\tfmt.Print(\"<\")\n\t\treturn\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x, y int\n\tfmt.Scanf(\"%d %d\\n\", &x, &y)\n\tif x == y {\n\t\tfmt.Println(\"=\")\n\t\treturn\n\t}\n\tif x > y {\n\t\tif y >= 3 {\n\t\t\tfmt.Println(\"<\")\n\t\t\treturn\n\t\t}\n\t\tif y == 2 {\n\t\t\tif x == 4 {\n\t\t\t\tfmt.Println(\"=\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif x == 3 {\n\t\t\t\tfmt.Println(\">\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif x > 4 {\n\t\t\t\tfmt.Println(\"<\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tif x < y {\n\t\tif x >= 3 {\n\t\t\tfmt.Println(\">\")\n\t\t\treturn\n\t\t}\n\t\tif x == 2 {\n\t\t\tif y == 4 {\n\t\t\t\tfmt.Println(\"=\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif y == 3 {\n\t\t\t\tfmt.Println(\"<\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif y > 4 {\n\t\t\t\tfmt.Println(\">\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x, y int\n\tfmt.Scanf(\"%d %d\", &x, &y)\n\n\tif x == y {\n\t\tfmt.Println(\"=\")\n\t\treturn\n\t}\n\tif x > y {\n\t\tif y >= 3 {\n\t\t\tfmt.Println(\"<\")\n\t\t\treturn\n\t\t}\n\t\tfmt.Println(\">\")\n\t}\n\tif x < y {\n\t\tif x >= 3 {\n\t\t\tfmt.Println(\">\")\n\t\t\treturn\n\t\t}\n\t\tfmt.Println(\"<\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x, y int\n\tfmt.Scanf(\"%d %d\\n\", &x, &y)\n\tif x == y {\n\t\tfmt.Println(\"=\")\n\t\treturn\n\t}\n\tif x > y {\n\t\tif y >= 3 {\n\t\t\tfmt.Println(\"<\")\n\t\t\treturn\n\t\t}\n\t\tif y == 2 {\n\t\t\tif x == 4 {\n\t\t\t\tfmt.Println(\"=\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif x == 3 {\n\t\t\t\tfmt.Println(\">\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif x > 4 {\n\t\t\t\tfmt.Println(\"<\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tif y == 1 {\n\t\t\tfmt.Println(\">\")\n\t\t}\n\t}\n\tif x < y {\n\t\tif x >= 3 {\n\t\t\tfmt.Println(\">\")\n\t\t\treturn\n\t\t}\n\t\tif x == 2 {\n\t\t\tif y == 4 {\n\t\t\t\tfmt.Println(\"=\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif y == 3 {\n\t\t\t\tfmt.Println(\"<\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif y > 4 {\n\t\t\t\tfmt.Println(\">\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tif y == 1 {\n\t\t\tfmt.Println(\"<\")\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tx := readInt()\n\ty := readInt()\n\tif y == x {\n\t\tfmt.Println(\"=\")\n\t} else if x == 1 {\n\t\tfmt.Println(\"<\")\n\t} else if y == 1 {\n\t\tfmt.Println(\">\")\n\t} else if x == 2 {\n\t\tfmt.Println(\"<\")\n\t} else if y == 2 {\n\t\tfmt.Println(\">\")\n\t} else if x > y {\n\t\tfmt.Println(\"<\")\n\t} else {\n\t\tfmt.Println(\">\")\n\t}\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tx := readInt()\n\ty := readInt()\n\tif y == x {\n\t\tfmt.Println(\"=\")\n\t} else if x == 1 {\n\t\tfmt.Println(\"<\")\n\t} else if y == 1 {\n\t\tfmt.Println(\">\")\n\t} else if x == 2 {\n\t\tfmt.Println(\"<\")\n\t} else if y == 2 {\n\t\tfmt.Println(\">\")\n\t} else if int64(x)*int64(x) > int64(y)*int64(y) {\n\t\tfmt.Println(\"<\")\n\t} else {\n\t\tfmt.Println(\">\")\n\t}\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tx := readInt()\n\ty := readInt()\n\tif y == x {\n\t\tfmt.Println(\"=\")\n\t\treturn\n\t}\n\tif y%x == 0 && y/x == x {\n\t\tfmt.Println(\"=\")\n\t\treturn\n\t}\n\tif x%y == 0 && x/y == y {\n\t\tfmt.Println(\"=\")\n\t\treturn\n\t}\n\tif x == 1 {\n\t\tfmt.Println(\"<\")\n\t} else if y == 1 {\n\t\tfmt.Println(\">\")\n\t} else if x == 2 {\n\t\tfmt.Println(\"<\")\n\t} else if y == 2 {\n\t\tfmt.Println(\">\")\n\t} else if int64(x)*int64(x) > int64(y)*int64(y) {\n\t\t//\t\t2 * 2 * 2 * 2\n\t\t//\n\t\t//\t\t4 * 4\n\t\tfmt.Println(\"<\")\n\t} else {\n\t\tfmt.Println(\">\")\n\t}\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tx := readInt()\n\ty := readInt()\n\tif y == x {\n\t\tfmt.Println(\"=\")\n\t} else if y < x {\n\t\tfmt.Println(\"<\")\n\t} else {\n\t\tfmt.Println(\">\")\n\t}\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}], "src_uid": "ec1e44ff41941f0e6436831b5ae543c6"} {"nl": {"description": "You are given three integers $$$a$$$, $$$b$$$ and $$$x$$$. Your task is to construct a binary string $$$s$$$ of length $$$n = a + b$$$ such that there are exactly $$$a$$$ zeroes, exactly $$$b$$$ ones and exactly $$$x$$$ indices $$$i$$$ (where $$$1 \\le i < n$$$) such that $$$s_i \\ne s_{i + 1}$$$. It is guaranteed that the answer always exists.For example, for the string \"01010\" there are four indices $$$i$$$ such that $$$1 \\le i < n$$$ and $$$s_i \\ne s_{i + 1}$$$ ($$$i = 1, 2, 3, 4$$$). For the string \"111001\" there are two such indices $$$i$$$ ($$$i = 3, 5$$$).Recall that binary string is a non-empty sequence of characters where each character is either 0 or 1.", "input_spec": "The first line of the input contains three integers $$$a$$$, $$$b$$$ and $$$x$$$ ($$$1 \\le a, b \\le 100, 1 \\le x < a + b)$$$.", "output_spec": "Print only one string $$$s$$$, where $$$s$$$ is any binary string satisfying conditions described above. It is guaranteed that the answer always exists.", "sample_inputs": ["2 2 1", "3 3 3", "5 3 6"], "sample_outputs": ["1100", "101100", "01010100"], "notes": "NoteAll possible answers for the first example: 1100; 0011. All possible answers for the second example: 110100; 101100; 110010; 100110; 011001; 001101; 010011; 001011. "}, "positive_code": [{"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n // initialize\n var a, b, x int\n var a_byte, b_byte byte = '0', '1'\n\n // read input\n fmt.Scan(&a, &b, &x)\n\n if a < b {\n a, b = b, a\n a_byte, b_byte = b_byte, a_byte\n }\n\n // print answer\n fmt.Printf(\"%c\", a_byte)\n a -= 1\n\n for x > 1 {\n fmt.Printf(\"%c\", b_byte)\n b -= 1\n\n a, b = b, a\n a_byte, b_byte = b_byte, a_byte\n\n x -= 1\n }\n\n // finish it\n for a > 0 {\n fmt.Printf(\"%c\", a_byte)\n a -= 1\n }\n for (b > 0) {\n fmt.Printf(\"%c\", b_byte)\n b -= 1\n }\n\n fmt.Println()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar a, b, x int\nvar i int\nvar s string\n\nfunc main() {\n\tfmt.Scan(&a, &b, &x)\n\n\tif x%2 == 0 {\n\t\tif a > b {\n\t\t\tfor i = 0; i < x/2; i++ {\n\t\t\t\ts += \"01\"\n\t\t\t}\n\n\t\t\tfor i = 0; i < b-x/2; i++ {\n\t\t\t\ts += \"1\"\n\t\t\t}\n\n\t\t\tfor i = 0; i < a-x/2; i++ {\n\t\t\t\ts += \"0\"\n\t\t\t}\n\t\t} else {\n\t\t\tfor i = 0; i < x/2; i++ {\n\t\t\t\ts += \"10\"\n\t\t\t}\n\n\t\t\tfor i = 0; i < a-x/2; i++ {\n\t\t\t\ts += \"0\"\n\t\t\t}\n\n\t\t\tfor i = 0; i < b-x/2; i++ {\n\t\t\t\ts += \"1\"\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif a > b {\n\t\t\tfor i = 0; i < x/2; i++ {\n\t\t\t\ts += \"01\"\n\t\t\t}\n\n\t\t\tfor i = 0; i < a-x/2; i++ {\n\t\t\t\ts += \"0\"\n\t\t\t}\n\n\t\t\tfor i = 0; i < b-x/2; i++ {\n\t\t\t\ts += \"1\"\n\t\t\t}\n\t\t} else {\n\t\t\tfor i = 0; i < x/2; i++ {\n\t\t\t\ts += \"10\"\n\t\t\t}\n\n\t\t\tfor i = 0; i < b-x/2; i++ {\n\t\t\t\ts += \"1\"\n\t\t\t}\n\n\t\t\tfor i = 0; i < a-x/2; i++ {\n\t\t\t\ts += \"0\"\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(s)\n}\n"}, {"source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t. \"strings\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tvar a, b, x int\n\tScan(&a, &b, &x)\n\tk := (x + 1) / 2\n\ta -= k\n\tb -= k\n\tR := Repeat\n\ts := R(\"01\", k)\n\tif x&1 > 0 {\n\t\ts = R(\"0\", a) + s + R(\"1\", b)\n\t} else if a > 0 {\n\t\ts += R(\"1\", b) + R(\"0\", a)\n\t} else {\n\t\ts = R(\"1\", b) + s\n\t}\n\tPrint(s)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b, x int\n\tfmt.Scan(&a, &b, &x)\n\tx++\n\tif a > b {\n\t\tfor ; x > 2; {\n\t\t\t\tfmt.Printf(\"01\")\n\t\t\t\tx -= 2\n\t\t\t\ta--\n\t\t\t\tb--\n\t\t\t\tcontinue\n\t\t}\n\t\tif x == 2 {\n\t\t\tfor ; a > 0 || b > 0 ; {\n\t\t\t\tif a != 0 {\n\t\t\t\t\tfmt.Printf(\"0\")\n\t\t\t\t\ta--\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif b != 0 {\n\t\t\t\t\tfmt.Printf(\"1\")\n\t\t\t\t\tb--\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ; a > 0 || b > 0 ; {\n\t\t\t\tif b != 0 {\n\t\t\t\t\tfmt.Printf(\"1\")\n\t\t\t\t\tb--\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif a != 0 {\n\t\t\t\t\tfmt.Printf(\"0\")\n\t\t\t\t\ta--\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor ; x > 2; {\n\t\t\tfmt.Printf(\"10\")\n\t\t\tx -= 2\n\t\t\ta--\n\t\t\tb--\n\t\t\tcontinue\n\t\t}\n\t\tif x == 2 {\n\t\t\tfor ; a > 0 || b > 0; {\n\t\t\t\tif b != 0 {\n\t\t\t\t\tfmt.Printf(\"1\")\n\t\t\t\t\tb--\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif a != 0 {\n\t\t\t\t\tfmt.Printf(\"0\")\n\t\t\t\t\ta--\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ; a > 0 || b > 0; {\n\t\t\t\tif a != 0 {\n\t\t\t\t\tfmt.Printf(\"0\")\n\t\t\t\t\ta--\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif b != 0 {\n\t\t\t\t\tfmt.Printf(\"1\")\n\t\t\t\t\tb--\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t. \"strings\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tvar a, b, x int\n\tScan(&a, &b, &x)\n\tk := (x + 1) / 2\n\ta -= k\n\tb -= k\n\tR := Repeat\n\ts := R(\"01\", k)\n\tif x&1 > 0 {\n\t\ts = R(\"0\", a) + s + R(\"1\", b)\n\t} else {\n\t\ts += R(\"1\", b) + R(\"0\", a)\n\t}\n\tPrint(s)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b, x int\n\tfmt.Scan(&a, &b, &x)\n\tif a > b {\n\t\tfor ; a > 0 || b > 0; {\n\t\t\tif x > 1 {\n\t\t\t\tfmt.Printf(\"10\")\n\t\t\t\tx -= 2\n\t\t\t\ta--\n\t\t\t\tb--\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif a != 0 {\n\t\t\t\tfmt.Printf(\"1\")\n\t\t\t\ta--\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif b != 0 {\n\t\t\t\tfmt.Printf(\"0\")\n\t\t\t\tb--\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor ; a > 0 || b > 0; {\n\t\t\tif x > 1 {\n\t\t\t\tfmt.Printf(\"01\")\n\t\t\t\tx -= 2\n\t\t\t\ta--\n\t\t\t\tb--\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif b != 0 {\n\t\t\t\tfmt.Printf(\"0\")\n\t\t\t\tb--\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif a != 0 {\n\t\t\t\tfmt.Printf(\"1\")\n\t\t\t\ta--\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b, x int\n\tfmt.Scan(&a, &b, &x)\n\tif a > b {\n\t\tfor ; a > 0 || b > 0; {\n\t\t\tif x > 1 {\n\t\t\t\tfmt.Printf(\"01\")\n\t\t\t\tx -= 2\n\t\t\t\ta--\n\t\t\t\tb--\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif b != 0 {\n\t\t\t\tfmt.Printf(\"1\")\n\t\t\t\tb--\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif a != 0 {\n\t\t\t\tfmt.Printf(\"0\")\n\t\t\t\ta--\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor ; a > 0 || b > 0; {\n\t\t\tif x > 1 {\n\t\t\t\tfmt.Printf(\"10\")\n\t\t\t\tx -= 2\n\t\t\t\ta--\n\t\t\t\tb--\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif a != 0 {\n\t\t\t\tfmt.Printf(\"0\")\n\t\t\t\ta--\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif b != 0 {\n\t\t\t\tfmt.Printf(\"1\")\n\t\t\t\tb--\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b, x int\n\tfmt.Scan(&a, &b, &x)\n\tif a > b {\n\t\tfor ; a > 0 || b > 0; {\n\t\t\tif x > 1 {\n\t\t\t\tfmt.Printf(\"01\")\n\t\t\t\tx -= 2\n\t\t\t\ta--\n\t\t\t\tb--\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif a != 0 {\n\t\t\t\tfmt.Printf(\"0\")\n\t\t\t\ta--\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif b != 0 {\n\t\t\t\tfmt.Printf(\"1\")\n\t\t\t\tb--\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor ; a > 0 || b > 0; {\n\t\t\tif x > 1 {\n\t\t\t\tfmt.Printf(\"10\")\n\t\t\t\tx -= 2\n\t\t\t\ta--\n\t\t\t\tb--\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif b != 0 {\n\t\t\t\tfmt.Printf(\"1\")\n\t\t\t\tb--\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif a != 0 {\n\t\t\t\tfmt.Printf(\"0\")\n\t\t\t\ta--\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t}\n\t}\n}\n"}], "src_uid": "ef4123b8f3f3b511fde8b79ea9a6b20c"} {"nl": {"description": "You are given an integer $$$n$$$ from $$$1$$$ to $$$10^{18}$$$ without leading zeroes.In one move you can swap any two adjacent digits in the given number in such a way that the resulting number will not contain leading zeroes. In other words, after each move the number you have cannot contain any leading zeroes.What is the minimum number of moves you have to make to obtain a number that is divisible by $$$25$$$? Print -1 if it is impossible to obtain a number that is divisible by $$$25$$$.", "input_spec": "The first line contains an integer $$$n$$$ ($$$1 \\le n \\le 10^{18}$$$). It is guaranteed that the first (left) digit of the number $$$n$$$ is not a zero.", "output_spec": "If it is impossible to obtain a number that is divisible by $$$25$$$, print -1. Otherwise print the minimum number of moves required to obtain such number. Note that you can swap only adjacent digits in the given number.", "sample_inputs": ["5071", "705", "1241367"], "sample_outputs": ["4", "1", "-1"], "notes": "NoteIn the first example one of the possible sequences of moves is 5071 $$$\\rightarrow$$$ 5701 $$$\\rightarrow$$$ 7501 $$$\\rightarrow$$$ 7510 $$$\\rightarrow$$$ 7150."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF988E(in io.Reader, out io.Writer) {\n\tvar s []byte\n\tFscan(in, &s)\n\tn, ans := len(s), 99\n\tif n < 2 {\n\t\tFprint(out, -1)\n\t\treturn\n\t}\n\tfor i := range s {\n\t\tfor j := range s {\n\t\t\tif i == j {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tt := make([]byte, n)\n\t\t\tcopy(t, s)\n\t\t\tc := 0\n\t\t\tfor k := i; k < n-1; k++ {\n\t\t\t\tt[k], t[k+1] = t[k+1], t[k]\n\t\t\t\tc++\n\t\t\t}\n\t\t\tk := j\n\t\t\tif j > i {\n\t\t\t\tk--\n\t\t\t}\n\t\t\tfor ; k < n-2; k++ {\n\t\t\t\tt[k], t[k+1] = t[k+1], t[k]\n\t\t\t\tc++\n\t\t\t}\n\t\t\tfor k = 0; t[k] == '0'; k++ {\n\t\t\t}\n\t\t\tfor ; k > 0; k-- {\n\t\t\t\tt[k], t[k-1] = t[k-1], t[k]\n\t\t\t\tc++\n\t\t\t}\n\t\t\tif v, _ := strconv.Atoi(string(t[n-2:])); c < ans && v%25 == 0 {\n\t\t\t\tans = c\n\t\t\t}\n\t\t}\n\t}\n\tif ans == 99 {\n\t\tans = -1\n\t}\n\tFprint(out, ans)\n}\n\nfunc main() { CF988E(os.Stdin, os.Stdout) }\n"}, {"source_code": "package main\n\nimport (\n\t. \"fmt\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tvar s []byte\n\tScan(&s)\n\tn, ans := len(s), 99\n\tif n < 2 {\n\t\tPrint(-1)\n\t\treturn\n\t}\n\tfor i := range s {\n\t\tfor j := range s {\n\t\t\tif i == j {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tt := make([]byte, n)\n\t\t\tcopy(t, s)\n\t\t\tc := 0\n\t\t\tfor k := i; k < n-1; k++ {\n\t\t\t\tt[k], t[k+1] = t[k+1], t[k]\n\t\t\t\tc++\n\t\t\t}\n\t\t\tk := j\n\t\t\tif j > i {\n\t\t\t\tk--\n\t\t\t}\n\t\t\tfor ; k < n-2; k++ {\n\t\t\t\tt[k], t[k+1] = t[k+1], t[k]\n\t\t\t\tc++\n\t\t\t}\n\t\t\tfor k = 0; t[k] == '0'; k++ {\n\t\t\t}\n\t\t\tfor ; k > 0; k-- {\n\t\t\t\tt[k], t[k-1] = t[k-1], t[k]\n\t\t\t\tc++\n\t\t\t}\n\t\t\tif c < ans && (t[n-2]&15*10+t[n-1]&15)%25 == 0 {\n\t\t\t\tans = c\n\t\t\t}\n\t\t}\n\t}\n\tif ans == 99 {\n\t\tans = -1\n\t}\n\tPrint(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst (\n\tINF = 12345\n)\n\nfunc Init() {\n}\n\nfunc Solve(io *FastIO) {\n\tS := io.NextLine()\n\n\tA := []rune(S)\n\tN := len(A)\n\n\tbest := INF\n\tfor i := 0; i < N; i++ {\n\t\tfor j := i + 1; j < N; j++ {\n\t\t\tif (A[i] == '0' && A[j] == '0') || (A[i] == '2' && A[j] == '5') || (A[i] == '5' && A[j] == '0') || (A[i] == '7' && A[j] == '5') {\n\t\t\t\tbest = Min(best, simulate(A, i, j))\n\t\t\t}\n\t\t\tif (A[i] == '5' && A[j] == '2') || (A[i] == '0' && A[j] == '5') || (A[i] == '5' && A[j] == '7') {\n\t\t\t\tbest = Min(best, simulate(A, j, i))\n\t\t\t}\n\t\t}\n\t}\n\tif best < INF {\n\t\tio.Println(best)\n\t} else {\n\t\tio.Println(-1)\n\t}\n}\n\nfunc simulate(A []rune, front, back int) int {\n\tN := len(A)\n\n\tX := make([]rune, N)\n\tcopy(X, A)\n\n\tif back < front {\n\t\tfront--\n\t}\n\n\ta := swapTo(X, back, N - 1)\n\tb := swapTo(X, front, N - 2)\n\tc := fix(X)\n\n\t// fmt.Printf(\"A = %v, front = %d, back = %d, a = %d, b = %d, c = %d\\n\", A, front, back, a, b, c)\n\n\treturn a + b + c\n}\n\nfunc swapTo(A []rune, i, j int) int {\n\tcnt := 0\n\tfor i + 1 <= j {\n\t\tA[i], A[i + 1] = A[i + 1], A[i]\n\t\tcnt++\n\t\ti++\n\t}\n\treturn cnt\n}\n\nfunc fix(A []rune) int {\n\tif A[0] != '0' {\n\t\treturn 0\n\t}\n\tfor i := 1; i < len(A) - 2; i++ {\n\t\tif A[i] != '0' {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn INF\n}\n\nfunc Min(args ...int) int {\n\tmin := args[0]\n\tfor i := 1; i < len(args); i++ {\n\t\tif args[i] < min {\n\t\t\tmin = args[i]\n\t\t}\n\t}\n\treturn min\n}\n\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}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst (\n\tINF = 12345\n)\n\nfunc Init() {\n}\n\nfunc Solve(io *FastIO) {\n\tS := io.NextLine()\n\n\tA := []rune(S)\n\tN := len(A)\n\n\tbest := INF\n\tfor i := 0; i < N; i++ {\n\t\tfor j := i + 1; j < N; j++ {\n\t\t\tif (A[i] == '0' && A[j] == '0') || (A[i] == '2' && A[j] == '5') || (A[i] == '5' && A[j] == '0') || (A[i] == '7' && A[j] == '5') {\n\t\t\t\tbest = Min(best, simulate(A, i, j))\n\t\t\t}\n\t\t\tif (A[i] == '5' && A[j] == '2') || (A[i] == '0' && A[j] == '5') || (A[i] == '5' && A[j] == '7') {\n\t\t\t\tbest = Min(best, simulate(A, j, i))\n\t\t\t}\n\t\t}\n\t}\n\tif best < INF {\n\t\tio.Println(best)\n\t} else {\n\t\tio.Println(-1)\n\t}\n}\n\nfunc simulate(A []rune, front, back int) int {\n\tN := len(A)\n\n\tX := make([]rune, N)\n\tcopy(X, A)\n\n\tif back < front {\n\t\tfront--\n\t}\n\n\ta := swapTo(X, back, N - 1)\n\tb := swapTo(X, front, N - 2)\n\tc := fix(X)\n\n\treturn a + b + c\n}\n\nfunc swapTo(A []rune, i, j int) int {\n\tcnt := 0\n\tfor i + 1 <= j {\n\t\tA[i], A[i + 1] = A[i + 1], A[i]\n\t\tcnt++\n\t\ti++\n\t}\n\treturn cnt\n}\n\nfunc fix(A []rune) int {\n\tif A[0] != '0' {\n\t\treturn 0\n\t}\n\tfor i := 1; i < len(A) - 2; i++ {\n\t\tif A[i] != '0' {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn INF\n}\n\nfunc Min(args ...int) int {\n\tmin := args[0]\n\tfor i := 1; i < len(args); i++ {\n\t\tif args[i] < min {\n\t\t\tmin = args[i]\n\t\t}\n\t}\n\treturn min\n}\n\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}"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst (\n\tINF = 12345\n)\n\nfunc Init() {\n}\n\nfunc Solve(io *FastIO) {\n\tS := io.NextLine()\n\n\tA := []rune(S)\n\tN := len(A)\n\n\tbest := INF\n\tfor i := 0; i < N; i++ {\n\t\tfor j := i + 1; j < N; j++ {\n\t\t\tif (A[i] == '0' && A[j] == '0') || (A[i] == '2' && A[j] == '5') || (A[i] == '5' && A[j] == '0') || (A[i] == '7' && A[j] == '5') {\n\t\t\t\tbest = Min(best, simulate(A, i, j))\n\t\t\t}\n\t\t\tif (A[i] == '5' && A[j] == '2') || (A[i] == '0' && A[j] == '5') || (A[i] == '5' && A[j] == '7') {\n\t\t\t\tbest = Min(best, simulate(A, i, j))\n\t\t\t}\n\t\t}\n\t}\n\tif best < INF {\n\t\tio.Println(best)\n\t} else {\n\t\tio.Println(-1)\n\t}\n}\n\nfunc simulate(A []rune, front, back int) int {\n\tN := len(A)\n\n\tX := make([]rune, N)\n\tcopy(A, X)\n\n\tif back < front {\n\t\tfront--\n\t}\n\n\ta := swapTo(X, back, N - 1)\n\tb := swapTo(X, front, N - 2)\n\tc := fix(X)\n\n\treturn a + b + c\n}\n\nfunc swapTo(A []rune, i, j int) int {\n\tcnt := 0\n\tfor i + 1 <= j {\n\t\tA[i], A[i + 1] = A[i + 1], A[i]\n\t\tcnt++\n\t\ti++\n\t}\n\treturn cnt\n}\n\nfunc fix(A []rune) int {\n\tif A[0] != '0' {\n\t\treturn 0\n\t}\n\tfor i := 1; i < len(A) - 2; i++ {\n\t\tif A[i] != '0' {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn INF\n}\n\nfunc Min(args ...int) int {\n\tmin := args[0]\n\tfor i := 1; i < len(args); i++ {\n\t\tif args[i] < min {\n\t\t\tmin = args[i]\n\t\t}\n\t}\n\treturn min\n}\n\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}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst (\n\tINF = 12345\n)\n\nfunc Init() {\n}\n\nfunc Solve(io *FastIO) {\n\tS := io.NextLine()\n\n\tA := []rune(S)\n\tN := len(A)\n\n\tbest := INF\n\tfor i := 0; i < N; i++ {\n\t\tfor j := i + 1; j < N; j++ {\n\t\t\tif (A[i] == '0' && A[j] == '0') || (A[i] == '2' && A[j] == '5') || (A[i] == '5' && A[j] == '0') || (A[i] == '7' && A[j] == '5') {\n\t\t\t\tbest = Min(best, simulate(A, i, j))\n\t\t\t}\n\t\t\tif (A[i] == '5' && A[j] == '2') || (A[i] == '0' && A[j] == '5') || (A[i] == '5' && A[j] == '7') {\n\t\t\t\tbest = Min(best, simulate(A, i, j))\n\t\t\t}\n\t\t}\n\t}\n\tif best < INF {\n\t\tio.Println(best)\n\t} else {\n\t\tio.Println(-1)\n\t}\n}\n\nfunc simulate(A []rune, front, back int) int {\n\tN := len(A)\n\n\tX := make([]rune, N)\n\tcopy(X, A)\n\n\tif back < front {\n\t\tfront--\n\t}\n\n\ta := swapTo(X, back, N - 1)\n\tb := swapTo(X, front, N - 2)\n\tc := fix(X)\n\n\treturn a + b + c\n}\n\nfunc swapTo(A []rune, i, j int) int {\n\tcnt := 0\n\tfor i + 1 <= j {\n\t\tA[i], A[i + 1] = A[i + 1], A[i]\n\t\tcnt++\n\t\ti++\n\t}\n\treturn cnt\n}\n\nfunc fix(A []rune) int {\n\tif A[0] != '0' {\n\t\treturn 0\n\t}\n\tfor i := 1; i < len(A) - 2; i++ {\n\t\tif A[i] != '0' {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn INF\n}\n\nfunc Min(args ...int) int {\n\tmin := args[0]\n\tfor i := 1; i < len(args); i++ {\n\t\tif args[i] < min {\n\t\t\tmin = args[i]\n\t\t}\n\t}\n\treturn min\n}\n\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": "ea1c737956f88be94107f2565ca8bbfd"} {"nl": {"description": "Pasha has a wooden stick of some positive integer length n. He wants to perform exactly three cuts to get four parts of the stick. Each part must have some positive integer length and the sum of these lengths will obviously be n. Pasha likes rectangles but hates squares, so he wonders, how many ways are there to split a stick into four parts so that it's possible to form a rectangle using these parts, but is impossible to form a square.Your task is to help Pasha and count the number of such ways. Two ways to cut the stick are considered distinct if there exists some integer x, such that the number of parts of length x in the first way differ from the number of parts of length x in the second way.", "input_spec": "The first line of the input contains a positive integer n (1 ≤ n ≤ 2·109) — the length of Pasha's stick.", "output_spec": "The output should contain a single integer — the number of ways to split Pasha's stick into four parts of positive integer length so that it's possible to make a rectangle by connecting the ends of these parts, but is impossible to form a square. ", "sample_inputs": ["6", "20"], "sample_outputs": ["1", "4"], "notes": "NoteThere is only one way to divide the stick in the first sample {1, 1, 2, 2}.Four ways to divide the stick in the second sample are {1, 1, 9, 9}, {2, 2, 8, 8}, {3, 3, 7, 7} and {4, 4, 6, 6}. Note that {5, 5, 5, 5} doesn't work."}, "positive_code": [{"source_code": "// stick.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tc := 0\n\tif n%2 == 0 {\n\t\tc = int((n - 1) / 4)\n\t}\n\tfmt.Println(c)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc solve(n int64) int64 {\n if n%2 != 0 {\n return 0 \n }\n if n < 6 {\n return 0\n }\n if n == 6 {\n return 1 \n }\n if n%4 == 0 {\n return n/4 - 1\n }\n return n/4\n}\n\nfunc main() {\n var n int64\n fmt.Scanf(\"%d\", &n)\n fmt.Println(solve(n))\n}\n"}, {"source_code": "package main\n\nimport \t\"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\ta := 0\n\tif n%2 == 0 {\n\t\ta = int((n - 1) / 4)\n\t}\n\tfmt.Println(a)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"math\"\n\nvar n float64\n\nfunc main() {\n fmt.Scanln(&n)\n if int(n)%2 != 0 {\n fmt.Println(0)\n return\n }\n ans := int(math.Ceil(((n / 2) / 2)))\n ans -= 1\n fmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, o int\n\tfmt.Scanln(&n)\n\tif n%2 != 0 {\n\t\to = 0\n\t} else {\n\t\tif n%4 == 0 {\n\t\t\to = n/4 - 1\n\t\t} else {\n\t\t\to = n / 4\n\t\t}\n\t}\n\tfmt.Println(o)\n}"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc solve(n int64) int64 {\n if n < 6 {\n return 0\n }\n if n == 6 {\n return 1 \n }\n if n%4 == 0 {\n return n/4 - 1\n }\n return n/4\n}\n\nfunc main() {\n var n int64\n fmt.Scanf(\"%d\", &n)\n fmt.Println(solve(n))\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc solve(n int64) int64 {\n if n < 6 {\n return 0\n }\n if n == 6 {\n return 1 \n }\n if n%4 == 0 {\n return n/4 - 1\n }\n return n/4 - 1\n}\n\nfunc main() {\n var n int64\n fmt.Scanf(\"%d\", &n)\n fmt.Println(solve(n))\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"math\"\n\nvar n float64\n\nfunc main() {\n fmt.Scanln(&n)\n if int(n)%2 == 0 {\n fmt.Println(0)\n return\n }\n ans := int(math.Ceil(((n / 2) / 2)))\n ans -= 1\n fmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, o int\n\tfmt.Scanln(&n)\n\tif n%4 == 0 {\n\t\to = n/4 - 1\n\t} else {\n\t\to = n / 4\n\t}\n\tfmt.Println(o)\n}"}], "src_uid": "32b59d23f71800bc29da74a3fe2e2b37"} {"nl": {"description": "Vanya got an important task — he should enumerate books in the library and label each book with its number. Each of the n books should be assigned with a number from 1 to n. Naturally, distinct books should be assigned distinct numbers.Vanya wants to know how many digits he will have to write down as he labels the books.", "input_spec": "The first line contains integer n (1 ≤ n ≤ 109) — the number of books in the library.", "output_spec": "Print the number of digits needed to number all the books.", "sample_inputs": ["13", "4"], "sample_outputs": ["17", "4"], "notes": "NoteNote to the first test. The books get numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, which totals to 17 digits.Note to the second sample. The books get numbers 1, 2, 3, 4, which totals to 4 digits."}, "positive_code": [{"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\tvar cnt, num, minus, length, base int64\n\n\tnum = n\n\tbase = 1\n\tlength = 1\n\n\tfor num >= 10 {\n\t\tminus += 9 * base\n\t\tcnt += 9 * base * length\n\t\tnum /= 10\n\t\tbase *= 10\n\t\tlength++\n\t}\n\n\tcnt += (n - minus) * length\n\n\tprintln(cnt)\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"os\"\n)\n\nvar in = bufio.NewScanner(os.Stdin)\nvar out = bufio.NewWriter(os.Stdout)\n\nfunc count(n int64) int64 {\n\tif n < 10 {\n\t\treturn int64(n)\n\t}\n\tvar l, p int64 = 1, 1\n\tfor p * 10 <= n {\n\t\tl++\n\t\tp *= 10\n\t}\n\n\treturn l * ((n / p - 1) * p + (n % p + 1)) + count(p - 1)\n}\n\nfunc main() {\n\n\tdefer out.Flush()\n\tin.Split(bufio.ScanWords)\n\n\tfmt.Fprintln(out, count(NextInt64()))\n}\n\nfunc Next() string{\n\tif !in.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn in.Text()\n}\n\nfunc NextInt() int{\n\tret, _ := strconv.Atoi(Next())\n\treturn ret\n}\n\nfunc NextInt64() int64 {\n\tret, _ := strconv.ParseInt(Next(), 10, 64)\n\treturn ret\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nfunc main() {\n //io\n scanner := bufio.NewReader(os.Stdin)\n writer := bufio.NewWriter(os.Stdout)\n //---\n var n, d, c, ans int64\n \n fmt.Fscan(scanner, &n)\n for c = 1; c <= n; c *= 10 {\n d++\n }\n //writer.WriteString(strconv.Itoa(c))\n c /= 10\n ans = (n - c + 1) * d;\n for d > 0 {\n ans += (c - c / 10) * (d-1);\n d--\n c /= 10\n }\n \n writer.WriteString(strconv.FormatInt(ans, 10))\n writer.Flush()\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar input uint64\n\tfmt.Scanf(\"%d\", &input)\n\tdigits := countDigits(input)\n\trem := (input - pow10(digits-1) + 1) * digits\n\tres := uint64(0)\n\tfor i := uint64(1); i < digits; i++ {\n\t\tres += (pow10(i) - pow10(i-1)) * i\n\t}\n\tfmt.Println(res + rem)\n}\n\nfunc pow10(n uint64) uint64 {\n\tif n == 0 {\n\t\treturn 1\n\t} else {\n\t\tres := uint64(1)\n\t\tfor ; n > 0; n-- {\n\t\t\tres *= 10\n\t\t}\n\t\treturn res\n\t}\n}\n\nfunc countDigits(ub uint64) uint64 {\n\tcount := uint64(0)\n\tfor ; ub > 0; ub /= 10 {\n\t\tcount++\n\t}\n\treturn count\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n \n var n int64\n fmt.Scanf(\"%v\\n\", &n)\n var count int64 = 0;\n \n var i,x int64 = 9,1;\n\n for n > 0 {\n if n < i {\n count += n*x;\n } else {\n count += i*x;\n }\n n -= i\n i *= 10\n x++\n }\n fmt.Printf(\"%v\\n\",count)\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"os\"\n)\n\nvar in = bufio.NewScanner(os.Stdin)\nvar out = bufio.NewWriter(os.Stdout)\n\nfunc count(n int64) int64 {\n\tif n < 10 {\n\t\treturn int64(n)\n\t}\n\tvar l, p int64 = 1, 1\n\tfor p * 10 <= n {\n\t\tl++\n\t\tp *= 10\n\t}\n\n\treturn l * (n / p) * (n % p + 1) + count(p - 1)\n}\n\nfunc main() {\n\n\tdefer out.Flush()\n\tin.Split(bufio.ScanWords)\n\n\tfmt.Fprintln(out, count(NextInt64()))\n}\n\nfunc Next() string{\n\tif !in.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn in.Text()\n}\n\nfunc NextInt() int{\n\tret, _ := strconv.Atoi(Next())\n\treturn ret\n}\n\nfunc NextInt64() int64 {\n\tret, _ := strconv.ParseInt(Next(), 10, 64)\n\treturn ret\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nfunc main() {\n //io\n scanner := bufio.NewReader(os.Stdin)\n writer := bufio.NewWriter(os.Stdout)\n //---\n var n, d, c, ans int\n \n fmt.Fscan(scanner, &n)\n for c = 1; c <= n; c *= 10 {\n d++\n }\n //writer.WriteString(strconv.Itoa(c))\n c /= 10\n ans = (n - c + 1) * d;\n for d > 0 {\n ans += (c - c / 10) * (d-1);\n d--\n c /= 10\n }\n \n writer.WriteString(strconv.Itoa(ans))\n writer.Flush()\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nfunc main() {\n //io\n scanner := bufio.NewReader(os.Stdin)\n writer := bufio.NewWriter(os.Stdout)\n //---\n var n, d, c, ans int\n \n fmt.Fscan(scanner, &n)\n for c = 1; c <= n; c *= 10 {\n d++\n }\n //writer.WriteString(strconv.Itoa(c))\n c /= 10\n b := d\n ans = (n - c) * d;\n for d > 0 {\n ans += (c - c / 10) * (b-d+1);\n d--\n c /= 10\n }\n \n writer.WriteString(strconv.Itoa(ans))\n writer.Flush()\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar input int\n\tfmt.Scanf(\"%d\", &input)\n\tdigits := countDigits(input)\n\trem := (input - pow10(digits-1) + 1) * digits\n\tres := 0\n\tfor i := 1; i < digits; i++ {\n\t\tres += (pow10(i) - pow10(i-1)) * i\n\t}\n\tfmt.Println(res + rem)\n}\n\nfunc pow10(n int) int {\n\tif n == 0 {\n\t\treturn 1\n\t} else {\n\t\tres := 1\n\t\tfor ; n > 0; n-- {\n\t\t\tres *= 10\n\t\t}\n\t\treturn res\n\t}\n}\n\nfunc countDigits(ub int) int {\n\tcount := 0\n\tfor ; ub > 0; ub /= 10 {\n\t\tcount++\n\t}\n\treturn count\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar input int\n\tfmt.Scanf(\"%d\", &input)\n\tdigits := countDigits(input)\n\trem := (input - pow10(digits-1) + 1) * digits\n\tres := 0\n\tfor i := 1; i < digits; i++ {\n\t\tres += pow10(i) - 1\n\t}\n\tfmt.Println(res + rem)\n}\n\nfunc pow10(n int) int {\n\tif n == 0 {\n\t\treturn 1\n\t} else {\n\t\tres := 1\n\t\tfor ; n > 0; n-- {\n\t\t\tres *= 10\n\t\t}\n\t\treturn res\n\t}\n}\n\nfunc countDigits(ub int) int {\n\tcount := 0\n\tfor ; ub > 0; ub /= 10 {\n\t\tcount++\n\t}\n\treturn count\n}\n"}], "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9"} {"nl": {"description": "You will receive 3 points for solving this problem.Manao is designing the genetic code for a new type of algae to efficiently produce fuel. Specifically, Manao is focusing on a stretch of DNA that encodes one protein. The stretch of DNA is represented by a string containing only the characters 'A', 'T', 'G' and 'C'.Manao has determined that if the stretch of DNA contains a maximal sequence of consecutive identical nucleotides that is of even length, then the protein will be nonfunctional. For example, consider a protein described by DNA string \"GTTAAAG\". It contains four maximal sequences of consecutive identical nucleotides: \"G\", \"TT\", \"AAA\", and \"G\". The protein is nonfunctional because sequence \"TT\" has even length.Manao is trying to obtain a functional protein from the protein he currently has. Manao can insert additional nucleotides into the DNA stretch. Each additional nucleotide is a character from the set {'A', 'T', 'G', 'C'}. Manao wants to determine the minimum number of insertions necessary to make the DNA encode a functional protein.", "input_spec": "The input consists of a single line, containing a string s of length n (1 ≤ n ≤ 100). Each character of s will be from the set {'A', 'T', 'G', 'C'}. This problem doesn't have subproblems. You will get 3 points for the correct submission.", "output_spec": "The program should print on one line a single integer representing the minimum number of 'A', 'T', 'G', 'C' characters that are required to be inserted into the input string in order to make all runs of identical characters have odd length.", "sample_inputs": ["GTTAAAG", "AACCAACCAAAAC"], "sample_outputs": ["1", "5"], "notes": "NoteIn the first example, it is sufficient to insert a single nucleotide of any type between the two 'T's in the sequence to restore the functionality of the protein."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\tvar s string\n\tfmt.Fscanf(reader, \"%s\", &s)\n\tcount, ans := 1, 0\n\tfor i := 1; i < len(s); i++ {\n\t\tif s[i] == s[i-1] {\n\t\t\tcount++\n\t\t} else {\n\t\t\tcount, ans = 1, ans+1-(count%2)\n\t\t}\n\t}\n\tans = ans + 1 - (count % 2)\n\tfmt.Printf(\"%d\", ans)\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t// \"time\"\n)\n\nfunc main() {\n\t// defer func(start time.Time) {\n\t// \tfmt.Println(time.Since(start))\n\t// }(time.Now())\n\n\treader := bufio.NewReader(os.Stdin)\n\n\tvar s string\n\tfmt.Fscan(reader, &s)\n\tvar c uint8\n\tvar index, count int\n\n\t// fmt.Println(s)\n\tfor i:=0; i 0; t-- {\n\t\tvar k int\n\t\tfmt.Scanf(\"%d\\n\", &k)\n\n\t\tif k == 100 {\n\t\t\tfmt.Println(1)\n\t\t} else {\n\t\t\tcurr := lcm(k, 100-k)\n\t\t\tfmt.Println(curr/k + curr/(100-k))\n\t\t}\n\t}\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"}, {"source_code": "package main\r\nimport( \r\n \"fmt\"\r\n \"bufio\"\r\n \"os\"\r\n)\r\nfunc main() {\r\n\tin:= bufio.NewReader(os.Stdin)\r\n\tout:= bufio.NewWriter(os.Stdout)\r\n\tdefer out.Flush()\r\n\tvar t int\r\n\tfmt.Fscan(in,&t)\r\n\tfor i:=0;i0;i--{\r\n\t\t\t\tif a%i == 0 {\r\n\t\t\t\t\tif b%i == 0 {\r\n\t\t\t\t\t\treturn i\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t} else {\r\n\t\tif a%b == 0 {\r\n\t\t\treturn b\r\n\t\t} else {\r\n\t\t\tfor i:=b/2;i>0;i--{\r\n\t\t\t\tif b%i == 0 {\r\n\t\t\t\t\tif a%i == 0 {\r\n\t\t\t\t\t\treturn i\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn 1\r\n}"}, {"source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"os\"\r\n)\r\n\r\nfunc gcd(a, b int) int {\r\n\tfor b != 0 {\r\n\t\ta, b = b, a%b\r\n\t}\r\n\treturn a\r\n}\r\n\r\nfunc main() {\r\n\tin := bufio.NewReader(os.Stdin)\r\n\tout := bufio.NewWriter(os.Stdout)\r\n\tdefer out.Flush()\r\n\r\n\tvar T int\r\n\tfmt.Fscan(in, &T)\r\n\tfor t := 0; t < T; t++ {\r\n\t\tvar k int\r\n\t\tfmt.Fscan(in, &k)\r\n\r\n\t\tfmt.Fprintln(out, 100/(gcd(k, 100)))\r\n\t}\r\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n)\n\n// var m []int\n// err = json.Unmarshal([]byte(r.FormValue(\"example\")), &m)\n\n// for i := 0; i < len(m); i++ {\n// \tfmt.Println(m[i])\n// }\n\n// sort.Slice(arr, func(i, j int) bool {\n// \treturn arr[i] > arr[j]\n// })\n\nfunc MIN(x, y int64) int64 {\n\tif x > y {\n\t\treturn y\n\t} else {\n\t\treturn x\n\t}\n}\n\nfunc MKO(x, y int64) int64 {\n\tif x < y {\n\t\treturn 0\n\t} else {\n\t\treturn x - y + 1\n\t}\n}\n\nfunc MAX(x, y int64) int64 {\n\tif x > y {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc LCM(x, y int) int {\n\tif x >= y {\n\t\tinitial := x\n\t\tfor i := 1; i < y+2; i++ {\n\t\t\tif initial%y == 0 {\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\tinitial = initial + x\n\t\t\t}\n\n\t\t}\n\t\treturn initial\n\t} else {\n\t\tinitial := y\n\t\tfor i := 1; i < x+2; i++ {\n\t\t\tif initial%x == 0 {\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\tinitial = initial + y\n\t\t\t}\n\n\t\t}\n\t\treturn initial\n\t}\n}\n\nfunc GCD(x, y int64) int64 {\n\tvar l, q int64\n\tl = MAX(x, y)\n\tq = MIN(x, y)\n\tvar m int64\n\tfor l*q > 0 {\n\t\ta := l % q\n\t\tb := l - a\n\t\tcc := int64(b / q)\n\t\tremain := l - cc*q\n\t\tl = MAX(remain, q)\n\t\tq = MIN(remain, q)\n\t\tif l*q == 0 {\n\t\t\tm = l + q\n\t\t\tbreak\n\t\t}\n\n\t}\n\treturn m\n\n}\n\nfunc IsItPrime(x int) bool {\n\tif x < 10 {\n\t\tif x == 2 || x == 3 || x == 5 || x == 7 {\n\t\t\treturn true\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t} else {\n\t\tj := 0\n\t\tk := math.Sqrt(float64(x))\n\t\tfor m := 3; m <= int(k); {\n\t\t\tif x%m == 0 {\n\t\t\t\tj = 1\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tm = m + 2\n\t\t}\n\t\tif j == 1 {\n\t\t\treturn false\n\t\t} else {\n\t\t\treturn true\n\t\t}\n\t}\n\n}\n\nvar t int\n\nfunc main() {\n\tvar input io.Reader = bufio.NewReader(os.Stdin)\n\tfmt.Fscan(input, &t)\n\tfor o := 0; o < t; o++ {\n\t\tvar k int\n\t\tfmt.Fscan(input, &k)\n\t\tm := 1\n\t\tif k%2 == 0 {\n\t\t\tm = m * 2\n\t\t\tk = int(k / 2)\n\t\t}\n\t\tif k%2 == 0 {\n\t\t\tm = m * 2\n\t\t\tk = int(k / 2)\n\t\t}\n\t\tif k%5 == 0 {\n\t\t\tm = m * 5\n\t\t\tk = int(k / 5)\n\t\t}\n\t\tif k%5 == 0 {\n\t\t\tm = m * 5\n\t\t\tk = int(k / 5)\n\t\t}\n\t\tfmt.Println(100 / m)\n\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n)\n\n// var m []int\n// err = json.Unmarshal([]byte(r.FormValue(\"example\")), &m)\n\n// for i := 0; i < len(m); i++ {\n// \tfmt.Println(m[i])\n// }\n\n// sort.Slice(arr, func(i, j int) bool {\n// \treturn arr[i] > arr[j]\n// })\n\nfunc MIN(x, y int64) int64 {\n\tif x > y {\n\t\treturn y\n\t} else {\n\t\treturn x\n\t}\n}\n\nfunc MKO(x, y int64) int64 {\n\tif x < y {\n\t\treturn 0\n\t} else {\n\t\treturn x - y + 1\n\t}\n}\n\nfunc MAX(x, y int64) int64 {\n\tif x > y {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc LCM(x, y int) int {\n\tif x >= y {\n\t\tinitial := x\n\t\tfor i := 1; i < y+2; i++ {\n\t\t\tif initial%y == 0 {\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\tinitial = initial + x\n\t\t\t}\n\n\t\t}\n\t\treturn initial\n\t} else {\n\t\tinitial := y\n\t\tfor i := 1; i < x+2; i++ {\n\t\t\tif initial%x == 0 {\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\tinitial = initial + y\n\t\t\t}\n\n\t\t}\n\t\treturn initial\n\t}\n}\n\nfunc GCD(x, y int64) int64 {\n\tvar l, q int64\n\tl = MAX(x, y)\n\tq = MIN(x, y)\n\tvar m int64\n\tfor l*q > 0 {\n\t\ta := l % q\n\t\tb := l - a\n\t\tcc := int64(b / q)\n\t\tremain := l - cc*q\n\t\tl = MAX(remain, q)\n\t\tq = MIN(remain, q)\n\t\tif l*q == 0 {\n\t\t\tm = l + q\n\t\t\tbreak\n\t\t}\n\n\t}\n\treturn m\n\n}\n\nfunc IsItPrime(x int) bool {\n\tif x < 10 {\n\t\tif x == 2 || x == 3 || x == 5 || x == 7 {\n\t\t\treturn true\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t} else {\n\t\tj := 0\n\t\tk := math.Sqrt(float64(x))\n\t\tfor m := 3; m <= int(k); {\n\t\t\tif x%m == 0 {\n\t\t\t\tj = 1\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tm = m + 2\n\t\t}\n\t\tif j == 1 {\n\t\t\treturn false\n\t\t} else {\n\t\t\treturn true\n\t\t}\n\t}\n\n}\n\nvar t int\n\nfunc main() {\n\tvar input io.Reader = bufio.NewReader(os.Stdin)\n\tfmt.Fscan(input, &t)\n\tfor o := 0; o < t; o++ {\n\t\tvar k int64\n\t\tfmt.Fscan(input, &k)\n\n\t\tif k == 100 {\n\t\t\tfmt.Println(1)\n\t\t} else {\n\t\t\tm := GCD(k, 100-k)\n\t\t\tsum := int(k/m) + int((100-k)/m)\n\t\t\tfmt.Println(sum)\n\t\t}\n\n\t}\n}\n"}, {"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 T int\n\t_, err := fmt.Fscanln(input, &T)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfor k := 0; k < T; k++ {\n\t\tvar x int\n\t\t_, err := fmt.Fscanln(input, &x)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tans := 100\n\t\tfor _, y := range ps {\n\t\t\tif x%y == 0 {\n\t\t\t\tx /= y\n\t\t\t\tans /= y\n\t\t\t}\n\t\t}\n\t\tfmt.Println(ans)\n\t}\n}\n\nvar (\n\tps = []int{2, 2, 5, 5}\n)\n"}, {"source_code": "package main\r\n \r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"os\"\r\n)\r\n \r\nfunc main() {\r\n\tinput := bufio.NewReader(os.Stdin)\r\n\tvar T int\r\n\t_, err := fmt.Fscanln(input, &T)\r\n\tif err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n\tfor k := 0; k < T; k++ {\r\n\t\tvar x int\r\n\t\t_, err := fmt.Fscanln(input, &x)\r\n\t\tif err != nil {\r\n\t\t\tpanic(err)\r\n\t\t}\r\n\t\tans := 100\r\n\t\tfor _, y := range ps {\r\n\t\t\tif x%y == 0 {\r\n\t\t\t\tx /= y\r\n\t\t\t\tans /= y\r\n\t\t\t}\r\n\t\t}\r\n\t\tfmt.Println(ans)\r\n\t}\r\n}\r\n \r\nvar (\r\n\tps = []int{2, 2, 5, 5}\r\n)"}, {"source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"os\"\r\n\t\"strconv\"\r\n\t\"strings\"\r\n)\r\n\r\ntype CF1525A 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 *CF1525A) 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 *CF1525A) 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 *CF1525A) 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 *CF1525A) 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 *CF1525A) NextString() string {\r\n\tin.load()\r\n\tval := strings.TrimSpace(in.split[in.index])\r\n\tin.index++\r\n\treturn val\r\n}\r\n\r\n/**\r\nRun solve the problem CF1525A\r\nDate: 22/11/21\r\nUser: epradere\r\nURL: https://codeforces.com/problemset/problem/1525/A\r\nProblem: CF1525A\r\n**/\r\nfunc (in *CF1525A) Run() {\r\n\tfor t := in.NextInt(); t > 0; t-- {\r\n\t\tmagic := in.NextInt()\r\n\t\twater := 100 - magic\r\n\t\tdiv := Max(magic, water)\r\n\t\tans := 0\r\n\t\tfor {\r\n\t\t\tif magic%div == 0 && water%div == 0 {\r\n\t\t\t\tmagic /= div\r\n\t\t\t\twater /= div\r\n\t\t\t\tdiv = Max(magic, water)\r\n\t\t\t} else {\r\n\t\t\t\tdiv--\r\n\t\t\t}\r\n\t\t\tif div == 1 {\r\n\t\t\t\tans = magic + water\r\n\t\t\t\tbreak\r\n\t\t\t}\r\n\t\t}\r\n\t\tfmt.Println(ans)\r\n\r\n\t}\r\n}\r\n\r\nfunc Max(a, b int) int {\r\n\tif a > b {\r\n\t\treturn a\r\n\t}\r\n\treturn b\r\n}\r\n\r\nfunc NewCF1525A(r *bufio.Reader) *CF1525A {\r\n\treturn &CF1525A{\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\tNewCF1525A(bufio.NewReader(os.Stdin)).Run()\r\n}\r\n"}, {"source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"os\"\r\n)\r\n\r\nvar (\r\n\treader = bufio.NewReader(os.Stdin)\r\n\tt, k int\r\n)\r\n\r\nfunc gcd(x, y int) int {\r\n\tif x < y {\r\n\t\tx, y = y, x\r\n\t}\r\n\tfor y > 0 {\r\n\t\tx, y = y, x%y\r\n\t}\r\n\treturn x\r\n}\r\n\r\nfunc solve(k int) int {\r\n\tg := gcd(k, 100-k)\r\n\treturn 100 / g\r\n}\r\n\r\nfunc main() {\r\n\tfmt.Fscan(reader, &t)\r\n\tfor ; t > 0; t-- {\r\n\t\tfmt.Fscan(reader, &k)\r\n\t\tfmt.Println(solve(k))\r\n\t}\r\n}\r\n"}, {"source_code": "package main\r\n\r\nimport \"fmt\"\r\n\r\n//t = int(input())\r\n//for _ in range(t):\r\n// k = int(input())\r\n// n = 100\r\n// while n != k:\r\n// if n > k:\r\n// n -= k\r\n// else:\r\n// k -= n\r\n// print(int(100 / k))\r\n\r\nfunc main() {\r\n\tvar t int\r\n\tfmt.Scanln(&t)\r\n\tfor i := 0; i < t; i++ {\r\n\t\tvar k int\r\n\t\tfmt.Scanln(&k)\r\n\t\tn := 100\r\n\t\tfor n != k {\r\n\t\t\tif n > k {\r\n\t\t\t\tn -= k\r\n\t\t\t} else {\r\n\t\t\t\tk -= n\r\n\t\t\t}\r\n\t\t}\r\n\t\tfmt.Println(100 / k)\r\n\t}\r\n}"}, {"source_code": "// 要求essence达到特定百分比,但总量最少,本质上就是求essence与100的最大公约数,约掉。\n\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar t, k int\n\tfmt.Scan(&t)\n\tfor i := 0; i < t; i++ {\n\t\tfmt.Scan(&k)\n\t\tfmt.Println(100 / gcd(100, k))\n\t}\n}\n\n// 求最大公约数\nfunc gcd(a, b int) int {\n\tif a < b {\n\t\ta, b = b, a\n\t}\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn gcd(b, a%b)\n}\n"}, {"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 min(a, b int) int {\r\n\r\n\tif a < b {\r\n\t\treturn a\r\n\t}\r\n\treturn b\r\n}\r\n\r\nfunc run(r io.Reader, w io.Writer) {\r\n\r\n\tin := bufio.NewReader(r)\r\n\tout := bufio.NewWriter(w)\r\n\tdefer out.Flush()\r\n\r\n\tsolve := func() {\r\n\r\n\t\tvar n int\r\n\t\t\r\n\r\n\r\n\t\tfmt.Fscan(in, &n)\r\n \t\t\r\n \t\t\r\n\t\tfmt.Fprintln(out, 100 / gcd(n,100) )\r\n\r\n\t\r\n\r\n\t}\r\n\r\n\tT := 1\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() {\r\n\r\n\trun(os.Stdin, os.Stdout)\r\n}\r\n\r\nfunc gcd(a, b int) int {\r\n\tfor a != 0 {\r\n\t\ta, b = b%a, a\r\n\t\t//fmt.Println(\"a =>\",a , \"b =>\",b)\r\n\t}\r\n\treturn b\r\n}"}, {"source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"os\"\r\n\t\"fmt\"\r\n)\r\n\r\nfunc main() {\r\n\r\n\tr := bufio.NewReader(os.Stdin)\r\n\r\n\tvar t int\r\n\r\n\tfmt.Fscan(r, &t)\r\n\r\n\r\n\tfor i := 0; i < t; i++ {\r\n\t\tvar k int\r\n\r\n\t\tfmt.Fscan(r, &k)\r\n\r\n\t\tans := solve(k)\r\n\r\n\t\tfmt.Println(ans)\r\n\r\n\t}\r\n}\r\n\r\nfunc solve(k int) int {\r\n\tfor j := 0; j <= 100; j++ {\r\n\t\tfor p := 0; p <= 100; p++ {\r\n\t\t\tif j == 0 && p == 0 {\r\n\t\t\t\tcontinue\r\n\t\t\t}\r\n\t\t\tif 100 * j == k * (j + p) {\r\n\t\t\t\treturn j + p\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn -1\r\n}\r\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"strings\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc run(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tsolve := func(Case int) {\n\t\tvar n int\n\t\tFscan(in, &n)\n\t\tg := gcd(n,100)\n\t\tFprintln(out, 100/g)\n\t}\n\n\tT := 1\n\tFscan(in, &T) //\n\tfor Case := 1; Case <= T; Case++ {\n\t\tsolve(Case)\n\t}\n\n\t_leftData, _ := ioutil.ReadAll(in)\n\tif _s := strings.TrimSpace(string(_leftData)); _s != \"\" {\n\t\tpanic(\"有未读入的数据:\\n\" + _s)\n\t}\n}\n\nfunc main() { run(os.Stdin, os.Stdout) }\nfunc gcd(a, b int) int {\n\tfor a != 0 {\n\t\ta, b = b%a, a\n\t}\n\treturn b\n}"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar t int\n\tfmt.Scan(\"%d\", &t)\n\n\tfor ; t > 0; t-- {\n\t\tvar k int\n\t\tfmt.Scan(\"%d\", &k)\n\n\t\tif k == 100 {\n\t\t\tfmt.Println(1)\n\t\t} else {\n\t\t\tcurr := lcm(k, 100-k)\n\t\t\tfmt.Println(curr/k + curr/(100-k))\n\t\t}\n\t}\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"}, {"source_code": "package main\r\nimport( \r\n \"fmt\"\r\n \"bufio\"\r\n \"os\"\r\n)\r\nfunc main() {\r\n\tin:= bufio.NewReader(os.Stdin)\r\n\tout:= bufio.NewWriter(os.Stdout)\r\n\tdefer out.Flush()\r\n\tvar t int\r\n\tfmt.Fscan(in,&t)\r\n\tfor i:=0;i 1\n}\n\nfunc withSameCase(word string) string {\n\tlowerCount := 0\n\tfor _, letter := range word {\n\t\tif unicode.IsLower(letter) {\n\t\t\tlowerCount++\n\t\t}\n\t}\n\tif lowerCount*2 >= len(word) {\n\t\treturn strings.ToLower(word)\n\t}\n\treturn strings.ToUpper(word)\n}\n\nfunc solve(matrix [][]int) []string {\n\tn := 3\n\tstate := make([][]byte, n)\n\tfor i := range state {\n\t\tstate[i] = make([]byte, n)\n\t\tfor j := range matrix[i] {\n\t\t\tstate[i][j] = byte(matrix[i][j])\n\t\t\tif i > 0 {\n\t\t\t\tstate[i][j] += byte(matrix[i-1][j])\n\t\t\t}\n\t\t\tif i+1 < n {\n\t\t\t\tstate[i][j] += byte(matrix[i+1][j])\n\t\t\t}\n\t\t\tif j > 0 {\n\t\t\t\tstate[i][j] += byte(matrix[i][j-1])\n\t\t\t}\n\t\t\tif j+1 < n {\n\t\t\t\tstate[i][j] += byte(matrix[i][j+1])\n\t\t\t}\n\t\t\tstate[i][j] &= 1\n\t\t\tstate[i][j] ^= 1\n\t\t\tstate[i][j] += '0'\n\t\t}\n\t}\n\tres := make([]string, n)\n\tfor i := range res {\n\t\tres[i] = string(state[i])\n\t}\n\treturn res\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc abs64(a int64) int64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max64(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min64(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar (\n\treader = bufio.NewReaderSize(os.Stdin, 1<<13)\n\twriter = bufio.NewWriterSize(os.Stdout, 1<<13)\n)\n\nfunc readi() int {\n\treturn int(readi64())\n}\n\nfunc read2i() (int, int) {\n\treturn readi(), readi()\n}\n\nfunc read3i() (int, int, int) {\n\treturn readi(), readi(), readi()\n}\n\nfunc read4i() (int, int, int, int) {\n\treturn readi(), readi(), readi(), readi()\n}\n\nfunc readis(n int) []int {\n\tres := make([]int, n)\n\tfor i := range res {\n\t\tres[i] = readi()\n\t}\n\treturn res\n}\n\nfunc readi64() int64 {\n\tb, err := reader.ReadByte()\n\tfor !isValid(b, err) {\n\t\tb, err = reader.ReadByte()\n\t}\n\tsign, res := int64(1), int64(0)\n\tif b == '-' {\n\t\tsign *= -1\n\t\tb, err = reader.ReadByte()\n\t}\n\tfor isValid(b, err) {\n\t\tres = res*10 + int64(b-'0')\n\t\tb, err = reader.ReadByte()\n\t}\n\treturn res * sign\n}\n\nfunc readi64s(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := range res {\n\t\tres[i] = readi64()\n\t}\n\treturn res\n}\n\nfunc readline() string {\n\tres := new(bytes.Buffer)\n\tfor {\n\t\tline, isPrefix, err := reader.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tres.Write(line)\n\t\tif !isPrefix {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn res.String()\n}\n\nfunc isValid(b byte, err error) bool {\n\treturn err == nil && (('0' <= b && b <= '9') || b == '-')\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tx:= [...]int{2,3,5,7,11,13,17,19,23,29,31,37,41,43,47}\n\tvar n,m int\n\tp:=15\n\tfmt.Scan(&n,&m)\n\to:=false\n\tfor i:=0;i= i (dari 2..(i-1))\n if i%j == 0 { prime = false; break }// jika i habis dibagi j, maka prime diubah menjadi false dan break\n }\n if prime { // jika nilai prime = true\n if i == m { ans = true } // jika nilai i sama dengan nilai m, maka ans diubah menjadi true\n break // break dari looping\n }\n }\n if ans { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") } // jika nilai ans = true, maka cetak output \"YES\". Jika tidak, maka cetak output \"NO\"\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n,m int\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(in, \"%d %d\\n\", &n, &m)\n\tif check(n,m){\n\t\tfmt.Println(\"YES\")\n\t}else{\n\t\tfmt.Println(\"NO\")\n\t}\n}\nfunc check(n int, m int) bool{\n\tfor i:= n + 1; i <= m; i++{\n\t\tif checkPrime(i) > 0{\n\t\t\tif i == m{\n\t\t\t\treturn true\n\t\t\t}else{\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\nfunc checkPrime(a int) int{\n\tfor k:= 2; k < a; k++{\n\t\tif a % k == 0{\n\t\t\treturn -1\n\t\t}\n\t}\n\treturn a\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tx:= [...]int{2,3,5,7,11,13,17,19,23,29,31,37,41,43,47}\n\tvar n,m int\n\tp:=15\n\tfmt.Scan(&n,&m)\n\to:=false\n\tfor i:=0;i 0 {\n\t\tif (b & 1) == 1 {\n\t\t\tret = ret * a % mod\n\t\t\tb--\n\t\t} else {\n\t\t\ta = a * a % mod\n\t\t\tb /= 2\n\t\t}\n\t}\n\treturn ret\n}\n\nfunc main() {\n\tvar reader = bufio.NewReader(os.Stdin)\n\tvar writer = bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tfmt.Fscanf(reader, \"%d %d %d %d\", &n, &m, &L, &R)\n\n\tvar diff = R - L + 1\n\tvar odd = diff / 2\n\tvar evn = diff / 2\n\n\tif diff % 2 != 0 {\n\t\tif L % 2 == 0 {\n\t\t\tevn++\n\t\t} else {\n\t\t\todd++\n\t\t}\n\t}\n\n\tvar T = int64(n) * int64(m)\n\n\tvar ret = pw(int64(evn + odd), T)\n\tret = (ret + pw(int64(evn - odd + mod), T)) % mod\n\n\tif ret < 0 {\n\t\tret += mod\n\t}\n\n\tif T % 2 == 1 {\n\t\tevn, odd = odd, evn\n\t\tret += pw(int64(evn + odd), T)\n\t\tret %= mod\n\t\tret += pw(int64(evn - odd + mod), T)\n\t\tret %= mod\n\t}\n\n\tret = ret * pw(2, mod - 2) % mod\n\tfmt.Fprintf(writer, \"%d\", ret)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nconst mod = 998244353\nconst N = 2\nvar n, m, L, R int\n\ntype matrix struct {\n\tf[N][N] int64\n}\n\nfunc print_out(a matrix) {\n\tfor i := 0; i < N; i++ {\n\t\tfor j := 0; j < N; j++ {\n\t\t\tfmt.Fprintf(writer, \"%d \", a.f[i][j])\n\t\t}\n\t\tfmt.Fprintf(writer, \"\\n\")\n\t}\n}\n\nfunc mul(a matrix, b matrix) matrix {\n\tvar c = matrix{}\n\tfor i := 0; i < N; i++ {\n\t\tfor j := 0; j < N; j++ {\n\t\t\tfor k := 0; k < N; k++ {\n\t\t\t\tc.f[i][j] += a.f[i][k] * b.f[k][j]\n\t\t\t\tc.f[i][j] %= mod\n\t\t\t}\n\t\t}\n\t}\n\treturn c\n}\n\nfunc pw(a matrix, b int64) matrix {\n\tvar ret = matrix{}\n\tfor i := 0; i < N; i++ {\n\t\tret.f[i][i] = 1\n\t}\n\n\tfor b > 0 {\n\t\tif (b & 1) == 1 {\n\t\t\tret = mul(ret, a)\n\t\t\tb--\n\t\t} else {\n\t\t\ta = mul(a, a)\n\t\t\tb /= 2\n\t\t}\n\t}\n\treturn ret\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tfmt.Fscanf(reader, \"%d %d %d %d\", &n, &m, &L, &R)\n\n\tvar O = int64(R - L + 1) / 2\n\tvar E = int64(R - L + 1) / 2\n\tif (R - L + 1) % 2 != 0 {\n\t\tif L%2 == 0 {\n\t\t\tE++\n\t\t} else {\n\t\t\tO++\n\t\t}\n\t}\n\n\tvar T = int64(n) * int64(m)\n\n\tvar mt = matrix{}\n\tmt.f[0][0] = E\n\tmt.f[0][1] = O\n\tmt.f[1][0] = O\n\tmt.f[1][1] = E\n\n\t//print_out(mt)\n\n\tmt = pw(mt, T - 1)\n\n\t//print_out(mt)\n\n\tvar dp_odd = O\n\tvar dp_evn = E\n\n\tvar fn_dp_odd = mt.f[0][0] * dp_odd % mod + mt.f[1][0] * dp_evn % mod\n\tfn_dp_odd %= mod\n\n\tvar fn_dp_evn = mt.f[1][0] * dp_odd % mod + mt.f[1][1] * dp_evn % mod\n\tfn_dp_evn %= mod\n\n\tvar ret int64\n\tif T % 2 == 1 {\n\t\tret = (fn_dp_odd + fn_dp_evn) % mod\n\t} else {\n\t\tret = fn_dp_evn\n\t}\n\n\tfmt.Fprintf(writer, \"%d\", ret)\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst mod = 998244353\nvar n, m, L, R int\n\nfunc pw(a int, b int) int {\n\tif a == 0 {\n\t\tif b == 0 {\n\t\t\treturn 1\n\t\t}\n\t\treturn 0\n\t}\n\tvar ret = 1\n\tfor b > 0 {\n\t\tif (b & 1) == 1 {\n\t\t\tret = int(int64(ret) * int64(a) % mod)\n\t\t\tb--\n\t\t} else {\n\t\t\ta = int(int64(a) * int64(a) % mod)\n\t\t\tb /= 2\n\t\t}\n\t}\n\treturn ret\n}\n\nfunc main() {\n\tvar reader = bufio.NewReader(os.Stdin)\n\tvar writer = bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tfmt.Fscanf(reader, \"%d %d %d %d\", &n, &m, &L, &R)\n\n\tvar diff = R - L + 1\n\tvar odd = diff / 2\n\tvar evn = diff / 2\n\n\tif diff % 2 != 0 {\n\t\tif L % 2 == 0 {\n\t\t\tevn++\n\t\t} else {\n\t\t\todd++\n\t\t}\n\t}\n\n\tvar T = int(int64(n) * int64(m) % (mod - 1))\n\tvar ret = pw(evn + odd, T)\n\tret = (ret + pw(evn - odd + mod, T)) % mod\n\n\tif ret < 0 {\n\t\tret += mod\n\t}\n\n\tif int64(n) * int64(m) % 2 == 1 {\n\t\tevn, odd = odd, evn\n\t\tret += pw(evn + odd, T)\n\t\tret %= mod\n\t\tret += pw(evn - odd + mod, T)\n\t\tret %= mod\n\t}\n\n\tret = int(int64(ret) * int64(pw(2, mod - 2)) % mod)\n\tfmt.Fprintf(writer, \"%d\", ret)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst mod = 998244353\nvar n, m, L, R int\n\nfunc pw(a int, b int) int {\n\tif a == 0 {\n\t\tif b == 0 {\n\t\t\treturn 1\n\t\t}\n\t\treturn 0\n\t}\n\tvar ret = 1\n\tfor b > 0 {\n\t\tif (b & 1) == 1 {\n\t\t\tret = int(int64(ret) * int64(a) % mod)\n\t\t\tb--\n\t\t} else {\n\t\t\ta = int(int64(a) * int64(a) % mod)\n\t\t\tb /= 2\n\t\t}\n\t}\n\treturn ret\n}\n\nfunc main() {\n\tvar reader = bufio.NewReader(os.Stdin)\n\tvar writer = bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tfmt.Fscanf(reader, \"%d %d %d %d\", &n, &m, &L, &R)\n\n\tvar diff = R - L + 1\n\tvar odd = diff / 2\n\tvar evn = diff / 2\n\n\tif diff % 2 != 0 {\n\t\tif L % 2 == 0 {\n\t\t\tevn++\n\t\t} else {\n\t\t\todd++\n\t\t}\n\t}\n\n\tvar T = int(int64(n) * int64(m) % (mod - 1))\n\tvar ret = pw(evn + odd, T)\n\tret = (ret + pw(evn - odd, T)) % mod\n\n\tif ret < 0 {\n\t\tret += mod\n\t}\n\n\tret = int(int64(ret) * int64(pw(2, mod - 2)) % mod)\n\tfmt.Fprintf(writer, \"%d\", ret)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst mod = 998244353\nvar n, m, L, R int\n\nfunc pw(a int, b int) int {\n\tif a == 0 {\n\t\tif b == 0 {\n\t\t\treturn 1\n\t\t}\n\t\treturn 0\n\t}\n\tvar ret = 1\n\tfor b > 0 {\n\t\tif (b & 1) == 1 {\n\t\t\tret = int(int64(ret) * int64(a) % mod)\n\t\t\tb--\n\t\t} else {\n\t\t\ta = int(int64(a) * int64(a) % mod)\n\t\t\tb /= 2\n\t\t}\n\t}\n\treturn ret\n}\n\nfunc main() {\n\tvar reader = bufio.NewReader(os.Stdin)\n\tvar writer = bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tfmt.Fscanf(reader, \"%d %d %d %d\", &n, &m, &L, &R)\n\n\tvar diff = R - L + 1\n\tvar odd = diff / 2\n\tvar evn = diff / 2\n\n\tif diff % 2 != 0 {\n\t\tif L % 2 == 0 {\n\t\t\tevn++\n\t\t} else {\n\t\t\todd++\n\t\t}\n\t}\n\n\tvar T = int(int64(n) * int64(m) % (mod - 1))\n\tvar ret = pw(evn + odd, T)\n\tret = (ret + pw(evn - odd, T)) % mod\n\n\tif ret < 0 {\n\t\tret += mod\n\t}\n \n // review\n\tret = int(int64(ret) * int64(pw(2, mod - 2)) % mod)\n\tfmt.Fprintf(writer, \"%d\", ret)\n}\n"}], "src_uid": "ded299fa1cd010822c60f2389a3ba1a3"} {"nl": {"description": " It's the end of July – the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather here to discuss new trends in the world of confectionery. Yet some of the things discussed here are not supposed to be disclosed to the general public: the information can cause discord in the kingdom of Sweetland in case it turns out to reach the wrong hands. So it's a necessity to not let any uninvited guests in.There are 26 entrances in Jelly Castle, enumerated with uppercase English letters from A to Z. Because of security measures, each guest is known to be assigned an entrance he should enter the castle through. The door of each entrance is opened right before the first guest's arrival and closed right after the arrival of the last guest that should enter the castle through this entrance. No two guests can enter the castle simultaneously.For an entrance to be protected from possible intrusion, a candy guard should be assigned to it. There are k such guards in the castle, so if there are more than k opened doors, one of them is going to be left unguarded! Notice that a guard can't leave his post until the door he is assigned to is closed.Slastyona had a suspicion that there could be uninvited guests at the evening. She knows the order in which the invited guests entered the castle, and wants you to help her check whether there was a moment when more than k doors were opened.", "input_spec": "Two integers are given in the first string: the number of guests n and the number of guards k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26). In the second string, n uppercase English letters s1s2... sn are given, where si is the entrance used by the i-th guest.", "output_spec": "Output «YES» if at least one door was unguarded during some time, and «NO» otherwise. You can output each letter in arbitrary case (upper or lower).", "sample_inputs": ["5 1\nAABBB", "5 1\nABABB"], "sample_outputs": ["NO", "YES"], "notes": "NoteIn the first sample case, the door A is opened right before the first guest's arrival and closed when the second guest enters the castle. The door B is opened right before the arrival of the third guest, and closed after the fifth one arrives. One guard can handle both doors, as the first one is closed before the second one is opened.In the second sample case, the door B is opened before the second guest's arrival, but the only guard can't leave the door A unattended, as there is still one more guest that should enter the castle through this door. "}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\ts := bufio.NewScanner(os.Stdin)\n\tcapacity := 8 * 1024 * 1024\n\ts.Buffer(make([]byte, capacity), capacity)\n\ts.Split(bufio.ScanWords)\n\n\ts.Scan()\n\ts.Text()\n\n\ts.Scan()\n\tk, _ := strconv.Atoi(s.Text())\n\n\ts.Scan()\n\td := s.Text()\n\n\tf := make([]int, 26)\n\tl := make([]int, 26)\n\tfor i := range f {\n\t\tl[i] = -1\n\t\tf[i] = -1\n\t}\n\tfor i, c := range d {\n\t\tl[c-65] = i\n\t\tif f[c-65] == -1 {\n\t\t\tf[c-65] = i\n\t\t}\n\t}\n\tt := make([]int, len(d))\n\tfor i := 0; i < 26; i++ {\n\t\tif f[i] != -1 {\n\t\t\tt[f[i]]++\n\t\t}\n\t\tif l[i] != -1 && l[i]+1 < len(d) {\n\t\t\tt[l[i]+1]--\n\t\t}\n\t}\n\tvar m, cur int\n\tfor i := 0; i < len(d); i++ {\n\t\tcur = cur + t[i]\n\t\tif m < cur {\n\t\t\tm = cur\n\t\t}\n\t}\n\tif m > k {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"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\tk := readInt()\n\tq := readString()\n\topenAt := make([]bool, 26)\n\tclosedAt := make([]int, 26)\n\tfor i := 0; i < len(closedAt); i++ {\n\t\tclosedAt[i] = -1\n\t\topenAt[i] = false\n\t}\n\tfor i := 0; i < len(q); i++ {\n\t\tclosedAt[q[i]-'A'] = i\n\t}\n\n\tfor i := 0; i < len(q); i++ {\n\t\tv := q[i] - 'A'\n\t\tif !openAt[v] {\n\t\t\tk--\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\topenAt[v] = true\n\t\t}\n\t\tif closedAt[v] == i {\n\t\t\tk++\n\t\t}\n\t}\n\n\tfmt.Println(\"NO\")\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"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Solve(io *FastIO) {\n\tN := io.NextInt()\n\tK := io.NextInt()\n\tS := io.NextString()\n\n\topen := make([]int, 26)\n\tclose := make([]int, 26)\n\n\tFillArray(open, -1)\n\tFillArray(close, -1)\n\n\tfor i := N - 1; i >= 0; i-- {\n\t\td := S[i] - 'A'\n\t\topen[d] = i\n\t}\n\tfor i, c := range S {\n\t\td := c - 'A'\n\t\tclose[d] = i\n\t}\n\n\tfor i := 0; i < N; i++ {\n\t\tguards := 0\n\t\tfor d := 0; d < 26; d++ {\n\t\t\tif open[d] <= i && i <= close[d] {\n\t\t\t\tguards++\n\t\t\t}\n\t\t}\n\t\tif guards > K {\n\t\t\tio.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tio.Println(\"NO\")\n}\n\nfunc FillArray(arr []int, val int) {\n\tfor i := range arr {\n\t\tarr[i] = val\n\t}\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\tSolve(&io)\n\tio.FlushOutput()\n}\n"}, {"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\tK := sc.NextInt()\n\n\tS := sc.Next()\n\n\tAs := make([]int, 26)\n\tAe := make([]int, 26)\n\n\tfor i, _ := range As {\n\t\tAs[i] = -1\n\t\tAe[i] = -1\n\t}\n\n\tfor i, _ := range S {\n\n\t\ts := S[i]\n\n\t\tif As[s-'A'] < 0 {\n\t\t\tAs[s-'A'] = i\n\t\t}\n\n\t\tAe[s-'A'] = i\n\t}\n\n\timos := make([]int, N+1)\n\n\tfor i, _ := range As {\n\t\tif As[i] >= 0 {\n\t\t\timos[As[i]]++\n\t\t\timos[Ae[i]+1]--\n\t\t}\n\t}\n\n\ta := 0\n\tfor i, _ := range imos {\n\t\ta += imos[i]\n\t\tif a > K {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\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"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\ts := bufio.NewScanner(os.Stdin)\n\ts.Split(bufio.ScanWords)\n\n\ts.Scan()\n\ts.Text()\n\n\ts.Scan()\n\tk, _ := strconv.Atoi(s.Text())\n\n\ts.Scan()\n\td := s.Text()\n\n\tf := make([]int, 26)\n\tl := make([]int, 26)\n\tfor i := range f {\n\t\tl[i] = -1\n\t\tf[i] = -1\n\t}\n\tfor i, c := range d {\n\t\tl[c-65] = i\n\t\tif f[c-65] == -1 {\n\t\t\tf[c-65] = i\n\t\t}\n\t}\n\tt := make([]int, len(d))\n\tfor i := 0; i < 26; i++ {\n\t\tif f[i] != -1 {\n\t\t\tt[f[i]]++\n\t\t}\n\t\tif l[i] != -1 {\n\t\t\tt[l[i]]--\n\t\t}\n\t}\n\tvar m, cur int\n\tfor i := 0; i < len(d); i++ {\n\t\tcur = cur + t[i]\n\t\tif m < cur {\n\t\t\tm = cur\n\t\t}\n\t}\n\tif m > k {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\ts := bufio.NewScanner(os.Stdin)\n\ts.Split(bufio.ScanWords)\n\n\ts.Scan()\n\ts.Text()\n\n\ts.Scan()\n\tk, _ := strconv.Atoi(s.Text())\n\n\ts.Scan()\n\td := s.Text()\n\n\tf := make([]int, 26)\n\tl := make([]int, 26)\n\tfor i := range f {\n\t\tl[i] = -1\n\t\tf[i] = -1\n\t}\n\tfor i, c := range d {\n\t\tl[c-65] = i\n\t\tif f[c-65] == -1 {\n\t\t\tf[c-65] = i\n\t\t}\n\t}\n\tt := make([]int, len(d))\n\tfor i := 0; i < 26; i++ {\n\t\tif f[i] != -1 {\n\t\t\tt[f[i]]++\n\t\t}\n\t\tif l[i] != -1 && l[i]+1 < len(d) {\n\t\t\tt[l[i]+1]--\n\t\t}\n\t}\n\tvar m, cur int\n\tfor i := 0; i < len(d); i++ {\n\t\tcur = cur + t[i]\n\t\tif m < cur {\n\t\t\tm = cur\n\t\t}\n\t}\n\tif m > k {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\tfmt.Println(\"NO\")\n}\n"}], "src_uid": "216323563f5b2dd63edc30cb9b4849a5"} {"nl": {"description": "Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.In a single second, he can modify the length of a single side of the current triangle such that it remains a non-degenerate triangle (triangle of positive area). At any moment of time, the length of each side should be integer.What is the minimum number of seconds required for Memory to obtain the equilateral triangle of side length y?", "input_spec": "The first and only line contains two integers x and y (3 ≤ y < x ≤ 100 000) — the starting and ending equilateral triangle side lengths respectively.", "output_spec": "Print a single integer — the minimum number of seconds required for Memory to obtain the equilateral triangle of side length y if he starts with the equilateral triangle of side length x.", "sample_inputs": ["6 3", "8 5", "22 4"], "sample_outputs": ["4", "3", "6"], "notes": "NoteIn the first sample test, Memory starts with an equilateral triangle of side length 6 and wants one of side length 3. Denote a triangle with sides a, b, and c as (a, b, c). Then, Memory can do .In the second sample test, Memory can do .In the third sample test, Memory can do: ."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\nimport \"bufio\"\nimport \"os\"\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\nfunc main() {\n bufin = bufio.NewReader(os.Stdin)\n bufout = bufio.NewWriter(os.Stdout)\n defer bufout.Flush()\n\n var x, y int\n fmt.Fscanf(bufin, \"%d %d\\n\", &x, &y)\n\n var a []int = []int{y, y, y}\n res := 0\n\n i := 0\n j := 1\n k := 2\n\n for (a[i] < x) || (a[j] < x) || (a[k] < x) {\n res++\n a[k] = a[i] + a[j] - 1\n if a[k] > x {\n a[k] = x\n }\n i, j, k = j, k, i\n }\n\n fmt.Fprintf(bufout, \"%d\\n\", res)\n}\n"}, {"source_code": "// http://codeforces.com/contest/712/problem/C\npackage main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"math\"\n)\n\n// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc check(m [3]int, val int) bool {\n\treturn m[0] >= val && m[1] >= val && m[2] >= val\n}\n\nfunc main() {\n\tvar x, y int\n\n\t//f, _ := os.Open(\"input.txt\")\n\t//input := bufio.NewReader(f)\n\tinput := bufio.NewReader(os.Stdin)\n\tfmt.Fscanln(input, &x, &y)\n\tif x == y {\n\t\tfmt.Println(\"0\")\n\t\treturn\n\t}\n\n\ttr := [3]int{y, y, y}\n\n\tidx := 0\n\tans := 0\n\n\tfor {\n\t\tif tr[idx] >= x {\n\t\t\tidx = (idx + 1) % 3\n\t\t\tcontinue\n\t\t}\n\n\t\tans++\n\t\ttr[idx] = min(int(math.Abs(float64(tr[(idx + 1) % 3] + tr[(idx + 2) % 3]))) - 1, x)\n\t\tif tr[idx] >= x {\n\t\t\tif check(tr, x) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tidx = (idx + 1) % 3\n\n\t}\n\n\tfmt.Println(ans)\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nimport \"strings\"\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _ := reader.ReadString('\\n')\n\ttext = strings.TrimRight(text, \"\\r\\n\")\n\ts := strings.Split(text, \" \")\n\n\tx, _ := strconv.ParseInt(s[0], 10, 64)\n\ty, _ := strconv.ParseInt(s[1], 10, 64)\n\tif y > x {\n\t\tt := x\n\t\tx = y\n\t\ty = t\n\t}\n\tt := []int64{y, y, y}\n\tsec := 0\n\tfor t[2] != x {\n\t\tv := t[0] + t[1] - 1\n\t\tif v >= x {\n\t\t\tv = x\n\t\t}\n\t\tt[2] = t[1]\n\t\tt[1] = t[0]\n\t\tt[0] = v\n\t\tsec += 1\n\t}\n\tfmt.Println(sec)\n}\n"}], "negative_code": [], "src_uid": "8edf64f5838b19f9a8b19a14977f5615"} {"nl": {"description": "Vasya studies positional numeral systems. Unfortunately, he often forgets to write the base of notation in which the expression is written. Once he saw a note in his notebook saying a + b = ?, and that the base of the positional notation wasn’t written anywhere. Now Vasya has to choose a base p and regard the expression as written in the base p positional notation. Vasya understood that he can get different results with different bases, and some bases are even invalid. For example, expression 78 + 87 in the base 16 positional notation is equal to FF16, in the base 15 positional notation it is equal to 11015, in the base 10 one — to 16510, in the base 9 one — to 1769, and in the base 8 or lesser-based positional notations the expression is invalid as all the numbers should be strictly less than the positional notation base. Vasya got interested in what is the length of the longest possible expression value. Help him to find this length.The length of a number should be understood as the number of numeric characters in it. For example, the length of the longest answer for 78 + 87 = ? is 3. It is calculated like that in the base 15 (11015), base 10 (16510), base 9 (1769) positional notations, for example, and in some other ones.", "input_spec": "The first letter contains two space-separated numbers a and b (1 ≤ a, b ≤ 1000) which represent the given summands.", "output_spec": "Print a single number — the length of the longest answer.", "sample_inputs": ["78 87", "1 1"], "sample_outputs": ["3", "2"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport (\n \"fmt\"\n \"strconv\"\n \"math\"\n)\n\nfunc base1(n, b int) int {\n ans := 0\n for n > 0 {\n n = n/b\n ans += 1\n }\n return ans\n}\n\nfunc base(s string, b int) int {\n ans := 0\n k := len(s) - 1\n for i := 0; i < len(s); i++ {\n ans += (int(s[i])-48) * int(math.Pow(float64(b), float64(k)))\n k -= 1\n }\n return ans\n}\n\nfunc main(){\n var a, b int\n fmt.Scan(&a)\n fmt.Scan(&b)\n x := strconv.Itoa(a) + strconv.Itoa(b)\n z := uint8(48)\n for i := 0; i < len(x); i++ {\n if z < x[i] {\n z = x[i]\n }\n }\n d := int(z - 47)\n sum := base(strconv.Itoa(a), d) + base(strconv.Itoa(b), d)\n fmt.Print(base1(sum, d))\n \n}"}], "negative_code": [{"source_code": "package main\n\nimport (\n \"fmt\"\n \"strconv\"\n)\n\nfunc base(s, b int) int {\n ans := 0\n for s > 0 {\n s = s/b\n ans += 1 \n }\n return ans\n}\n\nfunc main(){\n var a, b int\n fmt.Scan(&a)\n fmt.Scan(&b)\n sum := a+b\n x := strconv.Itoa(a) + strconv.Itoa(b)\n z := uint8(48)\n for i := 0; i < len(x); i++ {\n if z < x[i] {\n z = x[i]\n }\n }\n fmt.Print(base(sum, int(z-47))) \n \n}"}], "src_uid": "8ccfb9b1fef6a992177cc49bd56fab7b"} {"nl": {"description": "Nothing has changed since the last round. Dima and Inna still love each other and want to be together. They've made a deal with Seryozha and now they need to make a deal with the dorm guards...There are four guardposts in Dima's dorm. Each post contains two guards (in Russia they are usually elderly women). You can bribe a guard by a chocolate bar or a box of juice. For each guard you know the minimum price of the chocolate bar she can accept as a gift and the minimum price of the box of juice she can accept as a gift. If a chocolate bar for some guard costs less than the minimum chocolate bar price for this guard is, or if a box of juice for some guard costs less than the minimum box of juice price for this guard is, then the guard doesn't accept such a gift.In order to pass through a guardpost, one needs to bribe both guards.The shop has an unlimited amount of juice and chocolate of any price starting with 1. Dima wants to choose some guardpost, buy one gift for each guard from the guardpost and spend exactly n rubles on it.Help him choose a post through which he can safely sneak Inna or otherwise say that this is impossible. Mind you, Inna would be very sorry to hear that!", "input_spec": "The first line of the input contains integer n (1 ≤ n ≤ 105) — the money Dima wants to spend. Then follow four lines describing the guardposts. Each line contains four integers a, b, c, d (1 ≤ a, b, c, d ≤ 105) — the minimum price of the chocolate and the minimum price of the juice for the first guard and the minimum price of the chocolate and the minimum price of the juice for the second guard, correspondingly.", "output_spec": "In a single line of the output print three space-separated integers: the number of the guardpost, the cost of the first present and the cost of the second present. If there is no guardpost Dima can sneak Inna through at such conditions, print -1 in a single line. The guardposts are numbered from 1 to 4 according to the order given in the input. If there are multiple solutions, you can print any of them.", "sample_inputs": ["10\n5 6 5 6\n6 6 7 7\n5 8 6 6\n9 9 9 9", "10\n6 6 6 6\n7 7 7 7\n4 4 4 4\n8 8 8 8", "5\n3 3 3 3\n3 3 3 3\n3 3 3 3\n3 3 3 3"], "sample_outputs": ["1 5 5", "3 4 6", "-1"], "notes": "NoteExplanation of the first example.The only way to spend 10 rubles to buy the gifts that won't be less than the minimum prices is to buy two 5 ruble chocolates to both guards from the first guardpost.Explanation of the second example.Dima needs 12 rubles for the first guardpost, 14 for the second one, 16 for the fourth one. So the only guardpost we can sneak through is the third one. So, Dima can buy 4 ruble chocolate for the first guard and 6 ruble juice of the second guard."}, "positive_code": [{"source_code": "package main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar n,a,b,c,d,m1,m2,tot int\n\tfmt.Scan(&n)\n\tflag:=false\n\tfor i:=0;i<4;i++ {\n\t\tfmt.Scan(&a,&b,&c,&d)\n\t\tif a>b {\n\t\t\tm1=b\n\t\t} else { m1=a }\n\t\tif c>d {\n\t\t\tm2=d\n\t\t} else { m2=c }\n\t\ttot=m1+m2\n\t\tif tot<=n {\n\t\t\tfmt.Println(i+1,m1,n-m1)\n\t\t\tflag=true\n\t\t\tbreak\n\t\t}\n\t}\n\tif flag==false {\n\t\tfmt.Println(\"-1\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n,a,b,c,d,x,y,z int\n fmt.Scan(&n)\n for i := 0; i < 4; i++ {\n fmt.Scan(&a,&b,&c,&d)\n if (a+c) <= n {\n x = i+1; y = a; z = n-a;\n } else if (a+d) <= n {\n x = i+1; y = a; z = n-a;\n } else if (b+c) <= n {\n x = i+1; y = b; z = n-b;\n } else if (b+d) <= n {\n x = i+1; y = b; z = n-b;\n }\n }\n if (x == 0) { fmt.Println(-1) } else { fmt.Println(x,y,z) }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n,a,b,c,d,x,y,z int\n fmt.Scan(&n)\n for i := 0; i < 4; i++ {\n fmt.Scan(&a,&b,&c,&d)\n if (a+c) <= n {\n x = i+1; y = a; z = n-a;\n } else if (a+d) <= n {\n x = i+1; y = a; z = n-a;\n } else if (b+c) <= n {\n x = i+1; y = b; z = n-b;\n } else if (b+d) <= n {\n x = i+1; y = b; z = n-b;\n }\n }\n if (x == 0) { fmt.Println(-1) } else { fmt.Println(x,y,z) }\n}\n"}, {"source_code": "// 366A-mic\npackage main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var n, m1, m2 int\n var s [5][5]int\n fmt.Scan(&n)\n for i := 1; i <= 4; i++ {\n for j := 1; j <= 4; j++ {\n fmt.Scan(&s[i][j])\n }\n\n }\n for i := 1; i <= 4; i++ {\n m1 = int(math.Min(float64(s[i][1]), float64(s[i][2])))\n m2 = int(math.Min(float64(s[i][3]), float64(s[i][4])))\n if m1+m2 <= n {\n fmt.Println(i, m1, n-m1)\n return\n }\n }\n fmt.Println(-1)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n,a,b,c,d,x,y,z int\n fmt.Scan(&n)\n for i := 0; i < 4; i++ {\n fmt.Scan(&a,&b,&c,&d)\n if (a+c) <= n {\n x = i+1; y = a; z = n-a;\n } else if (a+d) <= n {\n x = i+1; y = a; z = n-a;\n } else if (b+c) <= n {\n x = i+1; y = b; z = n-b;\n } else if (b+d) <= n {\n x = i+1; y = b; z = n-b;\n }\n }\n if (x == 0) { fmt.Println(-1) } else { fmt.Println(x,y,z) }\n}\n"}], "negative_code": [{"source_code": "package main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar n,a,b,c,d,m1,m2,tot int\n\tfmt.Scan(&n)\n\tflag:=false\n\tfor i:=0;i<4;i++ {\n\t\tfmt.Scan(&a,&b,&c,&d)\n\t\tif a>b {\n\t\t\tm1=b\n\t\t} else { m1=a }\n\t\tif c>d {\n\t\t\tm1=d\n\t\t} else { m2=c }\n\t\ttot=m1+m2\n\t\tif tot<=n {\n\t\t\tfmt.Println(i+1,m1,n-m1)\n\t\t\tflag=true\n\t\t\tbreak\n\t\t}\n\t}\n\tif flag==false {\n\t\tfmt.Println(\"-1\")\n\t}\n}\n"}, {"source_code": "package main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar n,a,b,c,d,m1,m2,tot int\n\tfmt.Scan(&n)\n\tflag:=false\n\tfor i:=0;i<4;i++ {\n\t\tfmt.Scan(&a,&b,&c,&d)\n\t\tif a>b {\n\t\t\tm1=b\n\t\t} else { m1=a }\n\t\tif c>d {\n\t\t\tm1=d\n\t\t} else { m2=c }\n\t\ttot=m1+m2\n\t\tif tot<=n {\n\t\t\tfmt.Println(i+1,m1,n-m1)\n\t\t\tflag=true\n\t\t}\n\t}\n\tif flag==false {\n\t\tfmt.Println(\"-1\")\n\t}\n}\n"}], "src_uid": "6e7ee0da980beb99ca49a5ddd04089a5"} {"nl": {"description": "The final match of the Berland Football Cup has been held recently. The referee has shown $$$n$$$ yellow cards throughout the match. At the beginning of the match there were $$$a_1$$$ players in the first team and $$$a_2$$$ players in the second team.The rules of sending players off the game are a bit different in Berland football. If a player from the first team receives $$$k_1$$$ yellow cards throughout the match, he can no longer participate in the match — he's sent off. And if a player from the second team receives $$$k_2$$$ yellow cards, he's sent off. After a player leaves the match, he can no longer receive any yellow cards. Each of $$$n$$$ yellow cards was shown to exactly one player. Even if all players from one team (or even from both teams) leave the match, the game still continues.The referee has lost his records on who has received each yellow card. Help him to determine the minimum and the maximum number of players that could have been thrown out of the game.", "input_spec": "The first line contains one integer $$$a_1$$$ $$$(1 \\le a_1 \\le 1\\,000)$$$ — the number of players in the first team. The second line contains one integer $$$a_2$$$ $$$(1 \\le a_2 \\le 1\\,000)$$$ — the number of players in the second team. The third line contains one integer $$$k_1$$$ $$$(1 \\le k_1 \\le 1\\,000)$$$ — the maximum number of yellow cards a player from the first team can receive (after receiving that many yellow cards, he leaves the game). The fourth line contains one integer $$$k_2$$$ $$$(1 \\le k_2 \\le 1\\,000)$$$ — the maximum number of yellow cards a player from the second team can receive (after receiving that many yellow cards, he leaves the game). The fifth line contains one integer $$$n$$$ $$$(1 \\le n \\le a_1 \\cdot k_1 + a_2 \\cdot k_2)$$$ — the number of yellow cards that have been shown during the match.", "output_spec": "Print two integers — the minimum and the maximum number of players that could have been thrown out of the game.", "sample_inputs": ["2\n3\n5\n1\n8", "3\n1\n6\n7\n25", "6\n4\n9\n10\n89"], "sample_outputs": ["0 4", "4 4", "5 9"], "notes": "NoteIn the first example it could be possible that no player left the game, so the first number in the output is $$$0$$$. The maximum possible number of players that could have been forced to leave the game is $$$4$$$ — one player from the first team, and three players from the second.In the second example the maximum possible number of yellow cards has been shown $$$(3 \\cdot 6 + 1 \\cdot 7 = 25)$$$, so in any case all players were sent off."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc scanner() string {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tfor scanner.Scan() {\n\t\treturn scanner.Text()\n\t}\n\treturn \"\"\n}\n\nfunc main() {\n\tvar input []string\n\tscanner := bufio.NewScanner(os.Stdin)\n\tfor scanner.Scan() {\n\t\tinput = append(input, scanner.Text())\n\t}\n\t// input = append(input, scanner())\n\t// input = append(input, scanner())\n\t// input = append(input, scanner())\n\t// input = append(input, scanner())\n\t// input = append(input, scanner())\n\n\ta1, _ := strconv.Atoi(input[0])\n\ta2, _ := strconv.Atoi(input[1])\n\tk1, _ := strconv.Atoi(input[2])\n\tk2, _ := strconv.Atoi(input[3])\n\tn, _ := strconv.Atoi(input[4])\n\n\tif k1 > k2 {\n\t\tk1, k2, a1, a2 = k2, k1, a2, a1\n\t}\n\tvar min, max int\n\n\tif a1*k1 >= n {\n\t\tmax = n / k1\n\t} else {\n\t\tmax = a1\n\t\tmax += (n - a1*k1) / k2\n\t}\n\n\tvar minCard int\n\n\tif k1 > 1 {\n\t\tminCard = a1 * (k1 - 1)\n\t}\n\tif k2 > 1 {\n\t\tminCard += a2 * (k2 - 1)\n\t}\n\n\tif minCard >= n {\n\t\tmin = 0\n\t} else {\n\t\tmin = n - minCard\n\t}\n\n\tfmt.Printf(\"%v %v\", min, max)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a1, a2, k1, k2, n int\n\n\t// scr := bufio.NewReader(os.Stdin)\n\t// ocr := bufio.NewWriter(os.Stdout)\n\n\tfmt.Scanln(&a1)\n\tfmt.Scanln(&a2)\n\tfmt.Scanln(&k1)\n\tfmt.Scanln(&k2)\n\tfmt.Scanln(&n)\n\n\tmin := n - (((k1 - 1) * a1) + ((k2 - 1) * a2))\n\n\tif min <= 0 {\n\t\tmin = 0\n\t} else if min >= a1+a2 {\n\t\tmin = a1 + a2\n\t}\n\n\tmax := 0\n\tif k1 < k2 {\n\t\tmax = n / k1\n\n\t\tif max > a1 {\n\t\t\tmax = a1\n\t\t} else if max < 1 {\n\t\t\tmax = 0\n\t\t}\n\t\tn -= k1 * max\n\n\t\tx := n / k2\n\t\tif x > a2 {\n\t\t\tx = a2\n\t\t} else if x < 1 {\n\t\t\tx = 0\n\t\t}\n\t\tmax += x\n\n\t} else {\n\t\tmax = n / k2\n\n\t\tif max > a2 {\n\t\t\tmax = a2\n\t\t} else if max < 1 {\n\t\t\tmax = 0\n\t\t}\n\t\tn -= k2 * max\n\n\t\tx := n / k1\n\t\tif x > a1 {\n\t\t\tx = a1\n\t\t} else if x < 1 {\n\t\t\tx = 0\n\t\t}\n\t\tmax += x\n\t}\n\n\tfmt.Println(min, max)\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scan *bufio.Scanner\nvar writer io.Writer\n\nfunc init() {\n\tscan = bufio.NewScanner(os.Stdin)\n\twriter = os.Stdout\n\tscan.Split(bufio.ScanWords)\n}\n\nfunc main() {\n\tsolve()\n}\n\nfunc solve() {\n\ta1 := nextInt()\n\ta2 := nextInt()\n\tk1 := nextInt()\n\tk2 := nextInt()\n\tn := nextInt()\n\n\t//\ta := a1+a2\n\n\tres1 := a1 + a2\n\tres2 := 0\n\n\tfor i := 0; i <= a1; i++ {\n\t\ttmp1 := n - k1*i\n\t\tco1 := (k1 - 1) * (a1 - i)\n\t\tfor j := 0; j <= a2; j++ {\n\t\t\ttmp2 := tmp1 - k2*j\n\t\t\tco2 := (k2 - 1) * (a2 - j)\n\t\t\tif tmp2 >= 0 {\n\t\t\t\tif tmp2 <= co1+co2 {\n\t\t\t\t\tsum := i + j\n\t\t\t\t\tif res1 > sum {\n\t\t\t\t\t\tres1 = sum\n\t\t\t\t\t}\n\t\t\t\t\tif res2 < sum {\n\t\t\t\t\t\tres2 = sum\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Fprint(writer, res1, \" \", res2)\n}\n\nfunc nextWord() string {\n\tscan.Scan()\n\tstr := scan.Text()\n\treturn str\n}\n\nfunc nextInt() int {\n\ti, e := strconv.Atoi(nextWord())\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn i\n}\n"}, {"source_code": "//HOWDY! IT'S ME! A HARD BLACKISH DICK MOVE!\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := PrintlnInts(X...)\n\n/*******************************************************************/\nfunc minPlayer(a1, a2, k1, k2, n int) int {\n\tn -= (k1-1)*a1 + (k2-1)*a2\n\tif n <= 0 {\n\t\treturn 0\n\t}\n\treturn min(a1+a2, n)\n}\n\nfunc maxPlayer(a1, a2, k1, k2, n int) int {\n\tp1 := min(a1, n/k1)\n\tn -= p1 * k1\n\tp2 := min(a2, n/k2)\n\treturn p1 + p2\n}\n\nfunc main() {\n\ta1 := ReadInt()\n\ta2 := ReadInt()\n\tk1 := ReadInt()\n\tk2 := ReadInt()\n\tn := ReadInt()\n\t//ensure k1 k2 {\n\t\ta1, a2 = a2, a1\n\t\tk1, k2 = k2, k1\n\t}\n\tfmt.Println(minPlayer(a1, a2, k1, k2, n), maxPlayer(a1, a2, k1, k2, n))\n}\n\n/*********** Math ***********/\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(args ...int) int {\n\tif len(args) == 0 {\n\t\tpanic(\"empty!\")\n\t}\n\tmin := args[0]\n\tfor i := 1; i < len(args); i++ {\n\t\tif args[i] < min {\n\t\t\tmin = args[i]\n\t\t}\n\t}\n\treturn min\n}\n\nfunc max(args ...int) int {\n\tif len(args) == 0 {\n\t\tpanic(\"empty!\")\n\t}\n\tmax := args[0]\n\tfor i := 1; i < len(args); i++ {\n\t\tif args[i] > max {\n\t\t\tmax = args[i]\n\t\t}\n\t}\n\treturn max\n}\n\nfunc _gcd(a, b int) int {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn _gcd(b, a%b)\n}\n\nfunc gcd(args ...int) int {\n\tif len(args) == 0 {\n\t\tpanic(\"empty!\")\n\t}\n\tgcd := args[0]\n\tfor i := 1; i < len(args); i++ {\n\t\tgcd = _gcd(gcd, args[i])\n\t}\n\treturn gcd\n}\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc init() {\n\tReadString = newReadString(os.Stdin)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc newReadString(ior io.Reader) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9))\n\t// Split sets the split function for the Scanner. The default split function is ScanLines.\n\t// Split panics if it is called after scanning has started.\n\tr.Split(bufio.ScanWords)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn readInt()\n}\nfunc ReadInt2() (int, int) {\n\treturn readInt(), readInt()\n}\nfunc ReadInt3() (int, int, int) {\n\treturn readInt(), readInt(), readInt()\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn readInt(), readInt(), readInt(), readInt()\n}\n\nfunc readInt64() int64 {\n\treturn readIntNbits(64)\n}\n\nfunc readInt() int {\n\treturn int(readIntNbits(32))\n}\n\nfunc readIntNbits(n int) int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, n)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintlnInts(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\n\nfunc main() {\n\n\t//stdin, err := os.Open(\"file.in\")\n\t//if err != nil {\n\t//\tpanic(err)\n\t//}\n\t//defer stdin.Close()\n\tstdin := os.Stdin\n\treader := bufio.NewReaderSize(stdin, 1024*1024)\n\n\t//stdout, err := os.Create(\"file.out\")\n\t//if err != nil {\n\t//\tpanic(err)\n\t//}\n\t//defer stdout.Close()\n\tstdout := os.Stdout\n\twriter := bufio.NewWriterSize(stdout, 1024*1024)\n\n\tvar a1, a2, k1, k2, n int\n\n\tfmt.Fscanf(reader, \"%d\\n\", &a1)\n\tfmt.Fscanf(reader, \"%d\\n\", &a2)\n\tfmt.Fscanf(reader, \"%d\\n\", &k1)\n\tfmt.Fscanf(reader, \"%d\\n\", &k2)\n\tfmt.Fscanf(reader, \"%d\\n\", &n)\n\n\tif k1 < k2 {\n\t\ta1, a2 = a2, a1\n\t\tk1, k2 = k2, k1\n\t}\n\n\tr1 := n\n\tr1 -= a1 * (k1 - 1) + a2 * (k2 - 1)\n\tif r1 < 0 {\n\t\tr1 = 0\n\t}\n\n\tr2 := n\n\tr2 /= k2\n\tif r2 > a2 {\n\t\tr2 = a2\n\t}\n\n\tn -= r2 * k2\n\n\tr2 += n / k1\n\n\tfmt.Fprintf(writer, \"%d %d\\n\", r1, r2)\n\n\twriter.Flush()\n}"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc scanner() string {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tfor scanner.Scan() {\n\t\treturn scanner.Text()\n\t}\n\treturn \"\"\n}\n\nfunc main() {\n\tvar input []string\n\tscanner := bufio.NewScanner(os.Stdin)\n\tfor scanner.Scan() {\n\t\tinput = append(input, scanner.Text())\n\t}\n\t// input = append(input, scanner())\n\t// input = append(input, scanner())\n\t// input = append(input, scanner())\n\t// input = append(input, scanner())\n\t// input = append(input, scanner())\n\n\ta1, _ := strconv.Atoi(input[0])\n\ta2, _ := strconv.Atoi(input[1])\n\tk1, _ := strconv.Atoi(input[2])\n\tk2, _ := strconv.Atoi(input[3])\n\tn, _ := strconv.Atoi(input[4])\n\n\tif a1*k1 > a2*k2 {\n\t\tk1, k2, a1, a2 = k2, k1, a2, a1\n\t}\n\tvar min, max int\n\n\tif a1*k1 >= n {\n\t\tmax = n / k1\n\t} else {\n\t\tmax = a1\n\t\tmax += (n - a1*k1) / k2\n\t}\n\n\tvar minCard int\n\n\tif k1 > 1 {\n\t\tminCard = a1 * (k1 - 1)\n\t}\n\tif k2 > 1 {\n\t\tminCard += a2 * (k2 - 1)\n\t}\n\n\tif minCard >= n {\n\t\tmin = 0\n\t} else {\n\t\tmin = n - minCard\n\t}\n\n\tfmt.Printf(\"%v %v\", min, max)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a1, a2, k1, k2, n int\n\n\t// scr := bufio.NewReader(os.Stdin)\n\t// ocr := bufio.NewWriter(os.Stdout)\n\n\tfmt.Scanln(&a1)\n\tfmt.Scanln(&a2)\n\tfmt.Scanln(&k1)\n\tfmt.Scanln(&k2)\n\tfmt.Scanln(&n)\n\n\tmin := n - (((k1 - 1) * a1) + ((k2 - 1) * a2))\n\n\tif min <= 0 {\n\t\tmin = 0\n\t} else if min >= a1+a2 {\n\t\tmin = a1 + a2\n\t}\n\n\tmax := 0\n\tif k1 < k2 {\n\t\tmax = n / k1\n\n\t\tif max > a1 {\n\t\t\tmax = a1\n\t\t} else if max < 1 {\n\t\t\tmax = 0\n\t\t}\n\t\tn -= k1 * max\n\n\t\tx := n / k2\n\t\tif x > a2 {\n\t\t\tx = a2\n\t\t} else if x < 1 {\n\t\t\tx = 0\n\t\t}\n\t\tmax += x\n\n\t} else {\n\t\tmax = n / k2\n\n\t\tif max > a2 {\n\t\t\tmax = a2\n\t\t} else if max < 1 {\n\t\t\tmax = 0\n\t\t}\n\t\tn -= k2 * max\n\n\t\tx := n / k1\n\t\tif x > a1 {\n\t\t\tmax = a1\n\t\t} else if x < 1 {\n\t\t\tmax = 0\n\t\t}\n\t\tmax += x\n\t}\n\n\tfmt.Println(min, max)\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a1, a2, k1, k2, n int\n\n\t// scr := bufio.NewReader(os.Stdin)\n\t// ocr := bufio.NewWriter(os.Stdout)\n\n\tfmt.Scanln(&a1)\n\tfmt.Scanln(&a2)\n\tfmt.Scanln(&k1)\n\tfmt.Scanln(&k2)\n\tfmt.Scanln(&n)\n\n\tmin := n - (((k1 - 1) * a1) + ((k2 - 1) * a2))\n\n\tif min <= 0 {\n\t\tmin = 0\n\t} else if min >= a1+a2 {\n\t\tmin = a1 + a2\n\t}\n\n\tmax := 0\n\tif k1 < k2 {\n\t\tmax = n / k1\n\n\t\tif max > a1+a2 {\n\t\t\tmax = a1 + a2\n\t\t} else if max < 1 {\n\t\t\tmax = 0\n\t\t}\n\t\tn -= k1 * max\n\n\t\tmax += n / k2\n\t\tif max > a1+a2 {\n\t\t\tmax = a1 + a2\n\t\t} else if max < 1 {\n\t\t\tmax = 0\n\t\t}\n\n\t} else {\n\t\tmax = n / k2\n\n\t\tif max > a2 {\n\t\t\tmax = a2\n\t\t} else if max < 1 {\n\t\t\tmax = 0\n\t\t}\n\t\tn -= k2 * max\n\n\t\tx := n / k1\n\t\tif x > a1 {\n\t\t\tmax = a1\n\t\t} else if x < 1 {\n\t\t\tmax = 0\n\t\t}\n\t\tmax += x\n\t}\n\n\tfmt.Println(min, max)\n\n}\n"}], "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91"} {"nl": {"description": "There are $$$n$$$ benches in the Berland Central park. It is known that $$$a_i$$$ people are currently sitting on the $$$i$$$-th bench. Another $$$m$$$ people are coming to the park and each of them is going to have a seat on some bench out of $$$n$$$ available.Let $$$k$$$ be the maximum number of people sitting on one bench after additional $$$m$$$ people came to the park. Calculate the minimum possible $$$k$$$ and the maximum possible $$$k$$$.Nobody leaves the taken seat during the whole process.", "input_spec": "The first line contains a single integer $$$n$$$ $$$(1 \\le n \\le 100)$$$ — the number of benches in the park. The second line contains a single integer $$$m$$$ $$$(1 \\le m \\le 10\\,000)$$$ — the number of people additionally coming to the park. Each of the next $$$n$$$ lines contains a single integer $$$a_i$$$ $$$(1 \\le a_i \\le 100)$$$ — the initial number of people on the $$$i$$$-th bench.", "output_spec": "Print the minimum possible $$$k$$$ and the maximum possible $$$k$$$, where $$$k$$$ is the maximum number of people sitting on one bench after additional $$$m$$$ people came to the park.", "sample_inputs": ["4\n6\n1\n1\n1\n1", "1\n10\n5", "3\n6\n1\n6\n5", "3\n7\n1\n6\n5"], "sample_outputs": ["3 7", "15 15", "6 12", "7 13"], "notes": "NoteIn the first example, each of four benches is occupied by a single person. The minimum $$$k$$$ is $$$3$$$. For example, it is possible to achieve if two newcomers occupy the first bench, one occupies the second bench, one occupies the third bench, and two remaining — the fourth bench. The maximum $$$k$$$ is $$$7$$$. That requires all six new people to occupy the same bench.The second example has its minimum $$$k$$$ equal to $$$15$$$ and maximum $$$k$$$ equal to $$$15$$$, as there is just a single bench in the park and all $$$10$$$ people will occupy it."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scanf(\"%d\\n%d\\n\", &n, &m)\n\ta := make([]int, 0, n)\n\tvar ai int\n\tmaxAi := 0\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\\n\", &ai)\n\t\ta = append(a, ai)\n\t\tif maxAi < ai {\n\t\t\tmaxAi = ai\n\t\t}\n\t}\n\tcomplement := 0\n\tfor _, ai = range a {\n\t\tcomplement += maxAi - ai\n\t}\n\n\tif m > complement {\n\t\trest := m - complement\n\t\tavg := rest / n\n\t\tremainder := rest % n\n\t\tif remainder == 0 {\n\t\t\tfmt.Println(maxAi+avg, maxAi+m)\n\t\t\treturn\n\t\t}\n\t\tfmt.Println(maxAi+avg+1, maxAi+m)\n\t\treturn\n\t}\n\tfmt.Println(maxAi, maxAi+m)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"math\"\n\nfunc main() {\n\tvar n int\n\tvar k int\n\tvar a int\n\t\n\tfmt.Scanln(&n)\n\tfmt.Scanln(&k)\n\t\n\tmini := k\n\tmaxi := 0\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanln(&a)\n\t\tmini = mini + a\n\t\tmaxi = int(math.Max(float64(maxi), float64(a)))\n\t}\n\t\n\tmini = int(math.Max(math.Ceil(float64(mini) / float64(n)), float64(maxi)))\n\tmaxi = maxi + k\n\t\n\tfmt.Println(mini, maxi)\n}"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar\twriter *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc ceilDiv(i, div int64) int64 {\n if div == 0 {\n return 0 // should not happen\n }\n if i % div == 0 {\n return i / div\n }\n return (i / div) + 1\n}\n\nfunc max(i, j int64) int64 {\n if i > j {\n return i\n }\n return j\n}\n\nfunc main() {\n defer writer.Flush()\n var n, m int64\n scanf(\"%d\\n\", &n)\n scanf(\"%d\\n\", &m)\n total := m\n maxSoFar := int64(0)\n for i := int64(0); i < n; i++ {\n var i int64\n scanf(\"%d\\n\", &i)\n total += i\n maxSoFar = max(maxSoFar, i)\n }\n minK := max(ceilDiv(total, n), maxSoFar)\n maxK := maxSoFar + m\n printf(\"%d %d\", minK, maxK)\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\nimport \"math\"\n\nfunc main() {\n\tvar n int\n\tvar k int\n\tvar a int\n\t\n\tfmt.Scanln(&n)\n\tfmt.Scanln(&k)\n\t\n\tmini := k\n\tmaxi := 0\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanln(&a)\n\t\tmini = mini + a\n\t\tmaxi = int(math.Max(float64(maxi), float64(a)))\n\t}\n\t\n\tmini = int(math.Ceil(float64(mini) / float64(n)))\n\tmaxi = maxi + k\n\t\n\tfmt.Println(mini, maxi)\n}"}], "src_uid": "78f696bd954c9f0f9bb502e515d85a8d"} {"nl": {"description": "During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation of one face of the cube in any direction.To check her answers she wants to use a program which will for some state of cube tell if it's possible to solve it using one rotation, described above.Cube is called solved if for each face of cube all squares on it has the same color.https://en.wikipedia.org/wiki/Rubik's_Cube", "input_spec": "In first line given a sequence of 24 integers ai (1 ≤ ai ≤ 6), where ai denotes color of i-th square. There are exactly 4 occurrences of all colors in this sequence.", "output_spec": "Print «YES» (without quotes) if it's possible to solve cube using one rotation and «NO» (without quotes) otherwise.", "sample_inputs": ["2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4", "5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3"], "sample_outputs": ["NO", "YES"], "notes": "NoteIn first test case cube looks like this: In second test case cube looks like this: It's possible to solve cube by rotating face with squares with numbers 13, 14, 15, 16."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar rotate = [][]int{\n\t{5, 6, 17, 18, 21, 22, 13, 14},\n\t{7, 8, 19, 20, 23, 24, 15, 16},\n\t{3, 4, 19, 20, 23, 24, 15, 16},\n\t{1, 2, 18, 20, 12, 11, 15, 13},\n\t{2, 4, 6, 8, 10, 12, 23, 21},\n\t{1, 3, 5, 7, 9, 11, 24, 22}}\n\nfunc main() {\n\tvar cube = make([]int, 24)\n\tfor i := 0; i < 24; i++ {\n\t\tfmt.Scanf(\"%d\", &cube[i])\n\t}\n\t//rotate\n\tfor i := 0; i < 6; i++ {\n\t\t//90-angle\n\t\tif check_rotate(cube, rotate[i], move_left2(rotate[i])) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t\t//another 90-angle\n\t\tif check_rotate(cube, rotate[i], move_right2(rotate[i])) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n\nfunc move_left2(in []int) []int {\n\tret := append(in[2:len(in)], in[0:2]...)\n\treturn ret\n}\n\nfunc move_right2(in []int) []int {\n\tret := append(in[len(in)-2:len(in)], in[0:len(in)-2]...)\n\treturn ret\n}\n\nfunc check_rotate(cube, rotate, moved []int) bool {\n\tafter := make([]int, len(cube))\n\tcopy(after, cube)\n\tfor i := 0; i < 8; i++ {\n\t\tafter[moved[i]-1] = cube[rotate[i]-1]\n\t}\n\treturn check_solved(after)\n}\n\nfunc check_solved(cube []int) bool {\n\tfor i := 0; i < 6; i++ {\n\t\tif cube[i*4] != cube[i*4+1] || cube[i*4] != cube[i*4+2] || cube[i*4] != cube[i*4+3] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc swap(a *int, b *int) {\n\ttemp := *a\n\t*a = *b\n\t*b = temp\n}\n\ntype Cube struct {\n\telements [24]int\n}\n\ntype Turn struct {\n\tsquare [4]int\n\twall [8]int\n}\n\nfunc NewTurn(cube [4]int, wall [8]int) Turn {\n\tfor index := 0; index < 4; index++ {\n\t\tcube[index]--\n\t}\n\n\tfor index := 0; index < 8; index++ {\n\t\twall[index]--\n\t}\n\n\treturn Turn{cube, wall}\n}\n\nfunc (cube *Cube) RotateLeft(turn Turn) {\n\tsquare := turn.square\n\twall := turn.wall\n\n\tfirst := cube.elements[square[0]]\n\tfor index := 0; index < 3; index++ {\n\t\tcube.elements[square[index]] = cube.elements[square[index+1]]\n\t}\n\tcube.elements[square[3]] = first\n\n\tfor iteration := 0; iteration < 2; iteration++ {\n\t\tfirst := cube.elements[wall[0]]\n\t\tfor index := 0; index < 7; index++ {\n\t\t\tcube.elements[wall[index]] = cube.elements[wall[index+1]]\n\t\t}\n\t\tcube.elements[wall[7]] = first\n\t}\n}\n\nfunc (cube *Cube) RotateRight(turn Turn) {\n\tsquare := turn.square\n\twall := turn.wall\n\n\tlast := cube.elements[square[3]]\n\tfor index := 3; index > 0; index-- {\n\t\tcube.elements[square[index]] = cube.elements[square[index-1]]\n\t}\n\tcube.elements[square[0]] = last\n\n\tfor iteration := 0; iteration < 2; iteration++ {\n\t\tlast := cube.elements[wall[7]]\n\t\tfor index := 7; index > 0; index-- {\n\t\t\tcube.elements[wall[index]] = cube.elements[wall[index-1]]\n\t\t}\n\t\tcube.elements[wall[0]] = last\n\t}\n}\n\nfunc (cube *Cube) IsPerfect() bool {\n\tperfect := true\n\n\tfor side := 0; side < 6 && perfect; side++ {\n\t\tfor index := 0; index < 4 && perfect; index++ {\n\t\t\tif cube.elements[4*side+index] != cube.elements[4*side] {\n\t\t\t\tperfect = false\n\t\t\t}\n\t\t}\n\t}\n\n\treturn perfect\n}\n\nfunc main() {\n\tvar cube Cube\n\tfor index := 0; index < 24; index++ {\n\t\tfmt.Scanf(\"%d\", &cube.elements[index])\n\t}\n\n\tturns := []Turn{\n\t\tNewTurn([4]int{1, 2, 4, 3}, [8]int{22, 21, 18, 17, 6, 5, 14, 13}),\n\t\tNewTurn([4]int{5, 6, 8, 7}, [8]int{3, 4, 17, 19, 10, 9, 16, 14}),\n\t\tNewTurn([4]int{9, 10, 12, 11}, [8]int{7, 8, 19, 20, 23, 24, 15, 16}),\n\t\tNewTurn([4]int{13, 14, 16, 15}, [8]int{1, 3, 5, 7, 9, 11, 24, 23}),\n\t\tNewTurn([4]int{17, 18, 20, 19}, [8]int{4, 2, 21, 23, 12, 10, 8, 6}),\n\t\tNewTurn([4]int{21, 22, 24, 23}, [8]int{2, 1, 13, 15, 11, 12, 20, 18}),\n\t}\n\n\tcan := false\n\n\tfor _, turn := range turns {\n\t\tcube.RotateLeft(turn)\n\n\t\tif cube.IsPerfect() {\n\t\t\tcan = true\n\t\t}\n\n\t\tcube.RotateRight(turn)\n\t\tcube.RotateRight(turn)\n\n\t\tif cube.IsPerfect() {\n\t\t\tcan = true\n\t\t}\n\n\t\tcube.RotateLeft(turn)\n\t}\n\n\tif can {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tvar data [24]int\n\tfor i := 0; i < 24; i++ {\n\t\tdata[i] = readInt()\n\t}\n\tif isFullSide(data, 3) && isFullSide(data, 4) {\n\t\trow0 := []int{1, 3, 5, 7, 9, 11, 20, 22}\n\t\trow1 := []int{0, 2, 4, 6, 8, 10, 23, 21}\n\n\t\tif check(data, row0, row1, 2) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t\tif check(data, row0, row1, -2) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tif isFullSide(data, 0) && isFullSide(data, 2) {\n\t\trow0 := []int{12, 13, 4, 5, 16, 17, 20, 21}\n\t\trow1 := []int{14, 15, 6, 7, 18, 19, 22, 23}\n\n\t\tif check(data, row0, row1, 2) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t\tif check(data, row0, row1, -2) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tif isFullSide(data, 1) && isFullSide(data, 5) {\n\t\trow0 := []int{8, 9, 18, 16, 3, 2, 13, 15}\n\t\trow1 := []int{10, 11, 19, 17, 1, 0, 12, 14}\n\n\t\tif check(data, row0, row1, 2) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t\tif check(data, row0, row1, -2) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n\nfunc check(data [24]int, row0, row1 []int, dir int) bool {\n\tfor i := 0; i < len(row0); i++ {\n\t\tif data[row0[i]] != data[row1[(i+dir+len(row1))%len(row1)]] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc isFullSide(data [24]int, side int) bool {\n\tcolor := data[side*4]\n\tfor i := 0; i < 4; i++ {\n\t\tif data[side*4+i] != color {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\nvar rotate = [][]int{\n\t{5,6,17,18,21,22,13,14},\n\t{7,8,19,20,23,24,15,16},\n\t{3,4,19,20,23,24,15,16},\n\t{1,2,18,20,12,11,15,13},\n\t{2,4,6,8,10,12,23,21},\n\t{1,3,5,7,9,11,24,22}}\n\nfunc main() {\n\tvar cube = make([]int,24)\n\tfor i := 0; i<24 ; i++ {\n\t\tfmt.Scanf(\"%d\", &cube[i])\n\t}\n\t//rotate\n\tfor i:=0;i<6;i++{\n\t\t//90-angle\n\t\tif check_solved(cube,rotate[i],move_left2(rotate[i])) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t\t//another 90-angle\n\t\tif check_solved(cube,rotate[i],move_right2(rotate[i])) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n\nfunc move_left2(in []int) []int {\n\tret:=make([]int,len(in))\n\tcopy(ret,in[2:len(in)])\n\tcopy(ret,in[0:2])\n\treturn ret\n}\n\nfunc move_right2(in []int) []int {\n\tret:=make([]int,len(in))\n\tcopy(ret,in[len(in)-2:len(in)])\n\tcopy(ret,in[0:len(in)-2])\n\treturn ret\n}\n\nfunc check_solved(cube, rotate, moved []int) bool {\n\tafter:=make([]int,len(cube))\n\tcopy(after,cube)\n\tfor i:=0;i<6;i++ {\n\t\tafter[moved[i]-1]=cube[rotate[i]-1]\n\t}\n\tfor i:=0;i<6;i++ {\n\t\tif after[i*4]== after[i*4+1] && after[i*4]== after[i*4+2] && after[i*4]== after[i*4+3] {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar rotate = [][]int{\n\t{5, 6, 17, 18, 21, 22, 13, 14},\n\t{7, 8, 19, 20, 23, 24, 15, 16},\n\t{3, 4, 19, 20, 23, 24, 15, 16},\n\t{1, 2, 18, 20, 12, 11, 15, 13},\n\t{2, 4, 6, 8, 10, 12, 23, 21},\n\t{1, 3, 5, 7, 9, 11, 24, 22}}\n\nfunc main() {\n\tvar cube = make([]int, 24)\n\tfor i := 0; i < 24; i++ {\n\t\tfmt.Scanf(\"%d\", &cube[i])\n\t}\n\t//check already solved\n\tif check_solved(cube) {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\t//rotate\n\tfor i := 0; i < 6; i++ {\n\t\t//90-angle\n\t\tif check_rotate(cube, rotate[i], move_left2(rotate[i])) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t\t//another 90-angle\n\t\tif check_rotate(cube, rotate[i], move_right2(rotate[i])) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n\nfunc move_left2(in []int) []int {\n\tret := make([]int, len(in))\n\tcopy(ret, in[2:len(in)])\n\tcopy(ret, in[0:2])\n\treturn ret\n}\n\nfunc move_right2(in []int) []int {\n\tret := make([]int, len(in))\n\tcopy(ret, in[len(in)-2:len(in)])\n\tcopy(ret, in[0:len(in)-2])\n\treturn ret\n}\n\nfunc check_rotate(cube, rotate, moved []int) bool {\n\tafter := make([]int, len(cube))\n\tcopy(after, cube)\n\tfor i := 0; i < 6; i++ {\n\t\tafter[moved[i]-1] = cube[rotate[i]-1]\n\t}\n\treturn check_solved(after)\n}\n\nfunc check_solved(cube []int) bool {\n\tfor i := 0; i < 6; i++ {\n\t\tif cube[i*4] != cube[i*4+1] || cube[i*4] != cube[i*4+2] || cube[i*4] != cube[i*4+3] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar rotate = [][]int{\n\t{5, 6, 17, 18, 21, 22, 13, 14},\n\t{7, 8, 19, 20, 23, 24, 15, 16},\n\t{3, 4, 19, 20, 23, 24, 15, 16},\n\t{1, 2, 18, 20, 12, 11, 15, 13},\n\t{2, 4, 6, 8, 10, 12, 23, 21},\n\t{1, 3, 5, 7, 9, 11, 24, 22}}\n\nfunc main() {\n\tvar cube = make([]int, 24)\n\tfor i := 0; i < 24; i++ {\n\t\tfmt.Scanf(\"%d\", &cube[i])\n\t}\n\t//check already solved\n\tif check_solved(cube) {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\t//rotate\n\tfor i := 0; i < 6; i++ {\n\t\t//90-angle\n\t\tif check_rotate(cube, rotate[i], move_left2(rotate[i])) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t\t//another 90-angle\n\t\tif check_rotate(cube, rotate[i], move_right2(rotate[i])) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n\nfunc move_left2(in []int) []int {\n\tret := append(in[2:len(in)], in[0:2]...)\n\treturn ret\n}\n\nfunc move_right2(in []int) []int {\n\tret := append(in[len(in)-2:len(in)], in[0:len(in)-2]...)\n\treturn ret\n}\n\nfunc check_rotate(cube, rotate, moved []int) bool {\n\tafter := make([]int, len(cube))\n\tcopy(after, cube)\n\tfor i := 0; i < 8; i++ {\n\t\tafter[moved[i]-1] = cube[rotate[i]-1]\n\t}\n\treturn check_solved(after)\n}\n\nfunc check_solved(cube []int) bool {\n\tfor i := 0; i < 6; i++ {\n\t\tif cube[i*4] != cube[i*4+1] || cube[i*4] != cube[i*4+2] || cube[i*4] != cube[i*4+3] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\nvar rotate = [][]int{\n\t{5,6,17,18,21,22,13,14},\n\t{7,8,19,20,23,24,15,16},\n\t{3,4,19,20,23,24,15,16},\n\t{1,2,18,20,12,11,15,13},\n\t{2,4,6,8,10,12,23,21},\n\t{1,3,5,7,9,11,24,22}}\n\nfunc main() {\n\tvar cube = make([]int,24)\n\tfor i := 0; i<24 ; i++ {\n\t\tfmt.Scanf(\"%d\", &cube[i])\n\t}\n\t//check already solved\n\tif check_solved(cube) {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t} \n\t//rotate\n\tfor i:=0;i<6;i++{\n\t\t//90-angle\n\t\tif check_rotate(cube,rotate[i],move_left2(rotate[i])) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t\t//another 90-angle\n\t\tif check_rotate(cube,rotate[i],move_right2(rotate[i])) {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n\nfunc move_left2(in []int) []int {\n\tret:=make([]int,len(in))\n\tcopy(ret,in[2:len(in)])\n\tcopy(ret,in[0:2])\n\treturn ret\n}\n\nfunc move_right2(in []int) []int {\n\tret:=make([]int,len(in))\n\tcopy(ret,in[len(in)-2:len(in)])\n\tcopy(ret,in[0:len(in)-2])\n\treturn ret\n}\n\nfunc check_rotate(cube, rotate, moved []int) bool {\n\tafter:=make([]int,len(cube))\n\tcopy(after,cube)\n\tfor i:=0;i<6;i++ {\n\t\tafter[moved[i]-1]=cube[rotate[i]-1]\n\t}\n\treturn check_solved(after)\n}\n\nfunc check_solved(cube []int) bool {\n\tfor i:=0;i<6;i++ {\n\t\tif cube[i*4]!= cube[i*4+1] || cube[i*4]!= cube[i*4+2] || cube[i*4]!= cube[i*4+3] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tvar data [6][2][2]int\n\tfor i := 0; i < 20; i++ {\n\t\tdata[i/4][(i%4)/2][i%2] = readInt()\n\t}\n\tdata[5][1][1] = readInt()\n\tdata[5][1][0] = readInt()\n\tdata[5][0][1] = readInt()\n\tdata[5][0][0] = readInt()\n\n\tvar sides []int\n\tif isSideFull(&data, 3) && isSideFull(&data, 4) {\n\t\tsides = []int{0, 1, 2, 5}\n\t} else if isSideFull(&data, 0) && isSideFull(&data, 2) {\n\t\tsides = []int{1, 4, 5, 3}\n\t} else if isSideFull(&data, 1) && isSideFull(&data, 5) {\n\t\tsides = []int{0, 4, 2, 3}\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\trotate0(&data, 1, sides)\n\tif isSolved(&data) {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\trotate0(&data, -1, sides)\n\trotate0(&data, -1, sides)\n\tif isSolved(&data) {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\tfmt.Println(\"NO\")\n}\n\nfunc isSolved(data *[6][2][2]int) bool {\n\tfor i := 0; i < 6; i++ {\n\t\tif !isSideFull(data, i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc rotate0(data *[6][2][2]int, dir int, sides []int) {\n\tvar nums [4][2]int\n\tfor i := 0; i < len(sides); i++ {\n\t\tside := sides[i]\n\t\tfor j := 0; j < 2; j++ {\n\t\t\tnums[i][j] = data[side][j][0]\n\t\t}\n\t}\n\tfor i := 0; i < len(sides); i++ {\n\t\tside := sides[(i+dir+4)%4]\n\t\tfor j := 0; j < 2; j++ {\n\t\t\tdata[side][j][0] = nums[i][j]\n\t\t}\n\t}\n}\n\nfunc isSideFull(data *[6][2][2]int, side int) bool {\n\tcolor := data[side][0][0]\n\tfor i := 0; i < 2; i++ {\n\t\tfor j := 0; j < 2; j++ {\n\t\t\tif data[side][i][j] != color {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\treturn true\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n"}], "src_uid": "881a820aa8184d9553278a0002a3b7c4"} {"nl": {"description": "A magic number is a number formed by concatenation of numbers 1, 14 and 144. We can use each of these numbers any number of times. Therefore 14144, 141414 and 1411 are magic numbers but 1444, 514 and 414 are not.You're given a number. Determine if it is a magic number or not.", "input_spec": "The first line of input contains an integer n, (1 ≤ n ≤ 109). This number doesn't contain leading zeros.", "output_spec": "Print \"YES\" if n is a magic number or print \"NO\" if it's not.", "sample_inputs": ["114114", "1111", "441231"], "sample_outputs": ["YES", "YES", "NO"], "notes": null}, "positive_code": [{"source_code": "package main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar n,d int\n\ts :=0\n\tm :=true\n\tfmt.Scan(&n)\n\tfor n!=0 {\n\t\td = n%10\n\t\tn/=10\n\t\tif d==1 {\n\t\t\ts=0\n\t\t} else if d==4 && s<2 {\n\t\t\ts++\n\t\t} else {\n\t\t\tm=false\n\t\t}\n\t}\n\tif s!=0 {\n\t\tm=false\n\t}\n\tif m==true {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\tfmt.Println(\"NO\")\n\t}\n}\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar num string\n\tfmt.Scan(&num)\n\n\tfor _, v := range []string{\"144\", \"14\", \"1\"} {\n\t\tnum = strings.Replace(num, v, \" \", -1)\n\t}\n\tnum = strings.Replace(num, \" \", \"\", -1)\n\n\tif len(num) > 0 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var input string\n var prev uint8 = 0\n var count int = 1\n var ok bool = true\n fmt.Scan(&input)\n for i:=0; i= 3 {\n ok = false\n break\n }\n prev = input[i]\n }\n if ok {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}"}, {"source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n s := getS()\n n := len(s)\n pos := 0\n for pos < n {\n if pos+3 <= n && s[pos:pos+3] == \"144\" {\n pos += 3\n } else if pos+2 <= n && s[pos:pos+2] == \"14\" {\n pos += 2\n } else if s[pos:pos+1] == \"1\" {\n pos++\n } else {\n writer.WriteString(\"NO\\n\")\n return\n }\n }\n writer.WriteString(\"YES\\n\")\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n ans, in := true, 0\n for in < len(s) {\n if s[in] == '1' {\n in++\n if in < len(s) {\n if s[in] == '4' { in++ }\n if in < len(s) {\n if s[in] == '4' { in++ }\n }\n }\n } else {\n ans = false\n break\n }\n }\n if ans { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n ans, in := true, 0\n for in < len(s) {\n if s[in] == '1' {\n in++\n if in < len(s) {\n if s[in] == '4' { in++ }\n if in < len(s) {\n if s[in] == '4' { in++ }\n }\n }\n } else {\n ans = false\n break\n }\n }\n if ans { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n"}, {"source_code": "package main\n\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strings\"\n )\n\n\nfunc main() {\n scanner := bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n scanner.Scan()\n a := scanner.Text()\n a = strings.Replace(a,\"144\",\" \",-1)\n a = strings.Replace(a,\"14\",\" \",-1)\n a = strings.Replace(a,\"1\",\" \",-1)\n if (strings.Trim(a, \" \") == \"\") {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"regexp\"\n\t\"strings\"\n)\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\n\nfunc getLine() string {\n\ts, _ := reader.ReadString('\\n')\n\tif strings.HasSuffix(s, \"\\r\\n\") {\n\t\ts = s[:len(s)-2]\n\t} else if strings.HasSuffix(s, \"\\n\") {\n\t\ts = s[:len(s)-1]\n\t}\n\treturn s\n}\nfunc getLine2Int() (n int) {\n\tscanf(\"%d\\n\", &n)\n\treturn\n}\nfunc getLine2Int2() (a, b int) {\n\tscanf(\"%d %d\\n\", &a, &b)\n\treturn\n}\nfunc getLine2Ints(n int) []int {\n\tans := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tscanf(\"%d \", &ans[i])\n\t}\n\tscanf(\"%d\\n\", &ans[n-1])\n\treturn ans\n}\n\nvar debug = false\n\nfunc see(a interface{}) {\n\tif debug {\n\t\tprintf(\"DEBUG:%v\\n\", a)\n\t}\n}\n\nfunc solve1() {\n\tinput := getLine()\n\tok, _ := regexp.Match(\"^(14{0,2})*$\", []byte(input))\n\tif ok {\n\t\tprintf(\"YES\\n\")\n\t} else {\n\t\tprintf(\"NO\\n\")\n\t}\n}\n\nfunc solve2() {\n\tinput := getLine()\n\n\tok := true\n\n\tfor i := 0; i < len(input) && ok; i++ {\n\t\tif input[i] != '1' && input[i] != '4' {\n\t\t\tok = false\n\t\t}\n\t}\n\n\tif ok && input[0] != '1' {\n\t\tok = false\n\t}\n\n\tfor i := 3; i < len(input) && ok; i++ {\n\t\tif input[i] == '4' && input[i-1] != '1' && input[i-2] != '1' {\n\t\t\tok = false\n\t\t}\n\t}\n\n\tif ok {\n\t\tprintf(\"YES\\n\")\n\t} else {\n\t\tprintf(\"NO\\n\")\n\t}\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\tinput := getLine()\n\n\tstatus := 0\n\tok := true\n\tfor i := 0; i < len(input) && ok; i++ {\n\t\tswitch status {\n\t\tcase 0: // must see 1\n\t\t\tif input[i] == '1' {\n\t\t\t\tstatus = 1\n\t\t\t} else {\n\t\t\t\tok = false\n\t\t\t}\n\t\tcase 1: // already see 1\n\t\t\tif input[i] != '1' {\n\t\t\t\tif input[i] != '4' {\n\t\t\t\t\tok = false\n\t\t\t\t} else {\n\t\t\t\t\tstatus = 2\n\t\t\t\t}\n\t\t\t}\n\t\tcase 2: // already see 14\n\t\t\tif input[i] == '1' {\n\t\t\t\tstatus = 1\n\t\t\t} else if input[i] != '4' {\n\t\t\t\tok = false\n\t\t\t} else {\n\t\t\t\tstatus = 0\n\t\t\t}\n\t\t}\n\t}\n\tif ok {\n\t\tprintf(\"YES\\n\")\n\t} else {\n\t\tprintf(\"NO\\n\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"regexp\"\n\t\"strings\"\n)\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\n\nfunc getLine() string {\n\ts, _ := reader.ReadString('\\n')\n\tif strings.HasSuffix(s, \"\\r\\n\") {\n\t\ts = s[:len(s)-2]\n\t} else if strings.HasSuffix(s, \"\\n\") {\n\t\ts = s[:len(s)-1]\n\t}\n\treturn s\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\tinput := getLine()\n\tok, _ := regexp.Match(\"^(14{0,2})*$\", []byte(input))\n\tif ok {\n\t\tprintf(\"YES\\n\")\n\t} else {\n\t\tprintf(\"NO\\n\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\n\nfunc getLine() string {\n\ts, _ := reader.ReadString('\\n')\n\tif strings.HasSuffix(s, \"\\r\\n\") {\n\t\ts = s[:len(s)-2]\n\t} else if strings.HasSuffix(s, \"\\n\") {\n\t\ts = s[:len(s)-1]\n\t}\n\treturn s\n}\nfunc getLine2Int() (n int) {\n\tscanf(\"%d\\n\", &n)\n\treturn\n}\nfunc getLine2Int2() (a, b int) {\n\tscanf(\"%d %d\\n\", &a, &b)\n\treturn\n}\nfunc getLine2Ints(n int) []int {\n\tans := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tscanf(\"%d \", &ans[i])\n\t}\n\tscanf(\"%d\\n\", &ans[n-1])\n\treturn ans\n}\n\nvar debug = false\n\nfunc see(a interface{}) {\n\tif debug {\n\t\tprintf(\"DEBUG:%v\\n\", a)\n\t}\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\tinput := getLine()\n\n\tok := true\n\n\tfor i := 0; i < len(input) && ok; i++ {\n\t\tif input[i] != '1' && input[i] != '4' {\n\t\t\tok = false\n\t\t}\n\t}\n\n\tif ok && input[0] != '1' {\n\t\tok = false\n\t}\n\n\tfor i := 3; i < len(input) && ok; i++ {\n\t\tif input[i] == '4' && input[i-1] != '1' && input[i-2] != '1' {\n\t\t\tok = false\n\t\t}\n\t}\n\n\tif ok {\n\t\tprintf(\"YES\\n\")\n\t} else {\n\t\tprintf(\"NO\\n\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var s string\n fmt.Scanf(\"%s\", &s)\n for i:=len(s)-1; i>=0; {\n if s[i] == '4' {\n if i>1 && s[i-1] == '4' && s[i-2] == '1' {\n i -= 3\n } else if i>0 && s[i-1] =='1' {\n i -= 2\n } else {\n fmt.Println(\"NO\")\n return\n }\n } else if s[i] == '1' {\n i -= 1\n } else {\n fmt.Println(\"NO\")\n return\n }\n }\n fmt.Println(\"YES\")\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar line string\n\tfmt.Scanf(\"%s\", &line)\n\n\tfoursExpect := 0\n\tokay := true\n\n\tfor i := 0; i < len(line); i++ {\n\t\tswitch line[i] {\n\t\tcase '1':\n\t\t\tfoursExpect = 2\n\t\tcase '4':\n\t\t\tfoursExpect--\n\t\t\tif foursExpect < 0 {\n\t\t\t\tokay = false\n\t\t\t}\n\t\tdefault:\n\t\t\tokay = false\n\t\t}\n\t}\n\n\tif okay {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nvar sc *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar w *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ni() int {\n sc.Scan()\n ans, _ := strconv.Atoi(sc.Text())\n return ans\n}\n\nfunc nll() int64 {\n sc.Scan()\n ans, _ := strconv.ParseInt(sc.Text(), 10, 64)\n return ans\n}\n\nfunc next() string {\n sc.Scan()\n return sc.Text()\n}\n\nfunc pri(n int) { w.WriteString(strconv.Itoa(n)) }\nfunc prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }\nfunc sp() { w.WriteByte(' ') }\nfunc endl() { w.WriteByte('\\n') }\n\nfunc main() {\n sc.Split(bufio.ScanWords)\n sc.Scan()\n s := sc.Text()\n c := 0\n if s[0] != '1' {\n w.WriteString(\"NO\\n\")\n w.Flush()\n return\n }\n for i := 0; i < len(s); i++ {\n if s[i] == '1' {\n if c >= 3 {\n w.WriteString(\"NO\\n\")\n w.Flush()\n return\n } else {\n c = 0\n }\n } else if s[i] == '4' {\n c++\n } else {\n w.WriteString(\"NO\\n\")\n w.Flush()\n return\n }\n }\n if c >= 3 {\n w.WriteString(\"NO\\n\")\n w.Flush()\n return\n }\n w.WriteString(\"YES\\n\")\n w.Flush()\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n ans, in := true, 0\n for in < len(s) {\n if s[in] == '1' {\n in++\n if in < len(s) {\n if s[in] == '4' { in++ }\n if in < len(s) {\n if s[in] == '4' { in++ }\n }\n }\n } else {\n ans = false\n break\n }\n }\n if ans { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n"}, {"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\n\nfunc solution(reader io.Reader, writer io.Writer) {\n\tvar n int\n\tfmt.Fscanf(reader, \"%d\\n\", &n)\n\tfor n > 0 {\n\t\tif n % 1000 == 144 {\n\t\t\tn /= 1000\n\t\t} else if n % 100 == 14 {\n\t\t\tn /= 100\n\t\t} else if n % 10 == 1 {\n\t\t\tn /= 10\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\tif n > 0 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n\nfunc main() {\n\n\t//stdin, err := os.Open(\"file.in\")\n\t//if err != nil {\n\t//\tpanic(err)\n\t//}\n\t//defer stdin.Close()\n\tstdin := os.Stdin\n\treader := bufio.NewReaderSize(stdin, 1024*1024)\n\n\t//stdout, err := os.Create(\"file.out\")\n\t//if err != nil {\n\t//\tpanic(err)\n\t//}\n\t//defer stdout.Close()\n\tstdout := os.Stdout\n\twriter := bufio.NewWriterSize(stdout, 1024*1024)\n\tdefer writer.Flush()\n\n\tsolution(reader, writer)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar i int\n\tfmt.Scanf(\"%d\", &i)\n\n\tans := \"NO\"\n\nloop:\n\tfor {\n\t\tswitch {\n\t\tcase i == 0:\n\t\t\tans = \"YES\"\n\t\t\tbreak loop\n\t\tcase i%10 == 1:\n\t\t\ti /= 10\n\t\tcase i%100 == 14:\n\t\t\ti /= 100\n\t\tcase i%1000 == 144:\n\t\t\ti /= 1000\n\t\tdefault:\n\t\t\tbreak loop\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"regexp\"\n\nfunc main() {\n\tvar s string\n\tfmt.Scanf(\"%s\", &s)\n\n\tr := regexp.MustCompile(\"^(14{0,2})+$\")\n\n\tans := \"NO\"\n\tif r.MatchString(s) {\n\t\tans = \"YES\"\n\t}\n\n\tfmt.Println(ans)\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar num string\n\tfmt.Scan(&num)\n\n\tfor _, v := range []string{\"144\", \"14\", \"1\"} {\n\t\tnum = strings.Replace(num, v, \"\", -1)\n\t}\n\n\tif len(num) > 0 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}"}, {"source_code": "package main\n\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strings\"\n )\n\n\nfunc main() {\n scanner := bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n scanner.Scan()\n a := scanner.Text()\n a = strings.Replace(a,\"144\",\"\",-1)\n a = strings.Replace(a,\"14\",\"\",-1)\n a = strings.Replace(a,\"1\",\"\",-1)\n if (a == \"\") {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar line string\n\tfmt.Scanf(\"%s\", &line)\n\n\tfoursExpect := 2\n\tokay := true\n\n\tfor i := 0; i < len(line); i++ {\n\t\tswitch line[i] {\n\t\tcase '1':\n\t\t\tfoursExpect = 2\n\t\tcase '4':\n\t\t\tfoursExpect--\n\t\t\tif foursExpect < 0 {\n\t\t\t\tokay = false\n\t\t\t}\n\t\tdefault:\n\t\t\tokay = false\n\t\t}\n\t}\n\n\tif okay {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nvar sc *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar w *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ni() int {\n sc.Scan()\n ans, _ := strconv.Atoi(sc.Text())\n return ans\n}\n\nfunc nll() int64 {\n sc.Scan()\n ans, _ := strconv.ParseInt(sc.Text(), 10, 64)\n return ans\n}\n\nfunc next() string {\n sc.Scan()\n return sc.Text()\n}\n\nfunc pri(n int) { w.WriteString(strconv.Itoa(n)) }\nfunc prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }\nfunc sp() { w.WriteByte(' ') }\nfunc endl() { w.WriteByte('\\n') }\n\nfunc main() {\n sc.Split(bufio.ScanWords)\n sc.Scan()\n s := sc.Text()\n c := 0\n for i := 0; i < len(s); i++ {\n if s[i] == '1' {\n if c >= 3 {\n w.WriteString(\"NO\\n\")\n w.Flush()\n return\n } else {\n c = 0\n }\n } else if s[i] == '4' {\n c++\n } else {\n w.WriteString(\"NO\\n\")\n w.Flush()\n return\n }\n }\n if c >= 3 {\n w.WriteString(\"NO\\n\")\n w.Flush()\n return\n }\n w.WriteString(\"YES\\n\")\n w.Flush()\n}\n"}], "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5"} {"nl": {"description": "Polycarpus has a ribbon, its length is n. He wants to cut the ribbon in a way that fulfils the following two conditions: After the cutting each ribbon piece should have length a, b or c. After the cutting the number of ribbon pieces should be maximum. Help Polycarpus and find the number of ribbon pieces after the required cutting.", "input_spec": "The first line contains four space-separated integers n, a, b and c (1 ≤ n, a, b, c ≤ 4000) — the length of the original ribbon and the acceptable lengths of the ribbon pieces after the cutting, correspondingly. The numbers a, b and c can coincide.", "output_spec": "Print a single number — the maximum possible number of ribbon pieces. It is guaranteed that at least one correct ribbon cutting exists.", "sample_inputs": ["5 5 3 2", "7 5 5 2"], "sample_outputs": ["2", "2"], "notes": "NoteIn the first example Polycarpus can cut the ribbon in such way: the first piece has length 2, the second piece has length 3.In the second example Polycarpus can cut the ribbon in such way: the first piece has length 5, the second piece has length 2."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\nimport \"sort\"\n\nfunc main() {\n\tvar n, a, b, c int\n\tfmt.Scan(&n, &a, &b, &c)\n\t//maxP := bruteForce(n, a, b, c)\n\tmaxP := dp(n, a, b, c)\n\tfmt.Print(maxP)\n}\n\nfunc dp(n, a, b, c int) int {\n\tdp := make([]int, 4001)\n\tdp[a] = 1\n\tdp[b] = 1\n\tdp[c] = 1\n\tfor i := 1; i <= n; i++ {\n\t\tdp[i] = max(dp, i, i-a, i-b, i-c)\n\t}\n\treturn dp[n]\n}\n\nfunc max(dp []int, nrs ...int) int {\n\tm := dp[nrs[0]]\n\tfor _, nr := range nrs[1:] {\n\t\tif nr < 0 || dp[nr] == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif dp[nr]+1 > m {\n\t\t\tm = dp[nr] + 1\n\t\t}\n\t}\n\treturn m\n}\n\nfunc bruteForce(n, a, b, c int) int {\n\tvar maxP int\n\tls := []int{a, b, c}\n\tsort.Sort(sort.Reverse(sort.IntSlice(ls)))\n\tfor i := 0; i <= n/ls[0]; i++ {\n\t\tfor j := 0; j <= n/ls[1]; j++ {\n\t\t\td := n - i*ls[0] - j*ls[1]\n\t\t\tif d%ls[2] == 0 {\n\t\t\t\tk := d / ls[2]\n\t\t\t\tif maxP < i+j+k {\n\t\t\t\t\tmaxP = i + j + k\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn maxP\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"sort\"\n\nfunc main() {\n\tvar n, a, b, c int\n\tfmt.Scan(&n, &a, &b, &c)\n\tvar maxP int\n\tls := []int{a, b, c}\n\tsort.Sort(sort.Reverse(sort.IntSlice(ls)))\n\tfor i := 0; i <= n/ls[0]; i++ {\n\t\tfor j := 0; j <= n/ls[1]; j++ {\n\t\t\td := n - i*ls[0] - j*ls[1]\n\t\t\tif d%ls[2] == 0 {\n\t\t\t\tk := d / ls[2]\n\t\t\t\tif maxP < i+j+k {\n\t\t\t\t\tmaxP = i + j + k\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Print(maxP)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"math\"\n\t\"fmt\"\n)\n\nconst maxN = 4000\n\nfunc intMax(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\n\treturn a\n}\n\nfunc resolver(a, b, c, n int) int {\n\tif n > maxN {\n\t\tpanic(\"Limit exceeded\")\n\t}\n\n\tmemo := make([]int, maxN + 1)\n\tunits := make([]int, 3)\n\n\tunits[0], units[1], units[2] = a, b, c\n\tmemo[0] = 0\n\tmemo[a] = 1\n\tmemo[b] = 1\n\tmemo[c] = 1\n\n\tfor i := 1; i <= n; i++ {\n\t\tvar localMax int = math.MinInt32\n\n\t\tfor _, v := range(units) {\n\t\t\tif delta := i - v; delta >= 0 && delta <= n {\n\t\t\t\tvar localMaxCand int = intMax(localMax, memo[delta] + 1)\n\n\t\t\t\tif localMaxCand > localMax {\n\t\t\t\t\tlocalMax = localMaxCand\n\t\t\t\t\tmemo[i] = localMax\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tmemo[i] = localMax\n\t}\n\n\treturn memo[n]\n}\n\nfunc main() {\n\tvar n, a, b, c int\n\tfmt.Scanln(&n, &a, &b, &c)\n\n\tfmt.Println(resolver(a, b, c, n))\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nvar dp [8005]int\n\nfunc main() {\n\tvar n, a, b, c int\n\tfmt.Scan(&n, &a, &b, &c)\n\n\tdp[a], dp[b], dp[c] = 1, 1, 1\n\tfor i := 1; i <= n; i++ {\n\t\tif dp[i] > 0 {\n\t\t\tdp[i+a] = max(dp[i+a], dp[i]+1)\n\t\t\tdp[i+b] = max(dp[i+b], dp[i]+1)\n\t\t\tdp[i+c] = max(dp[i+c], dp[i]+1)\n\t\t}\n\t}\n\n\tfmt.Println(dp[n])\n}\n\nfunc max(x, y int) int {\n\tif x < y {\n\t\tx = y\n\t}\n\n\treturn x\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nvar dp [4005]int\n\nfunc main() {\n\tvar n, a, b, c int\n\tfmt.Scan(&n, &a, &b, &c)\n\tif a > b {\n\t\ta, b = b, a\n\t}\n\tif a > c {\n\t\ta, c = c, a\n\t}\n\tif b > c {\n\t\tb, c = c, b\n\t}\n\n\tfor i := 1; i < len(dp); i++ {\n\t\tdp[i] = -100000\n\t}\n\tfor i := a; i <= n; i++ {\n\t\tdp[i] = max(dp[i], dp[i-a]+1)\n\t\tif i >= b {\n\t\t\tdp[i] = max(dp[i], dp[i-b]+1)\n\t\t}\n\t\tif i >= c {\n\t\t\tdp[i] = max(dp[i], dp[i-c]+1)\n\t\t}\n\t}\n\n\tfmt.Println(dp[n])\n}\n\nfunc max(x, y int) int {\n\tif x < y {\n\t\tx = y\n\t}\n\n\treturn x\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, a, b, c int\n\tfmt.Scan(&n, &a, &b, &c)\n\tif a > b {\n\t\ta, b = b, a\n\t}\n\tif a > c {\n\t\ta, c = c, a\n\t}\n\tif b > c {\n\t\tb, c = c, b\n\t}\n\n\tn1 := n / a\n\tn2 := n / b\n\tn3 := n / c\n\tif n%a == 0 || (a == b && b == c) {\n\t\tfmt.Println(n1)\n\t\treturn\n\t}\n\n\tmax := 0\n\tif a == b || b == c {\n\t\tfor i := 0; i <= n1; i++ {\n\t\t\tfor j := 0; j <= n3; j++ {\n\t\t\t\tv := i*a + j*c\n\t\t\t\tif v >= n {\n\t\t\t\t\tif v == n && i+j > max {\n\t\t\t\t\t\tmax = i + j\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfmt.Println(max)\n\t\treturn\n\t}\n\n\tfor i := 0; i <= n1; i++ {\n\t\tfor j := 0; j <= n2; j++ {\n\t\t\tfor k := 0; k <= n3; k++ {\n\t\t\t\tv := i*a + j*b + k*c\n\t\t\t\tif v >= n {\n\t\t\t\t\tif v == n && i+j+k > max {\n\t\t\t\t\t\tmax = i + j + k\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(max)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader\n\nfunc init() {\n\tstdin := os.Stdin\n\t// stdin, _ = os.Open(\"1.in\")\n\treader = bufio.NewReaderSize(stdin, 1<<20)\n}\n\nvar n int\nvar a [3]int\n\nfunc main() {\n\tfmt.Fscan(reader, &n, &a[0], &a[1], &a[2])\n\tdp := make([]int, n+1)\n\tok := make([]bool, n+1)\n\tok[0] = true\n\tfor i := 1; i <= n; i++ {\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tif i >= a[j] && dp[i] < dp[i-a[j]]+1 && ok[i-a[j]] {\n\t\t\t\tdp[i] = dp[i-a[j]] + 1\n\t\t\t\tok[i] = true\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(dp[n])\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar DEBUG = true\n\nfunc main() {\n\tdefer Flush()\n\n\tn := readi()\n\ta := readi()\n\tb := readi()\n\tc := readi()\n\n\tdp := make([]int, n+1)\n\tfor i := range dp {\n\t\tdp[i] = -1\n\t}\n\tdp[0] = 0\n\n\tfor i := 0; i <= n; i++ {\n\t\tif dp[i] < 0 {\n\t\t\tcontinue\n\t\t}\n\t\tfor _, v := range []int{a, b, c} {\n\t\t\tj := i + v\n\t\t\tif n < j {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tdp[j] = max(dp[j], dp[i]+1)\n\t\t}\n\t}\n\tprintln(dp[n])\n}\n\n// -----------------------------------------------------------------------------\n\n// IO helper functions\n\n// Returns next token from input. It must be initialized by SetInput()\n// before the first call.\nvar nextToken func() ([]byte, error)\nvar nextLine func() ([]byte, error)\n\n// Holds a buffer for output. It must be initialized by SetOutput().\n// All IO fucntions (read*() and [e]print*()) should write to OutputWriter\n// instead of this.\nvar OutputBuffer *bufio.Writer\n\n// Holds an io.Writer. It must be initialized by SetOutput()\nvar OutputWriter io.Writer\n\n// Set IO functions for interactive input/output.\nfunc SetInteractive(w io.Writer, r io.Reader) {\n\tSetUnbefferedInput(r)\n\tOutputBuffer = nil\n\tOutputWriter = w\n}\n\n// Setup OutputBuffer and OutputWriter.\nfunc SetOutput(w io.Writer) {\n\tOutputBuffer = bufio.NewWriter(w)\n\tOutputWriter = OutputBuffer\n}\n\n// Flushes OutputBuffer\nfunc Flush() {\n\tif OutputBuffer != nil {\n\t\tOutputBuffer.Flush()\n\t}\n}\n\n// Returns true if c is a white space\nfunc IsSpace(c byte) bool {\n\tswitch c {\n\tcase '\\t', '\\n', '\\v', '\\f', '\\r', ' ':\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc IsNewLine(c byte) bool {\n\tswitch c {\n\tcase '\\n', '\\r':\n\t\treturn true\n\t}\n\treturn false\n}\n\n// Setup nextToken with input buffer.\nfunc SetInput(r io.Reader) {\n\tbuf := new(bytes.Buffer)\n\tvar b []byte\n\n\tvar i int\n\trest := func() ([]byte, error) {\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\tinitial := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextToken = rest\n\t\treturn rest()\n\t}\n\tnextToken = initial\n\n\trestLn := func() ([]byte, error) {\n\t\tfor i < len(b) && IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\n\tinitialLn := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextLine = restLn\n\t\treturn restLn()\n\t}\n\tnextLine = initialLn\n}\n\n// Setup nextToken without input buffer.\nfunc SetUnbefferedInput(r io.Reader) {\n\tbuf := bufio.NewReader(r)\n\tvar b []byte\n\n\tvar i int\n\tnextToken = func() ([]byte, error) {\n\t\tvar err error\n\t\tif i == len(b) {\n\t\t\tb, err = buf.ReadBytes('\\n')\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\ti = 0\n\t\t\tj := len(b) - 1\n\t\t\tfor 0 <= j && IsSpace(b[j]) {\n\t\t\t\tj--\n\t\t\t}\n\t\t\tb = b[0 : j+1]\n\t\t}\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == j {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n}\n\n// -----------------------------------------------------------------------------\n\n// IO functions\n\n// Reads next token and return it as []byte\nfunc readb() []byte {\n\tb, err := nextToken()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b[:len(b):len(b)]\n}\n\n// Reads next token and return it as string\nfunc reads() string {\n\treturn string(readb())\n}\n\n// Read next line as []byte. Trailing '\\n' will not be included.\n// See also comments on readb()\nfunc readbln() []byte {\n\tb, err := nextLine()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b[:len(b):len(b)]\n}\n\n// Read next line as string\nfunc readsln() string {\n\treturn string(readbln())\n}\n\n// Reads next token and return it as int64\nfunc readll() int64 {\n\ti, err := strconv.ParseInt(reads(), 10, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// Reads next token and return it as int\nfunc readi() int {\n\treturn int(readll())\n}\n\n// Reads next token and return it as float64\nfunc readf() float64 {\n\tf, err := strconv.ParseFloat(reads(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// Write args to OutputWriter with the format f\nfunc printf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(OutputWriter, f, args...)\n}\n\n// Write args to OutputWriter without format\nfunc println(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(OutputWriter, args...)\n}\n\n// Write args to stderr with the format f\nfunc eprintf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(os.Stderr, f, args...)\n}\n\n// Write args to stderr without format\nfunc eprintln(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(os.Stderr, args...)\n}\n\nfunc dbgf(f string, args ...interface{}) {\n\tif !DEBUG {\n\t\treturn\n\t}\n\tfmt.Fprintf(os.Stderr, f, args...)\n}\n\nfunc dbg(args ...interface{}) {\n\tif !DEBUG {\n\t\treturn\n\t}\n\tfmt.Fprintln(os.Stderr, args...)\n}\n\n// -----------------------------------------------------------------------------\n\n// Utilities\n\nfunc sumSlice(a []int) int {\n\tvar res int\n\tfor _, v := range a {\n\t\tres += v\n\t}\n\treturn res\n}\n\nfunc sumSlicell(a []int64) int64 {\n\tvar res int64\n\tfor _, v := range a {\n\t\tres += v\n\t}\n\treturn res\n}\n\nfunc readInts(N int) (int, []int) {\n\tif N == 0 {\n\t\tN = readi()\n\t}\n\ta := make([]int, N)\n\tfor i := range a {\n\t\ta[i] = readi()\n\t}\n\treturn N, a\n}\n\nfunc readIntsll(N int) (int, []int64) {\n\tif N == 0 {\n\t\tN = readi()\n\t}\n\ta := make([]int64, N)\n\tfor i := range a {\n\t\ta[i] = readll()\n\t}\n\treturn N, a\n}\n\n// -----------------------------------------------------------------------------\n\n// Simple math functions\n\nconst (\n\t// big prime\n\tINF = 1000000007\n\tINF2 = 1000000009\n\tINF3 = 998244353\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc minll(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc minf(a, b float64) float64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc maxll(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc maxf(a, b float64) float64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc absll(a int64) int64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc absf(a float64) float64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// egcd(a, b) returns d, x, y:\n// d is gcd(a,b)\n// x, y are integers that satisfy ax + by = d\nfunc egcd(a, b int) (int, int, int) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcd(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc egcdll(a, b int64) (int64, int64, int64) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcdll(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc gcd(a, b int) int {\n\td, _, _ := egcd(a, b)\n\treturn d\n}\n\nfunc gcdll(a, b int64) int64 {\n\td, _, _ := egcdll(a, b)\n\treturn d\n}\n\n// set up IO functions\nfunc init() {\n\t// for non-interactive\n\tSetInput(os.Stdin)\n\tSetOutput(os.Stdout)\n\n\t// Enable below when interactive. Its ok to leave above intact.\n\t// SetInteractive(os.Stdout, os.Stdin)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar DEBUG = true\n\nfunc main() {\n\tdefer Flush()\n\n\tn := readi()\n\ta := readi()\n\tb := readi()\n\tc := readi()\n\n\tvar ans int\n\tfor i := 0; i*a <= n; i++ {\n\t\tfor j := 0; j*b <= n-i*a; j++ {\n\t\t\tm := n - i*a - j*b\n\t\t\tif m%c == 0 {\n\t\t\t\tans = max(ans, i+j+m/c)\n\t\t\t}\n\t\t}\n\t}\n\tprintln(ans)\n}\n\n// -----------------------------------------------------------------------------\n\n// IO helper functions\n\n// Returns next token from input. It must be initialized by SetInput()\n// before the first call.\nvar nextToken func() ([]byte, error)\nvar nextLine func() ([]byte, error)\n\n// Holds a buffer for output. It must be initialized by SetOutput().\n// All IO fucntions (read*() and [e]print*()) should write to OutputWriter\n// instead of this.\nvar OutputBuffer *bufio.Writer\n\n// Holds an io.Writer. It must be initialized by SetOutput()\nvar OutputWriter io.Writer\n\n// Set IO functions for interactive input/output.\nfunc SetInteractive(w io.Writer, r io.Reader) {\n\tSetUnbefferedInput(r)\n\tOutputBuffer = nil\n\tOutputWriter = w\n}\n\n// Setup OutputBuffer and OutputWriter.\nfunc SetOutput(w io.Writer) {\n\tOutputBuffer = bufio.NewWriter(w)\n\tOutputWriter = OutputBuffer\n}\n\n// Flushes OutputBuffer\nfunc Flush() {\n\tif OutputBuffer != nil {\n\t\tOutputBuffer.Flush()\n\t}\n}\n\n// Returns true if c is a white space\nfunc IsSpace(c byte) bool {\n\tswitch c {\n\tcase '\\t', '\\n', '\\v', '\\f', '\\r', ' ':\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc IsNewLine(c byte) bool {\n\tswitch c {\n\tcase '\\n', '\\r':\n\t\treturn true\n\t}\n\treturn false\n}\n\n// Setup nextToken with input buffer.\nfunc SetInput(r io.Reader) {\n\tbuf := new(bytes.Buffer)\n\tvar b []byte\n\n\tvar i int\n\trest := func() ([]byte, error) {\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\tinitial := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextToken = rest\n\t\treturn rest()\n\t}\n\tnextToken = initial\n\n\trestLn := func() ([]byte, error) {\n\t\tfor i < len(b) && IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == len(b) {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsNewLine(b[i]) {\n\t\t\ti++\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n\n\tinitialLn := func() ([]byte, error) {\n\t\tio.Copy(buf, r)\n\t\tb = buf.Bytes()\n\t\tnextLine = restLn\n\t\treturn restLn()\n\t}\n\tnextLine = initialLn\n}\n\n// Setup nextToken without input buffer.\nfunc SetUnbefferedInput(r io.Reader) {\n\tbuf := bufio.NewReader(r)\n\tvar b []byte\n\n\tvar i int\n\tnextToken = func() ([]byte, error) {\n\t\tvar err error\n\t\tif i == len(b) {\n\t\t\tb, err = buf.ReadBytes('\\n')\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\ti = 0\n\t\t\tj := len(b) - 1\n\t\t\tfor 0 <= j && IsSpace(b[j]) {\n\t\t\t\tj--\n\t\t\t}\n\t\t\tb = b[0 : j+1]\n\t\t}\n\t\tfor i < len(b) && IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tj := i\n\t\tfor i < len(b) && !IsSpace(b[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == j {\n\t\t\treturn nil, io.ErrUnexpectedEOF\n\t\t}\n\t\treturn b[j:i], nil\n\t}\n}\n\n// -----------------------------------------------------------------------------\n\n// IO functions\n\n// Reads next token and return it as []byte\nfunc readb() []byte {\n\tb, err := nextToken()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b[:len(b):len(b)]\n}\n\n// Reads next token and return it as string\nfunc reads() string {\n\treturn string(readb())\n}\n\n// Read next line as []byte. Trailing '\\n' will not be included.\n// See also comments on readb()\nfunc readbln() []byte {\n\tb, err := nextLine()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b[:len(b):len(b)]\n}\n\n// Read next line as string\nfunc readsln() string {\n\treturn string(readbln())\n}\n\n// Reads next token and return it as int64\nfunc readll() int64 {\n\ti, err := strconv.ParseInt(reads(), 10, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// Reads next token and return it as int\nfunc readi() int {\n\treturn int(readll())\n}\n\n// Reads next token and return it as float64\nfunc readf() float64 {\n\tf, err := strconv.ParseFloat(reads(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// Write args to OutputWriter with the format f\nfunc printf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(OutputWriter, f, args...)\n}\n\n// Write args to OutputWriter without format\nfunc println(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(OutputWriter, args...)\n}\n\n// Write args to stderr with the format f\nfunc eprintf(f string, args ...interface{}) (int, error) {\n\treturn fmt.Fprintf(os.Stderr, f, args...)\n}\n\n// Write args to stderr without format\nfunc eprintln(args ...interface{}) (int, error) {\n\treturn fmt.Fprintln(os.Stderr, args...)\n}\n\nfunc dbgf(f string, args ...interface{}) {\n\tif !DEBUG {\n\t\treturn\n\t}\n\tfmt.Fprintf(os.Stderr, f, args...)\n}\n\nfunc dbg(args ...interface{}) {\n\tif !DEBUG {\n\t\treturn\n\t}\n\tfmt.Fprintln(os.Stderr, args...)\n}\n\n// -----------------------------------------------------------------------------\n\n// Utilities\n\nfunc sumSlice(a []int) int {\n\tvar res int\n\tfor _, v := range a {\n\t\tres += v\n\t}\n\treturn res\n}\n\nfunc sumSlicell(a []int64) int64 {\n\tvar res int64\n\tfor _, v := range a {\n\t\tres += v\n\t}\n\treturn res\n}\n\nfunc readInts(N int) (int, []int) {\n\tif N == 0 {\n\t\tN = readi()\n\t}\n\ta := make([]int, N)\n\tfor i := range a {\n\t\ta[i] = readi()\n\t}\n\treturn N, a\n}\n\nfunc readIntsll(N int) (int, []int64) {\n\tif N == 0 {\n\t\tN = readi()\n\t}\n\ta := make([]int64, N)\n\tfor i := range a {\n\t\ta[i] = readll()\n\t}\n\treturn N, a\n}\n\n// -----------------------------------------------------------------------------\n\n// Simple math functions\n\nconst (\n\t// big prime\n\tINF = 1000000007\n\tINF2 = 1000000009\n\tINF3 = 998244353\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc minll(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc minf(a, b float64) float64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc maxll(a, b int64) int64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc maxf(a, b float64) float64 {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc absll(a int64) int64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc absf(a float64) float64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// egcd(a, b) returns d, x, y:\n// d is gcd(a,b)\n// x, y are integers that satisfy ax + by = d\nfunc egcd(a, b int) (int, int, int) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcd(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc egcdll(a, b int64) (int64, int64, int64) {\n\tif b == 0 {\n\t\treturn a, 1, 0\n\t}\n\td, x, y := egcdll(b, a%b)\n\treturn d, y, x - a/b*y\n}\n\nfunc gcd(a, b int) int {\n\td, _, _ := egcd(a, b)\n\treturn d\n}\n\nfunc gcdll(a, b int64) int64 {\n\td, _, _ := egcdll(a, b)\n\treturn d\n}\n\n// set up IO functions\nfunc init() {\n\t// for non-interactive\n\tSetInput(os.Stdin)\n\tSetOutput(os.Stdout)\n\n\t// Enable below when interactive. Its ok to leave above intact.\n\t// SetInteractive(os.Stdout, os.Stdin)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n,a,b,c int\n\ts:=0\n\tfmt.Scan(&n,&a,&b,&c)\n\tfor i:=0;i<=n/a;i++ {\n\t\tz:=n-i*a\n\t\tfor k:=0; k<=z/b;k++ {\n\t\t\th:=i+k+(z-k*b)/c\n\t\t\tif (z-k*b)%c==0 && h>s {\n\t\t\t\ts=h\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(s)\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc MaxOf(vars ...int) int {\n\tmax := vars[0]\n\n\tfor _, i := range vars {\n\t\tif max < i {\n\t\t\tmax = i\n\t\t}\n\t}\n\n\treturn max\n}\n\nfunc main() {\n\tvar reader io.Reader\n\tvar writer io.Writer\n\n\treader = os.Stdin\n\twriter = os.Stdout\n\n\t//file, _ := os.Open(\"input.txt\")\n\t//reader = file\n\n\tvar n, a, b, c int\n\n\tfmt.Fscanf(reader, \"%d %d %d %d\", &n, &a, &b, &c)\n\n\n\tf := make([]int, n+a+b+c+1)\n\tf[a] = 1\n\tf[b] = 1\n\tf[c] = 1\n\n\tfor i := 0; i <= n; i++ {\n\t\tif i >= a && f[i-a] != 0 {\n\t\t\tf[i] = MaxOf(f[i-a]+1, f[i])\n\t\t}\n\t\tif i >= b && f[i-b] != 0 {\n\t\t\tf[i] = MaxOf(f[i-b]+1, f[i])\n\t\t}\n\t\tif i >= c && f[i-c] != 0 {\n\t\t\tf[i] = MaxOf(f[i-c]+1, f[i])\n\t\t}\n\t}\n\n\tfmt.Fprintln(writer, f[n])\n\n}\n"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nvar sc *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar w *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ni() int {\n sc.Scan()\n ans, _ := strconv.Atoi(sc.Text())\n return ans\n}\n\nfunc nll() int64 {\n sc.Scan()\n ans, _ := strconv.ParseInt(sc.Text(), 10, 64)\n return ans\n}\n\nfunc next() string {\n sc.Scan()\n return sc.Text()\n}\n\nfunc pri(n int) { w.WriteString(strconv.Itoa(n)) }\nfunc prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }\nfunc sp() { w.WriteByte(' ') }\nfunc endl() { w.WriteByte('\\n') }\n\nfunc main() {\n sc.Split(bufio.ScanWords)\n n, a, b, c := ni(), ni(), ni(), ni()\n max := 0\n for i := 0; i*a <= n; i++ {\n for j := 0; j*b <= n-i*a; j++ {\n n2 := n - i*a - j*b\n if n2%c == 0 && n2/c+i+j > max {\n max = n2/c + i + j\n }\n }\n }\n pri(max)\n w.Flush()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"strings\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nfunc Readln(r *bufio.Reader) (string, error) {\n\tvar (\n\t\tisPrefix bool = true\n\t\terr error = nil\n\t\tline, ln []byte\n\t)\n\tfor isPrefix && err == nil {\n\t\tline, isPrefix, err = r.ReadLine()\n\t\tln = append(ln, line...)\n\t}\n\treturn string(ln), err\n}\n\nfunc readIntArray(line string) []int {\n\t\n\tnumStrings := strings.Split(strings.TrimSpace(string(line)), \" \")\n\t\n\tnumbers := make([]int, 0)\n\t\n\tfor _, v := range numStrings {\n\t\tvar converted int\n\t\t\n\t\tfmt.Sscanf(v, \"%d\", &converted)\n\t\tnumbers = append(numbers, converted)\n\t}\n\t\n\treturn numbers\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\t\n\tline, _ := Readln(reader)\n\tnumbers := readIntArray(line)\n\t\n\tlength := numbers[0]\n\tlengths := numbers[1:]\n\t\n\tcache := make(map[int]int, 0)\n\tsort.Ints(lengths)\n\tfmt.Println(Cut(length, lengths, 0, cache))\n}\n\nfunc Cut(length int, lengths []int, pieces int, cache map[int]int) int {\n\t\n\tif cached, ok := cache[length]; ok {\n\t\treturn cached\n\t}\n\t\n\tmaxPieces := pieces\n\tisCut := false\n\tfor _, ln := range lengths {\n\t\tif (length - ln) >= 0 {\n\t\t\tnewPieces := Cut(length - ln, lengths, pieces + 1, cache)\n\t\t\tif maxPieces < newPieces {\n\t\t\t\tisCut = true\n\t\t\t\tmaxPieces = newPieces\n\t\t\t}\n\t\t}\n\t}\n\t\n\tif (!isCut) && length > 0 {\n\t\tmaxPieces = -1\n\t\tcache[length] = maxPieces\n\t} else if isCut {\n\t\tcache[length] = maxPieces\n\t}\n\t\n\treturn maxPieces\n}\n"}, {"source_code": "package main\n\n\nimport \"fmt\"\n\n\nfunc max(a,b int)int {\nif a > b {\nreturn a\n} else {\nreturn b\n}\n}\n\n\nfunc main() {\n\n var n int\n\n var a [3]int\n\n fmt.Scan(&n,&a[0],&a[1],&a[2])\n\n dp := make([]int,n+1)\n\n dp[0] = 0\n\n for i := 1; i <= n; i++ {\n\n dp[i] = -999999999\n\n for k := 0; k < 3; k++ {\n\n if (i-a[k]) >= 0 {\n\n dp[i] = max(dp[i],1+dp[i-a[k]])\n\n }\n\n }\n\n }\n\n fmt.Println(dp[n])\n\n}\n"}, {"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 main() {\n\tvar n int\n\tvar a [3]int\n\tfmt.Scan(&n, &a[0], &a[1], &a[2])\n\tdp := make([]int, n+1)\n\tdp[0] = 0\n\tfor i := 1; i <= n; i++ {\n\t\tdp[i] = -999999999\n\t\tfor k := 0; k < 3; k++ {\n\t\t\tif (i - a[k]) >= 0 {\n\t\t\t\tdp[i] = max(dp[i], 1+dp[i-a[k]])\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(dp[n])\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nconst maxn = 4000 + 10\n\nfunc max(a, b int) int {\n\tif a >= b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar n, a, b, c int\n\tvar dp [maxn]int\n\tfmt.Scan(&n, &a, &b, &c)\n\tdp[0] = 0\n\tfor i := 1; i <= n; i++ {\n\t\tdp[i] = -0x3f3f3f3f\n\t}\n\tfor i := 1; i <= n; i++ {\n\t\tif i >= a {\n\t\t\tdp[i] = max(dp[i], dp[i-a]+1)\n\t\t}\n\t\tif i >= b {\n\t\t\tdp[i] = max(dp[i], dp[i-b]+1)\n\t\t}\n\t\tif i >= c {\n\t\t\tdp[i] = max(dp[i], dp[i-c]+1)\n\t\t}\n\t}\n\tif dp[n] < 0 {\n\t\tdp[n] = 0\n\t}\n\tfmt.Printf(\"%d\\n\", dp[n])\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\n// https://codeforces.com/problemset/problem/189/A\n// комментарии к решению\n// Задача решается полным перебором. Для сокращения кол-ва операций\n// итерируемся с максимального возможного вниз, т.к. в цикле for\n// вычисления из init производяться один раз (сокращается кол-во операций)\nfunc taskSolution(n, a, b, c int) int {\n\tmax := 0\n\tfor i := n / a; i >= 0; i -= 1 {\n\t\tfor j := (n - i*a) / b; j >= 0; j -= 1 {\n\t\t\tleft := n - i*a - j*b\n\t\t\tif left%c == 0 && max < i+j+left/c {\n\t\t\t\tmax = i + j + left/c\n\t\t\t}\n\t\t}\n\t}\n\treturn max\n}\n\nfunc main() {\n\tvar n, a, b, c int\n\tif _, err := fmt.Scan(&n, &a, &b, &c); err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(taskSolution(n, a, b, c))\n}\n"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc max(x, y int) int {\n if x > y {\n return x\n }\n return y\n}\n\nfunc main() {\n defer writer.Flush()\n var n, a, b, c int\n scanf(\"%d %d %d %d\\n\", &n, &a, &b, &c)\n\n dp := make([]int, n+1)\n\n for i, _ := range dp {\n dp[i] = -1\n }\n dp[0] = 0\n\n for i:=1; i <= n; i++ {\n for _, j := range []int{a, b, c} {\n if i-j >= 0 && dp[i-j] != -1 {\n dp[i] = max(dp[i], dp[i-j]+1)\n }\n }\n }\n printf(\"%d\\n\", dp[n])\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n,a,b,c int\n\ts:=0\n\tfmt.Scan(&n,&a,&b,&c)\n\tfor i:=0;i<=n/a;i++ {\n\t\tz:=n-i*a\n\t\tfor k:=0; k<=z/b;k++ {\n\t\t\th:=i+k+(z-k*b)/c\n\t\t\tif (z-k*b)%c==0 && h>s {\n\t\t\t\ts=h\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(s)\n}\n\n"}, {"source_code": "// http://codeforces.com/problemset/problem/189/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 max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc main () {\n\tvar (\n\t\tn, a, b, c int\n\t)\n\n\t//f, _ := os.Open(\"input.txt\")\n\t//input := bufio.NewReader(f)\n\tinput := bufio.NewReader(os.Stdin)\n\n\tfmt.Fscanln(input, &n, &a, &b, &c)\n\n\tdp := make([]struct{cnt, l int}, 1e4 + 1)\n\n\tdp[0].l = n\n\tdp[0].l = n\n\tdp[0].l = n\n\n\n\tfor i := 0; i <= n; i++ {\n\t\tif dp[i].cnt + 1 > dp[i + a].cnt && dp[i].l - a >= 0 {\n\t\t\tdp[i + a].cnt = dp[i].cnt + 1\n\t\t\tdp[i + a].l = dp[i].l - a\n\t\t}\n\n\t\tif dp[i].cnt + 1 > dp[i + b].cnt && dp[i].l - b >= 0 {\n\t\t\tdp[i + b].cnt = dp[i].cnt + 1\n\t\t\tdp[i + b].l = dp[i].l - b\n\t\t}\n\n\t\tif dp[i].cnt + 1 > dp[i + c].cnt && dp[i].l - c >= 0 {\n\t\t\tdp[i + c].cnt = dp[i].cnt + 1\n\t\t\tdp[i + c].l = dp[i].l - c\n\t\t}\n\t}\n\n\tfmt.Println(max(max(dp[n].cnt, dp[n].cnt), dp[n].cnt))\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar n, a, b, c int\n\tt := []int{0}\n\tfmt.Scanf(\"%d %d %d %d \\n\", &n, &a, &b, &c)\n\tfor i := 1; i <= n; i++ {\n\t\tt = append(t, -1)\n\t\tif i >= a && t[i-a] != -1 {\n\t\t\tt[i] = max(t[i], t[i-a]+1)\n\t\t}\n\t\tif i >= b && t[i-b] != -1 {\n\t\t\tt[i] = max(t[i], t[i-b]+1)\n\t\t}\n\t\tif i >= c && t[i-c] != -1 {\n\t\t\tt[i] = max(t[i], t[i-c]+1)\n\t\t}\n\t}\n\tfmt.Print(t[n])\n}\n"}, {"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 int\n var a [3]int\n fmt.Scan(&n,&a[0],&a[1],&a[2])\n dp := make([]int,n+1)\n dp[0] = 0\n for i := 1; i <= n; i++ {\n dp[i] = -999999999\n for k := 0; k < 3; k++ {\n if (i-a[k]) >= 0 {\n dp[i] = max(dp[i],1+dp[i-a[k]])\n }\n }\n }\n fmt.Println(dp[n])\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar n, a, b, c int\nvar res []int\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\traw := scanner.Text()\n\tsegs := strings.Split(raw, \" \")\n\tn, _ = strconv.Atoi(segs[0])\n\ta, _ = strconv.Atoi(segs[1])\n\tb, _ = strconv.Atoi(segs[2])\n\tc, _ = strconv.Atoi(segs[3])\n\n\td := Do()\n\tfmt.Println(d)\n}\n\nfunc Do() int {\n\tres = make([]int, n+1, n+1)\n\tfor idx := 1; idx <= n; idx++ {\n\t\tres[idx] = Cut(idx)\n\t\t// fmt.Println(\"res\", idx, res)\n\t}\n\treturn res[n]\n}\n\nfunc Cut(idx int) int {\n\tif idx == 0 {\n\t\treturn 0\n\t}\n\tmax := 0\n\tif idx >= a {\n\t\tleft := idx - a\n\t\tif left == 0 {\n\t\t\tmax = 1\n\t\t\tgoto bnote\n\t\t} else {\n\t\t\tif res[left] == 0 {\n\t\t\t\tmax = 0\n\t\t\t\tgoto bnote\n\t\t\t} else {\n\t\t\t\tmax = 1 + res[left]\n\t\t\t}\n\t\t}\n\t}\nbnote:\n\tbmax := 0\n\t{\n\t\tif idx >= b {\n\t\t\tleft := idx - b\n\t\t\tif left == 0 {\n\t\t\t\tbmax = 1\n\t\t\t\tgoto cnote\n\t\t\t} else {\n\t\t\t\tif res[left] == 0 {\n\t\t\t\t\tbmax = 0\n\t\t\t\t\tgoto cnote\n\t\t\t\t} else {\n\t\t\t\t\tbmax = 1 + res[left]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\ncnote:\n\tcmax := 0\n\t{\n\t\tif idx >= c {\n\t\t\tleft := idx - c\n\t\t\tif left == 0 {\n\t\t\t\tcmax = 1\n\t\t\t\tgoto over\n\t\t\t} else {\n\t\t\t\tif res[left] == 0 {\n\t\t\t\t\tcmax = 0\n\t\t\t\t\tgoto over\n\t\t\t\t} else {\n\t\t\t\t\tcmax = 1 + res[left]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\nover:\n\t{\n\t\tzhi := max3(max, bmax, cmax)\n\t\treturn zhi\n\t}\n}\n\nfunc max3(a, b, c int) int {\n\tres := []int{a, b, c}\n\t// fmt.Println(res)\n\tsort.Ints(res)\n\treturn res[2]\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc Max(a, b int) int {\n result := a\n if b > a {\n result = b\n }\n\n return result\n}\n\nfunc main() {\n var n, a, b, c int\n fmt.Scanln(&n, &a, &b, &c)\n\n arr := []int{a, b, c}\n dp := make([]int, n + 1)\n dp[0] = 1\n\n for i := 1; i <= n; i++ {\n var max int = 0\n for _, v := range arr {\n var cur_i int = i - v\n if cur_i >= 0 && dp[cur_i] != 0 {\n max = Max(max, dp[cur_i] + 1)\n }\n }\n\n dp[i] = max\n }\n\n fmt.Println(dp[n] - 1)\n}"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\nimport \"sort\"\n\nfunc main() {\n\tvar n, a, b, c int\n\tfmt.Scan(&n, &a, &b, &c)\n\t//maxP := bruteForce(n, a, b, c)\n\tmaxP := dp(n, a, b, c)\n\tfmt.Print(maxP)\n}\n\nfunc dp(n, a, b, c int) int {\n\tdp := make([]int, n+1)\n\tdp[a] = 1\n\tdp[b] = 1\n\tdp[c] = 1\n\tfor i := 1; i <= n; i++ {\n\t\tif i-a > 0 && a != 0 {\n\t\t\tdp[i] = max(dp[i], dp[i-a]+1)\n\t\t\tcontinue\n\t\t}\n\t\tif i-b > 0 && b != 0 {\n\t\t\tdp[i] = max(dp[i], dp[i-b]+1)\n\t\t\tcontinue\n\t\t}\n\t\tif i-c > 0 && c != 0 {\n\t\t\tdp[i] = max(dp[i], dp[i-c]+1)\n\t\t\tcontinue\n\t\t}\n\t}\n\treturn dp[n]\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc bruteForce(n, a, b, c int) int {\n\tvar maxP int\n\tls := []int{a, b, c}\n\tsort.Sort(sort.Reverse(sort.IntSlice(ls)))\n\tfor i := 0; i <= n/ls[0]; i++ {\n\t\tfor j := 0; j <= n/ls[1]; j++ {\n\t\t\td := n - i*ls[0] - j*ls[1]\n\t\t\tif d%ls[2] == 0 {\n\t\t\t\tk := d / ls[2]\n\t\t\t\tif maxP < i+j+k {\n\t\t\t\t\tmaxP = i + j + k\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn maxP\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"math\"\n\t\"fmt\"\n)\n\nconst maxN = 4000\n\nfunc intMax(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\n\treturn a\n}\n\nfunc resolver(a, b, c, n int) int {\n\tif n > maxN {\n\t\tpanic(\"Limit exceeded\")\n\t}\n\n\tmemo := make([]int, n+1)\n\tunits := make([]int, 3)\n\n\tunits[0], units[1], units[2] = a, b, c\n\tmemo[0] = 0\n\tmemo[a] = 1\n\tmemo[b] = 1\n\tmemo[c] = 1\n\n\tfor i := 1; i <= n; i++ {\n\t\tvar localMax int = math.MinInt32\n\n\t\tfor _, v := range(units) {\n\t\t\tif delta := i - v; delta >= 0 {\n\t\t\t\tvar localMaxCand int = intMax(memo[i], memo[delta] + 1)\n\n\t\t\t\tif localMaxCand > localMax {\n\t\t\t\t\tlocalMax = localMaxCand\n\t\t\t\t\tmemo[i] = localMax\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tmemo[i] = localMax\n\t}\n\n\treturn memo[n]\n}\n\nfunc main() {\n\tvar n, a, b, c int\n\tfmt.Scanln(&n, &a, &b, &c)\n\n\tfmt.Println(resolver(a, b, c, n))\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nvar dp [4005]int\n\nfunc main() {\n\tvar n, a, b, c int\n\tfmt.Scan(&n, &a, &b, &c)\n\tif a > b {\n\t\ta, b = b, a\n\t}\n\tif a > c {\n\t\ta, c = c, a\n\t}\n\tif b > c {\n\t\tb, c = c, b\n\t}\n\n\tfor i := 1; i < len(dp); i++ {\n\t\tdp[i] = -100000\n\t}\n\tfor i := a; i <= n; i++ {\n\t\tdp[i] = dp[i-a] + 1\n\t\tif i > b {\n\t\t\tdp[i] = max(dp[i], dp[i-b]+1)\n\t\t}\n\t\tif i > c {\n\t\t\tdp[i] = max(dp[i], dp[i-c]+1)\n\t\t}\n\t}\n\n\tfmt.Println(dp[n])\n}\n\nfunc max(x, y int) int {\n\tif x < y {\n\t\tx = y\n\t}\n\n\treturn x\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nvar dp [4005]int\n\nfunc main() {\n\tvar n, a, b, c int\n\tfmt.Scan(&n, &a, &b, &c)\n\tif a > b {\n\t\ta, b = b, a\n\t}\n\tif a > c {\n\t\ta, c = c, a\n\t}\n\tif b > c {\n\t\tb, c = c, b\n\t}\n\n\tdp[a], dp[b], dp[c] = 1, 1, 1\n\tfor i := a; i <= n; i++ {\n\t\tdp[i] = dp[i-a] + 1\n\t\tif i > b {\n\t\t\tdp[i] = max(dp[i], dp[i-b]+1)\n\t\t}\n\t\tif i > c {\n\t\t\tdp[i] = max(dp[i], dp[i-c]+1)\n\t\t}\n\t}\n\n\tfmt.Println(dp[n])\n}\n\nfunc max(x, y int) int {\n\tif x < y {\n\t\tx = y\n\t}\n\n\treturn x\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, a, b, c int\n\tfmt.Scan(&n, &a, &b, &c)\n\tif a > b {\n\t\ta, b = b, a\n\t}\n\tif a > c {\n\t\ta, c = c, a\n\t}\n\tif b > c {\n\t\tb, c = c, b\n\t}\n\n\tn1 := n / a\n\tn2 := n / b\n\tn3 := n / c\n\tif n%a == 0 || (a == b && b == c) {\n\t\tfmt.Println(n1)\n\t\treturn\n\t}\n\n\tmax := 0\n\tif a == b || b == c {\n\t\tfor i := 0; i < n1; i++ {\n\t\t\tfor j := 0; j < n3; j++ {\n\t\t\t\tv := i*a + j*c\n\t\t\t\tif v >= n {\n\t\t\t\t\tif v == n && i+j > max {\n\t\t\t\t\t\tmax = i + j\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfmt.Println(max)\n\t\treturn\n\t}\n\n\tfor i := 0; i <= n1; i++ {\n\t\tfor j := 0; j <= n2; j++ {\n\t\t\tfor k := 0; k <= n3; k++ {\n\t\t\t\tv := i*a + j*b + k*c\n\t\t\t\tif v >= n {\n\t\t\t\t\tif v == n && i+j+k > max {\n\t\t\t\t\t\tmax = i + j + k\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(max)\n}\n"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nvar sc *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar w *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ni() int {\n sc.Scan()\n ans, _ := strconv.Atoi(sc.Text())\n return ans\n}\n\nfunc nll() int64 {\n sc.Scan()\n ans, _ := strconv.ParseInt(sc.Text(), 10, 64)\n return ans\n}\n\nfunc next() string {\n sc.Scan()\n return sc.Text()\n}\n\nfunc pri(n int) { w.WriteString(strconv.Itoa(n)) }\nfunc prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }\nfunc sp() { w.WriteByte(' ') }\nfunc endl() { w.WriteByte('\\n') }\n\nfunc dioph(b, c, n int) (int, bool) {\n max := 0\n noerr := false\n for k := 0; k*b <= n; k++ {\n if (n-k*b)%c == 0 && k+(n-k*b)/c > max {\n max = k + (n-k*b)/c\n noerr = true\n }\n }\n return max, noerr\n}\n\nfunc main() {\n sc.Split(bufio.ScanWords)\n n, a, b, c := ni(), ni(), ni(), ni()\n max := 0\n for k := 0; k*a <= n; k++ {\n k2, noerr := dioph(b, c, n-k*a)\n if noerr && k+k2 > max {\n max = k + k2\n }\n }\n pri(max)\n w.Flush()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"strings\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Readln(r *bufio.Reader) (string, error) {\n\tvar (\n\t\tisPrefix bool = true\n\t\terr error = nil\n\t\tline, ln []byte\n\t)\n\tfor isPrefix && err == nil {\n\t\tline, isPrefix, err = r.ReadLine()\n\t\tln = append(ln, line...)\n\t}\n\treturn string(ln), err\n}\n\nfunc readIntArray(line string) []int {\n\t\n\tnumStrings := strings.Split(strings.TrimSpace(string(line)), \" \")\n\t\n\tnumbers := make([]int, 0)\n\t\n\tfor _, v := range numStrings {\n\t\tvar converted int\n\t\t\n\t\tfmt.Sscanf(v, \"%d\", &converted)\n\t\tnumbers = append(numbers, converted)\n\t}\n\t\n\treturn numbers\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\t\n\tline, _ := Readln(reader)\n\tnumbers := readIntArray(line)\n\t\n\tlength := numbers[0]\n\tlengths := numbers[1:]\n\t\n\tcache := make(map[int]int, 0)\n\tfmt.Println(Cut(length, lengths, 0, cache))\n}\n\nfunc Cut(length int, lengths []int, pieces int, cache map[int]int) int {\n\t\n\tif cached, ok := cache[length]; ok {\n\t\treturn cached\n\t}\n\t\n\tmaxPieces := pieces\n\tisCut := false\n\tfor _, ln := range lengths {\n\t\tif (length - ln) >= 0 {\n\t\t\tnewPieces := Cut(length - ln, lengths, pieces + 1, cache)\n\t\t\tif maxPieces < newPieces {\n\t\t\t\tisCut = true\n\t\t\t\tmaxPieces = newPieces\n\t\t\t}\n\t\t}\n\t}\n\t\n\tif (!isCut) && length > 0 {\n\t\tmaxPieces = -1\n\t\tcache[length] = maxPieces\n\t} else if isCut {\n\t\tcache[length] = maxPieces\n\t}\n\t\n\treturn maxPieces\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"strings\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Readln(r *bufio.Reader) (string, error) {\n\tvar (\n\t\tisPrefix bool = true\n\t\terr error = nil\n\t\tline, ln []byte\n\t)\n\tfor isPrefix && err == nil {\n\t\tline, isPrefix, err = r.ReadLine()\n\t\tln = append(ln, line...)\n\t}\n\treturn string(ln), err\n}\n\nfunc readIntArray(line string) []int {\n\t\n\tnumStrings := strings.Split(strings.TrimSpace(string(line)), \" \")\n\t\n\tnumbers := make([]int, 0)\n\t\n\tfor _, v := range numStrings {\n\t\tvar converted int\n\t\t\n\t\tfmt.Sscanf(v, \"%d\", &converted)\n\t\tnumbers = append(numbers, converted)\n\t}\n\t\n\treturn numbers\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\t\n\tline, _ := Readln(reader)\n\tnumbers := readIntArray(line)\n\t\n\tlength := numbers[0]\n\tlengths := numbers[1:]\n\t\n\tcache := make(map[int]int, 0)\n\tfmt.Println(Cut(length, lengths, 0, cache))\n}\n\nfunc Cut(length int, lengths []int, pieces int, cache map[int]int) int {\n\t\n\tif cached, ok := cache[length]; ok {\n\t\treturn cached\n\t}\n\t\n\tmaxPieces := pieces\n\tisCut := false\n\tfor _, ln := range lengths {\n\t\tif (length - ln) >= 0 {\n\t\t\tisCut = true\n\t\t\tnewPieces := Cut(length - ln, lengths, pieces + 1, cache)\n\t\t\tif maxPieces < newPieces {\n\t\t\t\tmaxPieces = newPieces\n\t\t\t}\n\t\t}\n\t}\n\t\n\tif (isCut == false) && length > 0 {\n\t\tmaxPieces = -1\n\t\tcache[length] = maxPieces\n\t} else if isCut {\n\t\tcache[length] = maxPieces\n\t}\n\t\n\treturn maxPieces\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"strings\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Readln(r *bufio.Reader) (string, error) {\n\tvar (\n\t\tisPrefix bool = true\n\t\terr error = nil\n\t\tline, ln []byte\n\t)\n\tfor isPrefix && err == nil {\n\t\tline, isPrefix, err = r.ReadLine()\n\t\tln = append(ln, line...)\n\t}\n\treturn string(ln), err\n}\n\nfunc readIntArray(line string) []int {\n\t\n\tnumStrings := strings.Split(strings.TrimSpace(string(line)), \" \")\n\t\n\tnumbers := make([]int, 0)\n\t\n\tfor _, v := range numStrings {\n\t\tvar converted int\n\t\t\n\t\tfmt.Sscanf(v, \"%d\", &converted)\n\t\tnumbers = append(numbers, converted)\n\t}\n\t\n\treturn numbers\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\t\n\tline, _ := Readln(reader)\n\tnumbers := readIntArray(line)\n\t\n\tlength := numbers[0]\n\tlengths := numbers[1:]\n\t\n\tcache := make(map[int]int, 0)\n\tfmt.Println(Cut(length, lengths, 0, cache))\n}\n\nfunc Cut(length int, lengths []int, pieces int, cache map[int]int) int {\n\t\n\tif cached, ok := cache[length]; ok {\n\t\treturn cached\n\t}\n\t\n\tmaxPieces := pieces\n\tisCut := false\n\tfor _, ln := range lengths {\n\t\tif (length - ln) >= 0 {\n\t\t\tisCut = true\n\t\t\tnewPieces := Cut(length - ln, lengths, pieces + 1, cache)\n\t\t\tif maxPieces < newPieces {\n\t\t\t\tmaxPieces = newPieces\n\t\t\t}\n\t\t}\n\t}\n\t\n\tif (isCut == false) && length > 0 {\n\t\tmaxPieces = -1\n\t}\n\t\n\tcache[length] = maxPieces\n\t\n\treturn maxPieces\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc sortThree(a, b, c int) (int, int, int) {\n\tif a > b {\n\t\ta, b = b, a\n\t}\n\tif b > c {\n\t\tb, c = c, b\n\t}\n\tif a > b {\n\t\ta, b = b, a\n\t}\n\treturn a, b, c\n}\n\n// https://codeforces.com/problemset/problem/189/A\n// комментарии к решению\n// Задача решается перебором. Для сокращения кол-ва комбинаций\n// пытаемся сначала разрезать ленту на максимальное кол-во мелких кусочков,\n// уменьшая их кол-во с каждой итерацией пробуем разрезать оставшуюся часть\n// на ленты среднего размера, проводя аналогичный критерий выбора для\n// среднего/крупного размера.\n// Первое найденное целочисленное решение и будет ответом\nfunc taskSolution(n, a, b, c int) int {\n\ta, b, c = sortThree(a, b, c)\n\tfor i := n / a; i >= 0; i -= 1 {\n\t\tfor j := (n - i*a) / b; j >= 0; j -= 1 {\n\t\t\tfor k := (n - i*a - j*b) / c; k >= 0; k -= 1 {\n\t\t\t\tif n == i*a+j*b+k*c {\n\t\t\t\t\treturn i + j + k\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn 0\n}\n\nfunc main() {\n\tvar n, a, b, c int\n\tif _, err := fmt.Scan(&n, &a, &b, &c); err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(taskSolution(n, a, b, c))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n,a,b,c int\n\ts:=0\n\tfmt.Scan(&n,&a,&b,&c)\n\tfor i:=0;i<=n/a;i++ {\n\t\tz:=n-i*a\n\t\tfor k:=0; k<=z/b;k++ {\n\t\t\th:=i+k+(z-k*b)/c\n\t\t\tif (z-k*b)%c!=0 && h>s {\n\t\t\t\ts=h\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(s)\n}\n"}, {"source_code": "// http://codeforces.com/problemset/problem/189/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 max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc main () {\n\tvar (\n\t\tn, a, b, c int\n\t)\n\n\t//f, _ := os.Open(\"input.txt\")\n\t//input := bufio.NewReader(f)\n\tinput := bufio.NewReader(os.Stdin)\n\n\tfmt.Fscanln(input, &n, &a, &b, &c)\n\n\tdp := make([]struct{cnt, l int}, 1e4 + 1)\n\n\tdp[0].l = n\n\tdp[0].l = n\n\tdp[0].l = n\n\n\n\tfor i := 0; i <= n; i++ {\n\n\t\tif dp[i].l - a == a || dp[i].l - a == b || dp[i].l - a == c || dp[i].l - a == 0{\n\t\t\tif dp[i].cnt + 1 > dp[i + a].cnt {\n\t\t\t\tdp[i + a].cnt = dp[i].cnt + 1\n\t\t\t\tdp[i + a].l = dp[i].l - a\n\t\t\t}\n\t\t}\n\n\t\tif dp[i].l - b == a || dp[i].l - b == b || dp[i].l - b == c || dp[i].l - b == 0{\n\t\t\tif dp[i].cnt + 1 > dp[i + b].cnt {\n\t\t\t\tdp[i + b].cnt = dp[i].cnt + 1\n\t\t\t\tdp[i + b].l = dp[i].l - b\n\t\t\t}\n\t\t}\n\n\t\tif dp[i].l - c == a || dp[i].l - c == b || dp[i].l - c == c || dp[i].l - c == 0{\n\t\t\tif dp[i].cnt + 1 > dp[i + c].cnt {\n\t\t\t\tdp[i + c].cnt = dp[i].cnt + 1\n\t\t\t\tdp[i + c].l = dp[i].l - c\n\t\t\t}\n\t\t}\n\n\t}\n\n\tfmt.Println(max(max(dp[n].cnt, dp[n].cnt), dp[n].cnt))\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n var a [3]int\n fmt.Scan(&n,&a[0],&a[1],&a[2])\n dp := make([]int,n+1)\n dp[0] = 1\n for k := 0; k < 3; k++ {\n for i := 1; i <= n; i++ {\n if (i-a[k]) >= 0 {\n dp[i] += dp[i-a[k]]\n }\n }\n }\n fmt.Println(dp[n])\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"sort\"\n\nfunc main() {\n\tvar n, a, b, c int\n\tfmt.Scan(&n, &a, &b, &c)\n\tvar maxP int\n\tls := []int{a, b, c}\n\tsort.Sort(sort.Reverse(sort.IntSlice(ls)))\n\tfmt.Println(ls)\n\tvar i, j, k int\n\tfor i = 0; i <= n/ls[0]; i++ {\n\t\tfor j = 0; j <= n/ls[1]; j++ {\n\t\t\tfor k = 0; k <= n/ls[2]; k++ {\n\t\t\t\tif n == i*ls[0]+j*ls[1]+k*ls[2] {\n\t\t\t\t\tif maxP < i+j+k {\n\t\t\t\t\t\tmaxP = i + j + k\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Print(maxP)\n}\n"}], "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43"} {"nl": {"description": "You've got a rectangular table with length a and width b and the infinite number of plates of radius r. Two players play the following game: they take turns to put the plates on the table so that the plates don't lie on each other (but they can touch each other), and so that any point on any plate is located within the table's border. During the game one cannot move the plates that already lie on the table. The player who cannot make another move loses. Determine which player wins, the one who moves first or the one who moves second, provided that both players play optimally well.", "input_spec": "A single line contains three space-separated integers a, b, r (1 ≤ a, b, r ≤ 100) — the table sides and the plates' radius, correspondingly.", "output_spec": "If wins the player who moves first, print \"First\" (without the quotes). Otherwise print \"Second\" (without the quotes).", "sample_inputs": ["5 5 2", "6 7 4"], "sample_outputs": ["First", "Second"], "notes": "NoteIn the first sample the table has place for only one plate. The first player puts a plate on the table, the second player can't do that and loses. In the second sample the table is so small that it doesn't have enough place even for one plate. So the first player loses without making a single move. "}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\ta, b, r := 0, 0, 0\n\tfmt.Scanf(\"%d %d %d\\n\", &a, &b, &r)\n\tif a >= r*2 && b >= r*2 {\n\t\tfmt.Printf(\"First\\n\")\n\t} else {\n\t\tfmt.Printf(\"Second\\n\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Scan()\n\ta, _ := strconv.Atoi(scanner.Text())\n\tscanner.Scan()\n\tb, _ := strconv.Atoi(scanner.Text())\n\tscanner.Scan()\n\tr, _ := strconv.Atoi(scanner.Text())\n\n\tif a >= r*2 && b >= r*2 {\n\t\tfmt.Printf(\"First\\n\")\n\t} else {\n\t\tfmt.Printf(\"Second\\n\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n)\n\nfunc scanInt(scanner *bufio.Scanner) int {\n\tscanner.Scan()\n\tx, _ := strconv.Atoi(scanner.Text())\n\treturn x\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\ta, b, r := scanInt(scanner), scanInt(scanner), scanInt(scanner)\n\tif a >= 2*r && b >= 2*r {\n\t\twriter.WriteString(\"First\\n\")\n\t} else {\n\t\twriter.WriteString(\"Second\\n\")\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\ta, b, r := 0, 0, 0\n\tfmt.Scanf(\"%d %d %d\\n\", &a, &b, &r)\n\twinner := \"Second\"\n\tvar xDiameter float32\n\tif a > b {\n\t\txDiameter = float32(a) / float32(r*2)\n\t} else {\n\t\txDiameter = float32(b) / float32(r*2)\n\t}\n\tif xDiameter >= 1 && int32((xDiameter-1)/1.5)%2 == 0 {\n\t\twinner = \"First\"\n\t}\n\tfmt.Printf(\"%s\\n\", winner)\n}\n"}], "src_uid": "90b9ef939a13cf29715bc5bce26c9896"} {"nl": {"description": "Arpa is taking a geometry exam. Here is the last problem of the exam.You are given three points a, b, c.Find a point and an angle such that if we rotate the page around the point by the angle, the new position of a is the same as the old position of b, and the new position of b is the same as the old position of c.Arpa is doubting if the problem has a solution or not (i.e. if there exists a point and an angle satisfying the condition). Help Arpa determine if the question has a solution or not.", "input_spec": "The only line contains six integers ax, ay, bx, by, cx, cy (|ax|, |ay|, |bx|, |by|, |cx|, |cy| ≤ 109). It's guaranteed that the points are distinct.", "output_spec": "Print \"Yes\" if the problem has a solution, \"No\" otherwise. You can print each letter in any case (upper or lower).", "sample_inputs": ["0 1 1 1 1 0", "1 1 0 0 1000 1000"], "sample_outputs": ["Yes", "No"], "notes": "NoteIn the first sample test, rotate the page around (0.5, 0.5) by .In the second sample test, you can't find any solution."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar ax,ay,bx,by,cx,cy int64\n\tfmt.Scanf(\"%d%d%d%d%d%d\",&ax,&ay,&bx,&by,&cx,&cy)\n\tax*=2\n\tay*=2\n\tbx*=2\n\tby*=2\n\tcx*=2\n\tcy*=2\n\tdx:=(ax+cx)/2\n\tdy:=(ay+cy)/2\n\tux := bx - ax\n\tuy := by - ay\n\tvx := bx - cx\n\tvy := by - cy\n\tra := ux * ux + uy * uy;\n\trc := vx * vx + vy * vy;\n\tif !(dx == bx && dy == by) && ra == rc {\n\t\tfmt.Printf(\"Yes\")\n\t}else{\n\t\tfmt.Printf(\"No\")\n\t};\n}\n"}, {"source_code": "// Codeforces 785 B Anton and Classes done\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"strings\"\n\t\"strconv\"\n\t\"os\"\n)\nvar in *bufio.Reader\n\nfunc readFive() (int,int,int,int,int) {\n\tvar a [5]int\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"first read failure\", err)\n\t\tpanic(err)\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n\tfor i:=0; i ON\nif any other number is present, then the light is switched off with that swtich*/\nfunc main() {\n var n,m,b int\n var light [200]int\n\n fmt.Scan(&n, &m)\n\n for l := 0; l < m; l++ {\n fmt.Scan(&b)\n\n b = b - 1\n for i := b; i < n; i++ {\n if light[i] == 0 {\n light[i] = b + 1\n }\n }\n }\n\n for i := 0; i < n; i++ {\n fmt.Printf(\"%d\", light[i])\n if i == n - 1 {\n fmt.Println()\n } else {\n fmt.Printf(\" \")\n }\n }\n\n return\n}\n\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n,m,b int\n var a [105]int\n fmt.Scan(&n,&m)\n for i := 0; i < m; i++ {\n fmt.Scan(&b)\n for j := b; j <= n; j++ {\n if a[j] == 0 { a[j] = b }\n }\n }\n for i := 1; i <= n; i++ {\n fmt.Print(a[i])\n if i == n { fmt.Println() } else { fmt.Print(\" \") }\n }\n}\n"}, {"source_code": "// 415A-mic\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var n, m, x int\n fmt.Scan(&n, &m)\n a := make([]int, n+1)\n v := make([]int, n+1)\n\n for i := 0; i <= n; i++ {\n v[i] = 0\n }\n for i := 0; i < m; i++ {\n fmt.Scan(&x)\n for j := x; j <= n; j++ {\n if v[j] == 0 {\n a[j] = x\n v[j] = 1\n }\n }\n }\n\n for i := 1; i <= n; i++ {\n fmt.Print(a[i])\n fmt.Print(\" \")\n }\n\n fmt.Println()\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n,m,b int\n var a [105]int\n fmt.Scan(&n,&m)\n for i := 0; i < m; i++ {\n fmt.Scan(&b)\n for j := b; j <= n; j++ {\n if a[j] == 0 { a[j] = b }\n }\n }\n for i := 1; i <= n; i++ {\n fmt.Print(a[i])\n if i == n { fmt.Println() } else { fmt.Print(\" \") }\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar light [200]int;\n\tvar n, m, button int;\n\tfmt.Scanf(\"%d %d\", &n, &m);\n\tfor i := 1; i <= m; {\n\t\tretN, _ := fmt.Scanf(\"%d\", &button);\n\t\tif retN == 0 {\n\t\t\tcontinue;\n\t\t}\n\t\tfor j := button; j <= n; j = j + 1 {\n\t\t\tif light[j] == 0 {\n\t\t\t\tlight[j] = button;\n\t\t\t}\n\t\t}\n\t\ti = i + 1;\n\t}\n\n\tfor i := 1; i <= n; i = i + 1 {\n\t\tfmt.Printf(\"%d \", light[i]);\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var t, n, m, cnt int\n var light [110]int\n fmt.Scanf(\"%d %d\", &n, &m)\n cnt = 100000\n for i := 0; i < m; i++ {\n c, _ := fmt.Scanf(\"%d\", &t)\n if c == 0 {\n continue\n }\n if t < cnt {\n cnt = t\n light[t] = 1\n }\n }\n for i := 1; i <= n; i++ {\n if light[i] == 1 {\n cnt = i\n }\n fmt.Printf(\"%d \", cnt)\n }\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var t, n, m, cnt int\n var light [110]int\n fmt.Scanf(\"%d%d\", &n, &m)\n cnt = 100000\n for i := 0; i < m; i++ {\n fmt.Scanf(\"%d\", &t)\n if t < cnt {\n cnt = t\n light[t] = 1\n }\n }\n for i := 1; i <= n; i++ {\n if light[i] == 1 {\n cnt = i\n }\n fmt.Printf(\"%d \", cnt)\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, m int\n\t\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\n\tpushes := make([]int, m + 10)\n\tlightstatus := make([] int, n + 10)\n\n\tfor i := 0; i < m; i++ {\n\t\tfmt.Scanf(\"%d\", &pushes[i])\n\t}\n\n\tfor i := 0; i < m; i++ {\n\t\tfor j := pushes[i]; j <= n && lightstatus[j] == 0; j ++ {\n\t\t\tlightstatus[j] = pushes[i]\n\t\t}\n\t}\n\n\tfor i := 1; i <= n; i++ {\n\t\tfmt.Printf(\"%d \", lightstatus[i])\n\t}\n\n}\n\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar light [200]int;\n\tvar n, m, button int;\n\tfmt.Scanf(\"%d %d\", &n, &m);\n\tfor i := 1; i <= m; i = i + 1 {\n\t\tfmt.Scanf(\"%d\", &button);\n\t\tfor j := button; j <= n; j = j + 1 {\n\t\t\tif light[j] == 0 {\n\t\t\t\tlight[j] = button;\n\t\t\t}\n\t\t}\n\t}\n\n\tfor i := 1; i <= n; i = i + 1 {\n\t\tfmt.Printf(\"%d \", light[i]);\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, m int\n\tvar pushes, lightstatus [200]int\n\t\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\n//\tpushes := make([]int, m + 10)\n//\tlightstatus := make([] int, n + 10)\n\n\tfor i := 0; i < m; i++ {\n\t\tret, _ := fmt.Scanf(\"%d\", &pushes[i])\n\t\tif ret == 0 {\n\t\t\tcontinue\n\t\t}\n\t}\n\n\tfor i := 0; i < m; i++ {\n\t\tfor j := pushes[i]; j <= n && lightstatus[j] == 0; j ++ {\n\t\t\tlightstatus[j] = pushes[i]\n\t\t}\n\t}\n\n\tfor i := 1; i <= n; i++ {\n\t\tfmt.Printf(\"%d \", lightstatus[i])\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, m int\n\t\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\n\tpushes := make([]int, m + 10)\n\tlightstatus := make([] int, n + 10)\n\n\tfor i := 0; i < m; i++ {\n\t\tret, _ := fmt.Scanf(\"%d\", &pushes[i])\n\t\tif ret == 0 {\n\t\t\tcontinue\n\t\t}\n\t}\n\n\tfor i := 0; i < m; i++ {\n\t\tfor j := pushes[i]; j <= n && lightstatus[j] == 0; j ++ {\n\t\t\tlightstatus[j] = pushes[i]\n\t\t}\n\t}\n\n\tfor i := 1; i <= n; i++ {\n\t\tfmt.Printf(\"%d \", lightstatus[i])\n\t}\n\n}\n\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\n/*Simulating the problem of mashmokh and the lights\nlights array will contain the current state of the light -1 / -2\n0 -> ON\nif any other number is present, then the light is switched off with that swtich*/\nfunc main() {\n var n,m,b int\n fmt.Scanf(\"%d %d\", &n, &m)\n var light []int = make([]int, n)\n for i := 0; i < n; i++ {\n light[i] = -1\n }\n\n for l := 0; l < m; l++ {\n retN, _ := fmt.Scanf(\"%d\", &b)\n if retN == 0 {\n continue\n }\n\n b = b - 1\n for i := b; (i < n ) && (light[i] == -1); i++ {\n light[i] = b + 1\n }\n }\n\n for i := 0; i < n; i++ {\n fmt.Printf(\"%d \", light[i])\n if i == n {\n fmt.Println()\n } else {\n fmt.Printf(\" \")\n }\n }\n\n return\n}\n\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, m int\n\t\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\n\tpushes := make([]int, m + 10)\n\tlightstatus := make([] int, n + 10)\n\n\tfor i := 0; i < m; i++ {\n\t\tfmt.Scanf(\"%d\", &pushes[i])\n\t}\n\n\tfor i := 0; i < m; i++ {\n\t\tfor j := pushes[i]; j <= n && lightstatus[j] == 0; j ++ {\n\t\t\tlightstatus[j] = pushes[i]\n\t\t}\n\t}\n\n\tfmt.Println(lightstatus[1:n + 1])\n\n}\n\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar light [200]int;\n\tvar n, m, button int;\n\tfmt.Scanf(\"%d %d\", &n, &m);\n\tfor i := 1; i <= m; i = i + 1 {\n\t\tfmt.Scanf(\"%d\", &button);\n\t\tfor j := button; j <= n; j = j + 1 {\n\t\t\tif light[j] == 0 {\n\t\t\t\tlight[j] = button;\n\t\t\t}\n\t\t}\n\t}\n\n\tfor i := 1; i <= n; i = i + 1 {\n\t\tfmt.Printf(\"%d \", light[i]);\n\t}\n}\n"}], "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863"} {"nl": {"description": "Fangy collects cookies. Once he decided to take a box and put cookies into it in some way. If we take a square k × k in size, divided into blocks 1 × 1 in size and paint there the main diagonal together with cells, which lie above it, then the painted area will be equal to the area occupied by one cookie k in size. Fangy also has a box with a square base 2n × 2n, divided into blocks 1 × 1 in size. In a box the cookies should not overlap, and they should not be turned over or rotated. See cookies of sizes 2 and 4 respectively on the figure: To stack the cookies the little walrus uses the following algorithm. He takes out of the repository the largest cookie which can fit in some place in the box and puts it there. Everything could be perfect but alas, in the repository the little walrus has infinitely many cookies of size 2 and larger, and there are no cookies of size 1, therefore, empty cells will remain in the box. Fangy wants to know how many empty cells will be left in the end.", "input_spec": "The first line contains a single integer n (0 ≤ n ≤ 1000).", "output_spec": "Print the single number, equal to the number of empty cells in the box. The answer should be printed modulo 106 + 3.", "sample_inputs": ["3"], "sample_outputs": ["9"], "notes": "NoteIf the box possesses the base of 23 × 23 (as in the example), then the cookies will be put there in the following manner: "}, "positive_code": [{"source_code": "//70A\npackage main\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar nn, a int64\n\ta=1\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tr.Scan()\n\tnn, _ = strconv.ParseInt(r.Text(), 0, 64)\n\tif nn==1 {\n\t\ta=1\n\t} else {\n\t\tfor i:=2; int64(i)<=nn; i++ {\n\t\t\ta=(a*3)%1000003\n\t\t}\n\t}\n\tfmt.Println(a)\n}\t\n"}, {"source_code": "// 70A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar m int\n\te := 1\n\tfmt.Scan(&m)\n\tfor j := 1; j <= m-1; j++ {\n\t\te = (3 * e) % 1000003\n\t}\n\tfmt.Print(e)\n}"}], "negative_code": [], "src_uid": "1a335a9638523ca0315282a67e18eec7"} {"nl": {"description": "The last stage of Football World Cup is played using the play-off system.There are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the remaining teams are sorted in the order of their ids, then the first in this order plays with the second, the third — with the fourth, the fifth — with the sixth, and so on. It is guaranteed that in each round there is even number of teams. The winner of each game advances to the next round, the loser is eliminated from the tournament, there are no draws. In the last round there is the only game with two remaining teams: the round is called the Final, the winner is called the champion, and the tournament is over.Arkady wants his two favorite teams to play in the Final. Unfortunately, the team ids are already determined, and it may happen that it is impossible for teams to meet in the Final, because they are to meet in some earlier stage, if they are strong enough. Determine, in which round the teams with ids a and b can meet.", "input_spec": "The only line contains three integers n, a and b (2 ≤ n ≤ 256, 1 ≤ a, b ≤ n) — the total number of teams, and the ids of the teams that Arkady is interested in. It is guaranteed that n is such that in each round an even number of team advance, and that a and b are not equal.", "output_spec": "In the only line print \"Final!\" (without quotes), if teams a and b can meet in the Final. Otherwise, print a single integer — the number of the round in which teams a and b can meet. The round are enumerated from 1.", "sample_inputs": ["4 1 2", "8 2 6", "8 7 5"], "sample_outputs": ["1", "Final!", "2"], "notes": "NoteIn the first example teams 1 and 2 meet in the first round.In the second example teams 2 and 6 can only meet in the third round, which is the Final, if they win all their opponents in earlier rounds.In the third example the teams with ids 7 and 5 can meet in the second round, if they win their opponents in the first round."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, a, b, cnt uint\n\tfor {\n\t\t_, err := fmt.Scanln(&n, &a, &b)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\tif a > b {\n\t\t\ta, b = b, a\n\t\t}\n\t\tif (b & 1) > 0 {\n\t\t\tb++\n\t\t}\n\t\tres := b - a\n\t\tcnt = 1\n\t\tfor res > 1 {\n\t\t\ta = (a + 1) >> 1\n\t\t\tb = (b + 1) >> 1\n\t\t\tif (b & 1) > 0 {\n\t\t\t\tb++\n\t\t\t}\n\t\t\tres = b - a\n\t\t\tcnt++\n\t\t}\n\t\tif n == (1 << cnt) {\n\t\t\tfmt.Println(\"Final!\")\n\t\t} else {\n\t\t\tfmt.Println(cnt)\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Init() {\n}\n\nfunc Solve(io *FastIO) {\n N := io.NextInt()\n\tA := io.NextInt()\n\tB := io.NextInt()\n\t\n\trounds := 0\n\trem := N\n\tfor rem > 1 {\n\t rounds++\n\t rem >>= 1\n\t}\n\t\n\tteams := make([]int, 0)\n\tfor i := 1; i <= N; i++ {\n\t teams = append(teams, i)\n\t}\n\t\n\twhich := -1\n\tfor r := 1; which < 0; r++ {\n\t next := make([]int, 0)\n\t for i := 0; i < len(teams); i += 2 {\n\t if isOr(A, teams[i], teams[i + 1]) && isOr(B, teams[i], teams[i + 1]) {\n\t which = r\n\t break\n\t }\n\t if isOr(A, teams[i], teams[i + 1]) {\n\t next = append(next, A)\n\t } else if isOr(B, teams[i], teams[i + 1]) {\n\t next = append(next, B)\n\t } else {\n\t next = append(next, teams[i])\n\t }\n\t }\n\t teams = next\n\t}\n\t\n\tif which == rounds {\n\t io.Println(\"Final!\")\n\t} else {\n\t io.Println(which)\n\t}\n}\n\nfunc isOr(x, a, b int) bool {\n return x == a || x == b\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tInit()\n\tSolve(&io)\n\tio.FlushOutput()\n}"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, a, b int\n\tfor {\n\t\t_, err := fmt.Scanln(&n, &a, &b)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\n\t\tif a%2 == 1 {\n\t\t\ta += 1\n\t\t}\n\t\tif b%2 == 1 {\n\t\t\tb += 1\n\t\t}\n\n\t\trest := a - b\n\t\tif rest < 0 {\n\t\t\trest = -rest\n\t\t}\n\t\tcnt := 1\n\t\tfor rest > 1 {\n\t\t\trest >>= 1\n\t\t\tcnt++\n\t\t}\n\t\tmax := 0\n\t\tfor n > 1 {\n\t\t\tn >>= 1\n\t\t\tmax++\n\t\t}\n\t\tif cnt < max {\n\t\t\tfmt.Println(cnt)\n\t\t} else {\n\t\t\tfmt.Println(\"Final!\")\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, a, b int\n\tfor {\n\t\t_, err := fmt.Scanln(&n, &a, &b)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\n\t\tif a%2 == 1 {\n\t\t\ta += 1\n\t\t}\n\t\tif b%2 == 1 {\n\t\t\tb += 1\n\t\t}\n\n\t\trest := a - b\n\t\tif rest < 0 {\n\t\t\trest = -rest\n\t\t}\n\t\tif n-rest*2 <= 0 {\n\t\t\tfmt.Println(\"Final!\")\n\t\t} else {\n\t\t\tcnt := 1\n\t\t\tfor rest > 1 {\n\t\t\t\trest >>= 1\n\t\t\t\tcnt++\n\t\t\t}\n\t\t\tfmt.Println(cnt)\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, a, b int\n\tfor {\n\t\t_, err := fmt.Scanln(&n, &a, &b)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\trest := a - b\n\t\tif rest < 0 {\n\t\t\trest = -rest\n\t\t}\n\t\tif n/rest == 2 {\n\t\t\tfmt.Println(\"Final!\")\n\t\t} else {\n\t\t\tcnt := 0\n\t\t\tfor rest > 0 {\n\t\t\t\trest >>= 1\n\t\t\t\tcnt++\n\t\t\t}\n\t\t\tfmt.Println(cnt)\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, a, b int\n\tfor {\n\t\t_, err := fmt.Scanln(&n, &a, &b)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\trest := a - b\n\t\tif rest < 0 {\n\t\t\trest = -rest\n\t\t}\n\t\tif n-rest*2 <= 0 {\n\t\t\tfmt.Println(\"Final!\")\n\t\t} else {\n\t\t\tcnt := 0\n\t\t\tfor rest > 0 {\n\t\t\t\trest >>= 1\n\t\t\t\tcnt++\n\t\t\t}\n\t\t\tfmt.Println(cnt)\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, a, b int\n\tfor {\n\t\t_, err := fmt.Scanln(&n, &a, &b)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\trest := a - b\n\t\tif rest < 0 {\n\t\t\trest = -rest\n\t\t}\n\t\tif n/rest <= 2 {\n\t\t\tfmt.Println(\"Final!\")\n\t\t} else {\n\t\t\tcnt := 0\n\t\t\tfor rest > 0 {\n\t\t\t\trest >>= 1\n\t\t\t\tcnt++\n\t\t\t}\n\t\t\tfmt.Println(cnt)\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Init() {\n}\n\nfunc Solve(io *FastIO) {\n N := io.NextInt()\n\tA := io.NextInt()\n\tB := io.NextInt()\n\t\n\trounds := 0\n\trem := N\n\tfor rem > 1 {\n\t rounds++\n\t rem >>= 1\n\t}\n\t\n\twhich := 0\n\tfor i := uint(0); ; i++ {\n\t bitA := (A >> i) & 1\n\t bitB := (B >> i) & 1\n\t if bitA != bitB {\n\t which = int(i + 1)\n\t break\n\t }\n\t}\n\t\n\tif which == rounds {\n\t io.Println(\"Final!\")\n\t} else {\n\t io.Println(which)\n\t}\n}\n\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": "a753bfa7bde157e108f34a28240f441f"} {"nl": {"description": "Fox Ciel is playing a game with numbers now. Ciel has n positive integers: x1, x2, ..., xn. She can do the following operation as many times as needed: select two different indexes i and j such that xi > xj hold, and then apply assignment xi = xi - xj. The goal is to make the sum of all numbers as small as possible.Please help Ciel to find this minimal sum.", "input_spec": "The first line contains an integer n (2 ≤ n ≤ 100). Then the second line contains n integers: x1, x2, ..., xn (1 ≤ xi ≤ 100).", "output_spec": "Output a single integer — the required minimal sum.", "sample_inputs": ["2\n1 2", "3\n2 4 6", "2\n12 18", "5\n45 12 27 30 18"], "sample_outputs": ["2", "6", "12", "15"], "notes": "NoteIn the first example the optimal way is to do the assignment: x2 = x2 - x1.In the second example the optimal sequence of operations is: x3 = x3 - x2, x2 = x2 - x1."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc GCD(x, y int) int {\n\tfor y != 0 {\n\t\tx, y = y, x%y\n\t}\n\treturn x\n}\n\nfunc main() {\n\tvar n, gcd int\n\tfmt.Scan(&n)\n\tfor i := 0; i < n; i++ {\n\t\tvar x int\n\t\tfmt.Scan(&x)\n\t\tif i == 0 {\n\t\t\tgcd = x\n\t\t} else {\n\t\t\tgcd = GCD(gcd, x)\n\t\t}\n\t}\n\tfmt.Println(n * gcd)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\n\tfmt.Scan(&n)\n\n\tx := make([]int, n)\n\n\tfor i := range x {\n\t\tfmt.Scan(&x[i])\n\t}\n\n\tfor x[0] != x[1] {\n\t\tif x[0] > x[1] {\n\t\t\tx[0] -= x[1]\n\t\t} else {\n\t\t\tx[1] -= x[0]\n\t\t}\n\t}\n\n\tgcd := x[0]\n\n\tfor i:=2; i gcd {\n\t\t\t\tx[i] -= gcd\n\t\t\t} else {\n\t\t\t\tgcd -= x[i]\n\t\t\t}\n\t\t}\t\t\n\t}\n\t\n\tfmt.Println(gcd*len(x))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\nfunc gcd(x, y int) int {\n for y != 0 {\n x, y = y, x%y\n }\n return x\n}\n\nfunc main() {\n\tvar n,g,x int\n\tfmt.Scan(&n,&g)\n\tfor i:=1;i a {\n\t\ta, b = b, a\n\t}\n\treturn sub_algorithm(a-b, b)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc gcd(a,b int) int { if b == 0 { return a } else { return gcd(b,a%b) } }\n\nfunc main() {\n var n,x int\n fmt.Scan(&n)\n a := -1\n for i := 0; i < n ; i++ {\n fmt.Scan(&x)\n if a == -1 { a = x } else { a = gcd(a,x) }\n }\n fmt.Println(a*n)\n}\n"}, {"source_code": "// 389A-mic\npackage main\n\nimport (\n \"fmt\"\n \"math/big\"\n)\n\nfunc gcd(x, y int64) int64 {\n return new(big.Int).GCD(nil, nil, big.NewInt(x), big.NewInt(y)).Int64()\n}\n\nfunc main() {\n var n, g, k, i int64\n fmt.Scan(&n, &g)\n for i = 1; i < n; i++ {\n fmt.Scan(&k)\n g = gcd(g, k)\n }\n fmt.Println(g * n)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc gcd(a,b int) int { if b == 0 { return a } else { return gcd(b,a%b) } }\n\nfunc main() {\n var n,x int\n fmt.Scan(&n)\n a := -1\n for i := 0; i < n ; i++ {\n fmt.Scan(&x)\n if a == -1 { a = x } else { a = gcd(a,x) }\n }\n fmt.Println(a*n)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc gcd(a,b int) int { if b == 0 { return a } else { return gcd(b,a%b) } }\n\nfunc main() {\n var n,x int\n fmt.Scan(&n)\n a := -1\n for i := 0; i < n ; i++ {\n fmt.Scan(&x)\n if a == -1 { a = x } else { a = gcd(a,x) }\n }\n fmt.Println(a*n)\n}\n"}], "negative_code": [], "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4"} {"nl": {"description": "n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if he has at least two pillows less than some of his neighbors have. Frodo will sleep on the k-th bed in the row. What is the maximum number of pillows he can have so that every hobbit has at least one pillow, every pillow is given to some hobbit and no one is hurt?", "input_spec": "The only line contain three integers n, m and k (1 ≤ n ≤ m ≤ 109, 1 ≤ k ≤ n) — the number of hobbits, the number of pillows and the number of Frodo's bed.", "output_spec": "Print single integer — the maximum number of pillows Frodo can have so that no one is hurt.", "sample_inputs": ["4 6 2", "3 10 3", "3 6 1"], "sample_outputs": ["2", "4", "3"], "notes": "NoteIn the first example Frodo can have at most two pillows. In this case, he can give two pillows to the hobbit on the first bed, and one pillow to each of the hobbits on the third and the fourth beds.In the second example Frodo can take at most four pillows, giving three pillows to each of the others.In the third example Frodo can take three pillows, giving two pillows to the hobbit in the middle and one pillow to the hobbit on the third bed."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i interface{}, delim string) error {\n\t_, err := fmt.Fscanf(r, \"%v\"+delim, i)\n\treturn err\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.txt\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tfor I(&n, \" \") == nil {\n\t\tsolve(n)\n\t}\n}\n\nvar n, m, k int64\n\nfunc solve(n int64) {\n\tI(&m, \" \")\n\tI(&k, \"\\n\")\n\tif n == m {\n\t\tO(1, \"\\n\")\n\t\treturn\n\t}\n\tif n == 1 {\n\t\tO(m, \"\\n\")\n\t\treturn\n\t}\n\tans := int64(2)\n\tm -= n + 1\n\th := int64(1)\n\tl := k - 1\n\tr := n - k\n\tfor m > 0 {\n\t\tif l > 0 {\n\t\t\th++\n\t\t\tl--\n\t\t}\n\t\tif r > 0 {\n\t\t\th++\n\t\t\tr--\n\t\t}\n\t\tif r <= 0 && l <= 0 {\n\t\t\tans += m / h\n\t\t\tm = 0\n\t\t} else {\n\t\t\tm -= h\n\t\t\tif m >= 0 {\n\t\t\t\tans++\n\t\t\t}\n\t\t}\n\t}\n\tO(ans, \"\\n\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tpeople := readInt()\n\tpillow := readInt()\n\tk := readInt()\n\tif people == 1 {\n\t\tfmt.Println(pillow)\n\t\treturn\n\t}\n\tpillow -= people\n\tleft := int64(k - 1)\n\tright := int64(people - k)\n\tbest := 0\n\tlo := 0\n\thi := pillow\n\tfor lo <= hi && pillow > 0 {\n\t\tmi := lo + (hi-lo)/2\n\t\trest := int64(pillow - mi)\n\t\tstep := int64(mi - 1)\n\t\tvar sum1 int64\n\t\tvar sum2 int64\n\t\tif left > 0 && step > 0 {\n\t\t\tt := left\n\t\t\tif step < t {\n\t\t\t\tt = step\n\t\t\t}\n\t\t\tsum1 = int64(step-t+1+step) * t / 2\n\t\t}\n\t\tif right > 0 && step > 0 {\n\t\t\tt := right\n\t\t\tif step < t {\n\t\t\t\tt = step\n\t\t\t}\n\t\t\tsum2 = int64(step-t+1+step) * t / 2\n\t\t}\n\t\tif sum1+sum2 <= rest {\n\t\t\tbest = mi\n\t\t\tlo = mi + 1\n\t\t} else {\n\t\t\thi = mi - 1\n\t\t}\n\t}\n\tfmt.Println(best + 1)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i interface{}, delim string) error {\n\t_, err := fmt.Fscanf(r, \"%v\"+delim, i)\n\treturn err\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.txt\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tvar n int64\n\tfor I(&n, \" \") == nil {\n\t\tsolve(n)\n\t}\n}\n\nfunc solve(n int64) {\n\tvar m, k int64\n\tI(&m, \" \")\n\tI(&k, \"\\n\")\n\tfair := m / n\n\tarr := make([]int64, n+1)\n\tfor i := int64(1); i <= n; i++ {\n\t\tarr[i] = fair\n\t}\n\tfor i := int64(1); i < k; i++ {\n\t\tif arr[i] > 1 {\n\t\t\tarr[i]--\n\t\t\tarr[i+1]++\n\t\t}\n\t}\n\tif k != n {\n\t\tfor i := n; i > k; i-- {\n\t\t\tif arr[i] > 1 {\n\t\t\t\tarr[i]--\n\t\t\t\tarr[i-1]++\n\t\t\t}\n\t\t}\n\t}\n\tarr[k] += m % n\n\tif k > 0 {\n\t\tooo := int64(1)\n\t\tfor arr[k]-arr[k-1] > 1 && k != ooo {\n\t\t\tarr[k]--\n\t\t\tooo %= k\n\t\t\tif ooo == int64(0) {\n\t\t\t\tooo++\n\t\t\t}\n\t\t\tarr[ooo]++\n\t\t\tooo++\n\t\t}\n\t}\n\tif k < 0 {\n\t\tooo := int64(n)\n\t\tfor arr[k]-arr[k+1] > 1 && k != ooo {\n\t\t\tarr[k]--\n\t\t\tif ooo == int64(k) {\n\t\t\t\tooo = n\n\t\t\t}\n\t\t\tarr[ooo]++\n\t\t\tooo--\n\t\t}\n\t}\n\tO(arr[k], \"\\n\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i interface{}, delim string) error {\n\t_, err := fmt.Fscanf(r, \"%v\"+delim, i)\n\treturn err\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.txt\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tfor I(&n, \" \") == nil {\n\t\tsolve(n)\n\t}\n}\n\nvar n, m, k int64\n\nfunc solve(n int64) {\n\tI(&m, \" \")\n\tI(&k, \"\\n\")\n\tp := k - (n - k)\n\to := (k * (k + 1) / 2) + (k*(k-1))/2 - (p * (p - 1) / 2)\n\tans := k\n\tif o < m {\n\t\tans += (m - o) / n\n\t} else if o > m {\n\t\tans -= (o-m)/n + 1\n\t}\n\tif m == n {\n\t\tans = 1\n\t}\n\tO(ans, \"\\n\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i interface{}, delim string) error {\n\t_, err := fmt.Fscanf(r, \"%v\"+delim, i)\n\treturn err\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.txt\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tvar n int64\n\tfor I(&n, \" \") == nil {\n\t\tsolve(n)\n\t}\n}\n\nfunc solve(n int64) {\n\tvar m, k int64\n\tI(&m, \" \")\n\tI(&k, \"\\n\")\n\tfair := m / n\n\tarr := make([]int64, n+1)\n\tfor i := int64(1); i <= n; i++ {\n\t\tarr[i] = fair\n\t}\n\tfor i := int64(1); i < k; i++ {\n\t\tif arr[i] > 1 {\n\t\t\tarr[i]--\n\t\t\tarr[i+1]++\n\t\t}\n\t}\n\tif k != n {\n\t\tfor i := n; i > k; i-- {\n\t\t\tif arr[i] > 1 {\n\t\t\t\tarr[i]--\n\t\t\t\tarr[i-1]++\n\t\t\t}\n\t\t}\n\t}\n\tarr[k] += m % n\n\tif k != 1 {\n\t\tooo := int64(1)\n\t\tfor arr[k]-arr[k-1] > 1 {\n\t\t\tarr[k]--\n\t\t\tarr[ooo]++\n\t\t\tooo++\n\t\t\tooo %= k\n\t\t\tif ooo == int64(0) {\n\t\t\t\tooo++\n\t\t\t}\n\t\t}\n\t}\n\tif k != n {\n\t\tooo := int64(n)\n\t\tfor arr[k]-arr[k+1] > 1 {\n\t\t\tarr[k]--\n\t\t\tarr[ooo]++\n\t\t\tooo--\n\t\t\tif ooo == int64(k) {\n\t\t\t\tooo = n\n\t\t\t}\n\t\t}\n\t}\n\tO(arr[k], \"\\n\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i interface{}, delim string) error {\n\t_, err := fmt.Fscanf(r, \"%v\"+delim, i)\n\treturn err\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.txt\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tfor I(&n, \" \") == nil {\n\t\tsolve(n)\n\t}\n}\n\nvar n, m, k int64\n\nfunc solve(n int64) {\n\tI(&m, \" \")\n\tI(&k, \"\\n\")\n\tp := k - (n - k)\n\to := (k * (k + 1) / 2) + (k*(k-1))/2 - (p * (p - 1) / 2)\n\tans := k\n\tif o < m {\n\t\tans += (m - o) / n\n\t} else if o > m {\n\t\tans -= (o-m)/n + 1\n\t}\n\tO(ans, \"\\n\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tpeople := readInt()\n\tpillow := readInt()\n\tk := readInt()\n\tif people == 1 {\n\t\tfmt.Println(pillow)\n\t\treturn\n\t}\n\tpillow -= people\n\tleft := int64(k - 1)\n\tright := int64(people - k)\n\tlo := 0\n\thi := pillow\n\tbest := 0\n\tfor lo <= hi && pillow > 0 {\n\t\tmi := lo + (hi-lo)/2\n\t\trest := int64(pillow - mi)\n\t\tstep := int64(mi - 1)\n\t\tvar sum1 int64\n\t\tvar sum2 int64\n\t\tif left > 0 && step > 0 {\n\t\t\tif step < left {\n\t\t\t\tleft = step\n\t\t\t}\n\t\t\tsum1 = int64(step-left+1+step) * left / 2\n\t\t}\n\t\tif right > 0 && step > 0 {\n\t\t\tif step < right {\n\t\t\t\tright = step\n\t\t\t}\n\t\t\tsum2 = int64(step-right+1+step) * right / 2\n\t\t}\n\t\tif sum1 < 0 || sum2 < 0 {\n\t\t\tpanic(\"sum1 < 0\")\n\t\t}\n\t\tif sum1+sum2 <= rest {\n\t\t\tlo = mi + 1\n\t\t\tif best < mi {\n\t\t\t\tbest = mi\n\t\t\t}\n\t\t} else {\n\t\t\thi = mi - 1\n\t\t}\n\t}\n\n\tfmt.Println(best + 1)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}, {"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\tpeople := readInt()\n\tpillow := readInt()\n\tk := readInt()\n\tpillow -= people\n\tleft := k - 1\n\tright := people - k\n\tlo := 0\n\thi := math.MaxInt32\n\tbest := 0\n\tfor lo <= hi && pillow > 0 {\n\t\tmi := lo + (hi-lo)/2\n\t\trest := pillow - mi\n\t\tstep := mi - 1\n\t\tvar sum1 int\n\t\tvar sum2 int\n\t\tif left > 0 && step > 0 {\n\t\t\tif step < left {\n\t\t\t\tleft = step\n\t\t\t}\n\t\t\tsum1 = (step - left + 1 + step) * left / 2\n\t\t}\n\t\tif right > 0 && step > 0 {\n\t\t\tif step < right {\n\t\t\t\tright = step\n\t\t\t}\n\t\t\tsum2 = (step - right + 1 + step) * right / 2\n\t\t}\n\t\tif sum1+sum2 <= rest {\n\t\t\tlo = mi + 1\n\t\t\tif best < mi {\n\t\t\t\tbest = mi\n\t\t\t}\n\t\t} else {\n\t\t\thi = mi - 1\n\t\t}\n\t}\n\n\tfmt.Println(best + 1)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}, {"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\tpeople := readInt()\n\tpillow := readInt()\n\tk := readInt()\n\tif people == 1 {\n\t\tfmt.Println(pillow)\n\t\treturn\n\t}\n\tpillow -= people\n\tleft := k - 1\n\tright := people - k\n\tlo := 0\n\thi := math.MaxInt32\n\tbest := 0\n\tfor lo <= hi && pillow > 0 {\n\t\tmi := lo + (hi-lo)/2\n\t\trest := pillow - mi\n\t\tstep := mi - 1\n\t\tvar sum1 int\n\t\tvar sum2 int\n\t\tif left > 0 && step > 0 {\n\t\t\tif step < left {\n\t\t\t\tleft = step\n\t\t\t}\n\t\t\tsum1 = (step - left + 1 + step) * left / 2\n\t\t}\n\t\tif right > 0 && step > 0 {\n\t\t\tif step < right {\n\t\t\t\tright = step\n\t\t\t}\n\t\t\tsum2 = (step - right + 1 + step) * right / 2\n\t\t}\n\t\tif sum1+sum2 <= rest {\n\t\t\tlo = mi + 1\n\t\t\tif best < mi {\n\t\t\t\tbest = mi\n\t\t\t}\n\t\t} else {\n\t\t\thi = mi - 1\n\t\t}\n\t}\n\n\tfmt.Println(best + 1)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tpeople := readInt()\n\tpillow := readInt()\n\tk := readInt()\n\tif people == 1 {\n\t\tfmt.Println(pillow)\n\t\treturn\n\t}\n\tpillow -= people\n\tleft := int64(k - 1)\n\tright := int64(people - k)\n\tlo := 0\n\thi := pillow\n\tbest := 0\n\tfor lo <= hi && pillow > 0 {\n\t\tmi := lo + (hi-lo)/2\n\t\trest := int64(pillow - mi)\n\t\tstep := int64(mi - 1)\n\t\tvar sum1 int64\n\t\tvar sum2 int64\n\t\tif left > 0 && step > 0 {\n\t\t\tif step < left {\n\t\t\t\tleft = step\n\t\t\t}\n\t\t\tsum1 = int64(step-left+1+step) * left / 2\n\t\t}\n\t\tif right > 0 && step > 0 {\n\t\t\tif step < right {\n\t\t\t\tright = step\n\t\t\t}\n\t\t\tsum2 = int64(step-right+1+step) * right / 2\n\t\t}\n\t\tif sum1+sum2 <= rest {\n\t\t\tlo = mi + 1\n\t\t\tif best < mi {\n\t\t\t\tbest = mi\n\t\t\t}\n\t\t} else {\n\t\t\thi = mi - 1\n\t\t}\n\t}\n\tfmt.Println(best + 1)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}], "src_uid": "da9ddd00f46021e8ee9db4a8deed017c"} {"nl": {"description": "You've got a rectangular parallelepiped with integer edge lengths. You know the areas of its three faces that have a common vertex. Your task is to find the sum of lengths of all 12 edges of this parallelepiped.", "input_spec": "The first and the single line contains three space-separated integers — the areas of the parallelepiped's faces. The area's values are positive ( > 0) and do not exceed 104. It is guaranteed that there exists at least one parallelepiped that satisfies the problem statement.", "output_spec": "Print a single number — the sum of all edges of the parallelepiped.", "sample_inputs": ["1 1 1", "4 6 6"], "sample_outputs": ["12", "28"], "notes": "NoteIn the first sample the parallelepiped has sizes 1 × 1 × 1, in the second one — 2 × 2 × 3."}, "positive_code": [{"source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var ab, ac, bc int64\n fmt.Scanf(\"%d %d %d\", &ab, &ac, &bc)\n abc := int64(math.Sqrt(float64(ab*ac*bc)))\n fmt.Print(4*(abc/bc + abc/ac + abc/ab))\n}"}, {"source_code": " package main\n\n import (\n \t\"fmt\"\n \t\"math\"\n )\n\n func main() {\n \tvar x,y,z,t float64\n \tfmt.Scan(&x,&y,&z)\n \tt= math.Sqrt(x*y*z)\n \tt= t/x+t/y+t/z\n \tt*=4\n \t\tfmt.Println(t)\n }\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar x, y, z int\n\tif _, err := fmt.Scanf(\"%d %d %d\\n\", &x, &y, &z); err != nil {\n\t\treturn\n\t}\n\n\ta := math.Sqrt(float64(x * z / y))\n\tb := math.Sqrt(float64(x * y / z))\n\tc := math.Sqrt(float64(y * z / x))\n\n\tfmt.Println(4 * int32(a+b+c))\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var a,b,c int\n fmt.Scan(&a,&b,&c)\n y := int(math.Sqrt(float64((a*c)/b)))\n x := (y*b)/c\n z := b/x\n fmt.Println(4*(x+y+z))\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var a,b,c int\n fmt.Scan(&a,&b,&c)\n y := int(math.Sqrt(float64((a*c)/b)))\n x := (y*b)/c\n z := b/x\n fmt.Println(4*(x+y+z))\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var a, b, c float64\n fmt.Scanf(\"%f%f%f\", &a, &b, &c)\n fmt.Print(4 * (math.Sqrt(a * b / c) + math.Sqrt(a * c / b) + math.Sqrt(b * c / a)))\n}\n"}, {"source_code": "// 224A-mic\npackage main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var s1, s2, s3 int\n fmt.Scan(&s1, &s2, &s3)\n a := int(math.Sqrt(float64(s1 * s3 / s2)))\n b := int(math.Sqrt(float64(s1 * s2 / s3)))\n c := int(math.Sqrt(float64(s2 * s3 / s1)))\n fmt.Println(4 * (a + b + c))\n}\n"}, {"source_code": " package main\n\n import (\n \t\"fmt\"\n \t\"math\"\n )\n\n func main() {\n \tvar x,y,z,t float64\n \tfmt.Scan(&x,&y,&z)\n \tt= math.Sqrt(x*y*z)\n \tt= t/x+t/y+t/z\n \tt*=4\n \tfmt.Println(t)\n }\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var a,b,c int\n fmt.Scan(&a,&b,&c)\n y := int(math.Sqrt(float64((a*c)/b)))\n x := (y*b)/c\n z := b/x\n fmt.Println(4*(x+y+z))\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var ab, ac, bc int\n fmt.Scanf(\"%d %d %d\", &ab, &ac, &bc)\n abc := int(math.Sqrt(float64(ab*ac*bc)))\n fmt.Print(4*(abc/bc + abc/ac + abc/ab))\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nfunc main() {\n scanner := bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n var n,k int\n fmt.Scan(&n,&k)\n a := make([]int,n+1)\n ok := true\n for i := 1; i <= n; i++ {\n scanner.Scan()\n a[i], _ = strconv.Atoi(scanner.Text())\n if (i > k) && (a[i] != a[k]) {\n ok = false\n }\n }\n if ok {\n ans := k\n for a[ans-1] == a[k] { ans-- }\n fmt.Println(ans-1)\n } else {\n fmt.Println(-1)\n }\n}\n"}], "src_uid": "c0a3290be3b87f3a232ec19d4639fefc"} {"nl": {"description": "Polycarp plays \"Game 23\". Initially he has a number $$$n$$$ and his goal is to transform it to $$$m$$$. In one move, he can multiply $$$n$$$ by $$$2$$$ or multiply $$$n$$$ by $$$3$$$. He can perform any number of moves.Print the number of moves needed to transform $$$n$$$ to $$$m$$$. Print -1 if it is impossible to do so.It is easy to prove that any way to transform $$$n$$$ to $$$m$$$ contains the same number of moves (i.e. number of moves doesn't depend on the way of transformation).", "input_spec": "The only line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\le n \\le m \\le 5\\cdot10^8$$$).", "output_spec": "Print the number of moves to transform $$$n$$$ to $$$m$$$, or -1 if there is no solution.", "sample_inputs": ["120 51840", "42 42", "48 72"], "sample_outputs": ["7", "0", "-1"], "notes": "NoteIn the first example, the possible sequence of moves is: $$$120 \\rightarrow 240 \\rightarrow 720 \\rightarrow 1440 \\rightarrow 4320 \\rightarrow 12960 \\rightarrow 25920 \\rightarrow 51840.$$$ The are $$$7$$$ steps in total.In the second example, no moves are needed. Thus, the answer is $$$0$$$.In the third example, it is impossible to transform $$$48$$$ to $$$72$$$."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m int64\n\tfmt.Scan(&n, &m)\n\tif m%n != 0 {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\tm /= n\n\tcnt := 0\n\tfor ; m%2 == 0; m /= 2 {\n\t\tcnt += 1\n\t}\n\tfor ; m%3 == 0; m /= 3 {\n\t\tcnt += 1\n\t}\n\tif m > 1 {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\tfmt.Println(cnt)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc rec(a, b, cnt int) int {\n\tif a > b {\n\t\treturn -1\n\t}\n\tif a == b {\n\t\t// fmt.Printf(\"%d\\n\", cnt)\n\t\treturn cnt\n\t}\n\tif rec(a*2, b, cnt+1) != -1 {\n\t\treturn rec(a*2, b, cnt+1)\n\t}\n\tif rec(a*3, b, cnt+1) != -1 {\n\t\treturn rec(a*3, b, cnt+1)\n\t}\n\treturn -1\n}\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scanf(\"%d %d\\n\", &a, &b)\n\tfmt.Printf(\"%d\\n\", rec(a, b, 0))\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc recurs(a, b int) int {\n\tif a > b {\n\t\treturn -1\n\t}\n\tif a == b {\n\t\t// fmt.Printf(\"%d\\n\", cnt)\n\t\treturn 0\n\t}\n\tif recurs(a*2, b) != -1 {\n\t\treturn 1 + recurs(a*2, b)\n\t}\n\tif recurs(a*3, b) != -1 {\n\t\treturn 1 + recurs(a*3, b)\n\t}\n\treturn -1\n}\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scanf(\"%d %d\\n\", &a, &b)\n\tfmt.Printf(\"%d\\n\", recurs(a, b))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tbuf := bufio.NewReader(os.Stdin)\n\n\tvar n, m int\n\tfmt.Fscanf(buf, \"%d %d\\n\", &n, &m)\n\tif m%n != 0 {\n\t\tfmt.Printf(\"-1\\n\")\n\t\treturn\n\t}\n\tans := 0\n\tm /= n\n\tfor m > 1 {\n\t\tif m%2 == 0 {\n\t\t\tm /= 2\n\t\t\tans++\n\t\t} else if m%3 == 0 {\n\t\t\tm /= 3\n\t\t\tans++\n\t\t} else {\n\t\t\tfmt.Printf(\"-1\\n\")\n\t\t\treturn \n\t\t}\n\t}\n\tfmt.Printf(\"%d\\n\", ans)\n\n}\n"}, {"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,m int\n\tfmt.Fscan(in,&n)\n\tfmt.Fscan(in,&m)\n\tif(m == n){\n\t\tfmt.Fprint(out,0)\n\t\treturn\n\t}\n\ttemp := m / n;\n\tcnt := -1\n\tif(temp * n == m){\n\n\tfor temp % 2 == 0{\n\t\tif(cnt == -1){\n\t\t\tcnt = 0\n\t\t}\n\t\tcnt++\n\t\ttemp /= 2\n\t}\n\n\tfor temp % 3 == 0{\n\t\tif(cnt == -1){\n\t\t\tcnt = 0\n\t\t}\n\t\tcnt ++\n\t\ttemp /= 3\n\t}\n\n\tif(temp == 1){\n\t\tfmt.Fprint(out,cnt)\n\t\treturn\n\t}\n\n\t}\n\tif(temp == 1){\n\t\tfmt.Fprint(out,cnt)\n\t}else{\n\t\tfmt.Fprint(out,-1)\n\t}\n\n\n\n\n}\n\nfunc max(i int, i2 int) int {\n\tif(i < i2){\n\t\treturn i2\n\t}else{\n\t\treturn i\n\t}\n}\nfunc min(i int , i2 int) int {\n\tif(i < i2){\n\t\treturn i\n\t}else{\n\t\treturn i2\n\t}\n\n}\n"}, {"source_code": "package main\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strconv\"\n \"strings\"\n)\n\nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n \n input, _ := reader.ReadString('\\n')\n input = strings.Trim(input, \"\\r\\n\")\n splitted := strings.Split(input, \" \")\n \n n, _ := strconv.Atoi(splitted[0])\n m, _ := strconv.Atoi(splitted[1])\n \n if n == m {\n fmt.Println(\"0\")\n os.Exit(0)\n } else if m % n != 0 {\n fmt.Println(\"-1\")\n os.Exit(0)\n }\n \n div := m / n\n if div % 2 != 0 && div % 3 != 0 {\n fmt.Println(\"-1\")\n os.Exit(0)\n }\n \n divisors := [3] int {6, 3, 2}\n ans := 0\n \n for i := 0; i < 3; i++ {\n for div % divisors[i] == 0 {\n if i == 0 {\n ans += 2\n } else {\n ans++\n }\n div /= divisors[i]\n }\n }\n \n if div == 1 {\n fmt.Println(ans)\n } else {\n fmt.Println(\"-1\")\n }\n}"}, {"source_code": "/*package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\td:=0\n\tvar s string\n\tfmt.Scan(&n)\n\tfmt.Scan(&s)\n\tfor i:=0; i1{\n\t if x%2==0{\n\t x=x/2\n\t d+=1\n\t }\n\t if x%3==0{\n\t x=x/3\n\t d+=1\n\t }\n\t }\n\t if x==1{\n\t fmt.Printf(\"%d\", d)\n\t }\n\t if x!=1{\n\t fmt.Printf(\"%d\", -1)\n\t }\n\t}\n\t\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main () {\n\tvar n, m int\n\tfmt.Scanln(&n, &m)\n\n\ttwoCount1 := 0\n\tthreeCount1 := 0\n\ttwoCount2 := 0\n\tthreeCount2 := 0\n\n\tfor n%2==0 {\n\t\ttwoCount1 += 1\n\t\tn /= 2\n\t}\n\tfor m%2==0 {\n\t\ttwoCount2 += 1\n\t\tm /= 2\n\t}\n\tfor n%3==0 {\n\t\tthreeCount1 += 1\n\t\tn /= 3\n\t}\n\tfor m%3==0 {\n\t\tthreeCount2 += 1\n\t\tm /= 3\n\t}\n\n\tif m != n || twoCount1 > twoCount2 || threeCount1 > threeCount2 {\n\t\tfmt.Println(\"-1\")\n\t\treturn\n\t} else {\n\t\tfmt.Println(twoCount2 - twoCount1 + threeCount2 - threeCount1)\n\t}\n\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\ntype Cin struct {\n\tscanner *bufio.Scanner\n}\n\nfunc (c *Cin) NextInt() int {\n\tc.scanner.Scan()\n\tline := c.scanner.Text()\n\treturn c.convertInt(line)\n}\n\nfunc (c *Cin) NextIntSlice() []int {\n\tc.scanner.Scan()\n\tline := strings.Split(c.scanner.Text(), \" \")\n\tvar ret []int\n\tfor _, s := range line {\n\t\tret = append(ret, c.convertInt(s))\n\t}\n\treturn ret\n}\n\nfunc (c *Cin) NextTwoInt() (int, int) {\n\tline := c.NextIntSlice()\n\treturn line[0], line[1]\n}\n\nfunc (c *Cin) convertInt(data string) int {\n\ti, _ := strconv.Atoi(data)\n\treturn i\n}\n\nvar cin = &Cin{\n\tscanner: bufio.NewScanner(os.Stdin),\n}\n\ntype element struct {\n\tvalue int\n\tstep int\n\tnext *element\n\tlast *element\n}\n\nfunc newElement(value, step int) *element {\n\treturn &element{value: value, step: step}\n}\n\ntype queue struct {\n\thead *element\n\ttail *element\n}\n\nfunc (q *queue) push(value, step int) {\n\titem := newElement(value, step)\n\tif q.isEmpty() {\n\t\tq.head = item\n\t\tq.tail = q.head\n\t\treturn\n\t}\n\titem.last = q.tail\n\tq.tail.next = item\n\tq.tail = item\n}\n\nfunc (q *queue) isEmpty() bool {\n\treturn q.head == nil\n}\n\nfunc (q *queue) pop() *element {\n\tif q.isEmpty() {\n\t\tpanic(\"pop from empty queue\")\n\t}\n\titem := q.head\n\tq.head = q.head.next\n\treturn item\n}\n\nfunc newQueue() *queue {\n\treturn &queue{}\n}\n\nfunc handle(n, m int) int {\n\tq := newQueue()\n\tq.push(n, 0)\n\tset := map[int]int{n: 0}\n\tfor !q.isEmpty() {\n\t\tele := q.pop()\n\t\tif ele.value == m {\n\t\t\treturn ele.step\n\t\t}\n\t\tif ele.value > m {\n\t\t\tcontinue\n\t\t}\n\t\tif _, ok := set[ele.value*2]; !ok {\n\t\t\tset[ele.value*2] = ele.step + 1\n\t\t\t// fmt.Printf(\"val=[%v],step=[%v]\\n\", ele.value*2, ele.step+1)\n\t\t\tq.push(ele.value*2, ele.step+1)\n\t\t}\n\t\tif _, ok := set[ele.value*3]; !ok {\n\t\t\tset[ele.value*3] = ele.step + 1\n\t\t\t// fmt.Printf(\"val=[%v],step=[%v]\\n\", ele.value*3, ele.step+1)\n\t\t\tq.push(ele.value*3, ele.step+1)\n\t\t}\n\t}\n\treturn -1\n}\n\nfunc main() {\n\tn, m := cin.NextTwoInt()\n\tfmt.Printf(\"%d\\n\", handle(n, m))\n}\n"}, {"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\n var a, b int\n scanf(\"%d %d\\n\", &a, &b)\n\n if b % a != 0 {\n printf(\"%d\\n\", -1)\n return\n }\n\n div := b / a\n count := 0\n\n for div > 1 {\n if div % 2 == 0 {\n div /= 2\n count += 1\n } else if div % 3 == 0 {\n div /= 3\n count += 1\n } else {\n break\n }\n }\n\n if div == 1 {\n printf(\"%d\\n\", count)\n } else {\n printf(\"%d\\n\", -1)\n }\n return\n}\n"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc p(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc pln(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\n\nfunc scan(a ...interface{}) { fmt.Fscan(reader, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc main() {\n defer writer.Flush()\n\n var a, b int\n scan(&a, &b)\n\n if b % a != 0 {\n pln(-1)\n return\n }\n\n div := b / a\n count := 0\n\n for div > 1 {\n if div % 2 == 0 {\n div /= 2\n count += 1\n } else if div % 3 == 0 {\n div /= 3\n count += 1\n } else {\n break\n }\n }\n\n if div == 1 {\n pln(count)\n } else {\n pln(-1)\n }\n return\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvar n, m int\n\tfmt.Fscan(reader, &n, &m)\n\n\tvar vl int\n\n\tif ok := m % n; ok == 0 {\n\t\tvl = m / n\n\t} else {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\n\tvar count int\n\tfor vl > 1 {\n\t\tif vl%3 == 0 {\n\t\t\tvl /= 3\n\t\t\tcount++\n\t\t} else if vl%2 == 0 {\n\t\t\tvl /= 2\n\t\t\tcount++\n\t\t} else {\n\t\t\tfmt.Println(-1)\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Println(count)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m int\n\tfmt.Scan(&n, &m)\n\tif m%n != 0 {\n\t\tfmt.Print(\"-1\")\n\t} else {\n\t\tvar div int = m / n\n\t\tvar count int = 0\n\t\tfor div%2 == 0 {\n\t\t\tcount++\n\t\t\tdiv /= 2\n\t\t}\n\t\tfor div%3 == 0 {\n\t\t\tcount++\n\t\t\tdiv /= 3\n\t\t}\n\t\tif div != 1 {\n\t\t\tfmt.Printf(\"-1\")\n\t\t} else {\n\t\t\tfmt.Printf(\"%v\", count)\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m, fact, step int64\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\tif m != n {\n\t\tif m%n == 0 {\n\t\t\tfact = m / n\n\t\t\tfor fact%3 == 0 {\n\t\t\t\tfact /= 3\n\t\t\t\tstep++\n\t\t\t}\n\t\t\tfor fact%2 == 0 {\n\t\t\t\tfact /= 2\n\t\t\t\tstep++\n\t\t\t}\n\t\t}\n\t\tif fact != 1 {\n\t\t\tstep = -1\n\t\t}\n\t}\n\n\tfmt.Println(step)\n}\n"}, {"source_code": "// Author: sighduck\n// URL: https://codeforces.com/contest/1141/problem/A\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc reduceDivisor(divisor int, moves int) int {\n\tif divisor == 1 {\n\t\treturn moves\n\t} else if divisor%2 == 0 {\n\t\treturn reduceDivisor(divisor/2, moves+1)\n\t} else if divisor%3 == 0 {\n\t\treturn reduceDivisor(divisor/3, moves+1)\n\t}\n\treturn -1\n}\n\nfunc Solve(n int, m int) int {\n\tif m%n != 0 || m < n {\n\t\treturn -1\n\t}\n\treturn reduceDivisor(m/n, 0)\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n, m int\n\tfmt.Fscanf(reader, \"%d %d\\n\", &n, &m)\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(n, m))\n}\n"}], "negative_code": [{"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,m int\n\tfmt.Fscan(in,&n)\n\tfmt.Fscan(in,&m)\n\tcnt := -1\n\tif m % n == 0{\n\ttemp := m / n\n\tfor temp % 2 == 0{\n\t\ttemp /= 2\n\t\tif(cnt == -1){\n\t\t\tcnt = 0\n\t\t}\n\t\tcnt ++\n\t}\n\tfor temp % 3 == 0{\n\t\ttemp /= 3\n\t\tif(cnt == -1){\n\t\t\tcnt = 0\n\t\t}\n\t\tcnt++\n\t}\n\t}else{\n\t\tcnt = -1\n\t}\n\tfmt.Fprint(out,cnt)\n}\n\nfunc max(i int, i2 int) int {\n\tif(i < i2){\n\t\treturn i2\n\t}else{\n\t\treturn i\n\t}\n}\nfunc min(i int , i2 int) int {\n\tif(i < i2){\n\t\treturn i\n\t}else{\n\t\treturn i2\n\t}\n\n}\n"}, {"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,m int\n\tfmt.Fscan(in,&n)\n\tfmt.Fscan(in,&m)\n\tif(n == m){\n\t\tfmt.Fprint(out,0)\n\t\treturn\n\t}\n\tcnt := -1\n\tif m % n == 0{\n\ttemp := m / n\n\tfor temp % 2 == 0{\n\t\ttemp /= 2\n\t\tif(cnt == -1){\n\t\t\tcnt = 0\n\t\t}\n\t\tcnt ++\n\t}\n\tfor temp % 3 == 0{\n\t\ttemp /= 3\n\t\tif(cnt == -1){\n\t\t\tcnt = 0\n\t\t}\n\t\tcnt++\n\t}\n\t}else{\n\t\tcnt = -1\n\t}\n\tfmt.Fprint(out,cnt)\n}\n\nfunc max(i int, i2 int) int {\n\tif(i < i2){\n\t\treturn i2\n\t}else{\n\t\treturn i\n\t}\n}\nfunc min(i int , i2 int) int {\n\tif(i < i2){\n\t\treturn i\n\t}else{\n\t\treturn i2\n\t}\n\n}\n"}, {"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,m int\n\tfmt.Fscan(in,&n)\n\tfmt.Fscan(in,&m)\n\tcnt := 0\n\tif m % n == 0{\n\ttemp := m / n\n\tfor temp % 2 == 0{\n\t\ttemp /= 2\n\t\tcnt ++\n\t}\n\tfor temp % 3 == 0{\n\t\ttemp /= 3\n\t\tcnt++\n\t}\n\t}else{\n\t\tcnt = -1\n\t}\n\tfmt.Fprint(out,cnt)\n}\n\nfunc max(i int, i2 int) int {\n\tif(i < i2){\n\t\treturn i2\n\t}else{\n\t\treturn i\n\t}\n}\nfunc min(i int , i2 int) int {\n\tif(i < i2){\n\t\treturn i\n\t}else{\n\t\treturn i2\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main () {\n\tvar n, m int\n\tfmt.Scanln(&n, &m)\n\n\ttwoCount1 := 0\n\tthreeCount1 := 0\n\ttwoCount2 := 0\n\tthreeCount2 := 0\n\n\tfor n%2==0 {\n\t\ttwoCount1 += 1\n\t\tn /= 2\n\t}\n\tfor m%2==0 {\n\t\ttwoCount2 += 1\n\t\tm /= 2\n\t}\n\tfor n%3==0 {\n\t\tthreeCount1 += 1\n\t\tn /= 3\n\t}\n\tfor m%3==0 {\n\t\tthreeCount2 += 1\n\t\tm /= 3\n\t}\n\n\tif m != n || twoCount1 > twoCount2 || threeCount1 > threeCount2 {\n\t\tprintln(\"-1\")\n\t\treturn\n\t} else {\n\t\tprintln(twoCount2 - twoCount1 + threeCount2 - threeCount1)\n\t}\n\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x, y, z, a, b, c int32\n\tfmt.Scan(&x, &y, &z, &a, &b, &c)\n\tvar answer string = \"YES\"\n\tif a -= x; a < 0 {\n\t\tanswer = \"NO\"\n\t}\n\tif b = a + b - y; b < 0 {\n\t\tanswer = \"NO\"\n\t}\n\tif c = b + c - z; c < 0 {\n\t\tanswer = \"NO\"\n\t}\n\tfmt.Printf(\"%v\", answer)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m, fact, step int64\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\tif m != n {\n\t\tif m%n == 0 {\n\t\t\tfact = m / n\n\t\t\tfmt.Println(fact)\n\t\t\tfor fact%3 == 0 {\n\t\t\t\tfact /= 3\n\t\t\t\tstep++\n\t\t\t}\n\t\t\tfmt.Println(fact)\n\t\t\tfor fact%2 == 0 {\n\t\t\t\tfact /= 2\n\t\t\t\tstep++\n\t\t\t}\n\t\t\tfmt.Println(fact)\n\t\t}\n\t\tif fact != 1 {\n\t\t\tstep = -1\n\t\t}\n\t}\n\n\tfmt.Println(step)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m, step int\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\tif m != n {\n\t\tif m%n == 0 {\n\t\t\tvar fact = m / n\n\t\t\tfor fact%3 == 0 {\n\t\t\t\tfact /= 3\n\t\t\t\tstep++\n\t\t\t}\n\t\t\tfor fact%2 == 0 {\n\t\t\t\tfact /= 2\n\t\t\t\tstep++\n\t\t\t}\n\t\t} else {\n\t\t\tstep = -1\n\t\t}\n\t}\n\n\tfmt.Println(step)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m, fact, step int64\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\tif m != n {\n\t\tif m%n == 0 {\n\t\t\tfact = m / n\n\t\t\tfor fact%3 == 0 {\n\t\t\t\tfact /= 3\n\t\t\t\tstep++\n\t\t\t}\n\t\t\tfor fact%2 == 0 {\n\t\t\t\tfact /= 2\n\t\t\t\tstep++\n\t\t\t}\n\t\t}\n\t\tif fact != 1 {\n\t\t\tstep = -1\n\t\t}\n\t\tstep = -1\n\t}\n\n\tfmt.Println(step)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m, step int\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\tif m != n {\n\t\tif m%n == 0 {\n\t\t\tvar fact = m / n\n\t\t\tfor fact%3 == 0 {\n\t\t\t\tfact /= 3\n\t\t\t\tstep++\n\t\t\t}\n\t\t\tfor fact%2 == 0 {\n\t\t\t\tfact /= 2\n\t\t\t\tstep++\n\t\t\t}\n\t\t\tif step == 0 {\n\t\t\t\tstep = -1\n\t\t\t}\n\t\t} else {\n\t\t\tstep = -1\n\t\t}\n\t}\n\n\tfmt.Println(step)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, m, step uint\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\tif m%n == 0 {\n\t\tvar fact = m / n\n\t\tfor fact%3 == 0 {\n\t\t\tfact /= 3\n\t\t\tstep++\n\t\t}\n\t\tfor fact%2 == 0 {\n\t\t\tfact /= 2\n\t\t\tstep++\n\t\t}\n\t}\n\tfmt.Println(step)\n}\n"}], "src_uid": "3f9980ad292185f63a80bce10705e806"} {"nl": {"description": "Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Let next(x) be the minimum lucky number which is larger than or equals x. Petya is interested what is the value of the expression next(l) + next(l + 1) + ... + next(r - 1) + next(r). Help him solve this problem.", "input_spec": "The single line contains two integers l and r (1 ≤ l ≤ r ≤ 109) — the left and right interval limits.", "output_spec": "In the single line print the only number — the sum next(l) + next(l + 1) + ... + next(r - 1) + next(r). Please do not use the %lld specificator to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specificator.", "sample_inputs": ["2 7", "7 7"], "sample_outputs": ["33", "7"], "notes": "NoteIn the first sample: next(2) + next(3) + next(4) + next(5) + next(6) + next(7) = 4 + 4 + 4 + 7 + 7 + 7 = 33In the second sample: next(7) = 7"}, "positive_code": [{"source_code": "// 121A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc min(a, b int64) int64 {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc main() {\n\tvar a [15]int64\n\tvar i, l, r, x, j, n1, n2 int64\n\tx, j = 0, 1\n\tfmt.Scan(&l, &r)\n\tfor i = 0; i <= 10; i++ {\n\t\ta[i] = 0\n\t}\n\tfor j <= r {\n\t\ti = 10\n\t\ta[i]++\n\t\tfor a[i] > 2 {\n\t\t\ta[i] = 0\n\t\t\ti--\n\t\t\ta[i]++\n\t\t}\n\t\tj = 0\n\t\tfor i = 1; i <= 10; i++ {\n\t\t\tif j > 0 && a[i] == 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif a[i] == 1 {\n\t\t\t\tn1 = 4\n\t\t\t} else {\n\t\t\t\tn1 = 0\n\t\t\t}\n\t\t\tif a[i] == 2 {\n\t\t\t\tn2 = 7\n\t\t\t} else {\n\t\t\t\tn2 = 0\n\t\t\t}\n\t\t\tj = j*10 + n1 + n2\n\t\t}\n\t\tif x == 0 && j >= l {\n\t\t\tx += j\n\t\t}\n\t\tif i <= 10 {\n\t\t\tcontinue\n\t\t}\n\t\tif j >= l {\n\t\t\tx += (min(j, r) - l) * j\n\t\t\tl = j\n\t\t}\n\t}\n\tfmt.Print(x)\n}\n"}, {"source_code": "// 121A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc min(a, b int64) int64 {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc main() {\n\tvar a [15]int64\n\tvar i, l, r, x, j, n1, n2 int64\n\tx, j = 0, 1\n\tfmt.Scan(&l, &r)\n\tfor i = 0; i <= 10; i++ {\n\t\ta[i] = 0\n\t}\n\tfor j <= r {\n\t\ti = 10\n\t\ta[i]++\n\t\tfor a[i] > 2 {\n\t\t\ta[i] = 0\n\t\t\ti--\n\t\t\ta[i]++\n\t\t}\n\t\tj = 0\n\t\tfor i = 1; i <= 10; i++ {\n\t\t\tif j > 0 && a[i] == 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif a[i] == 1 {\n\t\t\t\tn1 = 4\n\t\t\t} else {\n\t\t\t\tn1 = 0\n\t\t\t}\n\t\t\tif a[i] == 2 {\n\t\t\t\tn2 = 7\n\t\t\t} else {\n\t\t\t\tn2 = 0\n\t\t\t}\n\t\t\tj = j*10 + n1 + n2\n\t\t}\n\t\tif x == 0 && j >= l {\n\t\t\tx += j\n\t\t}\n\t\tif i <= 10 {\n\t\t\tcontinue\n\t\t}\n\t\tif j >= l {\n\t\t\tx += (min(j, r) - l) * j\n\t\t\tl = j\n\t\t}\n\t}\n\tfmt.Print(x)\n}\n"}, {"source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc getNext(x int64) int64 {\n //fmt.Fprintf(os.Stderr, \"in: %d\\n\", x)\n digits := []int64{}\n for x != 0 {\n digits = append(digits, x%10)\n x /= 10\n }\n carry := int64(0)\n resetIndex := -1\n for i, digit := range digits {\n if carry == 1 {\n digit++\n carry = 0\n }\n if digit <= 4 {\n if digit < 4 {\n resetIndex = i-1\n }\n digits[i] = 4\n } else if digit <= 7 {\n if digit < 7 {\n resetIndex = i-1\n }\n digits[i] = 7\n } else {\n digits[i] = 4\n resetIndex = i\n carry = 1\n }\n }\n if carry == 1 {\n digits = append(digits, 4)\n }\n for i := 0; i <= resetIndex; i++ {\n digits[i] = 4\n }\n base := int64(1)\n for _, digit := range digits {\n x += base*digit\n base *= 10\n }\n //fmt.Fprintf(os.Stderr, \" -> %d\\n\", x)\n return x\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n left, right := getI64(), getI64()\n total := int64(0)\n max := getNext(right)\n current := left-1\n for {\n next := getNext(current+1)\n if next == max {\n total += (right-current)*next\n break\n }\n total += (next-current)*next\n current = next\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", total))\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc getNext(x int64) int64 {\n digits := []int64{}\n for x != 0 {\n digits = append(digits, x%10)\n x /= 10\n }\n carry := int64(0)\n for i, digit := range digits {\n digit += carry\n carry = 0\n if digit <= 4 {\n digits[i] = 4\n } else if digit <= 7 {\n digits[i] = 7\n } else {\n digits[i] = 4\n carry = 1\n }\n }\n if carry == 1 {\n digits = append(digits, 4)\n }\n base := int64(1)\n for _, digit := range digits {\n x += base*digit\n base *= 10\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 left, right := getI64(), getI64()\n total := int64(0)\n max := getNext(right)\n current := left-1\n for {\n next := getNext(current+1)\n if next == max {\n total += (right-current)*next\n break\n }\n total += (next-current)*next\n current = next\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", total))\n}\n"}, {"source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc getNext(x int64) int64 {\n //fmt.Fprintf(os.Stderr, \"in: %d\\n\", x)\n digits := []int64{}\n for x != 0 {\n digits = append(digits, x%10)\n x /= 10\n }\n carry := int64(0)\n carryIndex := -1\n for i, digit := range digits {\n if carry == 1 {\n digit++\n carry = 0\n }\n if digit <= 4 {\n digits[i] = 4\n } else if digit <= 7 {\n digits[i] = 7\n } else {\n digits[i] = 4\n carry = 1\n carryIndex = i\n }\n }\n if carry == 1 {\n digits = append(digits, 4)\n }\n for i := 0; i <= carryIndex; i++ {\n digits[i] = 4\n }\n base := int64(1)\n for _, digit := range digits {\n x += base*digit\n base *= 10\n }\n //fmt.Fprintf(os.Stderr, \" -> %d\\n\", x)\n return x\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n left, right := getI64(), getI64()\n total := int64(0)\n max := getNext(right)\n current := left-1\n for {\n next := getNext(current+1)\n if next == max {\n total += (right-current)*next\n break\n }\n total += (next-current)*next\n current = next\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", total))\n}\n"}, {"source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc getNext(x int64) int64 {\n fmt.Fprintf(os.Stderr, \"%d ->\", x)\n digits := []int64{}\n for x != 0 {\n digits = append(digits, x%10)\n x /= 10\n }\n carry := int64(0)\n for i, digit := range digits {\n digit += carry\n carry = 0\n if digit <= 4 {\n digits[i] = 4\n } else if digit <= 7 {\n digits[i] = 7\n } else {\n digits[i] = 4\n carry = 1\n }\n }\n if carry == 1 {\n digits = append(digits, 4)\n }\n base := int64(1)\n for _, digit := range digits {\n x += base*digit\n base *= 10\n }\n fmt.Fprintf(os.Stderr, \" %d\\n\", x)\n return x\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n span := int64(0)\n left, right := getI64(), getI64()\n total := uint64(0)\n max := getNext(right)\n current := left-1\n for current != max {\n next := getNext(current+1)\n total += uint64(next-current)*uint64(next)\n span += next-current\n fmt.Fprintf(os.Stderr, \"(%d - %d = %d) * %d\\n\", next, current,\n next-current, next)\n if next < current {\n fmt.Fprintf(os.Stderr, \"%d < %d\\n\", next, current)\n break\n }\n current = next\n fmt.Fprintf(os.Stderr, \" %d\\n\", total)\n }\n fmt.Fprintf(os.Stderr, \"span = %d, right-left+1 = %d\\n\", span, right-left+1)\n writer.WriteString(fmt.Sprintf(\"%d\\n\", total))\n}\n"}], "src_uid": "8a45fe8956d3ac9d501f4a13b55638dd"} {"nl": {"description": "Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. Initially, each hole has $$$a_i$$$ stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction.Note that the counter-clockwise order means if the player takes the stones from hole $$$i$$$, he will put one stone in the $$$(i+1)$$$-th hole, then in the $$$(i+2)$$$-th, etc. If he puts a stone in the $$$14$$$-th hole, the next one will be put in the first hole.After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli.Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move.", "input_spec": "The only line contains 14 integers $$$a_1, a_2, \\ldots, a_{14}$$$ ($$$0 \\leq a_i \\leq 10^9$$$) — the number of stones in each hole. It is guaranteed that for any $$$i$$$ ($$$1\\leq i \\leq 14$$$) $$$a_i$$$ is either zero or odd, and there is at least one stone in the board.", "output_spec": "Output one integer, the maximum possible score after one move.", "sample_inputs": ["0 1 1 0 0 0 0 0 0 7 0 0 0 0", "5 1 1 1 1 0 0 0 0 0 0 0 0 0"], "sample_outputs": ["4", "8"], "notes": "NoteIn the first test case the board after the move from the hole with $$$7$$$ stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to $$$4$$$."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar line string\n\tvar max int64\n\tvar start [14]int64\n\tvar end [14]int64\n\treader := bufio.NewReader(os.Stdin)\n\tline, _ = reader.ReadString('\\n')\n\tarrStartStrings := strings.Split(strings.TrimSpace(line), \" \")\n\tfor i, v := range arrStartStrings {\n\t\tstart[i], _ = strconv.ParseInt(v, 10, 0)\n\t}\n\tfor i := 0; i < 14; i++ {\n\t\tend[i] = igra(start, i)\n\t}\n\tfor i := 0; i < 14; i++ {\n\t\tif max < end[i]{\n\t\t\tmax=end[i]\n\t\t}\n\t}\n\tfmt.Println(max)\n}\n\nfunc igra(start [14]int64, i int) int64 {\n\tvar n, addToAll, result int64\n\tn = start[i]\n\tstart[i] = 0\n\tif n == 0 {\n\t\treturn 0\n\t}\n\taddToAll = n / 14\n\tn = n % 14\n\tfor i := 0; i < 14; i++ {\n\t\tstart[i] += addToAll\n\t}\n\tfor n != 0 {\n\t\tif i+1 == 14 {\n\t\t\ti = 0\n\t\t} else {\n\t\t\ti++\n\t\t}\n\t\tstart[i]++\n\t\tn--\n\t}\n\tfor i := 0; i < 14; i++ {\n\t\tif start[i]%2==0{\n\t\t\tresult+=start[i]\n\t\t}\n\t}\n\treturn result\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printF(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanF(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc scanSlice(n int) []int64 {\n\ta := make([]int64, n)\n\tl, _ := reader.ReadString('\\n')\n\ts := strings.Split(strings.TrimSpace(l), \" \")\n\tfor i := 0; i < n; i++ {\n\t\ta[i], _ = strconv.ParseInt(s[i], 10, 0)\n\t}\n\treturn a\n}\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\ta := scanSlice(14)\n\n\tmaxcount := int64(0)\n\tfor i := range a {\n\t\tif a[i] == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tcount, k := int64(0), a[i]\n\t\ta[i] = 0\n\t\tfor j := range a {\n\t\t\tn := a[(i+j)%14] + k/14\n\t\t\tif (int64(j)-1+14)%14 < k%14 {\n\t\t\t\tn++\n\t\t\t}\n\t\t\tif n%2 == 0 {\n\t\t\t\tcount += n\n\t\t\t}\n\t\t}\n\t\tmaxcount, a[i] = max(maxcount, count), k\n\t}\n\tprintF(\"%d\", maxcount)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc scanInt(a interface{}) { fmt.Fscanf(reader, \"%d\", a) }\nfunc scanlnInt(a interface{}) { fmt.Fscanf(reader, \"%d\\n\", a) }\nfunc scanChar(a interface{}) { fmt.Fscanf(reader, \"%c\", a) }\nfunc scanString(a interface{}) { fmt.Fscanf(reader, \"%s\", a) }\n\nfunc max(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\ta := make([]int64, 14)\n\tfor i := range a {\n\t\tscanInt(&a[i])\n\t}\n\tmaxcount := int64(0)\n\tfor i := int64(0); i < 14; i++ {\n\t\tcount, k := int64(0), a[i]\n\t\ta[i] = 0\n\t\tfor j := int64(0); j < 14; j++ {\n\t\t\tn := a[(i+j)%14] + k/14\n\t\t\tif (j-1+14)%14 < k%14 {\n\t\t\t\tn++\n\t\t\t}\n\t\t\tif n%2 == 0 {\n\t\t\t\tcount += n\n\t\t\t}\n\t\t}\n\t\tmaxcount, a[i] = max(maxcount, count), k\n\t}\n\tprintf(\"%d\", maxcount)\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc scanInt(a interface{}) { fmt.Fscanf(reader, \"%d\", a) }\nfunc scanlnInt(a interface{}) { fmt.Fscanf(reader, \"%d\\n\", a) }\nfunc scanChar(a interface{}) { fmt.Fscanf(reader, \"%c\", a) }\nfunc scanString(a interface{}) { fmt.Fscanf(reader, \"%s\", a) }\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\ta := make([]int, 14)\n\tfor i := range a {\n\t\tscanInt(&a[i])\n\t}\n\tmaxcount := 0\n\tfor i := range a {\n\t\tcount, k := 0, a[i]\n\t\ta[i] = 0\n\t\tfor j := range a {\n\t\t\tn := a[(i+j)%14] + k/14\n\t\t\tif (j-1+14)%14 < k%14 {\n\t\t\t\tn++\n\t\t\t}\n\t\t\tif n%2 == 0 {\n\t\t\t\tcount += n\n\t\t\t}\n\t\t}\n\t\tmaxcount, a[i] = max(maxcount, count), k\n\t}\n\tprintf(\"%d\", maxcount)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printF(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanF(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc scanSlice(n int) []int {\n\ta := make([]int, n)\n\tl, _ := reader.ReadString('\\n')\n\ts := strings.Split(strings.TrimSpace(l), \" \")\n\tfor i := 0; i < n; i++ {\n\t\ta[i], _ = strconv.Atoi(s[i])\n\t}\n\treturn a\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\ta := scanSlice(14)\n\n\tmaxcount := 0\n\tfor i := range a {\n\t\tif a[i] == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tcount, k := 0, a[i]\n\t\ta[i] = 0\n\t\tfor j := range a {\n\t\t\tn := a[(i+j)%14] + k/14\n\t\t\tif (j-1+14)%14 < k%14 {\n\t\t\t\tn++\n\t\t\t}\n\t\t\tif n%2 == 0 {\n\t\t\t\tcount += n\n\t\t\t}\n\t\t}\n\t\tmaxcount, a[i] = max(maxcount, count), k\n\t}\n\tprintF(\"%d\", maxcount)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc scanInt(a interface{}) { fmt.Fscanf(reader, \"%d\", a) }\nfunc scanlnInt(a interface{}) { fmt.Fscanf(reader, \"%d\\n\", a) }\nfunc scanlnSInt(n int) []int {\n\ts := make([]int, n)\n\tfor i := 0; i < n-1; i++ {\n\t\tfmt.Fscanf(reader, \"%d \", &s[i])\n\t}\n\tfmt.Fscanf(reader, \"%d\\n\", &s[n-1])\n\treturn s\n}\nfunc scanChar(a interface{}) { fmt.Fscanf(reader, \"%c\", a) }\nfunc scanString(a interface{}) { fmt.Fscanf(reader, \"%s\", a) }\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\tdefer writer.Flush()\n\n\ta := scanlnSInt(14)\n\n\tmaxcount := 0\n\tfor i := range a {\n\t\tif a[i] == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tcount, k := 0, a[i]\n\t\ta[i] = 0\n\t\tfor j := range a {\n\t\t\tn := a[(i+j)%14] + k/14\n\t\t\tif (j-1+14)%14 < k%14 {\n\t\t\t\tn++\n\t\t\t}\n\t\t\tif n%2 == 0 {\n\t\t\t\tcount += n\n\t\t\t}\n\t\t}\n\t\tmaxcount, a[i] = max(maxcount, count), k\n\t}\n\tprintf(\"%d\", maxcount)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc scanInt(a interface{}) { fmt.Fscanf(reader, \"%d\", a) }\nfunc scanlnInt(a interface{}) { fmt.Fscanf(reader, \"%d\\n\", a) }\nfunc scanChar(a interface{}) { fmt.Fscanf(reader, \"%c\", a) }\nfunc scanString(a interface{}) { fmt.Fscanf(reader, \"%s\", a) }\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\n\ta := make([]int, 14)\n\tfor i := range a {\n\t\tscanInt(&a[i])\n\t}\n\tmaxcount := 0\n\tfor i := range a {\n\t\tif a[i] == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tcount, k := 0, a[i]\n\t\ta[i] = 0\n\t\tfor j := range a {\n\t\t\tn := a[(i+j)%14] + k/14\n\t\t\tif (j-1+14)%14 < k%14 {\n\t\t\t\tn++\n\t\t\t}\n\t\t\tif n%2 == 0 {\n\t\t\t\tcount += n\n\t\t\t}\n\t\t}\n\t\tmaxcount, a[i] = max(maxcount, count), k\n\t}\n\tprintf(\"%d\", maxcount)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc scanInt(a interface{}) { fmt.Fscanf(reader, \"%d\", a) }\nfunc scanlnInt(a interface{}) { fmt.Fscanf(reader, \"%d\\n\", a) }\nfunc scanlnSInt(n int) []int {\n\ts := make([]int, n)\n\tfor i := 0; i < n-1; i++ {\n\t\tfmt.Fscanf(reader, \"%d\", &s[i])\n\t}\n\tfmt.Fscanf(reader, \"%d\\n\", &s[n-1])\n\treturn s\n}\nfunc scanChar(a interface{}) { fmt.Fscanf(reader, \"%c\", a) }\nfunc scanString(a interface{}) { fmt.Fscanf(reader, \"%s\", a) }\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\tdefer writer.Flush()\n\n\ta := scanlnSInt(14)\n\n\tmaxcount := 0\n\tfor i := range a {\n\t\tif a[i] == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tcount, k := 0, a[i]\n\t\ta[i] = 0\n\t\tfor j := range a {\n\t\t\tn := a[(i+j)%14] + k/14\n\t\t\tif (j-1+14)%14 < k%14 {\n\t\t\t\tn++\n\t\t\t}\n\t\t\tif n%2 == 0 {\n\t\t\t\tcount += n\n\t\t\t}\n\t\t}\n\t\tmaxcount, a[i] = max(maxcount, count), k\n\t}\n\tprintf(\"%d\", maxcount)\n}\n"}], "src_uid": "1ac11153e35509e755ea15f1d57d156b"} {"nl": {"description": "Luba is surfing the Internet. She currently has n opened tabs in her browser, indexed from 1 to n from left to right. The mouse cursor is currently located at the pos-th tab. Luba needs to use the tabs with indices from l to r (inclusive) for her studies, and she wants to close all the tabs that don't belong to this segment as fast as possible.Each second Luba can either try moving the cursor to the left or to the right (if the cursor is currently at the tab i, then she can move it to the tab max(i - 1, a) or to the tab min(i + 1, b)) or try closing all the tabs to the left or to the right of the cursor (if the cursor is currently at the tab i, she can close all the tabs with indices from segment [a, i - 1] or from segment [i + 1, b]). In the aforementioned expressions a and b denote the minimum and maximum index of an unclosed tab, respectively. For example, if there were 7 tabs initially and tabs 1, 2 and 7 are closed, then a = 3, b = 6.What is the minimum number of seconds Luba has to spend in order to leave only the tabs with initial indices from l to r inclusive opened?", "input_spec": "The only line of input contains four integer numbers n, pos, l, r (1 ≤ n ≤ 100, 1 ≤ pos ≤ n, 1 ≤ l ≤ r ≤ n) — the number of the tabs, the cursor position and the segment which Luba needs to leave opened.", "output_spec": "Print one integer equal to the minimum number of seconds required to close all the tabs outside the segment [l, r].", "sample_inputs": ["6 3 2 4", "6 3 1 3", "5 2 1 5"], "sample_outputs": ["5", "1", "0"], "notes": "NoteIn the first test Luba can do the following operations: shift the mouse cursor to the tab 2, close all the tabs to the left of it, shift the mouse cursor to the tab 3, then to the tab 4, and then close all the tabs to the right of it.In the second test she only needs to close all the tabs to the right of the current position of the cursor.In the third test Luba doesn't need to do anything."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t// \"os\"\n\t)\n\nconst INF = 0x3f3f3f3f\n\nvar n, m, tot int\n\nfunc min(x, y int) int {\n\tif xy {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc abs(x int) int {\n\tif x<0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc main() {\n\t// fd, _ := os.Open(\"in.txt\")\n\t// os.Stdin = fd\n\tvar T int = 1\n\t// fmt.Scanf(\"%d\", &T)\n\tfor ci:=1; ci<=T; ci++ {\n\t\tvar l, r int\n\t\tfmt.Scanf(\"%d %d %d %d\\n\", &n, &m, &l, &r)\n\t\t// fmt.Printf(\"Case #%d: \", ci)\n\t\tif l==1 && r==n {\n\t\t\tfmt.Println(0)\n\t\t} else if l==1 {\n\t\t\tif m<=r {\n\t\t\t\tfmt.Println(1+r-m)\n\t\t\t} else {\n\t\t\t\tfmt.Println(1-r+m)\n\t\t\t}\n\t\t} else if r==n {\n\t\t\tif m>1\n\t\t\tif m<=mid {\n\t\t\t\tfmt.Println(r+2-l+abs(m-l))\n\t\t\t} else {\n\t\t\t\tfmt.Println(r+2-l+abs(r-m))\n\t\t\t}\n\t\t}\n\t}\n}\n"}, {"source_code": "// http://codeforces.com/contest/915/problem/B\npackage main\n\nimport \"fmt\"\n\nfunc min(x, y int) int {\n if x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\n// comentar que nem gente\nfunc main() {\n\tvar n, pos, l, r int\n\tfmt.Scanf(\"%d %d %d %d\\n\", &n, &pos, &l, &r)\n\tif l == 1 && r == n {\n\t\tfmt.Printf(\"0\\n\")\n\t} else if l == 1 {\n\t\tfmt.Printf(\"%d\\n\", abs(r - pos) + 1)\n\t} else if r == n {\n\t\tfmt.Printf(\"%d\\n\", abs(l - pos) + 1)\n\t} else {\n\t\tif abs(l - pos) < abs(r - pos) {\n\t\t\tfmt.Printf(\"%d\\n\", abs(l - pos) + r - l + 2)\n\t\t} else {\n\t\t\tfmt.Printf(\"%d\\n\", abs(r - pos) + r - l + 2)\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var n, pos, l, r int\n fmt.Scan(&n, &pos, &l, &r)\n var ans int\n if l == 1 {\n if r == n {\n ans = 0\n } else {\n ans = int(math.Abs(float64(pos - r))) + 1\n }\n } else if r == n {\n ans = int(math.Abs(float64(pos - l))) + 1\n } else {\n var diff int = int(math.Abs(float64(l - r)))\n var ans1 int = int(math.Abs(float64(pos - l))) + diff + 2\n var ans2 int = int(math.Abs(float64(pos - r))) + diff + 2\n if ans1 < ans2 {\n ans = ans1\n } else {\n ans = ans2\n }\n }\n fmt.Println(ans)\n}\n"}, {"source_code": "package main\n\n/*\n\tIf we breakdown the problem, we will found 3 cases:\n\t- if non-studies tabs exist both in left & right of studies tabs: 1, [2, 3, 4, 5], 6\n\t- if non-studies tabs exist only in right of studies tabs: [1, 2, 3], 4, 5, 6\n\t- if non-studies tabs exist only in left of studies tabs: 1, 2, 3, [4, 5, 6]\n\n\tFor the first case the minimum number of seconds would be:\n\t\tmin(abs(pos-l), abs(pos-r)) + 1 + abs(l-r) + 1\n\tIn the second case:\n\t\tabs(pos-r) + 1\n\tIn the third case:\n\t\tabs(pos-l) + 1\n*/\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n, pos, l, r int\n\tstdin := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(stdin, \"%d %d %d %d\", &n, &pos, &l, &r)\n\tfmt.Println(solve(n, pos, l, r))\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\ta *= -1\n\t}\n\treturn a\n}\n\nfunc solve(n, pos, l, r int) int {\n\tisLeftExist := abs(1-l) > 0\n\tisRightExist := abs(r-n) > 0\n\tif isLeftExist && isRightExist {\n\t\treturn min(abs(pos-l), abs(pos-r)) + 1 + abs(l-r) + 1\n\t} else if isRightExist {\n\t\treturn abs(pos-r) + 1\n\t} else if isLeftExist {\n\t\treturn abs(pos-l) + 1\n\t}\n\treturn 0\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n, pos, l, r int\n\tstdin := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(stdin, \"%d %d %d %d\", &n, &pos, &l, &r)\n\tfmt.Println(solve(n, pos, l, r))\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\ta *= -1\n\t}\n\treturn a\n}\n\nfunc solve(n, pos, l, r int) int {\n\tisLeftExist := abs(1-l) > 0\n\tisRightExist := abs(r-n) > 0\n\tif isLeftExist && isRightExist {\n\t\treturn min(abs(pos-l), abs(pos-r)) + 1 + abs(l-r) + 1\n\t} else if isRightExist {\n\t\treturn abs(pos-r) + 1\n\t} else if isLeftExist {\n\t\treturn abs(pos-l) + 1\n\t}\n\treturn 0\n}\n"}, {"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\tpos := readInt()\n\tl := readInt()\n\tr := readInt()\n\tif l == 1 && r == n {\n\t\tfmt.Println(0)\n\t} else if l == 1 {\n\t\tfmt.Println(abs(r-pos) + 1)\n\t} else if r == n {\n\t\tfmt.Println(abs(pos-l) + 1)\n\t} else {\n\t\tfmt.Println(min(abs(pos-l)+1+r-l+1, abs(r-pos)+1+r-l+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\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\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"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc abs(x int) int {\n\tif x > 0 {\n\t\treturn x\n\t}\n\treturn -x\n}\n\nfunc min(i, j int) int {\n\tif i < j {\n\t\treturn i\n\t}\n\treturn j\n}\n\nfunc main() {\n\tvar n, pos, l, r int\n\tfmt.Scan(&n, &pos, &l, &r)\n\n\tgoright := abs(r - pos)\n\tgoleft := abs(l - pos)\n\tif l == 1 && r == n {\n\t\tfmt.Println(0)\n\t} else if l == 1 {\n\t\tfmt.Println(goright + 1)\n\t} else if r == n {\n\t\tfmt.Println(goleft + 1)\n\t} else {\n\t\tif pos < l {\n\t\t\tfmt.Println(goright + 2)\n\t\t} else if pos > r {\n\t\t\tfmt.Println(goleft + 2)\n\t\t} else {\n\t\t\tfmt.Println(min(goleft, goright) + r - l + 2)\n\t\t}\n\t}\n}\n"}, {"source_code": "//\tURL: http://codeforces.com/contest/915/problem/B\n//\tPROBLEM RESTATEMENT\n//\t\tLet x be an array 1 ... n.\n//\t\tGiven an integer pos in the range [1, n]\n//\t\tTwo operations: move, and close.\n//\t\tThe move operation either increment or decrements pos in range [1, n]\n//\t\tClose operator removes either (pos, n] or [1, pos) from the set.\n//\t\tDetermine minimum number of operations needed to remove all elements\n//\t\tfrom x except for [l, r].\n//\tSETUP\n//\t\tThere are three cases:\n//\t\t\t1) l = 1 and r = n.\n//\t\t\t2) l = 1 and r != n, by symmetry, also: l != 1 and r = n.\n//\t\t\t3) l != 1 and r != n.\n//\tCASES\n//\t\t1) We terminate in 0 operations - solved state.\n//\t\t2) Need to fix one interval: either (r, n] or [1, l). This cost is\n//\t\t the distance from pos to r or pos to l, and one close() operation.\n//\t\t3) Need to fix both of the aforementioned intervals. We traverse to\n//\t\t whichever interval is closer (r or l), close(), move r - l to the\n//\t\t other interval, and close() again.\n\npackage main\n\nimport \"fmt\"\n\nfunc min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc solve(n int, pos int, l int, r int) int {\n\tif l == 1 && r == n {\n\t\treturn 0\n\t} else if l == 1 && r != n {\n\t\treturn abs(r-pos) + 1\n\t} else if l != 1 && r == n {\n\t\treturn abs(l-pos) + 1\n\t} else {\n\t\treturn r - l + min(abs(l-pos), abs(r-pos)) + 2\n\t}\n}\n\nfunc main() {\n\tvar n, pos, l, r int\n\tfmt.Scan(&n, &pos, &l, &r)\n\tfmt.Println(solve(n, pos, l, r))\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t// \"os\"\n\t)\n\nconst INF = 0x3f3f3f3f\n\nvar n, m, tot int\n\nfunc min(x, y int) int {\n\tif xy {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc main() {\n\t// fd, _ := os.Open(\"in.txt\")\n\t// os.Stdin = fd\n\tvar T int = 1\n\t// fmt.Scanf(\"%d\", &T)\n\tfor ci:=1; ci<=T; ci++ {\n\t\tvar l, r int\n\t\tfmt.Scanf(\"%d %d %d %d\\n\", &n, &m, &l, &r)\n\t\t// fmt.Printf(\"Case #%d: \", ci)\n\t\tif l==1 && r==n {\n\t\t\tfmt.Println(0)\n\t\t} else if l==1 {\n\t\t\tif m<=r {\n\t\t\t\tfmt.Println(1+r-m)\n\t\t\t} else {\n\t\t\t\tfmt.Println(1-r+m)\n\t\t\t}\n\t\t} else if r==n {\n\t\t\tif m>1\n\t\t\tif m<=mid {\n\t\t\t\tfmt.Println(r+2-l+m-l)\n\t\t\t} else {\n\t\t\t\tfmt.Println(r+2-l+r-m)\n\t\t\t}\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t// \"os\"\n\t)\n\nconst INF = 0x3f3f3f3f\n\nvar n, m, tot int\n\nfunc min(x, y int) int {\n\tif xy {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc main() {\n\t// fd, _ := os.Open(\"in.txt\")\n\t// os.Stdin = fd\n\tvar T int = 1\n\t// fmt.Scanf(\"%d\", &T)\n\tfor ci:=1; ci<=T; ci++ {\n\t\tvar l, r int\n\t\tfmt.Scanf(\"%d %d %d %d\\n\", &n, &m, &l, &r)\n\t\t// fmt.Printf(\"Case #%d: \", ci)\n\t\tif l==1 && r==n {\n\t\t\tfmt.Println(0)\n\t\t} else if l==1 {\n\t\t\tif m<=r {\n\t\t\t\tfmt.Println(1+r-m)\n\t\t\t} else {\n\t\t\t\tfmt.Println(1-r+m)\n\t\t\t}\n\t\t} else if r==n {\n\t\t\tif m>1\n\t\t\tif m<=mid {\n\t\t\t\tfmt.Println(r+2-l+m-l)\n\t\t\t} else {\n\t\t\t\tfmt.Println(r+2-l+r-m)\n\t\t\t}\n\t\t}\n\t}\n}\n"}, {"source_code": "// http://codeforces.com/contest/915/problem/B\npackage main\n\nimport \"fmt\"\n\nfunc min(x, y int) int {\n if x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\n// comentar que nem gente\nfunc main() {\n\tvar n, pos, l, r int\n\tfmt.Scanf(\"%d %d %d %d\\n\", &n, &pos, &l, &r)\n\tif l == 1 && r == n {\n\t\tfmt.Printf(\"0\\n\")\n\t} else if l == 1 {\n\t\tfmt.Printf(\"%d\\n\", abs(r - pos) + 1)\n\t} else if r == n {\n\t\tfmt.Printf(\"%d\\n\", abs(l - pos) + 2)\n\t} else {\n\t\tif abs(l - pos) < abs(r - pos) {\n\t\t\tfmt.Printf(\"%d\\n\", abs(l - pos) + r - l + 2)\n\t\t} else {\n\t\t\tfmt.Printf(\"%d\\n\", abs(r - pos) + r - l + 2)\n\t\t}\n\t}\n}\n"}, {"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\tpos := readInt()\n\tl := readInt()\n\tr := readInt()\n\tif l == 1 && r == n {\n\t\tfmt.Println(0)\n\t} else if l == 1 {\n\t\tfmt.Println(r - pos + 1)\n\t} else if r == n {\n\t\tfmt.Println(pos - l + 1)\n\t} else {\n\t\tfmt.Println(min(pos-l+1+r-l+1, r-pos+1+r-l+1))\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\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": "5deaac7bd3afedee9b10e61997940f78"} {"nl": {"description": "Tonight is brain dinner night and all zombies will gather together to scarf down some delicious brains. The artful Heidi plans to crash the party, incognito, disguised as one of them. Her objective is to get away with at least one brain, so she can analyze the zombies' mindset back home and gain a strategic advantage.They will be N guests tonight: N - 1 real zombies and a fake one, our Heidi. The living-dead love hierarchies as much as they love brains: each one has a unique rank in the range 1 to N - 1, and Heidi, who still appears slightly different from the others, is attributed the highest rank, N. Tonight there will be a chest with brains on display and every attendee sees how many there are. These will then be split among the attendees according to the following procedure:The zombie of the highest rank makes a suggestion on who gets how many brains (every brain is an indivisible entity). A vote follows. If at least half of the attendees accept the offer, the brains are shared in the suggested way and the feast begins. But if majority is not reached, then the highest-ranked zombie is killed, and the next zombie in hierarchy has to make a suggestion. If he is killed too, then the third highest-ranked makes one, etc. (It's enough to have exactly half of the votes – in case of a tie, the vote of the highest-ranked alive zombie counts twice, and he will of course vote in favor of his own suggestion in order to stay alive.)You should know that zombies are very greedy and sly, and they know this too – basically all zombie brains are alike. Consequently, a zombie will never accept an offer which is suboptimal for him. That is, if an offer is not strictly better than a potential later offer, he will vote against it. And make no mistake: while zombies may normally seem rather dull, tonight their intellects are perfect. Each zombie's priorities for tonight are, in descending order: survive the event (they experienced death already once and know it is no fun), get as many brains as possible. Heidi goes first and must make an offer which at least half of the attendees will accept, and which allocates at least one brain for Heidi herself.What is the smallest number of brains that have to be in the chest for this to be possible?", "input_spec": "The only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 109).", "output_spec": "Output one integer: the smallest number of brains in the chest which allows Heidi to take one brain home.", "sample_inputs": ["1", "4"], "sample_outputs": ["1", "2"], "notes": "Note"}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\n\nfunc main(){\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\tif n & 1 == 1 {\n\t\tfmt.Printf(\"%d\", (n + 1) >> 1)\n\t}else{\n\t\tfmt.Printf(\"%d\", n >> 1)\n\t}\n}"}, {"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\ttext, _ := reader.ReadString('\\n')\n\ttext = strings.TrimRight(text, \"\\r\\n\")\n\ts := strings.Split(text, \" \")\n\n\tc, _ := strconv.Atoi(s[0])\n\tif (c % 2) == 1 {\n\t\tc += 1\n\t}\n\tfmt.Println(c / 2)\n\t//x, _ := strconv.ParseInt(s[1], 10, 64)\n\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _ := reader.ReadString('\\n')\n\ttext = strings.TrimRight(text, \"\\r\\n\")\n\ts := strings.Split(text, \" \")\n\n\tc, _ := strconv.Atoi(s[0])\n\tfmt.Println(math.Ceil(float64(c) / 2.0))\n\t//x, _ := strconv.ParseInt(s[1], 10, 64)\n\n}\n"}], "src_uid": "30e95770f12c631ce498a2b20c2931c7"} {"nl": {"description": "Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors.The testing goes in n steps, at each step the processor gets some instructions, and then its temperature is measured. The head engineer in R2 is keeping a report record on the work of the processor: he writes down the minimum and the maximum measured temperature in his notebook. His assistant had to write down all temperatures into his notebook, but (for unknown reasons) he recorded only m.The next day, the engineer's assistant filed in a report with all the m temperatures. However, the chief engineer doubts that the assistant wrote down everything correctly (naturally, the chief engineer doesn't doubt his notes). So he asked you to help him. Given numbers n, m, min, max and the list of m temperatures determine whether you can upgrade the set of m temperatures to the set of n temperatures (that is add n - m temperatures), so that the minimum temperature was min and the maximum one was max.", "input_spec": "The first line contains four integers n, m, min, max (1 ≤ m < n ≤ 100; 1 ≤ min < max ≤ 100). The second line contains m space-separated integers ti (1 ≤ ti ≤ 100) — the temperatures reported by the assistant. Note, that the reported temperatures, and the temperatures you want to add can contain equal temperatures.", "output_spec": "If the data is consistent, print 'Correct' (without the quotes). Otherwise, print 'Incorrect' (without the quotes).", "sample_inputs": ["2 1 1 2\n1", "3 1 1 3\n2", "2 1 1 3\n2"], "sample_outputs": ["Correct", "Correct", "Incorrect"], "notes": "NoteIn the first test sample one of the possible initial configurations of temperatures is [1, 2].In the second test sample one of the possible initial configurations of temperatures is [2, 1, 3].In the third test sample it is impossible to add one temperature to obtain the minimum equal to 1 and the maximum equal to 3."}, "positive_code": [{"source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n total, found, min, max := getI(), getI(), getI(), getI()\n foundMin, foundMax := false, false\n for i := 0; i < found; i++ {\n x := getI()\n if x < min || x > max {\n writer.WriteString(\"Incorrect\\n\")\n return\n }\n if x == min {\n foundMin = true\n } else if x == max {\n foundMax = true\n }\n }\n result := \"Correct\"\n if !foundMin && !foundMax && total-found == 1 {\n result = \"Incorrect\"\n }\n writer.WriteString(fmt.Sprintf(\"%s\\n\", result))\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n total, found, min, max := getI(), getI(), getI(), getI()\n foundMin, foundMax := false, false\n for i := 0; i < found; i++ {\n x := getI()\n if x == min {\n foundMin = true\n } else if x == max {\n foundMax = true\n }\n }\n result := \"Correct\"\n if !foundMin && !foundMax && total-found == 1 {\n result = \"Incorrect\"\n }\n writer.WriteString(fmt.Sprintf(\"%s\\n\", result))\n}\n"}], "src_uid": "99f9cdc85010bd89434f39b78f15b65e"} {"nl": {"description": "Iahub is training for the IOI. What is a better way to train than playing a Zuma-like game? There are n balls put in a row. Each ball is colored in one of k colors. Initially the row doesn't contain three or more contiguous balls with the same color. Iahub has a single ball of color x. He can insert his ball at any position in the row (probably, between two other balls). If at any moment there are three or more contiguous balls of the same color in the row, they are destroyed immediately. This rule is applied multiple times, until there are no more sets of 3 or more contiguous balls of the same color. For example, if Iahub has the row of balls [black, black, white, white, black, black] and a white ball, he can insert the ball between two white balls. Thus three white balls are destroyed, and then four black balls become contiguous, so all four balls are destroyed. The row will not contain any ball in the end, so Iahub can destroy all 6 balls.Iahub wants to destroy as many balls as possible. You are given the description of the row of balls, and the color of Iahub's ball. Help Iahub train for the IOI by telling him the maximum number of balls from the row he can destroy.", "input_spec": "The first line of input contains three integers: n (1 ≤ n ≤ 100), k (1 ≤ k ≤ 100) and x (1 ≤ x ≤ k). The next line contains n space-separated integers c1, c2, ..., cn (1 ≤ ci ≤ k). Number ci means that the i-th ball in the row has color ci. It is guaranteed that the initial row of balls will never contain three or more contiguous balls of the same color. ", "output_spec": "Print a single integer — the maximum number of balls Iahub can destroy.", "sample_inputs": ["6 2 2\n1 1 2 2 1 1", "1 1 1\n1"], "sample_outputs": ["6", "0"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"flag\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"strconv\"\n\t\"time\"\n)\n\n// ******************************** CODE STARTS ********************************\n\nvar ()\n\nfunc getAns(array []int) int {\n\t// logln(\"lol\")\n\t// logln(array)\n\tn := len(array)\n\tres := 0\n\tfor {\n\t\tcount := 0\n\t\tleft := -1\n\t\tsum := -1\n\n\t\tfor i := 0; i < n; i++ {\n\t\t\tif array[i] == -1 {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tleft = i\n\t\t\tsum = 1\n\t\t\tbreak\n\t\t}\n\n\t\tif left != -1 {\n\t\t\tfor j := left + 1; j < n; j++ {\n\t\t\t\tif array[j] == -1 {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tif array[left] == array[j] {\n\t\t\t\t\tsum++\n\t\t\t\t} else {\n\t\t\t\t\tif sum >= 3 {\n\t\t\t\t\t\tfor i := left; i < j; i++ {\n\t\t\t\t\t\t\tarray[i] = -1\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcount = sum\n\t\t\t\t\t\tsum = 0\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\n\t\t\t\t\tleft = j\n\t\t\t\t\tsum = 1\n\t\t\t\t}\n\t\t\t\t// logln(array)\n\t\t\t}\n\n\t\t\tif sum >= 3 {\n\t\t\t\tfor i := left; i < n; i++ {\n\t\t\t\t\tarray[i] = -1\n\t\t\t\t}\n\t\t\t\tcount = sum\n\t\t\t}\n\t\t\t// logln(array)\n\t\t}\n\n\t\tif count == 0 {\n\t\t\tbreak\n\t\t}\n\t\tres += count\n\t\tcount = 0\n\t}\n\treturn res - 1\n}\n\nfunc solve() {\n\tn := readInt()\n\t_ = readInt()\n\tx := readInt()\n\tarray := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tarray[i] = readInt()\n\t}\n\n\tbest := 0\n\tfor j := 0; j <= n; j++ {\n\t\tvar newArray []int\n\t\tif j > 0 {\n\t\t\tnewArray = append(newArray, array[:j]...)\n\t\t}\n\t\tnewArray = append(newArray, x)\n\t\tif j < n {\n\t\t\tnewArray = append(newArray, array[j:]...)\n\t\t}\n\t\tbest = maxInt(best, getAns(newArray))\n\t}\n\tprintInt(best)\n\tprintLine()\n}\n\n// ********************************* CODE ENDS *********************************\n\n// IO.\n\nvar (\n\tscanner *bufio.Scanner\n\twriter *bufio.Writer\n\tlogger *log.Logger\n)\n\nfunc main() {\n\tlocal := flag.Bool(\"local\", false, \"Equals true, if run is local.\")\n\tflag.Parse()\n\n\tvar (\n\t\tinput *os.File\n\t\toutput *os.File\n\t)\n\n\tif *local {\n\t\tstartTime := time.Now()\n\t\tdefer func() {\n\t\t\tprintln(fmt.Sprintf(\"Time: %.5fs\", time.Since(startTime).Seconds()))\n\t\t}()\n\t\tinput, _ = os.Open(\"/home/outside/coding/workspace/go/io/input.txt\")\n\t\toutput, _ = os.Create(\"/home/outside/coding/workspace/go/io/output.txt\")\n\t\tlogger = log.New(output, \"log: \", 0)\n\t} else {\n\t\tinput = os.Stdin\n\t\toutput = os.Stdout\n\t\t// input, _ = os.Open(\"\")\n\t\t// output, _ = os.Create(\"\")\n\t}\n\tdefer input.Close()\n\tdefer output.Close()\n\n\tscanner = bufio.NewScanner(input)\n\tscanner.Split(bufio.ScanWords)\n\n\twriter = bufio.NewWriter(output)\n\tdefer writer.Flush()\n\n\tsolve()\n}\n\n// Read.\n\nfunc readString() string {\n\tscanner.Scan()\n\tans := scanner.Text()\n\treturn ans\n}\n\nfunc readLine() string {\n\tscanner.Split(bufio.ScanLines)\n\tdefer scanner.Split(bufio.ScanWords)\n\treturn readString()\n}\n\nfunc readInt() int {\n\tans, _ := strconv.ParseInt(readString(), 10, 0)\n\treturn int(ans)\n}\n\nfunc readInt64() int64 {\n\tans, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn ans\n}\n\nfunc readFloat64() float64 {\n\tans, _ := strconv.ParseFloat(readString(), 64)\n\treturn ans\n}\n\n// Write.\n\nfunc printString(value string) {\n\twriter.WriteString(value)\n}\n\nfunc printLine() {\n\tprintString(\"\\n\")\n}\n\nfunc printInt(value int) {\n\tprintString(strconv.FormatInt(int64(value), 10))\n}\n\nfunc printInt64(value int64) {\n\tprintString(strconv.FormatInt(value, 10))\n}\n\nfunc printFLoat64(value float64) {\n\tprintString(strconv.FormatFloat(value, 'f', 20, 64))\n}\n\n// Log.\n\nfunc logln(value ...interface{}) {\n\twriter.Flush()\n\tlogger.Println(value...)\n}\nfunc logf(format string, value ...interface{}) {\n\twriter.Flush()\n\tlogger.Printf(format, value...)\n}\n\n// Tuple\n\ntype Tuple struct {\n\ta, b int\n}\n\nfunc (p Tuple) Equals(key Key) bool {\n\treturn p.a == key.(Tuple).a\n}\n\nfunc (p Tuple) Less(key Key) bool {\n\treturn p.a < key.(Tuple).a\n}\n\ntype TupleSlice []Tuple\n\nfunc (p TupleSlice) Len() int {\n\treturn len(p)\n}\n\nfunc (p TupleSlice) Less(j, i int) bool {\n\treturn p[j].a < p[i].a\n}\n\nfunc (p TupleSlice) Swap(j, i int) {\n\tp[j], p[i] = p[i], p[j]\n}\n\n// Min, max, abs.\n\nfunc maxInt(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc minInt(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc absInt(a int) int {\n\tif a > 0 {\n\t\treturn a\n\t} else {\n\t\treturn -a\n\t}\n}\n\nfunc maxInt64(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc minInt64(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc absInt64(a int64) int64 {\n\tif a > 0 {\n\t\treturn a\n\t} else {\n\t\treturn -a\n\t}\n}\n\nfunc maxFloat64(a, b float64) float64 {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc minFloat64(a, b float64) float64 {\n\tif a < b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc absFloat64(a float64) float64 {\n\tif a > 0 {\n\t\treturn a\n\t} else {\n\t\treturn -a\n\t}\n}\n\n// Set Key interface implementations.\n\ntype Int int\n\nfunc (p Int) Equals(key Key) bool {\n\treturn int(p) == int(key.(Int))\n}\n\nfunc (p Int) Less(key Key) bool {\n\treturn int(p) < int(key.(Int))\n}\n\n// Set.\n\ntype Key interface {\n\tEquals(key Key) bool\n\tLess(key Key) bool\n}\n\ntype node struct {\n\tkey Key\n\tleft *node\n\tright *node\n}\n\nfunc newNode(key Key) *node {\n\treturn &node{key, nil, nil}\n}\n\ntype SplayTree struct {\n\troot *node\n\ttmp *node\n\tlen int\n}\n\nfunc NewSplayTree() *SplayTree {\n\treturn &SplayTree{nil, newNode(nil), 0}\n}\n\nfunc rotateLeft(x, p *node) {\n\tp.right = x.left\n\tx.left = p\n}\n\nfunc rotateRight(x, p *node) {\n\tp.left = x.right\n\tx.right = p\n}\n\nfunc (p *SplayTree) splay(x *node, key Key) *node {\n\tif x == nil {\n\t\treturn nil\n\t}\n\n\tleft := p.tmp\n\tright := p.tmp\n\n\tfor {\n\t\tif key.Less(x.key) {\n\t\t\ty := x.left\n\t\t\tif y == nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif key.Less(y.key) { // zig-zig\n\t\t\t\trotateRight(y, x)\n\t\t\t\tx = y\n\t\t\t\tif x.left == nil {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\t// link right\n\t\t\tright.left = x\n\t\t\tright = x\n\t\t\t// move left\n\t\t\tx = x.left\n\t\t} else if x.key.Less(key) {\n\t\t\ty := x.right\n\t\t\tif y == nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif y.key.Less(key) { // zig-zig\n\t\t\t\trotateLeft(y, x)\n\t\t\t\tx = y\n\t\t\t\tif x.right == nil {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\t// link left\n\t\t\tleft.right = x\n\t\t\tleft = x\n\t\t\t// move right\n\t\t\tx = x.right\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tleft.right = x.left\n\tright.left = x.right\n\tx.left = p.tmp.right\n\tx.right = p.tmp.left\n\n\treturn x\n}\n\n// left <= key < right\nfunc (p *SplayTree) split(key Key) (left, right *node) {\n\tp.root = p.splay(p.root, key)\n\tif p.root.key.Equals(key) || p.root.key.Less(key) {\n\t\tright := p.root.right\n\t\tp.root.right = nil\n\t\treturn p.root, right\n\t} else {\n\t\tleft := p.root.left\n\t\tp.root.left = nil\n\t\treturn left, p.root\n\t}\n}\n\n// keys from left tree must be less then keys from right tree\nfunc (p *SplayTree) join(left, right *node) *node {\n\tif left == nil {\n\t\treturn right\n\t} else if right == nil {\n\t\treturn left\n\t}\n\tleft = p.splay(left, right.key)\n\tleft.right = right\n\treturn left\n}\n\ntype Set interface {\n\tLen() int\n\tInsert(key Key) error\n\tFind(key Key) bool\n\tRemove(key Key) error\n}\n\nfunc NewSet() Set {\n\treturn Set(NewSplayTree())\n}\n\nfunc (p *SplayTree) Len() int {\n\treturn p.len\n}\n\nfunc (p *SplayTree) Insert(key Key) error {\n\tif p.root == nil {\n\t\tp.root = newNode(key)\n\t\tp.len++\n\t} else {\n\t\tp.root = p.splay(p.root, key)\n\t\tif p.root.key.Equals(key) {\n\t\t\treturn errors.New(\"Such key already exists\")\n\t\t} else {\n\t\t\tleft, right := p.split(key)\n\t\t\tp.root = newNode(key)\n\t\t\tp.root.left = left\n\t\t\tp.root.right = right\n\t\t\tp.len++\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (p *SplayTree) Find(key Key) bool {\n\tif p.root == nil {\n\t\treturn false\n\t}\n\tp.root = p.splay(p.root, key)\n\treturn p.root.key.Equals(key)\n}\n\nfunc (p *SplayTree) Remove(key Key) error {\n\tp.root = p.splay(p.root, key)\n\tif p.root == nil || !p.root.key.Equals(key) {\n\t\treturn errors.New(\"Such key doesn't exist\")\n\t}\n\tp.root = p.join(p.split(key))\n\treturn nil\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\n// Retorna slice de slices com as duplas retiradas.\nfunc possiveisJogadas(row []int, num int, x int) [][]int {\n\tduplas := make([][2]int, 0)\n\n\tfor i := 0; i+1 <= num-1; i++ {\n\t\tif row[i] == x && row[i] == row[i+1] {\n\t\t\tduplas = append(duplas, [2]int{i, i + 1})\n\t\t}\n\t}\n\n\tpossibilidades := make([][]int, len(duplas))\n\n\tfor i, v := range duplas {\n\t\tcopia := make([]int, num)\n\t\tcopy(copia, row)\n\t\tx, y := v[0], v[1]\n\n\t\tpossibilidades[i] = append(copia[:x], copia[y+1:]...)\n\n\t}\n\n\treturn possibilidades\n}\n\n// Remove um range de um array. [x, y] != [x, y)\nfunc removerElementos(row *[]int, x, y int) {\n\t*row = append((*row)[:x], (*row)[y+1:]...)\n}\n\nfunc limparRow(row []int) []int {\n\ti := 1\n\tgrupo := 1\n\tgrupoAchado := false\n\tfor {\n\t\tif i >= len(row) {\n\t\t\tif grupo >= 3 {\n\t\t\t\tremoverElementos(&row, i-grupo, i-1)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\n\t\tif row[i] == row[i-1] {\n\t\t\tgrupo++\n\t\t\tif grupo >= 3 {\n\t\t\t\tgrupoAchado = true\n\t\t\t}\n\t\t} else {\n\t\t\tif grupoAchado {\n\t\t\t\tremoverElementos(&row, i-grupo, i-1)\n\t\t\t\ti = 0\n\t\t\t\tgrupoAchado = false\n\n\t\t\t}\n\t\t\tgrupo = 1\n\t\t}\n\n\t\ti++\n\t}\n\n\treturn row\n}\n\nfunc main() {\n\t// len(row), num de cores, cor escolhida pelo player.\n\tvar num, k, x int\n\tfmt.Scan(&num, &k, &x)\n\n\t// Criar slice que representa a row.\n\trow := make([]int, num)\n\tfor i := 0; i < num; i++ {\n\t\tfmt.Scan(&row[i])\n\t}\n\n\t// Copia e algoritmos.\n\tjogadas := possiveisJogadas(row, num, x)\n\n\tmaior := 0\n\tfor _, jogada := range jogadas {\n\t\tcont := num - len(limparRow(jogada))\n\t\tif cont > maior {\n\t\t\tmaior = cont\n\t\t}\n\t}\n\tfmt.Println(maior)\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\n// Retorna slice de slices com as duplas retiradas.\nfunc possiveisJogadas(row []int, num int, x int) [][]int {\n\tduplas := make([][2]int, 0)\n\n\tfor i := 0; i+1 <= num-1; i++ {\n\t\tif row[i] == x && row[i] == row[i+1] {\n\t\t\tduplas = append(duplas, [2]int{i, i + 1})\n\t\t}\n\t}\n\n\tpossibilidades := make([][]int, len(duplas))\n\n\tfor i, v := range duplas {\n\t\tcopia := make([]int, num)\n\t\tcopy(copia, row)\n\t\tx, y := v[0], v[1]\n\n\t\tpossibilidades[i] = append(copia[:x], copia[y+1:]...)\n\n\t}\n\n\treturn possibilidades\n}\n\n// Remove um range de um array. [x, y] != [x, y)\nfunc removerElementos(row *[]int, x, y int) {\n\t*row = append((*row)[:x], (*row)[y+1:]...)\n}\n\nfunc limparRow(row []int) []int {\n\ti := 1\n\tgrupo := 1\n\tgrupoAchado := false\n\tfor {\n\t\tif i >= len(row) {\n\t\t\tif grupo >= 3 {\n\t\t\t\tremoverElementos(&row, i-grupo, i-1)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\n\t\tif row[i] == row[i-1] {\n\t\t\tgrupo++\n\t\t\tif grupo >= 3 {\n\t\t\t\tgrupoAchado = true\n\t\t\t}\n\t\t} else {\n\t\t\tif grupoAchado {\n\t\t\t\tremoverElementos(&row, i-grupo, i-1)\n\t\t\t\ti = 0\n\t\t\t\tgrupoAchado = false\n\n\t\t\t}\n\t\t\tgrupo = 1\n\t\t}\n\n\t\ti++\n\t}\n\n\treturn row\n}\n\nfunc main() {\n\t// len(row), num de cores, cor escolhida pelo player.\n\tvar num, k, x int\n\tfmt.Scan(&num, &k, &x)\n\n\t// Criar slice que representa a row.\n\trow := make([]int, num)\n\tfor i := 0; i < num; i++ {\n\t\tfmt.Scan(&row[i])\n\t}\n\n\t// Copia e algoritmos.\n\tjogadas := possiveisJogadas(row, num, x)\n\tif len(jogadas) == 0 {\n\t\tfmt.Println(0)\n\t}\n\n\tmaior := 0\n\tfor _, jogada := range jogadas {\n\t\tcont := num - len(limparRow(jogada))\n\t\tif cont > maior {\n\t\t\tmaior = cont\n\t\t}\n\t}\n\tfmt.Println(maior)\n}\n"}], "src_uid": "d73d9610e3800817a3109314b1e6f88c"} {"nl": {"description": "Igor K. always used to trust his favorite Kashpirovsky Antivirus. That is why he didn't hesitate to download the link one of his groupmates sent him via QIP Infinium. The link was said to contain \"some real funny stuff about swine influenza\". The antivirus had no objections and Igor K. run the flash application he had downloaded. Immediately his QIP Infinium said: \"invalid login/password\".Igor K. entered the ISQ from his additional account and looked at the info of his main one. His name and surname changed to \"H1N1\" and \"Infected\" correspondingly, and the \"Additional Information\" field contained a strange-looking binary code 80 characters in length, consisting of zeroes and ones. \"I've been hacked\" — thought Igor K. and run the Internet Exploiter browser to quickly type his favourite search engine's address.Soon he learned that it really was a virus that changed ISQ users' passwords. Fortunately, he soon found out that the binary code was actually the encrypted password where each group of 10 characters stood for one decimal digit. Accordingly, the original password consisted of 8 decimal digits.Help Igor K. restore his ISQ account by the encrypted password and encryption specification.", "input_spec": "The input data contains 11 lines. The first line represents the binary code 80 characters in length. That is the code written in Igor K.'s ISQ account's info. Next 10 lines contain pairwise distinct binary codes 10 characters in length, corresponding to numbers 0, 1, ..., 9.", "output_spec": "Print one line containing 8 characters — The password to Igor K.'s ISQ account. It is guaranteed that the solution exists.", "sample_inputs": ["01001100100101100000010110001001011001000101100110010110100001011010100101101100\n0100110000\n0100110010\n0101100000\n0101100010\n0101100100\n0101100110\n0101101000\n0101101010\n0101101100\n0101101110", "10101101111001000010100100011010101101110010110111011000100011011110010110001000\n1001000010\n1101111001\n1001000110\n1010110111\n0010110111\n1101001101\n1011000001\n1110010101\n1011011000\n0110001000"], "sample_outputs": ["12345678", "30234919"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var pass,code string\n fmt.Scan(&pass)\n digit := make(map[string]int)\n for i := 0; i < 10; i++ {\n fmt.Scan(&code)\n digit[code] = i\n }\n for i := 0; i < 8; i++ {\n a := pass[i*10:(i+1)*10]\n fmt.Print(digit[a])\n }\n fmt.Println()\n}\n"}, {"source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nfunc scanInt(scanner *bufio.Scanner) int {\n scanner.Scan()\n x, _ := strconv.Atoi(scanner.Text())\n return x\n}\n\nfunc main() {\n scanner := bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n scanner.Scan()\n code := scanner.Text()\n digits := map[string]int{}\n for i := 0; i < 10; i++ {\n scanner.Scan()\n digits[scanner.Text()] = i\n }\n for i := 0; i < 8; i++ {\n digit := digits[code[10*i:10*(i+1)]] \n writer.WriteString(fmt.Sprintf(\"%d\", digit))\n }\n writer.WriteString(\"\\n\")\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var pass,code string\n fmt.Scan(&pass)\n digit := make(map[string]int)\n for i := 0; i < 10; i++ {\n fmt.Scan(&code)\n digit[code] = i\n }\n for i := 0; i < 8; i++ {\n a := pass[i*10:(i+1)*10]\n fmt.Print(digit[a])\n }\n fmt.Println()\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var pass,code string\n fmt.Scan(&pass)\n digit := make(map[string]int)\n for i := 0; i < 10; i++ {\n fmt.Scan(&code)\n digit[code] = i\n }\n for i := 0; i < 8; i++ {\n a := pass[i*10:(i+1)*10]\n fmt.Print(digit[a])\n }\n fmt.Println()\n}\n"}], "negative_code": [], "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9"} {"nl": {"description": "One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem.Pete and Billy are great fans of even numbers, that's why they want to divide the watermelon in such a way that each of the two parts weighs even number of kilos, at the same time it is not obligatory that the parts are equal. The boys are extremely tired and want to start their meal as soon as possible, that's why you should help them and find out, if they can divide the watermelon in the way they want. For sure, each of them should get a part of positive weight.", "input_spec": "The first (and the only) input line contains integer number w (1 ≤ w ≤ 100) — the weight of the watermelon bought by the boys.", "output_spec": "Print YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case.", "sample_inputs": ["8"], "sample_outputs": ["YES"], "notes": "NoteFor example, the boys can divide the watermelon into two parts of 2 and 6 kilos respectively (another variant — two parts of 4 and 4 kilos)."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar w int\n\tfmt.Scanf(\"%d\", &w)\n\tif w <= 2 {\n\t\tfmt.Println(\"NO\")\n\t} else if w % 2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n \nimport (\n \"os\"\n \"fmt\"\n \"bufio\"\n \"strconv\"\n \"strings\"\n)\n \nfunc prErr(err error) {\n if err != nil {\n fmt.Println(err)\n } \n}\n \nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n text, err := reader.ReadString('\\n')\n prErr(err)\n text = strings.TrimSuffix(text, \"\\r\\n\")\n \n w, err := strconv.Atoi(text)\n prErr(err)\n \n if w!=2 && w%2 == 0 {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}"}, {"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 w uint8\n\tfmt.Fscanf(in, \"%d\\n\", &w)\n\tif w == 2 {\n\t\tfmt.Println(\"NO\")\n\t}else if w % 2 == 0{\n\t\tfmt.Println(\"YES\")\n\t}else{\n\t\tfmt.Println(\"NO\")\n\t}\n} \n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar input int64\n\tfmt.Scanln(&input)\n if input < 3 {\n fmt.Println(\"NO\")\n return\n }\n input -= 2\n if input % 2 == 0 {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n"}, {"source_code": "package main\nimport (\n\t\t\"fmt\"\n\t\t)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tif n > 2 && n % 2 == 0 {\n\t\tfmt.Print(\"YES\")\n\t} else {\n\t\tfmt.Print(\"NO\")\n\t}\n\treturn\n}\n"}, {"source_code": "package main;import\"fmt\";func main(){var a int8;fmt.Scan(&a);if(a&1==1||a==2){fmt.Print(\"NO\")}else{fmt.Print(\"YES\")}}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\tif n == 2 || n%2 == 1 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tfor scanner.Scan() {\n\t\tw, _ := strconv.Atoi(scanner.Text())\n\t\tyes := false\n\t\tfor i := 2; i < w; i += 2 {\n\t\t\tif (w-i)%2 == 0 {\n\t\t\t\tyes = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif yes {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar input int64\n\tfmt.Scanln(&input)\n if input < 3 {\n fmt.Println(\"NO\")\n return\n }\n input -= 2\n if input % 2 == 0 {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar weight,modulo int\n\tvar flag bool\n\tfmt.Scanf(\"%d\", &weight)\n\tif weight > 0 && weight < 101 {\n\t\tfor loop := 2; loop < 101 ; loop=loop+2 {\n\t\t\tmodulo = weight - loop \n\t\t\tif modulo < 2 { break }\n\t\t\tif modulo % 2 == 0 {\n\t\t\t\tflag = true\n\t\t\t}else{\n\t\t\t\tflag = false\n\t\t\t}\n\t\t}\n\t}\n\tif flag {\n\t\tfmt.Println(\"YES\")\n\t}else{\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tw := 0\n\tfmt.Scanf(\"%d\", &w)\n\tif w != 2 && w%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\nvar i int \n fmt.Scanf(\"%d\", &i);\n if i > 2 && i% 2 == 0{\n fmt.Print(\"YES\");\n }else{\nfmt.Print(\"NO\");\n }\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n// http://codeforces.com/problemset/problem/4/A\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _ := reader.ReadString('\\n')\n\ttext = strings.TrimSuffix(text, \"\\r\\n\")\n\tw, _ := strconv.ParseInt(text, 10, 8)\n\tif ( w > 2 && ((w-2)%2 == 0) ) {\n\t\tfmt.Printf(\"YES\")\n\t} else {\n\t\tfmt.Printf(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar w int\n\tfmt.Scanf(\"%d\\n\", &w)\n\t// even\n\tif w%2 == 0 && w != 2 {\n\t\tfmt.Printf(\"YES\")\n\t} else {\n\t\tfmt.Printf(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar weight int\n\n\tfmt.Scanf(\"%d\\n\", &weight)\n\n\tif weight == 2 {\n\t\tfmt.Printf(\"NO\\n\")\n\t} else if weight%2 == 0 {\n\t\tfmt.Printf(\"YES\\n\")\n\t} else {\n\t\tfmt.Printf(\"NO\\n\")\n\t}\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n\n var w int\n fmt.Scan(&w)\n \n if w % 2 == 0 && w > 2{\n fmt.Print(\"YES\")\n return\n }\n fmt.Print(\"NO\")\n\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc task_solution(n int) string {\n\tif n > 3 && n%2 == 0 {\n\t\treturn \"YES\"\n\t}\n\treturn \"NO\"\n}\n\nfunc main() {\n\tvar n int\n\t_, err := fmt.Scan(&n)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(task_solution(n))\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar weight int\n\n\tfmt.Scanf(\"%d\\n\", &weight)\n\n\tif weight == 2 {\n\t\tfmt.Printf(\"NO\\n\")\n\t} else if weight%2 == 0 {\n\t\tfmt.Printf(\"YES\\n\")\n\t} else {\n\t\tfmt.Printf(\"NO\\n\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar weight,modulo int\n\tvar flag bool\n\tfmt.Scanf(\"%d\", &weight)\n\tif weight > 0 && weight < 101 {\n\t\tfor loop := 2; loop < 101 ; loop=loop+2 {\n\t\t\tmodulo = weight - loop \n\t\t\tif modulo < 2 { break }\n\t\t\tif modulo % 2 == 0 {\n\t\t\t\tflag = true\n\t\t\t}else{\n\t\t\t\tflag = false\n\t\t\t}\n\t\t}\n\t}\n\tif flag {\n\t\tfmt.Println(\"YES\")\n\t}else{\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var x int\n fmt.Scanf(\"%d\",&x)\n if(x%2 == 0 && x > 2){\n fmt.Print(\"YES\\n\")\n }else{\n fmt.Print(\"NO\\n\")\n }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\nvar i int \nvar two = 2;\n fmt.Scanf(\"%d\", &i);\n if i > two {\n if i% two == 0{\n fmt.Print(\"YES\");\n }else{\nfmt.Print(\"NO\");\n }\n }else{\nfmt.Print(\"NO\");\n }\n}"}, {"source_code": "package main\nimport (\n\t\"fmt\"\n\t)\nfunc main() {\n number := 0\n fmt.Scanf(\"%d\\n\", &number)\n if number > 2 && number % 2 == 0 {\n fmt.Println(\"YES\")\n }else{\n fmt.Println(\"NO\")\n }\n \n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tw := 0\n\tfmt.Scanf(\"%d\", &w)\n\tif w != 2 && w%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"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)\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\n\nfunc main() {\n\tvar a int\n\tscanf(\"%d\\n\", &a)\n\n\tif !(a % 2 == 0) || a == 2 {\n\t\tprintf(\"%s\", \"NO\")\n\t\twriter.Flush()\n\t\treturn\n\t}\n\n\tprintf(\"%s\", \"YES\")\n\n\twriter.Flush()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _ := reader.ReadString('\\n')\n\ttext = strings.Replace(text, \"\\r\\n\", \"\", -1)\n\n\tnumber, err := strconv.ParseInt(text, 10, 0)\n\n\tif err != nil {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\n\tif number > 100 || number < 1 {\n\t\tfmt.Println(\"NO\")\n\t}\n\n\tif number >= 4 && number%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc check(n int) int {\n\treturn n%2\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\",&n)\n\n\tif check(n) == 0 && n != 2 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar weight,modulo int\n\tvar flag bool\n\tfmt.Scanf(\"%d\", &weight)\n\tif weight > 0 && weight < 101 {\n\t\tfor loop := 2; loop < 101 ; loop=loop+2 {\n\t\t\tmodulo = weight - loop \n\t\t\tif modulo < 2 { break }\n\t\t\tif modulo % 2 == 0 {\n\t\t\t\tflag = true\n\t\t\t}else{\n\t\t\t\tflag = false\n\t\t\t}\n\t\t}\n\t}\n\tif flag {\n\t\tfmt.Println(\"YES\")\n\t}else{\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tkilos := 0\n\tfmt.Scanf(\"%d\", &kilos)\n\n\tif kilos%2 != 0 || kilos == 2 {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\n\tfmt.Println(\"YES\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tw, _ := strconv.Atoi(scanner.Text())\n\tfor i := 2; i < w; i += 2 {\n\t\tif (w-i)%2 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\n// main function\nfunc main() {\n\tvar temp int = 6\n\tfmt.Scanln(&temp)\n\tif temp < 4 {\n\t\tfmt.Print(\"NO\")\n\t\treturn\n\t} else if temp%2 == 0 {\n\t\tif (temp)%2 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "/* Problemset:\nA. Watermelon\ntime limit per test1 second\nmemory limit per test64 megabytes\ninputstandard input\noutputstandard output\nOne hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem.\n\nPete and Billy are great fans of even numbers, that's why they want to divide the watermelon in such a way that each of the two parts weighs even number of kilos, at the same time it is not obligatory that the parts are equal. The boys are extremely tired and want to start their meal as soon as possible, that's why you should help them and find out, if they can divide the watermelon in the way they want. For sure, each of them should get a part of positive weight.\n\nInput\nThe first (and the only) input line contains integer number w (1 ≤ w ≤ 100) — the weight of the watermelon bought by the boys.\n\nOutput\nPrint YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case.\n\nExamples\ninputCopy\n8\noutputCopy\nYES\nNote\nFor example, the boys can divide the watermelon into two parts of 2 and 6 kilos respectively (another variant — two parts of 4 and 4 kilos).\n\n---\n\nWhat we learned:\nCodeForces takes input with fmt.Scanf and not os.Args. 1 is an odd number of slices. Each submission shows the full results of tests, including input, in the submission number link.\n*/\n\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanln(&n)\n\tif n%2 != 0 {\n\t\tfmt.Println(\"NO\")\n\t} else if n <= 2 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar weight int\n\n\tfmt.Scanf(\"%d\\n\", &weight)\n\n\tif weight == 2 {\n\t\tfmt.Printf(\"NO\\n\")\n\t} else if weight%2 == 0 {\n\t\tfmt.Printf(\"YES\\n\")\n\t} else {\n\t\tfmt.Printf(\"NO\\n\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanln(&n)\n\n\tif n%2 == 0 && n != 2 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var w int\n\tfmt.Scanf(\"%d\", &w)\n\tif w != 2 && w%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar i float64\n\tfmt.Scan(&i)\n\tif math.Mod(i, 2) == 0 && i > 2 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\\n\", &n)\n\n\tif n%2 == 0 && n > 2 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "\n\n\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar w int\n\tfmt.Scanf(\"%d\\n\",&w)\n\n\tif w % 2 == 1 || w <= 2 {\n\t\tfmt.Println(\"No\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar x int\n\tfmt.Scanf(\"%d\", &x)\n\tif x % 2 == 1 || x == 2 {\n\t\tif x > 2 && (x - 2) % 2 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t} else if x > 2 {\n\t\tfmt.Println(\"YES\")\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar number uint8\n\t_, _ = fmt.Scanln(&number)\n\tif number == 2 {\n\t\tfmt.Println(\"NO\")\n\t} else if number%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\nimport (\n \"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\nvar scanner = bufio.NewScanner(os.Stdin)\n\nfunc readInt() int {\n scanner.Scan()\n ret, _ := strconv.Atoi(scanner.Text())\n return ret\n}\n\nfunc main(){\n scanner.Split(bufio.ScanWords)\n n := readInt();\n if n % 2 == 0 {\n if (n > 2){\n fmt.Println(\"YES\")\n }else{\n fmt.Println(\"NO\")\n }\n }else{\n fmt.Println(\"NO\") \n }\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar k uint8\n\tfmt.Scanln(&k)\n\tif k == 2 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tif k%2 != 0 {\n\t\t\tfmt.Println(\"NO\")\n\t\t} else {\n\t\t\tfmt.Println(\"yes\")\n\t\t}\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\n\n\nfunc main() {\n\n var w int\n fmt.Scan(&w)\n \n for i := 1; i < w; i++ {\n \n if (w-i) % 2 == 0 && w % 2 == 0 {\n fmt.Print(\"YES\")\n return\n }\n }\n fmt.Print(\"NO\")\n\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\n// THIS WAS JUST TO TEST IF CODEFORCES UNDERSTAND GOLANG\n\n/*\nOne hot summer day Pete and his friend Billy decided to buy a watermelon.\nhey chose the biggest and the ripest one, in their opinion.\nAfter that the watermelon was weighed, and the scales showed w kilos.\nThey rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem.\n\nPete and Billy are great fans of even numbers,\nthat's why they want to divide the watermelon in such a way that each of the two parts weighs even number of kilos,\nat the same time it is not obligatory that the parts are equal.\nThe boys are extremely tired and want to start their meal as soon as possible\nthat's why you should help them and find out, if they can divide the watermelon in the way they want.\nFor sure, each of them should get a part of positive weight.\n\n\nInput\nThe first (and the only) input line contains integer number w (1 ≤ w ≤ 100) — the weight of the watermelon bought by the boys.\nOutput\nPrint YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case.\n*/\n\nfunc main() {\n\tvar number int\n\n\t_, err := fmt.Scanf(\"%d\", &number)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tcanDevide(number)\n\n}\n\nfunc canDevide(number int) {\n\tif number == 2 || number%2 != 0 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc main() {\n\t// The weight of watermelon\n\tvar w int\n\tscanf(\"%d\\n\", &w)\n\n\tvar b bool = false\n\tif w <= 2 {\n\t\tb = false\n\t} else if w%2 == 0 {\n\t\tb = true\n\t} else {\n\t\tb = false\n\t}\n\n\t// Display result\n\tif b {\n\t\tprintf(\"YES\\n\")\n\t} else {\n\t\tprintf(\"NO\\n\")\n\t}\n\n\twriter.Flush()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\n\ts := bufio.NewScanner(os.Stdin)\n\ts.Scan()\n\tw, _ := strconv.Atoi(s.Text())\n\n\tif w <= 100 {\n\t\tif w >= 1 {\n\t\t\tif w%2 == 0 {\n\t\t\t\tif w == 2 {\n\t\t\t\t\tfmt.Println(\"NO\")\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t}\n\t\t}\n\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar w int64\n\tfmt.Scan(&w)\n\n\tif w&1 == 1 || w == 2 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n"}, {"source_code": "//rextester.com:1.6.2--codeforces.com:1.8\npackage main;import\"fmt\"\nfunc main(){var a int8;fmt.Scan(&a);if(a&1==1||a==2){fmt.Print(\"NO\")}else{fmt.Print(\"YES\")}}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\n\n\nfunc main() {\n\n var w int\n fmt.Scan(&w)\n \n for i := 1; i < w; i++ {\n other := w-i\n if other % 2 == 0 && w % 2 == 0 {\n fmt.Print(\"YES\")\n return\n }\n }\n fmt.Print(\"NO\")\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar w int\n\tfmt.Scanf(\"%d\", &w)\n\n\tif w == 1 {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tfor i := 2; i <= w/2; i++ {\n\t\tif w%i == 0 && w%2 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar w int\n\tfmt.Scanf(\"%d\\n\", &w)\n\t// even\n\tif w%2 == 0 && w != 2 {\n\t\tfmt.Printf(\"YES\")\n\t} else {\n\t\tfmt.Printf(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\nimport \"fmt\"\nfunc main() {\n var w int\n fmt.Scan(&w)\n if w%2 == 0 && w > 2 {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar k uint8\n\tfmt.Scanln(&k)\n\tif k == 2 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tif k%2 != 0 {\n\t\t\tfmt.Println(\"NO\")\n\t\t} else {\n\t\t\tfmt.Println(\"yes\")\n\t\t}\n\t}\n\n}\n"}, {"source_code": "package main\n \nimport (\n \"os\"\n \"fmt\"\n \"bufio\"\n \"strconv\"\n \"strings\"\n)\n \nfunc prErr(err error) {\n if err != nil {\n fmt.Println(err)\n } \n}\n \nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n text, err := reader.ReadString('\\n')\n prErr(err)\n text = strings.TrimSuffix(text, \"\\r\\n\")\n \n w, err := strconv.Atoi(text)\n prErr(err)\n \n if !(w==0 || w==2) && w%2 == 0 {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}"}, {"source_code": "/* Problemset:\nA. Watermelon\ntime limit per test1 second\nmemory limit per test64 megabytes\ninputstandard input\noutputstandard output\nOne hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem.\n\nPete and Billy are great fans of even numbers, that's why they want to divide the watermelon in such a way that each of the two parts weighs even number of kilos, at the same time it is not obligatory that the parts are equal. The boys are extremely tired and want to start their meal as soon as possible, that's why you should help them and find out, if they can divide the watermelon in the way they want. For sure, each of them should get a part of positive weight.\n\nInput\nThe first (and the only) input line contains integer number w (1 ≤ w ≤ 100) — the weight of the watermelon bought by the boys.\n\nOutput\nPrint YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case.\n\nExamples\ninputCopy\n8\noutputCopy\nYES\nNote\nFor example, the boys can divide the watermelon into two parts of 2 and 6 kilos respectively (another variant — two parts of 4 and 4 kilos).\n\n---\n\nWhat we learned:\nCodeForces takes input with fmt.Scanf and not os.Args. 1 is an odd number of slices. Each submission shows the full results of tests, including input, in the submission number link.\n*/\n\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanln(&n)\n\tif n%2 != 0 {\n\t\tfmt.Println(\"NO\")\n\t} else if n <= 2 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar weight int\n\treader := bufio.NewReader(os.Stdin)\n\t// Carriage return\n\tif w, err := reader.ReadString('\\n'); err == nil {\n\t\ts := w[:len(w)-2]\n\t\tif r, err := strconv.Atoi(s); err == nil {\n\t\t\tweight = r\n\t\t} else {\n\t\t\tpanic(err)\n\t\t}\n\t} else {\n\t\tpanic(err)\n\t}\n\tif weight == 2 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tif weight % 2 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar input int64\n\tfmt.Scanln(&input)\n if input < 3 {\n fmt.Println(\"NO\")\n return\n }\n input -= 2\n if input % 2 == 0 {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n"}, {"source_code": "package main\n\nimport (\n \"io\"\n \"strings\"\n \"bytes\"\n \"os\"\n \"fmt\"\n)\n\ntype contestIn struct {\n\treader io.Reader\n}\n\ntype contestOut struct {\n\twriter io.Writer\n}\n\ntype Contest struct {\n\tIn contestIn\n\tOut contestOut\n}\n\nfunc NewSubmitContest() Contest {\n\treturn Contest{contestIn{os.Stdin}, contestOut{os.Stdout}}\n}\n\nfunc NewTestContest(testIn string, testOut *bytes.Buffer) Contest {\n\treturn Contest{contestIn{strings.NewReader(testIn)}, contestOut{testOut}}\n}\n\nfunc (in contestIn) Var(a interface{}) {\n\tfmt.Fscan(in.reader, a)\n}\n\nfunc (in contestIn) Vars(a interface{}) {\n\tfmt.Fscanln(in.reader, a)\n}\n\nfunc (in contestIn) Ints(len int) []int {\n\tarr := make([]int, 0, len)\n\tfor ; len > 0; len-- {\n\t\tvar i int\n\t\tin.Var(&i)\n\t\tarr = append(arr, i)\n\t}\n\n\treturn arr\n}\n\nfunc (out contestOut) Str(s string) {\n\tfmt.Fprintf(out.writer, \"%s\", s)\n}\n\nfunc (out contestOut) Nl() {\n\tfmt.Fprintln(out.writer)\n}\n\n// http://codeforces.com/problemset/problem/4/A\nfunc problem(c Contest) {\n\tvar w int\n\tc.In.Var(&w)\n\n\tif (w > 2) && (w % 2 == 0) {\n\t\tc.Out.Str(\"YES\")\n\t} else {\n\t\tc.Out.Str(\"NO\")\n\t}\n\n\tc.Out.Nl()\n}\n\nfunc main() {\n\tc := NewSubmitContest()\n\tproblem(c)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar number int\n\t_, err := fmt.Scanf(\"%d\", &number)\n\tif err != nil {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\n\tif number < 1 || number > 100 {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tif number == 2 {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tif number%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\n}\n"}, {"source_code": "// test\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\n\tvar a int\n\tfmt.Scanln(&a)\n\t//for a = 1; a <= 100; a++ {\n\t//\tfmt.Printf(\"%d: \", a)\n\tif a%2 == 1 {\n\t\tfmt.Println(\"NO\")\n\t} else if a/2 < 2 {\n\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n\t//}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a int\n\tfmt.Scanf(\"%d\", &a)\n\tif a > 2 && a%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t// \"bufio\"\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _, _ := reader.ReadLine()\n\n\tstr := string(text)\n\n\tatt1, _ := strconv.ParseInt(str, 10, 0)\n\tif att1%2 == 0 && att1 != 2 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}\n "}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar number int\n\t_, err := fmt.Scanf(\"%d\", &number)\n\tif err != nil {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\n\tif number < 1 || number > 100 {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tif number == 2 {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tif number%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar weight int\n\n\tfmt.Scanf(\"%d\\n\", &weight)\n\n\tif weight == 2 {\n\t\tfmt.Printf(\"NO\\n\")\n\t} else if weight%2 == 0 {\n\t\tfmt.Printf(\"YES\\n\")\n\t} else {\n\t\tfmt.Printf(\"NO\\n\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tnumber := -1\n\t_, err := fmt.Scanln(&number)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif number > 3 && (number%2) == 0 {\n\t\tfmt.Print(\"YES\")\n\t} else {\n\t\tfmt.Print(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n )\n\nfunc main() {\n var kilos int = 0\n fmt.Scan(&kilos)\n if kilos > 2 && kilos%2 == 0 {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n \n}"}, {"source_code": "package main\nimport \"fmt\"\nfunc main() {\n\tvar w int\n\tfmt.Scan(&w)\n\tif w%2 == 0 && w > 2 {\n fmt.Println(\"YES\")\n\t} else {\n fmt.Println(\"NO\")\n\t}\n}"}, {"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)\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\n\nfunc main() {\n\tvar a int\n\tscanf(\"%d\\n\", &a)\n\n\tif !(a % 2 == 0) || a == 2 {\n\t\tprintf(\"%s\", \"NO\")\n\t\twriter.Flush()\n\t\treturn\n\t}\n\n\tprintf(\"%s\", \"YES\")\n\n\twriter.Flush()\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var i int\n _, err := fmt.Scanf(\"%d\", &i)\n if err != nil {fmt.Println(err)}\n if (i%2 == 0) && (i<=100) && (i>2) {\n fmt.Println(\"Yes\")\n }else{\n fmt.Println(\"No\")\n }\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tw := 0\n\tfmt.Scanf(\"%d\", &w)\n\tif w != 2 && w%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"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 scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\n\nfunc main() {\n\tdefer writer.Flush()\n\tvar number int\n\tscanf(\"%d\", &number)\n\tif number == 2 {\n\t\tprintf(\"NO\")\n\t} else if number%2 == 0 {\n\t\tprintf(\"YES\")\n\t} else {\n\t\tprintf(\"NO\")\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar input int64\n\tfmt.Scanln(&input)\n if input < 3 {\n fmt.Println(\"NO\")\n return\n }\n input -= 2\n if input % 2 == 0 {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n"}, {"source_code": "// test\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\n\tvar a int\n\tfmt.Scanln(&a)\n\t//for a = 1; a <= 100; a++ {\n\t//\tfmt.Printf(\"%d: \", a)\n\tif a%2 == 1 {\n\t\tfmt.Println(\"NO\")\n\t} else if a/2 < 2 {\n\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n\t//}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar w int\n\tfmt.Scan(&w)\n\tx := w - 2\n\tif x > 0 && x%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc readNumber() (int, error) {\n\treader := bufio.NewReader(os.Stdin)\n\tstr, err := reader.ReadString('\\r')\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tweight, err := strconv.Atoi(strings.Replace(str, \"\\r\", \"\", -1))\n\treturn weight, err\n}\n\nfunc main() {\n\tweight, err := readNumber()\n\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tpanic(err)\n\t}\n\tvar answer string\n\n\tif weight % 2 == 0 && weight != 2 {\n\t\tanswer = \"YES\"\n\t} else {\n\t\tanswer = \"NO\"\n\t}\n\n\tfmt.Println(answer)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tw, _ := strconv.Atoi(scanner.Text())\n\tfor i := 2; i < w; i += 2 {\n\t\tif (w-i)%2 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar n string\n\t_, _ = fmt.Scanln(&n)\n\tvalue, _ := strconv.Atoi(n)\n\tif value > 2 && value % 2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tw := 0\n\tfmt.Scanf(\"%d\", &w)\n\tif w != 2 && w%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar weight int\n\tfmt.Scanln(&weight)\n\tif weight%2 == 0 && weight != 2 {\n\t\tfmt.Print(\"YES\")\n\t} else {\n\t\tfmt.Print(\"NO\")\n\t}\n}\n"}, {"source_code": "/* Problemset:\nA. Watermelon\ntime limit per test1 second\nmemory limit per test64 megabytes\ninputstandard input\noutputstandard output\nOne hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem.\n\nPete and Billy are great fans of even numbers, that's why they want to divide the watermelon in such a way that each of the two parts weighs even number of kilos, at the same time it is not obligatory that the parts are equal. The boys are extremely tired and want to start their meal as soon as possible, that's why you should help them and find out, if they can divide the watermelon in the way they want. For sure, each of them should get a part of positive weight.\n\nInput\nThe first (and the only) input line contains integer number w (1 ≤ w ≤ 100) — the weight of the watermelon bought by the boys.\n\nOutput\nPrint YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case.\n\nExamples\ninputCopy\n8\noutputCopy\nYES\nNote\nFor example, the boys can divide the watermelon into two parts of 2 and 6 kilos respectively (another variant — two parts of 4 and 4 kilos).\n\n---\n\nWhat we learned:\nCodeForces takes input with fmt.Scanf and not os.Args. 1 is an odd number of slices. Each submission shows the full results of tests, including input, in the submission number link.\n*/\n\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanln(&n)\n\tif n%2 != 0 {\n\t\tfmt.Println(\"NO\")\n\t} else if n <= 2 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\n// main function\nfunc main() {\n\tvar temp int = 6\n\tfmt.Scanln(&temp)\n\tif temp < 4 {\n\t\tfmt.Print(\"NO\")\n\t\treturn\n\t} else if temp%2 == 0 {\n\t\tif (temp)%2 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a int\n\tfmt.Scanf(\"%d\\n\", &a)\n\n\tif !(a%2 == 0) || a == 2 {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tfmt.Println(\"YES\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc readNumber() (int, error) {\n\treader := bufio.NewReader(os.Stdin)\n\tstr, err := reader.ReadString('\\r')\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tweight, err := strconv.Atoi(strings.Replace(str, \"\\r\", \"\", -1))\n\treturn weight, err\n}\n\nfunc main() {\n\tweight, err := readNumber()\n\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tpanic(err)\n\t}\n\tvar answer string\n\n\tif weight % 2 == 0 && weight != 2 {\n\t\tanswer = \"YES\"\n\t} else {\n\t\tanswer = \"NO\"\n\t}\n\n\tfmt.Println(answer)\n}\n"}, {"source_code": "// test\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\n\tvar a int\n\tfmt.Scanln(&a)\n\t//for a = 1; a <= 100; a++ {\n\t//\tfmt.Printf(\"%d: \", a)\n\tif a%2 == 1 {\n\t\tfmt.Println(\"NO\")\n\t} else if a/2 < 2 {\n\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n\t//}\n}\n"}, {"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)\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\n\nfunc main() {\n\tvar a int\n\tscanf(\"%d\\n\", &a)\n\n\tif !(a % 2 == 0) || a == 2 {\n\t\tprintf(\"%s\", \"NO\")\n\t} else {\n\t\tprintf(\"%s\", \"YES\")\n\t}\n\n\twriter.Flush()\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var w uint\n\n fmt.Scanf(\"%d\", &w)\n\n if (w == 2) {\n fmt.Println(\"NO\")\n } else if (w % 2 == 0) {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\n\n\nfunc main() {\n\n var w int\n fmt.Scan(&w)\n \n for i := 1; i < w; i++ {\n \n if (w-i) % 2 == 0 && w % 2 == 0 {\n fmt.Print(\"YES\")\n return\n }\n }\n fmt.Print(\"NO\")\n\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar w int\n\tfmt.Scanf(\"%d\", &w)\n\n\tif w == 1 {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tfor i := 2; i <= w/2; i++ {\n\t\tif w%i == 0 && w%2 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\tif n%2 == 0 && n > 2 {\n\t\tfmt.Printf(\"YES\")\n\t} else {\n\t\tfmt.Printf(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\n// https://codeforces.com/problemset/problem/4/A\n\nimport \"fmt\"\n\nfunc task_solution(n int) string {\n\tif n > 3 && n%2 == 0 {\n\t\treturn \"YES\"\n\t}\n\treturn \"NO\"\n}\n\nfunc main() {\n\tvar n int\n\t_, err := fmt.Scan(&n)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(task_solution(n))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar kilo float64\n\t_, _ = fmt.Scan(&kilo)\n\n\tnimf := int8(kilo)\n\tnimi := int8(kilo/2) * 2\n\n\tif kilo > 2 && nimf == nimi {\n\t\tfmt.Print(\"YES\")\n\t} else {\n\t\tfmt.Print(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n \nimport (\n \"fmt\"\n)\n \nfunc main(){\n var i int\n fmt.Scanf(\"%d\\n\", &i)\n //i, _ := strconv.Atoi(text)\n if (i%2==0 && i>2) {\n fmt.Print(\"YES\")\n return\n }\n fmt.Print(\"NO\")\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\n// main function\nfunc main() {\n\tvar temp int = 6\n\tfmt.Scanln(&temp)\n\tif temp < 4 {\n\t\tfmt.Print(\"NO\")\n\t\treturn\n\t} else if temp%2 == 0 {\n\t\tif (temp)%2 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar n string\n\t_, _ = fmt.Scanln(&n)\n\ti, _ := strconv.ParseInt(n, 10, 64)\n\tfl := float64(i)\n\n\tif math.Mod(fl, 2) == 0 && fl != 2 {\n\t\tfmt.Print(\"YES\")\n\t} else {\n\t\tfmt.Print(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport (\n \"io\"\n \"strings\"\n \"bytes\"\n \"os\"\n \"fmt\"\n)\n\ntype contestIn struct {\n\treader io.Reader\n}\n\ntype contestOut struct {\n\twriter io.Writer\n}\n\ntype Contest struct {\n\tIn contestIn\n\tOut contestOut\n}\n\nfunc NewSubmitContest() Contest {\n\treturn Contest{contestIn{os.Stdin}, contestOut{os.Stdout}}\n}\n\nfunc NewTestContest(testIn string, testOut *bytes.Buffer) Contest {\n\treturn Contest{contestIn{strings.NewReader(testIn)}, contestOut{testOut}}\n}\n\nfunc (in contestIn) Var(a interface{}) {\n\tfmt.Fscan(in.reader, a)\n}\n\nfunc (in contestIn) Vars(a interface{}) {\n\tfmt.Fscanln(in.reader, a)\n}\n\nfunc (in contestIn) Ints(len int) []int {\n\tarr := make([]int, 0, len)\n\tfor ; len > 0; len-- {\n\t\tvar i int\n\t\tin.Var(&i)\n\t\tarr = append(arr, i)\n\t}\n\n\treturn arr\n}\n\nfunc (out contestOut) Str(s string) {\n\tfmt.Fprintf(out.writer, \"%s\", s)\n}\n\nfunc (out contestOut) Nl() {\n\tfmt.Fprintln(out.writer)\n}\n\n// http://codeforces.com/problemset/problem/4/A\nfunc problem(c Contest) {\n\tvar w int\n\tc.In.Var(&w)\n\n\tif (w > 2) && (w % 2 == 0) {\n\t\tc.Out.Str(\"YES\")\n\t} else {\n\t\tc.Out.Str(\"NO\")\n\t}\n\n\tc.Out.Nl()\n}\n\nfunc main() {\n\tc := NewSubmitContest()\n\tproblem(c)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar weight int\n\tfmt.Scanln(&weight)\n\tif weight%2 == 0 && weight != 2 {\n\t\tfmt.Print(\"YES\")\n\t} else {\n\t\tfmt.Print(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar weight int32\n\t_, err := fmt.Scanf(\"%d\", &weight)\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t}\n\n\tif weight&1 == 1 || weight == 2 {\n\t\tfmt.Print(\"NO\")\n\t\treturn\n\t}\n\tfmt.Print(\"YES\")\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var x int\n fmt.Scanf(\"%d\",&x)\n if(x%2 == 0 && x > 2){\n fmt.Print(\"YES\\n\")\n }else{\n fmt.Print(\"NO\\n\")\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\tif n == 2 || n%2 == 1 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n"}, {"source_code": "package main;import\"fmt\";func main(){var a int8;fmt.Scan(&a);if(a&1==1||a==2){fmt.Print(\"NO\")}else{fmt.Print(\"YES\")}}"}, {"source_code": "package main\nimport (\n\t\t\"fmt\"\n\t\t)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tif n > 2 && n % 2 == 0 {\n\t\tfmt.Print(\"YES\")\n\t} else {\n\t\tfmt.Print(\"NO\")\n\t}\n\treturn\n}\n"}], "negative_code": [{"source_code": "package main\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a int\n\tfmt.Scan(&a)\n\tif a%2==0&&a>0&&a<101 {\n\t\tfmt.Println(\"YES\")\n\t} else{\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar input int64\n\tfmt.Scanln(&input)\n input -= 2\n if input % 2 == 0 {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n"}, {"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)\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\n\nfunc main() {\n\tvar a int\n\tscanf(\"%d\\n\", &a)\n\n\tif !(a % 2 == 0) {\n\t\tprintf(\"%s\\n\", \"NO\")\n\t} else {\n\t\tprintf(\"%s\", \"YES\")\n\t}\n\t\n\twriter.Flush()\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strconv\"\n \"strings\"\n)\n\nfunc main(){\n reader := bufio.NewReader(os.Stdin)\n kg, _ := reader.ReadString('\\n')\n\n //remove newline\n kg = strings.Replace(kg, \"\\n\",\"\",-1)\n\n //conver string variable to int variable\n\n kgnum, e := strconv.Atoi(kg)\n if e != nil {\n fmt.Println(\"conversion error:\", kg)\n }\n\n if(kgnum%2==0 && (kgnum/2)%2==0){\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\t//fmt.Println(\"Enter weight of the watermelon: \")\n\tvar wt int\n\t// Taking input from user\n\tfmt.Scanln(&wt)\n\n\tif wt%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t}\n\tfmt.Println(\"NO\")\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tkilos := 0\n\tfmt.Scanf(\"%d\", &kilos)\n\tif kilos%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n //\"os\"\n //\"strconv\"\n //\"io/ioutil\"\n)\n\nfunc main() {\n\nvar WKgVar uint\nvar OstatokDelVar uint = 0;\nvar Zero uint = 0;\n// var Kolvo2KgVar int = 1;\n// var ObshKgVar int = 1;\n\n// Ввод числа Килограмм.\nfmt.Scan(&WKgVar)\n// Четность, нечетность.\nOstatokDelVar = WKgVar%4;\nif WKgVar < 100{\nif OstatokDelVar == Zero{\n\t// fmt.Println(\"Остаток от деления равен ноль\")\n\tif WKgVar >= 4{\n\t\t//fmt.Println(\"WkgVar >= 4\")\n\t\tfmt.Println(\"YES\");\n\t\t}\n\t\n}\n} else {fmt.Println(\"NO\");\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar weight int\n\t_, err := fmt.Scanf(\"%d\", &weight)\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t}\n\tfor i := 1; i < weight; i++ {\n\t\tif i&11 == 0 {\n\t\t\tfmt.Print(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Print(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t// \"bufio\"\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _, _ := reader.ReadLine()\n\n\tstr := string(text)\n\n\tatt1, _ := strconv.ParseInt(str, 10, 0)\n\tif att1%2 == 0 || att1 != 2 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\n\n\nfunc main() {\n\n var w int\n fmt.Scan(&w)\n \n for i := 0; i < w; i++ {\n other := w-i\n if other % 2 == 0 && w % 2 == 0 {\n fmt.Print(\"YES\")\n return\n }\n }\n fmt.Print(\"NO\")\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar weight int\n\n\tfmt.Scanf(\"%d\", &weight)\n\n\tif weight/2 * 2 == weight {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar w float64\n\t_, _ = fmt.Scanf(\"%f\", &w)\n\n\tfmt.Println(Run(w))\n}\n\nfunc Run(w float64) string {\n\ta := w/2\n\t// Если у а есть точка, то NO\n\tif strings.Contains(fmt.Sprint(a), \".\") {\n\t\treturn \"NO\"\n\t}\n\n\t// Если у а нет точки, то а делим на два\n\t// Если a/2 есть точка, то NO\n\tif strings.Contains(fmt.Sprint(a/2), \".\"){\n\t\treturn \"NO\"\n\t}\n\n\t// Если точки нет, то YES\n\treturn \"YES\"\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar weight int\n\n\tfmt.Scanf(\"%d\", &weight)\n\n\tif weight/2 * 2 == weight {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var w int\n fmt.Scanf(\"%d\", &w)\n if w%2 == 0 {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n return\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar w int64\n\tfmt.Scan(&w)\n\n\tif w % 2 == 0 && w != 2 && 1<=w && w<=100 {\n\t\tfmt.Println(\"YES\")\n\t}\n\tif w % 2 == 1 && 1<=w && w<=100 {\n\t\tfmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar weight int\n\t_, err := fmt.Scanf(\"%d\", &weight)\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t}\n\tfor i := 1; i < weight; i++ {\n\t\tif i&11 == 0 {\n\t\t\tfmt.Print(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Print(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar weight = 0\n\t_, err := fmt.Scanf(\"%d\\n\", &weight)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tif isEven(weight) && weight > 3 {\n\t\tif weight % 4 == 0 {\n\t\t\tprintln(\"YES\\n\")\n\t\t\treturn\n\t\t}\n\n\t\tif (weight - 2) % 4 == 0 {\n\t\t\tprintln(\"YES\\n\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tprintln(\"NO\\n\")\n\treturn\n}\n\nfunc isEven(n int) bool {\n\treturn n % 2 == 0\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tstdin, err := os.OpenFile(\"input\", os.O_RDONLY|os.O_CREATE, 0666)\n\tif err != nil {\n\t\tfmt.Errorf(\"%s\\n\", err)\n\t}\n\tos.Stdin = stdin\n\n\tr := bufio.NewReader(os.Stdin)\n\n\tvar w int32\n\tfmt.Fscan(r, &w)\n\t// even\n\tif w%2 == 0 {\n\t\tif (w/2)%2 == 0 {\n\t\t\tfmt.Printf(\"YES\")\n\t\t} else {\n\t\t\tfmt.Printf(\"NO\")\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tvar cont int\n\tfmt.Scanf(\"%d\", &n)\n\tfor i := 1; i < n; i++ {\n\t\tif i%2 == 0 {\n\t\t\tif n%i == 0 {\n\t\t\t\tcont++\n\t\t\t}\n\t\t}\n\t}\n\tif cont >= 2 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a int\n\tfmt.Scanln(&a)\n\t\tif a%2 == 0 {\n\t\t\tb:=a/2\n\t\t\tif b%2==0 {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t} else if a==2{\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t\tc:=b-1\n\t\t\t\td:=b+1\n\t\t\t\tif c%2==0&&d%2==0 {\n\t\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Println(\"NO\")\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar weight int\n\tfmt.Scanf(\"%d\", &weight)\n\tif weight%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"os\"\nimport \"strconv\"\n\nfunc main() {\n fmt.Println(os.Args)\n if len(os.Args) == 2 {\n args := os.Args[1]\n //fmt.Printf(\"%T\\n\", args)\n argi, _ := strconv.Atoi(args)\n //fmt.Printf(\"%T\", argi)\n //fmt.Println(argi)\n if argi % 2 == 0 {\n fmt.Println(\"YES\")\n } else { \n fmt.Println(\"NO\") }\n\n }\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a int\n\tfmt.Scan(&a)\n\n\tif a%2 == 0 {\n\t\tb := a / 2\n\t\tif b%2 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\n// http://codeforces.com/problemset/problem/4/A\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _ := reader.ReadString('\\n')\n\tw, _ := strconv.ParseInt(text, 10, 8)\n\tif ((w-2)%2) == 0 {\n\t\tfmt.Printf(\"YES\")\n\t} else {\n\t\tfmt.Printf(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n\t)\nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n text, _ := reader.ReadString('\\n')\n number, _ := strconv.Atoi(text)\n if number > 2 && number % 2 == 0 {\n fmt.Println(\"YES\")\n }else{\n fmt.Println(\"NO\")\n }\n \n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar weight int\n\tfmt.Scanf(\"%d\", &weight)\n\tif (weight % 2 == 0 ) || (weight == 2) {\n\t\tfmt.Println(\"YES\")\n\t}else{\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc Watermelon(n int) bool {\n\treturn n%2 == 0\n}\n\nfunc main() {\n\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _ := reader.ReadString('\\n')\n\tnum, _ := strconv.Atoi(text)\n\tif Watermelon(num) {\n\t\tfmt.Println(\"YES\")\n\t}else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\n//https://codeforces.com/problemset/problem/4/A\nfunc main() {\n\tvar w int\n\tfmt.Scanf(\"%d\", &w)\n\tif w >= 1 && w <= 100 {\n\t\tif (w-3)%2 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport(\n\"fmt\"\n)\n\nfunc main(){\n\tvar weight int\n\t_, _ = fmt.Scanf(\"%d\", &weight)\n\tfmt.Println(weight)\n\tif weight % 2 == 0 && weight > 1{\n\t\tfmt.Println(\"YES\")\n\t}else{\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\\n\")\n\tfmt.Printf(\"%d\\n\", n % 2 == 0)\n}\n"}, {"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.NewReader(os.Stdin)\n\tstr, _ := reader.ReadString('\\r')\n\tstr = str[:len(str)-1]\n\tn, _ := strconv.Atoi(str)\n\tfor i := 2; i < n/2; i++ {\n\t\tif (n/i)%2 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc even (w int) bool {\n\tif w % 2 == 0 {\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc main() {\n\tvar weight int\n\treader := bufio.NewReader(os.Stdin)\n\t// Carriage return\n\tif w, err := reader.ReadString('\\n'); err == nil {\n\t\t// Depends.\n\t\ts := w[:len(w)-2]\n\t\tif r, err := strconv.Atoi(s); err == nil {\n\t\t\tweight = r\n\t\t} else {\n\t\t\tpanic(err)\n\t\t}\n\t} else {\n\t\tpanic(err)\n\t}\n\tif even(weight/2) && even(weight) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var w uint\n \n fmt.Scanf(\"%d\", &w) \n\n if (w % 2 == 0) {\n fmt.Println(\"YES\")\n } \n\n fmt.Println(\"NO\")\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tfmt.Println(\"Enter the watermelon's weight:\")\n\treader := bufio.NewReader(os.Stdin)\n\tr, _ := reader.ReadString('\\n')\n\tw, _ := strconv.Atoi(r)\n\n\tif w <= 100 {\n\t\tif w >= 1 {\n\t\t\tif w%2 == 0 {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t} else {\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t}\n\t\t}\n\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar a int\n\t//fmt.Print(\"Введите вес арбуза: \")\n\tfmt.Fscan(os.Stdin, &a)\n\tm := a%2\n\tif m == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"io\"\n \"strings\"\n \"bytes\"\n \"bufio\"\n \"os\"\n)\n\ntype contestIn struct {\n\treader io.Reader\n}\n\ntype contestOut struct {\n\twriter io.Writer\n}\n\ntype Contest struct {\n\tIn contestIn\n\tOut contestOut\n}\n\nfunc NewSubmitContest() Contest {\n\treturn Contest{contestIn{bufio.NewReader(os.Stdin)}, contestOut{bufio.NewWriter(os.Stdout)}}\n}\n\nfunc NewTestContest(testIn string, testOut *bytes.Buffer) Contest {\n\treturn Contest{contestIn{strings.NewReader(testIn)}, contestOut{testOut}}\n}\n\nfunc (in contestIn) Var(a interface{}) {\n\tfmt.Fscan(in.reader, a)\n}\n\nfunc (in contestIn) Vars(a interface{}) {\n\tfmt.Fscanln(in.reader, a)\n}\n\nfunc (in contestIn) Ints(len int) []int {\n\tarr := make([]int, 0, len)\n\tfor ; len > 0; len-- {\n\t\tvar i int\n\t\tin.Var(&i)\n\t\tarr = append(arr, i)\n\t}\n\n\treturn arr\n}\n\nfunc (out contestOut) Str(s string) {\n\tfmt.Fprintf(out.writer, \"%s\", s)\n}\n\nfunc (out contestOut) Nl() {\n\tfmt.Fprintln(out.writer)\n}\n\n// http://com/problemset/problem/4/A\nfunc problem(c Contest) {\n\tvar w int\n\tc.In.Var(&w)\n\n\tif w % 2 == 0 {\n\t\tc.Out.Str(\"YES\")\n\t} else {\n\t\tc.Out.Str(\"NO\")\n\t}\n\n\tc.Out.Nl()\n}\n\nfunc main() {\n\tc := NewSubmitContest()\n\tproblem(c)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar i int\n\t_, _ = fmt.Scanf(\"%d\", &i)\n\tif (i-2) > 0 && (i - 2) % 2 != 0{\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n\n}"}, {"source_code": "package main\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n\t)\nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n text, _ := reader.ReadString('\\n')\n number, _ := strconv.Atoi(text)\n if number > 2 && number % 2 == 0 {\n fmt.Print(\"YES\")\n }else{\n fmt.Print(\"NO\")\n }\n \n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\n// main function\nfunc main() {\n\tvar temp int\n\tfmt.Scanln(&temp)\n\tif temp%2 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t\t//fmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport(\n\t\"bufio\"\n\t\"strings\"\n\t\"strconv\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"io\"\n)\n\nfunc main(){\n\tfmt.Print(getStatus())\n}\n\nfunc getInput() int{\n\treader := bufio.NewReader(os.Stdin)\n\ts, err := reader.ReadString('\\n')\n\n\tif err != nil && err != io.EOF{\n\t\tlog.Fatal(err)\n\t}\n\ts = strings.TrimRight(s, \"\\r\\n\")\n\n\tw, err := strconv.Atoi(s)\n\tif err != nil && err != io.EOF{\n\t\tlog.Fatal(err)\n\t}\n\treturn w\n}\n\nfunc getStatus() string{\n\tw := getInput()\n\t\n\tif w%2 == 0 && w > 1{\n\t\treturn \"YES\"\n\t}\n\treturn \"NO\"\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar weight int\n\tfmt.Print(\"Enter the weight of watermelon (integral value from 1 to 100) bought by the boys : \")\n\tfmt.Scanln(&weight)\n\tif weight <= 100 && weight >= 1 {\n\t\tif weight%4 == 0 {\n\t\t\tfmt.Print(\"YES\")\n\t\t} else {\n\t\t\tfmt.Print(\"NO\")\n\t\t}\n\t} else {\n\t\tfmt.Println(\"Weight of watermelon must be an integral value from 1 to 100\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar input int64\n\tfmt.Scanln(&input)\n\tif (input/2)*2 == input && (input/2)%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a int\n\tfmt.Scan(&a)\n\n\tif a%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Fscanf(os.Stdin, \"%d\\n\", &n)\n\tif n%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\n\tfor i := 2; i < n; i += 2 {\n\t\tother := n - i\n\t\tif other%2 == 0 {\n\t\t\tprint(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tprint(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar w int\n\tfmt.Scan(&w)\n\n\tif w % 2 == 0 && (w != 2) && 1<=w && w<=100 {\n\t\tfmt.Println(\"YES\")\n\t}\n\tif w % 2 == 1 && 1<=w && w<=100 {\n\t\tfmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n \"strconv\"\n \"strings\"\n)\n\nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n text, _ := reader.ReadString('\\n')\n text = strings.Replace(text, \"\\n\", \"\", -1)\n\n num, err := strconv.Atoi(text)\n if err != nil {\n fmt.Printf(\"parse error, input text: %+v\", text)\n return\n }\n\n if num <= 0 || num > 100 || num%2 != 0 {\n fmt.Printf(\"NO\")\n return\n }\n\n fmt.Printf(\"YES\")\n}"}, {"source_code": "package main\n \nimport \"fmt\"\n \nfunc main() {\n var w int\n fmt.Scanln(&w)\n if w % 4 == 0 {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}"}, {"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 scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\n\nfunc main() {\n\tdefer writer.Flush()\n\tvar number int\n\tscanf(\"%d\", &number)\n\tif number == 2 {\n\t\tprintf(\"YES\")\n\t} else if number%2 == 0 {\n\t\tprintf(\"NO\")\n\t} else {\n\t\tprintf(\"YES\")\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar weight int\n\t_, err := fmt.Scanf(\"%d\", &weight)\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t}\n\tfor i := 1; i < weight; i++ {\n\t\tif i&11 == 0 {\n\t\t\tfmt.Print(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Print(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main(){\n kgnum := 8\n\n if(kgnum%2==0 && (kgnum/2)%2==0){\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\n// main function\nfunc main() {\n\tvar temp int\n\tfmt.Scanln(&temp)\n\tif temp%2 == 0 {\n\t\tif (temp/2)%2 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var x int\n var y int\n fmt.Scanf(\"%d\",&x)\n if(x % 2 == 0){\n y = x/2\n if(y % 2 == 0){\n fmt.Print(\"YES\\n\")\n }else {\n fmt.Print(\"NO\\n\")\n }\n }else{\n fmt.Print(\"NO\\n\")\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar w, x int\n\tfmt.Scan(&w)\n\tx = w/2\n\tif x > 0 && x % 2 == 0 && 1 <= w && w <= 100 {\n\t\tfmt.Println(\"YES\")\n\t}\n\tif x > 0 && x % 2 == 1 && 1 <= w && w <= 100 {\n\t\tfmt.Println(\"NO\")\n\t}\n\tif x == 0 && 1 <= w && w <= 100 {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"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.NewReader(os.Stdin)\n\tstr, _ := reader.ReadString('\\n')\n\tstr = str[:len(str)-1]\n\tfmt.Printf(\"str: %#v\", str)\n\treturn\n\n\tn, _ := strconv.Atoi(str)\n\tfor i := 2; i < n/2; i++ {\n\t\tif (n/i)%2 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n // for {\n var i int\n _, err := fmt.Scanf(\"%d\", &i)\n if err != nil {fmt.Println(err)}\n if i%2 == 0 {\n fmt.Println(\"Yes\")\n }else{\n fmt.Println(\"No\")\n }\n // }\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar weight int\n\n\tfmt.Scanf(\"%d\", &weight)\n\n\tif weight/2 * 2 == weight {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar w int\n\tfmt.Scan(&w)\n\tif (w%2)==0 && w>1{\n\t\tfmt.Print(\"YES\")\n\t}else{\n\t\tfmt.Print(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n //\"os\"\n //\"strconv\"\n //\"io/ioutil\"\n)\n\nfunc main() {\n\nvar WKgVar uint\nvar OstatokDelVar uint = 0;\nvar Zero uint = 0;\n// var Kolvo2KgVar int = 1;\n// var ObshKgVar int = 1;\n\n// Ввод числа Килограмм.\nfmt.Scan(&WKgVar)\n// Четность, нечетность.\nOstatokDelVar = WKgVar%4;\nif WKgVar <= 100{\nif OstatokDelVar == Zero{\n\t// fmt.Println(\"Остаток от деления равен ноль\")\n\tif WKgVar >= 4{\n\t\t//fmt.Println(\"WkgVar >= 4\")\n\t\tfmt.Println(\"YES\");\n\t\t}\n\t\n}\n} else {fmt.Println(\"NO\");\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Fscanf(os.Stdin, \"%d\\n\", &n)\n\tif n%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var melon int\n fmt.Scanln(&melon)\n if melon % 2 == 1 {\n fmt.Println(\"NO\")\n } else {\n fmt.Println(\"YES\")\n }\n}"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n \"strconv\"\n \"strings\"\n)\n\nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n text, _ := reader.ReadString('\\n')\n text = strings.Replace(text, \"\\n\", \"\", -1)\n\n num, err := strconv.Atoi(text)\n if err != nil {\n fmt.Print(\"NO\")\n return\n }\n\n if num <= 0 || num > 100 || num%2 != 0 {\n fmt.Printf(\"NO\")\n return\n }\n\n fmt.Printf(\"YES\")\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar ves int\n\tfmt.Scan(&ves)\n\tif ves < 1 || ves > 100 {\n\t\tfmt.Println(\"Таких арбузов не бывает\")\n\t} else {\n\t\tif (ves % 2 % 2) == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t}\n}\n"}, {"source_code": "// test\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\n\tvar a int\n\tfmt.Scanln(&a)\n\tif a%2 == 1 {\n\t\tfmt.Println(\"NO\")\n\t} else if a < 2 {\n\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\n// http://codeforces.com/problemset/problem/4/A\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _ := reader.ReadString('\\n')\n\tw, _ := strconv.ParseInt(text, 10, 8)\n\tif ((w-2)%2) == 0 {\n\t\tprint(\"YES\")\n\t} else {\n\t\tprint(\"NO\")\n\t}\n}"}, {"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.NewReader(os.Stdin)\n\ttext, _ := reader.ReadString('\\n')\n\tvalue, _ := strconv.ParseInt(text, 0, 64)\n\timpl(value)\n}\n\nfunc impl(n int64) {\n\tif n % 2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n \nimport (\n \"os\"\n \"fmt\"\n \"math\"\n \"bufio\"\n \"strings\"\n \"strconv\"\n)\n \nfunc main() {\n text, _ := bufio.NewReader(os.Stdin).ReadString('\\n')\n text = strings.TrimSuffix(text, \"\\n\")\n \n w, _ := strconv.Atoi(text)\n if math.Mod(float64(w), 2) == 0 {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var num int\n\n fmt.Scanf(\"%d\", &num)\n\n fmt.Printf(\"mod: %d\\n\", num%2)\n\n if num <= 2 || num > 100 || num%2 != 0 {\n fmt.Printf(\"NO\")\n return\n }\n\n fmt.Printf(\"YES\")\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar kilo int8\n\t_, _ = fmt.Scan(&kilo)\n\t//reader := bufio.NewReader(os.Stdin)\n\t//text, _ := reader.ReadString('\\n')\n\t//integer, _ := strconv.Atoi(text)\n\n\tif (kilo/2)%2 == 0 {\n\t\tfmt.Print(\"YES\")\n\t} else {\n\t\tfmt.Print(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\n\tfor i := 2; i < n; i += 2 {\n\t\tother := n - i\n\t\tif other%2 == 0 {\n\t\t\tprintln(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tprintln(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tfmt.Println(\"Enter the watermelon's weight:\")\n\treader := bufio.NewReader(os.Stdin)\n\tr, _ := reader.ReadString('\\n')\n\tw, _ := strconv.Atoi(r)\n\n\tif w <= 100 {\n\t\tif w >= 1 {\n\t\t\tif w%2 == 0 {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t} else {\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t}\n\t\t}\n\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar weight = 0\n\t_, err := fmt.Scanf(\"%d\", &weight)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tif isEven(weight) && weight > 3 {\n\t\tif weight % 4 == 0 {\n\t\t\tprintln(\"YES\")\n\t\t\treturn\n\t\t}\n\n\t\tif (weight - 2) % 4 == 0 {\n\t\t\tprintln(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tprintln(\"NO\")\n\treturn\n}\n\nfunc isEven(n int) bool {\n\treturn n % 2 == 0\n}\n"}, {"source_code": "package main\n\nimport (\n \"os\"\n \"fmt\"\n \"math\"\n \"bufio\"\n \"strconv\"\n)\n\nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n text, _ := reader.ReadString('\\n')\n \n w, _ := strconv.Atoi(text)\n if math.Mod(float64(w), 2) == 0 {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a int\n\tfmt.Scan(&a)\n\n\tif a%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n //\"os\"\n //\"strconv\"\n //\"io/ioutil\"\n)\n\nfunc main() {\n\nvar WKgVar int\nvar OstatokDelVar int = 0;\nvar Zero int = 0;\n// var Kolvo2KgVar int = 1;\n// var ObshKgVar int = 1;\n\n// Ввод числа Килограмм.\nfmt.Scan(&WKgVar)\n// Четность, нечетность.\nOstatokDelVar = WKgVar%2;\n\nif OstatokDelVar == Zero{\n\t// fmt.Println(\"Остаток от деления равен ноль\")\n\tif WKgVar >= 4{\n\t\t//fmt.Println(\"WkgVar >= 4\")\n\t\tfmt.Println(\"YES\");\n\t\t}\n\t\n\n} else {fmt.Println(\"NO\");\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a int\n\tfmt.Scanln(&a)\n\t\tif a%2 == 0 {\n\t\t\tb:=a/2\n\t\t\tif b%2==0 {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t} else {\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t}\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nfunc main(){\n var w int\n fmt.Scanf(\"%d\", &w)\n if w % 2 == 0 && w != 0 {fmt.Println(\"Yes\")\n }else {fmt.Println(\"No\")}\n \n}"}, {"source_code": "package main\n \nimport (\n \"os\"\n \"fmt\"\n \"bufio\"\n \"strconv\"\n \"strings\"\n)\n \nfunc prErr(err error) {\n if err != nil {\n fmt.Println(err)\n } \n}\n \nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n text, err := reader.ReadString('\\n')\n prErr(err)\n text = strings.TrimSuffix(text, \"\\r\\n\")\n \n w, err := strconv.Atoi(text)\n prErr(err)\n \n if w%2 == 0 {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\tif n%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc check(n int) int {\n\treturn n%2\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\",&n)\n\n\tif check(n) == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc isDivide(k int8) string {\n\tif k%4 == 0 {\n\t\treturn \"YES\"\n\t} else {\n\t\treturn \"NO\"\n\t}\n}\n\nfunc main() {\n\tvar k int8\n\tfmt.Scanln(&k)\n\tfmt.Println(isDivide(k))\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tfor scanner.Scan() {\n\t\ti, _ := strconv.Atoi(scanner.Text())\n\t\tif i%2 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar weight int\n\n\t_, _ = fmt.Scanf(\"%d\", &weight)\n\n\tif weight/2%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n // for {\n var i int\n _, err := fmt.Scanf(\"%d\", &i)\n if err != nil {fmt.Println(err)}\n if (i%2 == 0) && (i<100) && (i>0) {\n fmt.Println(\"Yes\")\n }else{\n fmt.Println(\"No\")\n }\n // }\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar w int\n\tfmt.Scan(&w)\n\n\tif w % 2 == 0 && (w != 2) && 1<=w && w<=100 {\n\t\tfmt.Println(\"YES\")\n\t}\n\tif w % 2 == 1 && 1<=w && w<=100 {\n\t\tfmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tfor scanner.Scan() {\n\t\ti, _ := strconv.Atoi(scanner.Text())\n\t\tif i%2 == 0 && (i/2)%2 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a int\n\tfmt.Scan(a)\n\tif a%2 == 0 {\n\t\tfmt.Printf(\"YES\")\n\t} else {\n\t\tfmt.Printf(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(\"Enter weight of the watermelon: \")\n\tvar wt int\n\t// Taking input from user\n\tfmt.Scanln(&wt)\n\n\tif wt%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t}\n\tfmt.Println(\"NO\")\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc Watermelon(n int) bool {\n\treturn n%2 == 0\n}\n\nfunc main() {\n\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _ := reader.ReadString('\\n')\n\tnum, _ := strconv.Atoi(text)\n\tfmt.Println(Watermelon(num))\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\n// main function\nfunc main() {\n\tvar temp int\n\tfmt.Scanln(&temp)\n\tif temp%2 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t\t//fmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a int\n\tfmt.Scan(&a)\n\n\tif a%2 == 0 {\n\t\tb := a / 2\n\t\tif b%2 == 0 {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tw, _ := strconv.Atoi(scanner.Text())\n\n\tif w <= 100 {\n\t\tif w >= 1 {\n\t\t\tif w%2 == 0 {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t} else {\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t}\n\t\t}\n\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\t//fmt.Println(\"Enter weight of the watermelon: \")\n\tvar wt int\n\t// Taking input from user\n\tfmt.Scanln(&wt)\n\n\tif wt%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\tfmt.Println(\"NO\")\n\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n //\"os\"\n //\"strconv\"\n //\"io/ioutil\"\n)\n\nfunc main() {\n\nvar WKgVar int\nvar OstatokDelVar int = 0;\nvar Zero int = 0;\n// var Kolvo2KgVar int = 1;\n// var ObshKgVar int = 1;\n\n// Ввод числа Килограмм.\nfmt.Scan(&WKgVar)\n// Четность, нечетность.\nOstatokDelVar = WKgVar%2;\n\nif OstatokDelVar == Zero{\n\t// fmt.Println(\"Остаток от деления равен ноль\")\n\tif WKgVar >= 4{\n\t\t//fmt.Println(\"WkgVar >= 4\")\n\t\tfmt.Println(\"YES\");\n\t\t}\n\t\n\n} else {fmt.Println(\"NO\");\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar input int\n\tfmt.Scanf(\"%d\", &input)\n\tif input%2 == 0 {\n\t\tfmt.Print(\"YES\")\n\t\treturn\n\t}\n\tfmt.Print(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", n)\n\tif n > 0 && n%2 == 0 {\n\t\tfmt.Printf(\"YES\")\n\t} else {\n\t\tfmt.Printf(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\nimport (\n\t\t\"bufio\"\n\t\t\"fmt\"\n\t\t\"os\"\n\t\t\"strconv\"\n\t\t)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput_string, _ := reader.ReadString('\\n')\n\tinput, _ := strconv.Atoi(input_string[:len(input_string)-1])\n\tanswer := 0\n\tif input%2==0 {\n\t\tanswer = 1\n\t}\n\tif input == 2 {\n\t\tanswer = 0\n\t}\n\tif answer == 0 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar number int\n\t_, err := fmt.Scanf(\"%d\", &number)\n\tif err != nil {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\n\tif number <= 1 || number >= 100 {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tif number%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar weight int\n\tfmt.Scanf(\"%d\", &weight)\n\tif (weight % 2 == 0 ) || (weight == 2) {\n\t\tfmt.Println(\"YES\")\n\t}else{\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"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\ttext, _ := reader.ReadString('\\n')\n\n\tw, err := strconv.Atoi(strings.Trim(text, \"\\n\"))\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tif w%2 == 0 {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\tfmt.Println(\"NO\")\n}\n"}], "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2"} {"nl": {"description": "PolandBall is a young, clever Ball. He is interested in prime numbers. He has stated a following hypothesis: \"There exists such a positive integer n that for each positive integer m number n·m + 1 is a prime number\".Unfortunately, PolandBall is not experienced yet and doesn't know that his hypothesis is incorrect. Could you prove it wrong? Write a program that finds a counterexample for any n.", "input_spec": "The only number in the input is n (1 ≤ n ≤ 1000) — number from the PolandBall's hypothesis. ", "output_spec": "Output such m that n·m + 1 is not a prime number. Your answer will be considered correct if you output any suitable m such that 1 ≤ m ≤ 103. It is guaranteed the the answer exists.", "sample_inputs": ["3", "4"], "sample_outputs": ["1", "2"], "notes": "NoteA prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself.For the first sample testcase, 3·1 + 1 = 4. We can output 1.In the second sample testcase, 4·1 + 1 = 5. We cannot output 1 because 5 is prime. However, m = 2 is okay since 4·2 + 1 = 9, which is not a prime number."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc main() {\n\tisPrime := make([]bool, 2e6)\n\tfor i := 2; i < len(isPrime); i++ {\n\t\tisPrime[i] = true\n\t}\n\tmax := int(math.Sqrt(float64(len(isPrime))))\n\tfor i := 2; i <= max; i++ {\n\t\tif isPrime[i] {\n\t\t\tfor j := i * i; j < len(isPrime); j += i {\n\t\t\t\tisPrime[j] = false\n\t\t\t}\n\t\t}\n\t}\n\tn := readi()\n\tfor m := 1; ; m++ {\n\t\tif !isPrime[n*m+1] {\n\t\t\tfmt.Println(m)\n\t\t\tbreak\n\t\t}\n\t}\n\twriter.Flush()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc abs64(a int64) int64 {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max64(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min64(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar (\n\treader = bufio.NewReaderSize(os.Stdin, 1<<13)\n\twriter = bufio.NewWriterSize(os.Stdout, 1<<13)\n)\n\nfunc readi() int {\n\treturn int(readi64())\n}\n\nfunc read2i() (int, int) {\n\treturn readi(), readi()\n}\n\nfunc readis(n int) []int {\n\tres := make([]int, n)\n\tfor i := range res {\n\t\tres[i] = readi()\n\t}\n\treturn res\n}\n\nfunc readi64() int64 {\n\tb, err := reader.ReadByte()\n\tfor !isValid(b, err) {\n\t\tb, err = reader.ReadByte()\n\t}\n\tsign, res := int64(1), int64(0)\n\tif b == '-' {\n\t\tsign *= -1\n\t\tb, err = reader.ReadByte()\n\t}\n\tfor isValid(b, err) {\n\t\tres = res*10 + int64(b-'0')\n\t\tb, err = reader.ReadByte()\n\t}\n\treturn res * sign\n}\n\nfunc readline() string {\n\tres := new(bytes.Buffer)\n\tfor {\n\t\tline, isPrefix, err := reader.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tres.Write(line)\n\t\tif !isPrefix {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn res.String()\n}\n\nfunc isValid(b byte, err error) bool {\n\treturn err == nil && (('0' <= b && b <= '9') || b == '-')\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i interface{}, delim string) error {\n\t_, err := fmt.Fscanf(r, \"%v\"+delim, i)\n\treturn err\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.txt\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tvar n int\n\tfor I(&n, \"\\n\") == nil {\n\t\tsolve(n)\n\t}\n}\n\nfunc solve(n int) {\n\tfor i := 2; i < 1001; i++ {\n\t\ta := i*n + 1\n\t\tfor j := 2; j < 10000; j++ {\n\t\t\tif a%j == 0 && a != j {\n\t\t\t\tO(i, \"\\n\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}"}, {"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\tif n > 1 && n%2 != 0 {\n\t\tfmt.Println(1)\n\t} else {\n\t\tfor i := 2; i <= n*1000+1; i++ {\n\t\t\tfor j := i; j <= n*1000+1; j++ {\n\t\t\t\tnon_prime := i * j\n\t\t\t\tif (non_prime-1)%n == 0 {\n\t\t\t\t\tfmt.Println((non_prime - 1) / n)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"}, {"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\tfor m := 1; m <= 1000; m++ {\n\t\tif !isPrime(n*m + 1) {\n\t\t\tfmt.Println(m)\n\t\t\treturn\n\t\t}\n\t}\n}\n\nfunc isPrime(num int) bool {\n\tif num < 2 {\n\t\treturn false\n\t}\n\tif num == 2 {\n\t\treturn true\n\t}\n\tif num%2 == 0 {\n\t\treturn false\n\t}\n\tfor i := 3; i*i <= num; i += 2 {\n\t\tif num%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\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"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar primeMap = make(map[int]bool)\n\nfunc isPrime(number int) bool {\n isPrime := true\n for j := 2; j <= number/2; j++ {\n if number%j == 0 {\n isPrime = false\n break\n }\n }\n return isPrime\n\n}\n\nfunc main() {\n var input int\n fmt.Scanf(\"%d\", &input)\n pynum := 1\n for {\n if !isPrime(input*pynum + 1) {\n fmt.Println(pynum)\n break\n\n } else {\n pynum++\n\n }\n }\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar number int\n\tfmt.Scanf(\"%d\\n\", &number)\n\tfor m:=1;m<1000;m++{\n\t\tif !isPrime(m*number + 1) {\n\t\t\tfmt.Println(m)\n\t\t\treturn\n\t\t}\n\t}\n}\n\nfunc isPrime(number int) bool {\n\tfor i:=2; i 0 {\n\t\t\tfmt.Println(i)\n\t\t\treturn\n\t\t}\n\t}\n}\n\nfunc main() {\n\n\t//stdin, err := os.Open(\"file.in\")\n\t//if err != nil {\n\t//\tpanic(err)\n\t//}\n\t//defer stdin.Close()\n\tstdin := os.Stdin\n\treader := bufio.NewReaderSize(stdin, 1024*1024)\n\n\t//stdout, err := os.Create(\"file.out\")\n\t//if err != nil {\n\t//\tpanic(err)\n\t//}\n\t//defer stdout.Close()\n\tstdout := os.Stdout\n\twriter := bufio.NewWriterSize(stdout, 1024*1024)\n\tdefer writer.Flush()\n\n\tsolution(reader, writer)\n}"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i interface{}, delim string) error {\n\t_, err := fmt.Fscanf(r, \"%v\"+delim, i)\n\treturn err\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.txt\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tvar n int\n\tfor I(&n, \"\\n\") == nil {\n\t\tsolve(n)\n\t}\n}\n\nfunc solve(n int) {\n\tfor i := 2; i < 1001; i++ {\n\t\ta := i*n + 1\n\t\tif a%2 == 0 || a%3 == 0 {\n\t\t\tO(i, \"\\n\")\n\t\t\treturn\n\t\t}\n\t}\n}"}, {"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\tif n%2 != 0 {\n\t\tfmt.Println(1)\n\t} else {\n\t\tfor i := 2; i <= n*1000+1; i++ {\n\t\t\tfor j := i; j <= n*1000+1; j++ {\n\t\t\t\tnon_prime := i * j\n\t\t\t\tif (non_prime-1)%n == 0 {\n\t\t\t\t\tfmt.Println((non_prime - 1) / n)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"}, {"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 solution(reader io.Reader, writer io.Writer) {\n\tvar n int\n\tfmt.Fscanf(reader, \"%d\\n\", &n)\n\n\tfor i := 1; i < 1000; i++ {\n\t\tm := i * n + 1\n\t\tf := 0\n\t\tfor j := 2; j * j < m; j++ {\n\t\t\tif m % j == 0 {\n\t\t\t\tf++\n\t\t\t}\n\t\t}\n\t\tif f > 0 {\n\t\t\tfmt.Println(m)\n\t\t\treturn\n\t\t}\n\t}\n}\n\nfunc main() {\n\n\t//stdin, err := os.Open(\"file.in\")\n\t//if err != nil {\n\t//\tpanic(err)\n\t//}\n\t//defer stdin.Close()\n\tstdin := os.Stdin\n\treader := bufio.NewReaderSize(stdin, 1024*1024)\n\n\t//stdout, err := os.Create(\"file.out\")\n\t//if err != nil {\n\t//\tpanic(err)\n\t//}\n\t//defer stdout.Close()\n\tstdout := os.Stdout\n\twriter := bufio.NewWriterSize(stdout, 1024*1024)\n\tdefer writer.Flush()\n\n\tsolution(reader, writer)\n}"}], "src_uid": "5c68e20ac6ecb7c289601ce8351f4e97"} {"nl": {"description": "Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?Please help Kolya answer this question.", "input_spec": "The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.", "output_spec": "Print \"YES\" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print \"NO\" (without quotes).", "sample_inputs": ["1359257", "17851817"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i interface{}, delim string) error {\n\t_, err := fmt.Fscanf(r, \"%v\"+delim, i)\n\treturn err\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.txt\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tvar n uint64\n\tfor I(&n, \"\\n\") == nil {\n\t\tsolve(n)\n\t}\n}\n\nfunc solve(n uint64) {\n\ta, b, c := uint64(1234567), uint64(123456), uint64(1234)\n\tfor i := uint64(0); i <= n/a; i++ {\n\t\taa := a * i\n\t\tfor j := uint64(0); j <= (n-aa)/b; j++ {\n\t\t\tbb := aa + j*b\n\t\t\tif (n-bb)%c == 0 {\n\t\t\t\tO(\"YES\", \"\\n\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tO(\"NO\", \"\\n\")\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\\n\", &n)\n\tres := false\n\tvar c string\n\taa := 1234567\n\tbb := 123456\n\tcc := 1234\n\tfor i := 0; ; i++ {\n\t\tif aa*i > n || res {\n\t\t\tbreak\n\t\t}\n\t\tfor j := 0; ; j++ {\n\t\t\tif (aa*i+bb*j) > n || res {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tvar k int\n\t\t\tk = n - aa*i - bb*j\n\t\t\tk /= cc\n\t\t\tres = aa*i+bb*j+cc*k == n\n\t\t}\n\t}\n\tif res {\n\t\tc = \"YES\"\n\t} else {\n\t\tc = \"NO\"\n\t}\n\tfmt.Println(c)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tconst house int = 1234567\n\tconst car int = 123456\n\tconst computer int = 1234\n\n\tvar n int\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\tok := false\n\tfor i := 0; i <= n/house; i++ {\n\t\tfor j := 0; j <= (n-house*i)/car; j++ {\n\t\t\tif (n-house*i-car*j)%computer == 0 {\n\t\t\t\tok = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif ok {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif ok {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tin, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\ta, _ := in.ReadString('\\n')\n\ta = strings.Trim(a, \"\\r\\n\")\n\tn, _ := strconv.ParseInt(string(a), 10, 64)\n\tfor a := int64(0); a <= 1000; a++ {\n\t\tfor b := int64(0); b <= 1000; b++ {\n\t\t\tif c := (n - a*1234567 - b*123456) / 1234; c >= 0 && a*1234567+b*123456+c*1234 == n {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar coins = []int{1234567, 123456, 1234}\n\nfunc canpay(amount int, coins []int) bool {\n\tif amount < 0 {\n\t\treturn false\n\t}\n\tif amount == 0 {\n\t\treturn true\n\t}\n\tif len(coins) == 0 {\n\t\treturn false\n\t}\n\tc := coins[0]\n\tif len(coins) == 1 {\n\t\treturn amount%c == 0\n\t}\n\tfor i := 0; i <= (amount / c); i++ {\n\t\tif canpay(amount-c*i, coins[1:]) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc main() {\n\tvar amount int\n\t_, err := fmt.Scanln(&amount)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif canpay(amount, coins) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tin, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\ta, _ := in.ReadString('\\n')\n\ta = strings.Trim(a, \"\\r\\n\")\n\tn, _ := strconv.ParseInt(string(a), 10, 64)\n\tfor a := int64(0); a <= 1000; a++ {\n\t\tfor b := int64(0); b <= 1000; b++ {\n\t\t\tif c := (n - a*1234567 + b*123456) / 1234; c >= 0 && a*1234567+b*123456+c*1234 == n {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}], "src_uid": "72d7e422a865cc1f85108500bdf2adf2"} {"nl": {"description": "You are a lover of bacteria. You want to raise some bacteria in a box. Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split into two bacteria. You hope to see exactly x bacteria in the box at some moment. What is the minimum number of bacteria you need to put into the box across those days?", "input_spec": "The only line containing one integer x (1 ≤ x ≤ 109).", "output_spec": "The only line containing one integer: the answer.", "sample_inputs": ["5", "8"], "sample_outputs": ["2", "1"], "notes": "NoteFor the first sample, we can add one bacterium in the box in the first day morning and at the third morning there will be 4 bacteria in the box. Now we put one more resulting 5 in the box. We added 2 bacteria in the process so the answer is 2.For the second sample, we can put one in the first morning and in the 4-th morning there will be 8 in the box. So the answer is 1."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n\t\"strconv\"\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\n\tn := nextInt()\n\tfmt.Println(strings.Count(strconv.FormatInt(int64(n), 2), \"1\"))\n}\n\nfunc nextInt() int {\n\tin.Scan()\n\tres, _ := strconv.Atoi(in.Text())\n\treturn res\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\n\n\nfunc main() {\n\tvar x int\n\tfmt.Scan(&x)\n\tcnt := 0\n\tfor x != 0{\n\t\tcnt += x&1\n\t\tx /= 2\n\t}\n\tfmt.Println(cnt)\n}\n"}, {"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\tcntBit := 0\n\n\tfor n > 0 {\n\t\tif n&1 == 1 {\n\t\t\tcntBit++\n\t\t}\n\t\tn >>= 1\n\t}\n\n\tprintln(cntBit)\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"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n, count int\n\tfmt.Scan(&n)\n\n\tfor n > 1 {\n\t\tj := int(math.Floor(math.Log2(float64(n))))\n\t\tn = n - (1 << j)\n\t\tcount += 1\n\t}\n\tif n == 1 {\n\t\tcount += 1\n\t}\n\tfmt.Println(count)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n, count int\n\tfmt.Scan(&n)\n\n\tfor n > 1 {\n\t\tj := int(math.Floor(math.Log2(float64(n))))\n\t\tn = n - (1 << j)\n\t\tcount += 1\n\t}\n\tif n == 1 {\n\t\tcount += 1\n\t}\n\tfmt.Println(count)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar n int64\n\tfmt.Scanf(\"%d \\n\", &n)\n\tfmt.Print(strings.Count(strconv.FormatInt(n, 2), \"1\"))\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc binary(n int) int {\n\tcount := 0\n\tfor n != 0 {\n\t\tif n % 2 == 1 {\n\t\t\tcount++\n\t\t}\n\t\tn /= 2\n\t}\n\treturn count\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\n\tfmt.Println(binary(n))\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar n int64\n\tfmt.Scanf(\"%d\", &n)\n\ts := strconv.FormatInt(n, 2)\n\tfmt.Println(strings.Count(s, \"1\"))\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\n\tcount := 0\n\tfor n > 0 {\n\t\tif n&1 == 1 {\n\t\t\tcount += 1\n\t\t}\n\t\tn >>= 1\n\t}\n\n\tfmt.Println(count)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\n\tcount := 0\n\tfor n > 0 {\n\t\tif n%2 == 1 {\n\t\t\tcount += 1\n\t\t}\n\t\tn = n / 2\n\t}\n\n\tfmt.Println(count)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\n\tcount := 0\n\tfor ; n > 0; count++ {\n\t\tn &= (n - 1)\n\t}\n\n\tfmt.Println(count)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader\n\nfunc init() {\n\tstdin := os.Stdin\n\t// stdin, _ = os.Open(\"1.in\")\n\treader = bufio.NewReaderSize(stdin, 1<<20)\n}\n\nvar n int\n\n// NumberOf1 计算二进制中1的个数\nfunc NumberOf1(n int) (res int) {\n\tfor n != 0 {\n\t\tn &= (n - 1)\n\t\tres++\n\t}\n\treturn\n}\n\nfunc main() {\n\tfmt.Fscan(reader, &n)\n\tfmt.Println(NumberOf1(n))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Fscanf(os.Stdin, \"%d\\n\", &n)\n\n\treminder := n\n\tval := math.Log2(float64(reminder))\n\treminder -= (1 << uint(val))\n\tcounter := 1\n\n\tfor reminder > 0 {\n\t\tval = math.Log2(float64(reminder))\n\t\treminder -= (1 << uint(val))\n\t\tcounter++\n\t}\n\n\tfmt.Println(counter)\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nvar x, res int\n\nfunc main() {\n\tfmt.Scanf(\"%d\", &x)\n\tres = popCountInt32(x)\n\tfmt.Printf(\"%d\\n\", res)\n}\n\nfunc popCountInt32(x int) (n int) {\n\tfor x > 0 {\n\t\tn += x % 2\n\t\tx = x >> 1\n\t}\n\treturn\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, res int\n\tfmt.Scan(&n)\n\tfor n > 0 {\n\t\tif n%2 == 0 {\n\t\t\tn /= 2\n\t\t} else {\n\t\t\tres++\n\t\t\tn--\n\t\t}\n\t}\n\tfmt.Println(res)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n)\n\nfunc fastGetInt(b []byte) int64 {\n\tneg := false\n\tif b[0] == '-' {\n\t\tneg = true\n\t\tb = b[1:]\n\t}\n\tvar n int64\n\tn = 0\n\tfor _, v := range b {\n\t\tn = n*10 + int64(v-'0')\n\t}\n\tif neg {\n\t\treturn -n\n\t}\n\treturn n\n}\n\n//========== Implement Algorithm =======================\nfunc solution(x int64) int64 {\n\tvar temp int64\n\ttemp = x\n\tvar count int64\n\tcount = 0\n\tfor temp != 0 {\n\t\tif temp%2 == 1 {\n\t\t\tcount++\n\t\t}\n\t\ttemp = temp / 2\n\t}\n\n\treturn count\n}\n\nfunc main() {\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\t//================== Variables used ====================\n\tvar x, ret int64\n\t//======================================================\n\n\t//============== Get return value from File ============\n\tif len(os.Args) >= 2 {\n\n\t\tfile, err := os.Open(os.Args[1])\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"failed opening file: %s\", err)\n\t\t}\n\t\tscanner = bufio.NewScanner(file)\n\t\tdefer file.Close()\n\n\t}\n\tscanner.Split(bufio.ScanWords)\n\t//======================= I/O ==========================\n\tscanner.Scan()\n\tx = fastGetInt(scanner.Bytes())\n\n\t//======================================================\n\tret = solution(x)\n\t//==================== OUTPUT ==========================\n\n\tfmt.Print(ret)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d \\n\", &n)\n\tfmt.Println(findMinBacteries(float64(n)))\n}\n\nfunc findMinBacteries(n float64) int {\n\tc := 0\n\tfor p := 0; n > 0; p++ {\n\t\ts := math.Pow(2, float64(p))\n\t\tif s > n {\n\t\t\tn -= math.Pow(2, float64(p-1))\n\t\t\tp = 0\n\t\t\tc++\n\t\t} else if s == n {\n\t\t\tn = 0\n\t\t\tc++\n\t\t}\n\t}\n\treturn c\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x int\n\tfmt.Scanln(&x)\n\ta := 0\n\tfor x>0 {\n\t\ta += x%2\n\t\tx /= 2\t\t\n\t}\n\tfmt.Println(a)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tvar tot int\n\tfmt.Scan(&n)\n\tfor n > 0 {\n\t\ttot++\n\t\tn &= (n - 1)\n\t}\n\tfmt.Println(tot)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\n// https://codeforces.com/problemset/problem/579/A\n// комментарии к решению\n// Т.к. бактерии удваиваются ежедневно, то нам достаточно\n// контролировать только нечетные изменения. На примере:\n// 5 {нужно получить}\n// -> 4{было}+1{положили}\n// -> 2{было}*2{1ночь}+1положили\n// -> 1{было}*2{1ночь}*2{2ночь}+1положили\n// -> (0{старт}+1{положили})*2{1ночь}*2{2ночь}+1положили\nfunc taskSolution(n int) (ans int) {\n\tfor n > 0 {\n\t\tif n%2 == 1 {\n\t\t\tans += 1\n\t\t}\n\t\tn /= 2\n\t}\n\treturn ans\n}\n\nfunc main() {\n\tvar n int\n\tif _, err := fmt.Scan(&n); err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(taskSolution(n))\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n)\n\nfunc fastGetInt(b []byte) int64 {\n\tneg := false\n\tif b[0] == '-' {\n\t\tneg = true\n\t\tb = b[1:]\n\t}\n\tvar n int64\n\tn = 0\n\tfor _, v := range b {\n\t\tn = n*10 + int64(v-'0')\n\t}\n\tif neg {\n\t\treturn -n\n\t}\n\treturn n\n}\n\n//========== Implement Algorithm =======================\nfunc solution(x int64) int64 {\n\treturn x % 2\n}\n\nfunc main() {\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\t//================== Variables used ====================\n\tvar x, ret int64\n\t//======================================================\n\n\t//============== Get return value from File ============\n\tif len(os.Args) >= 2 {\n\n\t\tfile, err := os.Open(os.Args[1])\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"failed opening file: %s\", err)\n\t\t}\n\t\tscanner = bufio.NewScanner(file)\n\t\tdefer file.Close()\n\n\t}\n\tscanner.Split(bufio.ScanWords)\n\t//======================= I/O ==========================\n\tscanner.Scan()\n\tx = fastGetInt(scanner.Bytes())\n\n\t//======================================================\n\tret = solution(x)\n\t//==================== OUTPUT ==========================\n\n\tfmt.Print(ret + 1)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n)\n\nfunc fastGetInt(b []byte) int64 {\n\tneg := false\n\tif b[0] == '-' {\n\t\tneg = true\n\t\tb = b[1:]\n\t}\n\tvar n int64\n\tn = 0\n\tfor _, v := range b {\n\t\tn = n*10 + int64(v-'0')\n\t}\n\tif neg {\n\t\treturn -n\n\t}\n\treturn n\n}\n\n//========== Implement Algorithm =======================\nfunc solution(x int64) int64 {\n\tvar temp int64\n\ttemp = 1\n\tvar count int64\n\tcount = 0\n\tfor temp < x/2 {\n\t\ttemp = temp * 2\n\t\tcount++\n\t}\n\tif temp*2 == x || x == 1 {\n\t\treturn 0\n\t}\n\tif temp%2 == 1 {\n\t\tcount++\n\t}\n\treturn count\n}\n\nfunc main() {\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\t//================== Variables used ====================\n\tvar x, ret int64\n\t//======================================================\n\n\t//============== Get return value from File ============\n\tif len(os.Args) >= 2 {\n\n\t\tfile, err := os.Open(os.Args[1])\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"failed opening file: %s\", err)\n\t\t}\n\t\tscanner = bufio.NewScanner(file)\n\t\tdefer file.Close()\n\n\t}\n\tscanner.Split(bufio.ScanWords)\n\t//======================= I/O ==========================\n\tscanner.Scan()\n\tx = fastGetInt(scanner.Bytes())\n\n\t//======================================================\n\tret = solution(x)\n\t//==================== OUTPUT ==========================\n\n\tfmt.Print(ret + 1)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n)\n\nfunc fastGetInt(b []byte) int64 {\n\tneg := false\n\tif b[0] == '-' {\n\t\tneg = true\n\t\tb = b[1:]\n\t}\n\tvar n int64\n\tn = 0\n\tfor _, v := range b {\n\t\tn = n*10 + int64(v-'0')\n\t}\n\tif neg {\n\t\treturn -n\n\t}\n\treturn n\n}\n\n//========== Implement Algorithm =======================\nfunc solution(x int64) int64 {\n\tvar temp int64\n\ttemp = 1\n\tvar count int64\n\tcount = 0\n\tfor temp < x/2 {\n\t\ttemp = temp * 2\n\t\tcount++\n\t}\n\tif temp*2 == x {\n\t\treturn 0\n\t}\n\tif temp%2 == 1 {\n\t\tcount++\n\t}\n\treturn count\n}\n\nfunc main() {\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\t//================== Variables used ====================\n\tvar x, ret int64\n\t//======================================================\n\n\t//============== Get return value from File ============\n\tif len(os.Args) >= 2 {\n\n\t\tfile, err := os.Open(os.Args[1])\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"failed opening file: %s\", err)\n\t\t}\n\t\tscanner = bufio.NewScanner(file)\n\t\tdefer file.Close()\n\n\t}\n\tscanner.Split(bufio.ScanWords)\n\t//======================= I/O ==========================\n\tscanner.Scan()\n\tx = fastGetInt(scanner.Bytes())\n\n\t//======================================================\n\tret = solution(x)\n\t//==================== OUTPUT ==========================\n\n\tfmt.Print(ret + 1)\n}\n"}], "src_uid": "03e4482d53a059134676f431be4c16d2"} {"nl": {"description": "Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled \"a\" to \"z\", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the photos in the booklet in order. He now wants to sell some \"special edition\" photobooks, each with one extra photo inserted anywhere in the book. He wants to make as many distinct photobooks as possible, so he can make more money. He asks Haruhi, how many distinct photobooks can he make by inserting one extra photo into the photobook he already has?Please help Haruhi solve this problem.", "input_spec": "The first line of input will be a single string s (1 ≤ |s| ≤ 20). String s consists only of lowercase English letters. ", "output_spec": "Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make.", "sample_inputs": ["a", "hi"], "sample_outputs": ["51", "76"], "notes": "NoteIn the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets. "}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar (\n\treader = bufio.NewReader(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\n//Wrong\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\ts := next()\n\tm := map[string]bool{}\n\tcnt := 0\n\n\tfor i := 0; i <= len(s); i++ {\n\t\tfor c := 'a'; c <= 'z'; c++ {\n\t\t\tt := s[0:i] + string(c) + s[i:len(s)]\n\n\t\t\tif checked, haveValue := m[t]; !haveValue && !checked {\n\t\t\t\tm[t] = true\n\t\t\t\tcnt++\n\t\t\t}\n\t\t}\n\t}\n\n\tprintln(cnt)\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n"}, {"source_code": "package main\nimport \"fmt\"\n\nfunc main(){\n var s string\n fmt.Scan(&s)\n fmt.Println(len(s)*25+26)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar inf int = 0x3f3f3f3f\nvar reader *bufio.Reader\n\nfunc init() {\n\tstdin := os.Stdin\n\t// stdin, _ = os.Open(\"1.in\")\n\treader = bufio.NewReaderSize(stdin, 1<<20)\n}\n\nvar s string\n\nfunc main() {\n\tfmt.Fscan(reader, &s)\n\tm := make(map[string]int)\n\tfor i := 0; i <= len(s); i++ {\n\t\tfor j := 0; j < 26; j++ {\n\t\t\tt := s[0:i] + string(j+'a') + s[i:len(s)]\n\t\t\tm[t] = 1\n\t\t}\n\t}\n\tfmt.Println(len(m))\n}\n"}], "negative_code": [], "src_uid": "556684d96d78264ad07c0cdd3b784bc9"} {"nl": {"description": "The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the full name. Typically there are multiple possible logins for each person.You are given the first and the last name of a user. Return the alphabetically earliest login they can get (regardless of other potential Polygon users).As a reminder, a prefix of a string s is its substring which occurs at the beginning of s: \"a\", \"ab\", \"abc\" etc. are prefixes of string \"{abcdef}\" but \"b\" and 'bc\" are not. A string a is alphabetically earlier than a string b, if a is a prefix of b, or a and b coincide up to some position, and then a has a letter that is alphabetically earlier than the corresponding letter in b: \"a\" and \"ab\" are alphabetically earlier than \"ac\" but \"b\" and \"ba\" are alphabetically later than \"ac\".", "input_spec": "The input consists of a single line containing two space-separated strings: the first and the last names. Each character of each string is a lowercase English letter. The length of each string is between 1 and 10, inclusive. ", "output_spec": "Output a single string — alphabetically earliest possible login formed from these names. The output should be given in lowercase as well.", "sample_inputs": ["harry potter", "tom riddle"], "sample_outputs": ["hap", "tomr"], "notes": null}, "positive_code": [{"source_code": "package main\n\n/*\n\tTo solve this problem basically we just need to generate login\n\tstring which alphabetically earliest than any other string login string.\n\n\tThe rules to generate login string are following:\n\t- must concatenate prefix of user's first name & last name\n\t- each prefix must not be empty\n\t- any prefix can be full name\n\n\tA string is said alphabetically earlier than other string if:\n\t- string is prefix of other string (ab >< abc, ab is earlier)\n\t- string is coincide up to some point with another\n\t string then string has char which alphabetically earlier than\n\t corresponding letter in another string (a >< ab >< ac => a < ab < ac)\n\n\tNotice that the minimum string we can generate is first[0] + last[0], yet\n\twith only this we already got decent enough early string. But can we make\n\tthis string much earlier?\n\n\tYes! If all char in first[1:] is alphabetically earlier than last[0]. So yeah,\n\tbasically we just need to get all chars in first name which earlier than last[0],\n\tthen combine them into a string.\n*/\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar first, second string\n\tstdio := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(stdio, \"%s %s\", &first, &second)\n\tidx := 1\n\tfor i := 1; i < len(first); i++ {\n\t\tif first[i] < second[0] {\n\t\t\tidx++\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(first[:idx] + \"\" + second[:1])\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar first, second string\n\tstdio := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(stdio, \"%s %s\", &first, &second)\n\tidx := 1\n\tfor i := 1; i < len(first); i++ {\n\t\tif first[i] < second[0] {\n\t\t\tidx++\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(first[:idx] + \"\" + second[:1])\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar a, b string\n\tfmt.Scanln(&a, &b)\n\tvar str []string\n\tfor i := 0; i < len(a); i++ {\n\t\tfor j := 0; j < len(b); j++ {\n\t\t\tstr = append(str, a[0:i+1]+b[0:j+1])\n\t\t}\n\t}\n\tsort.Strings(str)\n\tfmt.Println(str[0])\n}\n"}, {"source_code": "package main\n\nimport\n(\n\t\"fmt\"\n\t\n)\n\nfunc main() {\n\tvar a string\n\tvar b string\n\t//var c string\n\tfmt.Scanln(&a, &b)\n\t//fmt.Scanf(\"%s\", &b)\n\tfmt.Printf(\"%c\", a[0])\n\n\tvar i, j int\n\ti = 1\n\tj = 0\n\tfor ; ; {\n\t\tif i < len(a) && a[i] < b[j] {\n\t\t\tfmt.Printf(\"%c\", a[i])\n\t\t\ti++\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Printf(\"%c\", b[0])\n\t}\n"}], "negative_code": [], "src_uid": "aed892f2bda10b6aee10dcb834a63709"} {"nl": {"description": "Mary has just graduated from one well-known University and is now attending celebration party. Students like to dream of a beautiful life, so they used champagne glasses to construct a small pyramid. The height of the pyramid is n. The top level consists of only 1 glass, that stands on 2 glasses on the second level (counting from the top), then 3 glasses on the third level and so on.The bottom level consists of n glasses.Vlad has seen in the movies many times how the champagne beautifully flows from top levels to bottom ones, filling all the glasses simultaneously. So he took a bottle and started to pour it in the glass located at the top of the pyramid.Each second, Vlad pours to the top glass the amount of champagne equal to the size of exactly one glass. If the glass is already full, but there is some champagne flowing in it, then it pours over the edge of the glass and is equally distributed over two glasses standing under. If the overflowed glass is at the bottom level, then the champagne pours on the table. For the purpose of this problem we consider that champagne is distributed among pyramid glasses immediately. Vlad is interested in the number of completely full glasses if he stops pouring champagne in t seconds.Pictures below illustrate the pyramid consisting of three levels. ", "input_spec": "The only line of the input contains two integers n and t (1 ≤ n ≤ 10, 0 ≤ t ≤ 10 000) — the height of the pyramid and the number of seconds Vlad will be pouring champagne from the bottle.", "output_spec": "Print the single integer — the number of completely full glasses after t seconds.", "sample_inputs": ["3 5", "4 8"], "sample_outputs": ["4", "6"], "notes": "NoteIn the first sample, the glasses full after 5 seconds are: the top glass, both glasses on the second level and the middle glass at the bottom level. Left and right glasses of the bottom level will be half-empty."}, "positive_code": [{"source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n \"math/big\"\n)\n\nvar scanner *bufio.Scanner\nvar writer *bufio.Writer\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer = bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n zero := big.NewRat(0, 1)\n one := big.NewRat(1, 1)\n two := big.NewRat(2, 1)\n\n n, limit := getI(), getI()\n filled := make([][]*big.Rat, n)\n for r := range filled {\n filled[r] = make([]*big.Rat, r + 1)\n for c := range filled[r] {\n filled[r][c] = big.NewRat(0, 1)\n }\n }\n count := 0\n maxCount := (n + 1) * n / 2\n\n for t := 0; t < limit; t++ {\n pours := make([]*big.Rat, 1)\n pours[0] = big.NewRat(1, 1)\n for r := 0; r < n; r++ {\n allZero := true\n for _, pour := range pours {\n if pour.Cmp(zero) != 0 {\n allZero = false\n break\n }\n }\n if allZero {\n break\n }\n nextPours := make([]*big.Rat, r + 2)\n for i := range nextPours {\n nextPours[i] = big.NewRat(0, 1)\n }\n for c, pour := range pours {\n x := &big.Rat{}\n x.Add(filled[r][c], pour)\n if filled[r][c].Cmp(one) < 0 && x.Cmp(one) >= 0 {\n count++\n if count == maxCount {\n writer.WriteString(fmt.Sprintf(\"%d\\n\", count))\n return\n }\n }\n if x.Cmp(one) <= 0 {\n filled[r][c].Set(x)\n continue\n }\n pour.Sub(pour, one)\n pour.Add(pour, filled[r][c])\n filled[r][c].Set(one)\n pour.Quo(pour, two)\n nextPours[c].Add(nextPours[c], pour)\n nextPours[c + 1].Add(nextPours[c + 1], pour)\n }\n pours = nextPours\n }\n }\n\n writer.WriteString(fmt.Sprintf(\"%d\\n\", count))\n}\n"}, {"source_code": "// Codeforces 676 B\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\t\"strconv\"\n)\nvar in *bufio.Reader\n\nfunc readFive() (int,int,int,int,int) {\n var a [5]int\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"first read failure\", err)\n\t\tpanic(err)\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n for i:=0; i= drob {\n countFull ++\n v := aa[j]\n v = (v-drob)/2\n //fmt.Printf(\"a,v= %f %f\\n\",aa[j], v)\n an[j] += v\n an[j+1] += v\n }\n }\n // copy an -> a\n for j:=0; j= len(pyrimid) {\n\t\treturn\n\t}\n\tpyrimid[depth][index] += amount\n\tif pyrimid[depth][index] > 1024 {\n\t\tremain := pyrimid[depth][index] - 1024\n\t\tpyrimid[depth][index] = 1024\n\t\tpour(remain/2, depth+1, index, pyrimid)\n\t\tpour(remain/2, depth+1, index+1, pyrimid)\n\t}\n}\n\n\nfunc main() {\n\tvar n, t int\n\tfmt.Scanf(\"%d%d\", &n, &t)\n\tpyrimid := make([][]int, n, n)\n\n\tfor i := 1; i <= n; i++ {\n\t\tpyrimid[i-1] = make([]int, i, i)\n\t}\n\n\tfull_cnt := 0\n\tif t > 1024 {\n\t\tfull_cnt = (1 + n)*n/2\n\t\tfmt.Println(full_cnt)\n\t\treturn\n\t}\n\n\tfor i := 0; i < t; i++ {\n\t\tpour(1024, 0, 0, pyrimid)\n\t}\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j <= i; j++ {\n\t\t\tif pyrimid[i][j] >= 1024 {\n\t\t\t\tfull_cnt += 1\n\t\t\t}\n\t\t}\n\t}\n//\tfmt.Println(pyrimid)\n\tfmt.Println(full_cnt)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nvar one = int64(0x10000)\n\nfunc progressRow(p [][]int64, row int) (spill bool) {\n\tspill = false\n\tfor i := 0; i <= row; i++ {\n\t\tif p[row][i] > one {\n\t\t\tspill = true\n\t\t\tdiff := p[row][i] - one\n\t\t\tdiff >>= 1\n\t\t\tp[row+1][i] += diff\n\t\t\tp[row+1][i+1] += diff\n\t\t\tp[row][i] = one\n\t\t}\n\t}\n\treturn spill\n}\n\nfunc progress(p [][]int64, n int) {\n\tp[0][0] += one\n\tfor i := 0; i < n; i++ {\n\t\tspill := progressRow(p, i)\n\t\tif !spill {\n\t\t\treturn\n\t\t}\n\t}\n}\n\nfunc solve(n, t int) int {\n\tp := make([][]int64, n+1)\n\tfor i := 0; i <= n; i++ {\n\t\tp[i] = make([]int64, i+1)\n\t}\n\tfor i := 0; i < t; i++ {\n\t\tprogress(p, n)\n\t}\n\tcount := 0\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < i+1; j++ {\n\t\t\tif p[i][j] >= one {\n\t\t\t\tcount++\n\t\t\t}\n\t\t}\n\t}\n\treturn count\n}\n\nfunc main() {\n\tvar n, t int\n\tnr, err := fmt.Fscanln(os.Stdin, &n, &t)\n\tif nr != 2 || err != nil {\n\t\tpanic(err)\n\t}\n\tres := solve(n, t)\n\tfmt.Println(res)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t//\"math\"\n)\n\nvar glasses [][]float32\nvar n int\nvar t int\nfunc fill(glassNum int, level int, volume float32) {\n\tglasses[level][glassNum] += volume\n\tif glasses[level][glassNum] > 1 {\n\t\tremainVolume := glasses[level][glassNum] - 1\n\t\tglasses[level][glassNum] = 1\n\t\tif level != n - 1 {\n\t\t\tfill(glassNum, level + 1, remainVolume / 2.0)\n\t\t\tfill(glassNum + 1, level + 1, remainVolume / 2.0)\n\t\t}\n\t}\n}\n\nfunc main() {\n\n\t//fmt.Print(math.Abs(2 - 1))\n\n\tfmt.Scan(&n, &t)\n\n\tglasses = make([][]float32, 10)\n\n\tfor i := range glasses {\n\t\tglasses[i] = make([]float32, i + 1)\n\t}\n\n\tfor i := 0 ; i < t; i++ {\n\t\tfill(0,0,1)\n\t}\n\n\tans := 0\n\tfor i := range glasses {\n\t\tfor j := range glasses[i] {\n\t\t\tif glasses[i][j] == 1 {\n\t\t\t\tans++\n\t\t\t}\n\t\t}\n\t\tglasses[i] = make([]float32, i + 1)\n\t}\n\n\n\tfmt.Print(ans)\n\n}\n\n\n"}], "negative_code": [{"source_code": "// Codeforces 676 B\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\t\"strconv\"\n)\nvar in *bufio.Reader\n\nfunc readFive() (int,int,int,int,int) {\n var a [5]int\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"first read failure\", err)\n\t\tpanic(err)\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n for i:=0; i= 0.999999999999 {\n countFull ++\n v := (aa[j] - 1.0)/2.0\n //fmt.Printf(\"a,v= %f %f\\n\",aa[j], v)\n an[j] += v\n an[j+1] += v\n }\n }\n // copy an -> a\n //fmt.Println(i)\n for j:=0; j0;i-- {\n\t\tif j%i==0 {\n\t\t\tfmt.Print(i,\" \")\n\t\t\tj=i\n\t\t}\n\t}\n}\n\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nfunc main() {\n writer := bufio.NewWriter(os.Stdout)\n var n int\n fmt.Scan(&n)\n prev := n\n for i := n; i >= 1; i-- {\n if prev%i == 0 {\n writer.WriteString(strconv.Itoa(i))\n if i == 1 { writer.WriteRune('\\n') } else { writer.WriteRune(' ') }\n prev = i\n }\n }\n writer.Flush()\n}\n"}, {"source_code": "// Codeforces 58 B training, done\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\t\"strconv\"\n)\nvar in *bufio.Reader\n\nfunc readFive() (int,int,int,int,int) {\n var a [5]int\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"first read failure\", err)\n\t\tpanic(err)\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n for i:=0; i1; i-- {\n\t\tif n%i==0 {\n\t\t\tn = i\n\t\t\treturn\n\t\t}\n\t} \n\tn = 1\n}\n\nfunc solve() {\n\tfor n>1 {\n\t\tfmt.Printf(\"%d \", n)\n\t\tnextDiv()\n\t}\n}\n\nfunc printRes() {\n\tfmt.Print (\" 1\\n\")\n}\n\nfunc main() {\n \treadData() \n solve()\n printRes()\n}\n"}], "negative_code": [], "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63"} {"nl": {"description": "An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).The flying saucer, on which the brave pioneers set off, consists of three sections. These sections are connected by a chain: the 1-st section is adjacent only to the 2-nd one, the 2-nd one — to the 1-st and the 3-rd ones, the 3-rd one — only to the 2-nd one. The transitions are possible only between the adjacent sections.The spacecraft team consists of n aliens. Each of them is given a rank — an integer from 1 to n. The ranks of all astronauts are distinct. The rules established on the Saucer, state that an alien may move from section a to section b only if it is senior in rank to all aliens who are in the segments a and b (besides, the segments a and b are of course required to be adjacent). Any alien requires exactly 1 minute to make a move. Besides, safety regulations require that no more than one alien moved at the same minute along the ship.Alien A is senior in rank to alien B, if the number indicating rank A, is more than the corresponding number for B.At the moment the whole saucer team is in the 3-rd segment. They all need to move to the 1-st segment. One member of the crew, the alien with the identification number CFR-140, decided to calculate the minimum time (in minutes) they will need to perform this task.Help CFR-140, figure out the minimum time (in minutes) that all the astronauts will need to move from the 3-rd segment to the 1-st one. Since this number can be rather large, count it modulo m.", "input_spec": "The first line contains two space-separated integers: n and m (1 ≤ n, m ≤ 109) — the number of aliens on the saucer and the number, modulo which you should print the answer, correspondingly.", "output_spec": "Print a single number — the answer to the problem modulo m.", "sample_inputs": ["1 10", "3 8"], "sample_outputs": ["2", "2"], "notes": "NoteIn the first sample the only crew member moves from segment 3 to segment 2, and then from segment 2 to segment 1 without any problems. Thus, the whole moving will take two minutes.To briefly describe the movements in the second sample we will use value , which would correspond to an alien with rank i moving from the segment in which it is at the moment, to the segment number j. Using these values, we will describe the movements between the segments in the second sample: , , , , , , , , , , , , , , , , , , , , , , , , , ; In total: the aliens need 26 moves. The remainder after dividing 26 by 8 equals 2, so the answer to this test is 2."}, "positive_code": [{"source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\n\nfunc main(){\n\tvar n, m int64\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tn, _ = strconv.ParseInt(r.Text(), 0, 64)\n\tr.Scan()\n\tm, _ = strconv.ParseInt(r.Text(), 0, 64)\n\tvar a int64 = 3\n\tvar b int64 = 1\n\tfor n > 0 {\n\t\tif n%2 != 0 {\n\t\t\tb = (b*a)%m\n\t\t}\n\t\ta = (a*a)%m\n\t\tn = n/2\n\t}\n\tw.WriteString(strconv.FormatInt((b-1+m)%m, 10)+\"\\n\")\n\tw.Flush()\n}\n"}, {"source_code": "// 226A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc pow(x, n, mod int64) int64 {\n\tvar a, t int64\n\ta = 1\n\tt = x\n\tfor n != 0 {\n\t\tif n&1 == 1 {\n\t\t\ta = (a * t) % mod\n\t\t}\n\t\tt = (t * t) % mod\n\t\tn >>= 1\n\t}\n\treturn int64(a)\n}\nfunc main() {\n\tvar a, x, c int64\n\tfmt.Scan(&a, &x)\n\tc = pow(3, a, x)\n\tfmt.Println((c - 1 + x) % x)\n}\n"}, {"source_code": "// 226A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc pow(x, n, mod int64) int64 {\n\tvar a, t int64\n\ta = 1\n\tt = x\n\tfor n != 0 {\n\t\tif n&1 == 1 {\n\t\t\ta = (a * t) % mod\n\t\t}\n\t\tt = (t * t) % mod\n\t\tn >>= 1\n\t}\n\treturn int64(a)\n}\nfunc main() {\n\tvar a, x, c int64\n\tfmt.Scan(&a, &x)\n\tc = pow(3, a, x)\n\tfmt.Println((c - 1 + x) % x)\n}"}, {"source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\nfunc scanInt(scanner *bufio.Scanner) int {\n\tscanner.Scan()\n\tx, _ := strconv.Atoi(scanner.Text())\n\treturn x\n}\n\nvar memo map[int64]int64\n\nfunc pow3(n, m int64) int64 {\n\tx, present := memo[n]\n\tif present {\n\t\treturn x\n\t}\n\tx = (pow3(n/2, m) * pow3(n-n/2, m)) % m\n\tmemo[n] = x\n\treturn x\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tn := int64(scanInt(scanner))\n\tm := int64(scanInt(scanner))\n\tmemo = map[int64]int64{ 0: 1%m, 1: 3%m }\n\tx := pow3(n, m) - 1\n\tif x == -1 {\n\t\tx = m-1\n\t}\n\twriter.WriteString(fmt.Sprintf(\"%d\\n\", x))\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\nfunc scanInt(scanner *bufio.Scanner) int {\n\tscanner.Scan()\n\tx, _ := strconv.Atoi(scanner.Text())\n\treturn x\n}\n\nvar memo map[int]int\n\nfunc pow3(n, m int) int {\n\tx, present := memo[n]\n\tif present {\n\t\treturn x\n\t}\n\tx = (pow3(n/2, m) * pow3(n-n/2, m)) % m\n\tmemo[n] = x\n\treturn x\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tn := scanInt(scanner)\n\tm := scanInt(scanner)\n\tmemo = map[int]int{ 0: 1%m, 1: 3%m }\n\tx := pow3(n, m) - 1\n\tif x == -1 {\n\t\tx = m-1\n\t}\n\twriter.WriteString(fmt.Sprintf(\"%d\\n\", x))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\nfunc scanInt(scanner *bufio.Scanner) int {\n\tscanner.Scan()\n\tx, _ := strconv.Atoi(scanner.Text())\n\treturn x\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tn := int64(scanInt(scanner))\n\tm := int64(scanInt(scanner))\n\tx := int64(1)\n\tfor i := int64(1); i <= n; i++ {\n\t\tx *= 3\n\t\tif x >= m {\n\t\t\tx = ((x%m)*(n/i))%m\n\t\t\tfor j := n%i; j != 0; j-- {\n\t\t\t\tx *= 3\n\t\t\t\tif x >= m {\n\t\t\t\t\tx %= m\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\tx--\n\tif x == -1 {\n\t\tx = m-1\n\t}\n\twriter.WriteString(fmt.Sprintf(\"%d\\n\", x))\n}\n"}], "src_uid": "c62ad7c7d1ea7aec058d99223c57d33c"} {"nl": {"description": "This version of the problem differs from the next one only in the constraint on $$$n$$$.Note that the memory limit in this problem is lower than in others.You have a vertical strip with $$$n$$$ cells, numbered consecutively from $$$1$$$ to $$$n$$$ from top to bottom.You also have a token that is initially placed in cell $$$n$$$. You will move the token up until it arrives at cell $$$1$$$.Let the token be in cell $$$x > 1$$$ at some moment. One shift of the token can have either of the following kinds: Subtraction: you choose an integer $$$y$$$ between $$$1$$$ and $$$x-1$$$, inclusive, and move the token from cell $$$x$$$ to cell $$$x - y$$$. Floored division: you choose an integer $$$z$$$ between $$$2$$$ and $$$x$$$, inclusive, and move the token from cell $$$x$$$ to cell $$$\\lfloor \\frac{x}{z} \\rfloor$$$ ($$$x$$$ divided by $$$z$$$ rounded down). Find the number of ways to move the token from cell $$$n$$$ to cell $$$1$$$ using one or more shifts, and print it modulo $$$m$$$. Note that if there are several ways to move the token from one cell to another in one shift, all these ways are considered distinct (check example explanation for a better understanding).", "input_spec": "The only line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \\le n \\le 2 \\cdot 10^5$$$; $$$10^8 < m < 10^9$$$; $$$m$$$ is a prime number) — the length of the strip and the modulo.", "output_spec": "Print the number of ways to move the token from cell $$$n$$$ to cell $$$1$$$, modulo $$$m$$$.", "sample_inputs": ["3 998244353", "5 998244353", "42 998244353"], "sample_outputs": ["5", "25", "793019428"], "notes": "NoteIn the first test, there are three ways to move the token from cell $$$3$$$ to cell $$$1$$$ in one shift: using subtraction of $$$y = 2$$$, or using division by $$$z = 2$$$ or $$$z = 3$$$.There are also two ways to move the token from cell $$$3$$$ to cell $$$1$$$ via cell $$$2$$$: first subtract $$$y = 1$$$, and then either subtract $$$y = 1$$$ again or divide by $$$z = 2$$$.Therefore, there are five ways in total."}, "positive_code": [{"source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"os\"\r\n\t\"sort\"\r\n)\r\n\r\nvar (\r\n\tin = bufio.NewReader(os.Stdin)\r\n)\r\n\r\nfunc main() {\r\n\tvar test int\r\n\t//fmt.Fscan(in, &test)\r\n\ttest = 1\r\n\tfor i := 0; i < test; i++ {\r\n\t\tsolve()\r\n\t}\r\n\r\n}\r\nfunc solve() {\r\n\tvar n, m int64\r\n\tfmt.Fscan(in, &n)\r\n\tfmt.Fscan(in, &m)\r\n\tvar dp = make([]int64, n+1)\r\n\tdp[1] = 1\r\n\tvar currentWays int64 = 1\r\n\tfor i := 2; i <= int(n); i++ {\r\n\t\tdp[i] = currentWays\r\n\t\tfor j := 1; j*j <= i; j++ {\r\n\t\t\t//smaller ocurrance\r\n\t\t\tvar numberOfOccurance = int64(i/j - i/(j+1))\r\n\t\t\tdp[i] += (dp[j] * numberOfOccurance) % m\r\n\t\t\tdp[i] %= m\r\n\t\t\tif j != i/j && j > 1 {\r\n\t\t\t\tdp[i] += dp[i/j]\r\n\t\t\t\tdp[i] %= m\r\n\t\t\t}\r\n\t\t}\r\n\t\tcurrentWays += dp[i]\r\n\t\tcurrentWays %= m\r\n\t}\r\n\tfmt.Println(dp[n])\r\n}\r\n\r\n//x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-TEMPLATE_STARTING-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-\r\n\r\ntype pair struct {\r\n\ta int64\r\n\tb int64\r\n}\r\n\r\nfunc sortPair(pairs []pair) {\r\n\tsort.Slice(pairs, func(i, j int) bool {\r\n\t\treturn pairs[i].a < pairs[j].a\r\n\t})\r\n}\r\nfunc max(a int64, b int64) int64 {\r\n\tif a > b {\r\n\t\treturn a\r\n\t}\r\n\treturn b\r\n}\r\n\r\nfunc printArray(arr []int) {\r\n\tfor i := 1; i < len(arr); i++ {\r\n\t\tfmt.Print(arr[i], \" \")\r\n\t}\r\n\tfmt.Println()\r\n}\r\n\r\ntype runeSort []rune\r\n\r\nfunc (r runeSort) Len() int { return len(r) }\r\nfunc (r runeSort) Swap(i, j int) { r[i], r[j] = r[j], r[i] }\r\nfunc (r runeSort) Less(i, j int) bool { return r[i] < r[j] }\r\n"}, {"source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n)\r\n\r\nvar _, _, _ = main, rw, do\r\n\r\nfunc main() {\r\n\tr, w := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\r\n\tdefer w.Flush()\r\n\trw(r, w)\r\n}\r\n\r\nfunc rw(r io.Reader, w io.Writer) {\r\n\tvar n int\r\n\tvar m int64\r\n\tfmt.Fscan(r, &n, &m)\r\n\tw1 := do(n, m)\r\n\tfmt.Fprintln(w, w1)\r\n}\r\n\r\n/*x/2 x/3 ... x/n/2 ... x/n\r\n1 2,3 3,4,5 ... n/2 ... n\r\n2 4,5 6,7,8 ... n\r\n3 6,7 9,10,11 ...\r\n4 8,9 12,13,14 ...\r\n. ...\r\nn+n/2+n/3+...+n/n-1=n(1+1/2+1/3+...)=nlogn\r\n*/\r\n\r\nfunc do(n int, m int64) int64 {\r\n\ta := make([]int64, n+2)\r\n\ta[n] = 1\r\n\tfor i := n - 1; i >= 1; i-- {\r\n\t\ta[i] = a[i+1]\r\n\t\tfor j := 2; j*i <= n; j++ {\r\n\t\t\ta[i] = (a[i] + a[j*i] - a[min(n+1, j*i+j)] + m) % m\r\n\t\t}\r\n\t\ta[i] = (a[i] + a[i+1]) % m\r\n\t}\r\n\treturn (a[1] - a[2] + m) % m\r\n}\r\n\r\nfunc min(a, b int) int {\r\n\tif a < b {\r\n\t\treturn a\r\n\t}\r\n\treturn b\r\n}\r\n"}, {"source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"os\"\r\n)\r\n\r\nfunc main() {\r\n\tin := bufio.NewReader(os.Stdin)\r\n\tout := bufio.NewWriter(os.Stdout)\r\n\tdefer out.Flush()\r\n\tvar n, m int64\r\n\tfmt.Fscan(in, &n, &m)\r\n\tf := make([]int64, n+5)\r\n\tf[1] = 1\r\n\tpre := make([]int64, n+5)\r\n\tpre[1] = 1\r\n\tf[2] = 2\r\n\tf[3] = 5\r\n\tpre[2] = f[1] + f[2]\r\n\tpre[3] = f[1] + f[2] + f[3]\r\n\tvar i int64\r\n\tfor i = 4; i <= n; i++ {\r\n\t\tf[i] = pre[i-1] % m\r\n\t\tvar lst int64 = -1\r\n\t\tvar tmp int64 = 0\r\n\t\tvar j int64\r\n\t\tfor j = 2; j*j <= i; j++ {\r\n\t\t\tif j == 2 {\r\n\t\t\t\tlst = i / j\r\n\t\t\t\ttmp = ((tmp%m+((i%m-lst%m)%m*f[j-1]%m)%m)%m + f[i/j]%m) % m\r\n\t\t\t\tcontinue\r\n\t\t\t}\r\n\t\t\tt := lst\r\n\t\t\tlst = i / j\r\n\t\t\ttmp = ((tmp%m+((t%m-lst%m)%m*f[j-1]%m)%m)%m + f[i/j]%m) % m\r\n\t\t}\r\n\t\tif i/j == j-1 {\r\n\t\t\tt := lst\r\n\t\t\tlst = i / j\r\n\t\t\ttmp = (tmp%m + ((t%m-lst%m)%m*f[j-1]%m)%m) % m\r\n\t\t}\r\n\t\tf[i] = (f[i]%m + tmp%m) % m\r\n\t\tpre[i] = (pre[i-1]%m + f[i]%m) % m\r\n\t}\r\n\tfmt.Fprintln(out, f[n])\r\n}\r\n"}, {"source_code": "package main\r\n\r\nimport (\r\n\t. \"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n)\r\n\r\n// github.com/EndlessCheng/codeforces-go\r\nfunc CF1558B(in io.Reader, out io.Writer) {\r\n\tmin := func(a, b int) int {\r\n\t\tif a > b {\r\n\t\t\treturn b\r\n\t\t}\r\n\t\treturn a\r\n\t}\r\n\r\n\tvar n, m int\r\n\tFscan(in, &n, &m)\r\n\tf := make([]int, n+2)\r\n\tf[n] = 1\r\n\tfor i := n - 1; i > 0; i-- {\r\n\t\tf[i] = f[i+1] * 2 % m\r\n\t\tfor j := 2; j*i <= n; j++ {\r\n\t\t\tf[i] = (f[i] + (f[i*j]-f[min((i+1)*j, n+1)]+m)%m) % m\r\n\t\t}\r\n\t}\r\n\tFprint(out, (f[1]-f[2]+m)%m)\r\n}\r\n\r\nfunc main() { CF1558B(os.Stdin, os.Stdout) }\r\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tr := bufio.NewReaderSize(os.Stdin, 1024*1024)\n\n\tvar n, m int\n\tfmt.Fscanf(r, \"%d %d\\n\", &n, &m)\n\n\tf := make([]int, n+1)\n\ts := make([]int, n+1)\n\n\tf[1] = 1\n\ts[1] = 1\n\tfor i := 2; i <= n; i++ {\n\t\tf[i] = s[i-1]\n\t\tp := i\n\n\t\tif i <= 5 {\n\t\t\tfor j := 2; j <= i; j++ {\n\t\t\t\tf[i] = (f[i] + f[i/j]) % m\n\t\t\t}\n\t\t} else {\n\t\t\t/*\tfmt.Println(i, \": \")\n\t\t\t\tfor j := 2; j <= i; j++ {\n\t\t\t\t\tfmt.Print(i/j, \" \")\n\t\t\t\t}\n\t\t\t\tfmt.Println()*/\n\n\t\t\tfor j := 2; j < i; j++ {\n\t\t\t\tif j-1 > i/j {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif j-1 == i/j {\n\t\t\t\t\t//\tfmt.Println(i, i/j, p-i/j, \"x\", j-1)\n\t\t\t\t\tf[i] = int((int64(f[i]) + int64(p-i/j)*int64(f[j-1])) % int64(m))\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t//fmt.Println(i, i/j, p-i/j, \"x\", j-1)\n\t\t\t\tf[i] = int((int64(f[i]) + (int64(p-i/j) * int64(f[j-1]))) % int64(m))\n\t\t\t\tf[i] = (f[i] + f[i/j]) % m\n\t\t\t\tp = i / j\n\t\t\t}\n\t\t}\n\n\t\ts[i] = (s[i-1] + f[i]) % m\n\t}\n\n\tfmt.Println(f[n])\n}\n"}], "negative_code": [{"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\"sort\"\r\n)\r\n\r\nvar (\r\n\tin = bufio.NewReader(os.Stdin)\r\n\tdp []int64\r\n)\r\n\r\nfunc main() {\r\n\tvar test int = 1\r\n\t//fmt.Fscan(in, &test)\r\n\tfor i := 0; i < test; i++ {\r\n\t\tsolve()\r\n\t}\r\n\r\n}\r\n\r\nfunc init() {\r\n\tdp = make([]int64, 1000000)\r\n}\r\n\r\nfunc solve() {\r\n\tvar n, internalm int64\r\n\tfmt.Fscan(in, &n)\r\n\tfmt.Fscan(in, &internalm)\r\n\tsolve2(n, 0)\r\n\tfmt.Println(dp[n] % internalm)\r\n\r\n}\r\n\r\nfunc solve2(n int64, tempCount int64) int64 {\r\n\tif n < 1 {\r\n\t\treturn 0\r\n\t}\r\n\tif n == 1 {\r\n\t\treturn 1\r\n\t}\r\n\tif dp[n] != 0 {\r\n\t\treturn dp[n]\r\n\t}\r\n\tvar currentAns int64\r\n\tfor i := 1; i < int(n); i++ {\r\n\t\tcurrentAns += solve2(n-int64(i), tempCount+1)\r\n\t}\r\n\tfor i := 2; i <= int(n); i++ {\r\n\t\tcurrentAns += solve2(int64(math.Floor(float64(n/int64(i)))), tempCount+1)\r\n\t}\r\n\tdp[n] = currentAns\r\n\treturn currentAns\r\n}\r\n\r\n//x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-TEMPLATE_STARTING-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-\r\n\r\ntype pair struct {\r\n\ta int64\r\n\tb int64\r\n}\r\n\r\nfunc sortPair(pairs []pair) {\r\n\tsort.Slice(pairs, func(i, j int) bool {\r\n\t\treturn pairs[i].a < pairs[j].a\r\n\t})\r\n}\r\nfunc min(a int64, b int64) int64 {\r\n\tif a < b {\r\n\t\treturn a\r\n\t}\r\n\treturn b\r\n}\r\n\r\nfunc printArray(arr []int) {\r\n\tfor i := 1; i < len(arr); i++ {\r\n\t\tfmt.Print(arr[i], \" \")\r\n\t}\r\n\tfmt.Println()\r\n}\r\n\r\ntype runeSort []rune\r\n\r\nfunc (r runeSort) Len() int { return len(r) }\r\nfunc (r runeSort) Swap(i, j int) { r[i], r[j] = r[j], r[i] }\r\nfunc (r runeSort) Less(i, j int) bool { return r[i] < r[j] }\r\n"}], "src_uid": "a524aa54e83fd0223489a19531bf0e79"} {"nl": {"description": "Vova, the Ultimate Thule new shaman, wants to build a pipeline. As there are exactly n houses in Ultimate Thule, Vova wants the city to have exactly n pipes, each such pipe should be connected to the water supply. A pipe can be connected to the water supply if there's water flowing out of it. Initially Vova has only one pipe with flowing water. Besides, Vova has several splitters.A splitter is a construction that consists of one input (it can be connected to a water pipe) and x output pipes. When a splitter is connected to a water pipe, water flows from each output pipe. You can assume that the output pipes are ordinary pipes. For example, you can connect water supply to such pipe if there's water flowing out from it. At most one splitter can be connected to any water pipe. The figure shows a 4-output splitter Vova has one splitter of each kind: with 2, 3, 4, ..., k outputs. Help Vova use the minimum number of splitters to build the required pipeline or otherwise state that it's impossible.Vova needs the pipeline to have exactly n pipes with flowing out water. Note that some of those pipes can be the output pipes of the splitters.", "input_spec": "The first line contains two space-separated integers n and k (1 ≤ n ≤ 1018, 2 ≤ k ≤ 109). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.", "output_spec": "Print a single integer — the minimum number of splitters needed to build the pipeline. If it is impossible to build a pipeline with the given splitters, print -1.", "sample_inputs": ["4 3", "5 5", "8 4"], "sample_outputs": ["2", "1", "-1"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k int64\n\tfmt.Scanln(&n, &k)\n\tlo, hi := int64(0), k\n\tfor lo <= hi {\n\t\tx := (lo + hi) >> 1\n\t\tif (k+k-x-1)*x/2+1 >= n {\n\t\t\thi = x - 1\n\t\t} else {\n\t\t\tlo = x + 1\n\t\t}\n\t}\n\tif lo < k {\n\t\tfmt.Println(lo)\n\t} else {\n\t\tfmt.Println(-1)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc sum(k, num int64) int64 {\n\treturn num * k - (num - 1) * (num + 2) / 2\n\t//return num * ((k-1)+(k - num))/2 + 1\n}\n\nfunc run(n, k int64) {\n\tvar i, j, mid int64\n\ti, j = 0, k\n\tfor i < j {\n\t\tmid = (i + j) >> 1\n\t\ts := sum(k, mid)\n\t\tif s < n {\n\t\t\ti = mid + 1\n\t\t} else {\n\t\t\tj = mid\n\t\t}\n\t}\n\tmid = (i + j) >> 1\n\tif sum(k, mid) < n {\n\t\tfmt.Println(-1)\n\t} else {\n\t\tfmt.Println((i + j) >> 1)\n\t}\n}\n\nfunc main() {\n\tvar n, k int64\n\tfor _, err := fmt.Scanf(\"%d %d\", &n, &k); err == nil; _, err = fmt.Scanf(\"%d %d\", &n, &k) {\n\t\trun(n, k)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc sum(k, num int64) int64 {\n\treturn num * ((k-1)+(k - num))/2 + 1\n}\n\nfunc run(n, k int64) {\n\tvar i, j, mid int64\n\ti, j = 0, k-1\n\tmid = (i + j) >> 1\n\tif sum(k, j) < n {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\tfor i < j {\n\t\ts := sum(k, mid)\n\t\tif s >= n {\n\t\t\tj = mid\n\t\t} else {\n\t\t\ti = mid + 1\n\t\t}\n\t\tmid = (i + j) >> 1\n\t}\n\tfmt.Println(mid)\n}\n\nfunc main() {\n\tvar n, k int64\n\tfor _, err := fmt.Scanf(\"%d %d\", &n, &k); err == nil; _, err = fmt.Scanf(\"%d %d\", &n, &k) {\n\t\trun(n, k)\n\t}\n}"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc sum(k, num int64) int64 {\n\treturn num * ((k-1)+(k - num))/2 + 1\n}\n\nfunc run(n, k int64) {\n\tvar i, j, mid int64\n\ti, j = 1, k-1\n\tmid = (i + j) >> 1\n\tif sum(k, j) < n {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\tfor i < j {\n\t\ts := sum(k, mid)\n\t\tif s >= n {\n\t\t\tj = mid\n\t\t} else {\n\t\t\ti = mid + 1\n\t\t}\n\t\tmid = (i + j) >> 1\n\t}\n\tfmt.Println(mid)\n}\n\nfunc main() {\n\tvar n, k int64\n\tfor _, err := fmt.Scanf(\"%d %d\", &n, &k); err == nil; _, err = fmt.Scanf(\"%d %d\", &n, &k) {\n\t\trun(n, k)\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc sum(k, num int64) int64 {\n\treturn num * ((k-1)+(k - num))/2 + 1\n}\n\nfunc run(n, k int64) {\n\t//fmt.Println(\"------------------\", n, k)\n\tvar i, j, mid int64\n\ti, j = 1, k-1\n\tmid = (i + j) >> 1\n\tif sum(k, j) < n {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\tfor i < j {\n\t\ts := sum(k, mid)\n\t\tif s > n {\n\t\t\tj = mid - 1\n\t\t} else {\n\t\t\ti = mid + 1\n\t\t}\n\t\tmid = (i + j) >> 1\n\t}\n\tfmt.Println(mid)\n}\n\nfunc main() {\n\tvar n, k int64\n\tfor _, err := fmt.Scanf(\"%d %d\", &n, &k); err == nil; _, err = fmt.Scanf(\"%d %d\", &n, &k) {\n\t\trun(n, k)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc sum(k, num int64) int64 {\n\treturn num * ((k-1)+(k - num))/2 + 1\n}\n\nfunc run(n, k int64) {\n\tvar i, j, mid int64\n\ti, j = 1, k-1\n\tmid = (i + j) >> 1\n\tif sum(k, j) < n {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\tfor i < j {\n\t\tif sum(n, mid) > n {\n\t\t\tj = mid - 1\n\t\t} else {\n\t\t\ti = mid + 1\n\t\t}\n\t\tmid = (i + j) >> 1\n\t}\n\tfmt.Println(mid)\n}\n\nfunc main() {\n\tvar n, k int64\n\tfor _, err := fmt.Scanf(\"%d %d\", &n, &k); err == nil; _, err = fmt.Scanf(\"%d %d\", &n, &k) {\n\t\trun(n, k)\n\t}\n}\n"}], "src_uid": "83bcfe32db302fbae18e8a95d89cf411"} {"nl": {"description": "THE SxPLAY & KIVΛ - 漂流 KIVΛ & Nikki Simmons - PerspectivesWith a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space.The space can be considered a 2D plane, with an infinite number of data nodes, indexed from $$$0$$$, with their coordinates defined as follows: The coordinates of the $$$0$$$-th node is $$$(x_0, y_0)$$$ For $$$i > 0$$$, the coordinates of $$$i$$$-th node is $$$(a_x \\cdot x_{i-1} + b_x, a_y \\cdot y_{i-1} + b_y)$$$ Initially Aroma stands at the point $$$(x_s, y_s)$$$. She can stay in OS space for at most $$$t$$$ seconds, because after this time she has to warp back to the real world. She doesn't need to return to the entry point $$$(x_s, y_s)$$$ to warp home.While within the OS space, Aroma can do the following actions: From the point $$$(x, y)$$$, Aroma can move to one of the following points: $$$(x-1, y)$$$, $$$(x+1, y)$$$, $$$(x, y-1)$$$ or $$$(x, y+1)$$$. This action requires $$$1$$$ second. If there is a data node at where Aroma is staying, she can collect it. We can assume this action costs $$$0$$$ seconds. Of course, each data node can be collected at most once. Aroma wants to collect as many data as possible before warping back. Can you help her in calculating the maximum number of data nodes she could collect within $$$t$$$ seconds?", "input_spec": "The first line contains integers $$$x_0$$$, $$$y_0$$$, $$$a_x$$$, $$$a_y$$$, $$$b_x$$$, $$$b_y$$$ ($$$1 \\leq x_0, y_0 \\leq 10^{16}$$$, $$$2 \\leq a_x, a_y \\leq 100$$$, $$$0 \\leq b_x, b_y \\leq 10^{16}$$$), which define the coordinates of the data nodes. The second line contains integers $$$x_s$$$, $$$y_s$$$, $$$t$$$ ($$$1 \\leq x_s, y_s, t \\leq 10^{16}$$$) – the initial Aroma's coordinates and the amount of time available.", "output_spec": "Print a single integer — the maximum number of data nodes Aroma can collect within $$$t$$$ seconds.", "sample_inputs": ["1 1 2 3 1 0\n2 4 20", "1 1 2 3 1 0\n15 27 26", "1 1 2 3 1 0\n2 2 1"], "sample_outputs": ["3", "2", "0"], "notes": "NoteIn all three examples, the coordinates of the first $$$5$$$ data nodes are $$$(1, 1)$$$, $$$(3, 3)$$$, $$$(7, 9)$$$, $$$(15, 27)$$$ and $$$(31, 81)$$$ (remember that nodes are numbered from $$$0$$$).In the first example, the optimal route to collect $$$3$$$ nodes is as follows: Go to the coordinates $$$(3, 3)$$$ and collect the $$$1$$$-st node. This takes $$$|3 - 2| + |3 - 4| = 2$$$ seconds. Go to the coordinates $$$(1, 1)$$$ and collect the $$$0$$$-th node. This takes $$$|1 - 3| + |1 - 3| = 4$$$ seconds. Go to the coordinates $$$(7, 9)$$$ and collect the $$$2$$$-nd node. This takes $$$|7 - 1| + |9 - 1| = 14$$$ seconds. In the second example, the optimal route to collect $$$2$$$ nodes is as follows: Collect the $$$3$$$-rd node. This requires no seconds. Go to the coordinates $$$(7, 9)$$$ and collect the $$$2$$$-th node. This takes $$$|15 - 7| + |27 - 9| = 26$$$ seconds. In the third example, Aroma can't collect any nodes. She should have taken proper rest instead of rushing into the OS space like that."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF1292B(_r io.Reader, _w io.Writer) {\n\ttype point struct{ x, y int64 }\n\tabs := func(x int64) int64 {\n\t\tif x < 0 {\n\t\t\treturn -x\n\t\t}\n\t\treturn x\n\t}\n\tdis := func(a, b point) int64 { return abs(a.x-b.x) + abs(a.y-b.y) }\n\n\tvar ax, ay, bx, by, tt int64\n\tvar p, st point\n\tFscan(_r, &p.x, &p.y, &ax, &ay, &bx, &by, &st.x, &st.y, &tt)\n\tps := []point{}\n\tfor ; p.x < 9e16 && p.y < 9e16; p.x, p.y = ax*p.x+bx, ay*p.y+by {\n\t\tps = append(ps, p)\n\t}\n\n\tans := 0\n\tfor i, p := range ps {\n\t\tt := tt\n\t\tif d := dis(st, p); d <= t {\n\t\t\tt -= d\n\t\t\tc := 1\n\t\t\tfor j := i; j > 0; j-- {\n\t\t\t\tif d := dis(ps[j], ps[j-1]); d <= t {\n\t\t\t\t\tt -= d\n\t\t\t\t\tc++\n\t\t\t\t} else {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif i+1 < len(ps) {\n\t\t\t\tif d := dis(ps[0], ps[i+1]); d <= t {\n\t\t\t\t\tt -= d\n\t\t\t\t\tc++\n\t\t\t\t\tfor j := i + 2; j < len(ps); j++ {\n\t\t\t\t\t\tif d := dis(ps[j], ps[j-1]); d <= t {\n\t\t\t\t\t\t\tt -= d\n\t\t\t\t\t\t\tc++\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif c > ans {\n\t\t\t\tans = c\n\t\t\t}\n\t\t}\n\t}\n\tFprint(_w, ans)\n}\n\nfunc main() { CF1292B(os.Stdin, os.Stdout) }\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)\n\nfunc scanInt() int {\n\tsc.Scan(); a,_ := strconv.Atoi(sc.Text()); return a\n}\n\nfunc scanInt64() int64 {\n\tsc.Scan(); a,_ := strconv.ParseInt(sc.Text(),10,64); return a\n}\n\nfunc scanFloat64() float64 {\n\tsc.Scan(); a,_ := strconv.ParseFloat(sc.Text(),64); return a\n}\n\nfunc scanInts(n int) []int {\n\tres := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }\n\treturn res\n}\n\nfunc scanString() string {\n\tsc.Scan(); return sc.Text()\n}\n\nfunc printInts(a ...int) {\n\tfor i, e := range a {\n\t\tfmt.Fprint(wr, e); if i != len(a)-1 { fmt.Fprint(wr, \" \") }\n\t}\n\tfmt.Fprintln(wr); wr.Flush()\n}\n\nfunc abs(a int64) int64 { if a<0 { return -a }; return a }\nfunc min(a,b int) int { if ab { return a }; return b }\n\n//•*¨*•.¸¸♪Main•*¨*•.¸¸♪( -ω-)ノ ( ・ω・)\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\tsc.Buffer(make([]byte, 10000), 1000000)\n\n\tx0 := scanInt64()\n\ty0 := scanInt64()\n\tax := scanInt64()\n\tay := scanInt64()\n\tbx := scanInt64()\n\tby :=scanInt64()\n\txs := scanInt64()\n\tys := scanInt64()\n\tt := scanInt64()\n\n\tx := []int64{x0}\n\ty := []int64{y0}\n\n\tconst mat = 1 << 60\n\n\tfor x[len(x)-1] < (mat-bx)/ax && y[len(y)-1] < (mat-by)/ay {\n\t\tnext := len(x)-1\n\t\tx = append(x, ax*x[next]+bx)\n\t\ty = append(y, ay*y[next]+by)\n\t}\n\n\tans := 0\n\n\tfor i := 0; i < len(x); i++ {\n\t\tfor j := i; j < len(x); j++ {\n\t\t\tltor := x[j]-x[i]+y[j]-y[i]\n\t\t\ttol := abs(xs-x[i])+abs(ys-y[i])\n\t\t\ttor := abs(xs-x[j])+abs(ys-y[j])\n\n\t\t\tif t >= ltor+tor || t >= tol+ltor {\n\t\t\t\t// fmt.Println(ltor,tol,ltor+tor,j,i)\n\t\t\t\tans = max(ans, j-i+1)\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n\t// fmt.Println(x)\n\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF1292B(_r io.Reader, _w io.Writer) {\n\ttype point struct{ x, y int64 }\n\tabs := func(x int64) int64 {\n\t\tif x < 0 {\n\t\t\treturn -x\n\t\t}\n\t\treturn x\n\t}\n\tdis := func(a, b point) int64 { return abs(a.x-b.x) + abs(a.y-b.y) }\n\n\tvar ax, ay, bx, by, tt int64\n\tvar p, st point\n\tFscan(_r, &p.x, &p.y, &ax, &ay, &bx, &by, &st.x, &st.y, &tt)\n\tps := []point{}\n\tfor ; p.x < 1e17 && p.y < 1e17; p.x, p.y = ax*p.x+bx, ay*p.y+by {\n\t\tps = append(ps, p)\n\t}\n\n\tans := 0\n\tfor i, p := range ps {\n\t\tt := tt\n\t\tif d := dis(st, p); d <= t {\n\t\t\tt -= d\n\t\t\tc := 1\n\t\t\tfor j := i; j > 0; j-- {\n\t\t\t\tif d := dis(ps[j], ps[j-1]); d <= t {\n\t\t\t\t\tt -= d\n\t\t\t\t\tc++\n\t\t\t\t} else {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif i+1 < len(ps) {\n\t\t\t\tif d := dis(ps[0], ps[i+1]); d <= t {\n\t\t\t\t\tt -= d\n\t\t\t\t\tc++\n\t\t\t\t\tfor j := i + 2; j < len(ps); j++ {\n\t\t\t\t\t\tif d := dis(ps[j], ps[j-1]); d <= t {\n\t\t\t\t\t\t\tt -= d\n\t\t\t\t\t\t\tc++\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif c > ans {\n\t\t\t\tans = c\n\t\t\t}\n\t\t}\n\t}\n\tFprint(_w, ans)\n}\n\nfunc main() { CF1292B(os.Stdin, os.Stdout) }\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)\n\nfunc scanInt() int {\n\tsc.Scan(); a,_ := strconv.Atoi(sc.Text()); return a\n}\n\nfunc scanInt64() int64 {\n\tsc.Scan(); a,_ := strconv.ParseInt(sc.Text(),10,64); return a\n}\n\nfunc scanFloat64() float64 {\n\tsc.Scan(); a,_ := strconv.ParseFloat(sc.Text(),64); return a\n}\n\nfunc scanInts(n int) []int {\n\tres := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }\n\treturn res\n}\n\nfunc scanString() string {\n\tsc.Scan(); return sc.Text()\n}\n\nfunc printInts(a ...int) {\n\tfor i, e := range a {\n\t\tfmt.Fprint(wr, e); if i != len(a)-1 { fmt.Fprint(wr, \" \") }\n\t}\n\tfmt.Fprintln(wr); wr.Flush()\n}\n\nfunc abs(a int64) int64 { if a<0 { return -a }; return a }\nfunc min(a,b int) int { if ab { return a }; return b }\n\n//•*¨*•.¸¸♪Main•*¨*•.¸¸♪( -ω-)ノ ( ・ω・)\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\tsc.Buffer(make([]byte, 10000), 1000000)\n\n\tx0 := scanInt64()\n\ty0 := scanInt64()\n\tax := scanInt64()\n\tay := scanInt64()\n\tbx := scanInt64()\n\tby :=scanInt64()\n\txs := scanInt64()\n\tys := scanInt64()\n\tt := scanInt64()\n\n\tx := []int64{x0}\n\ty := []int64{y0}\n\n\tconst mat = 100000000000000000\n\n\tfor x[len(x)-1] < mat && y[len(y)-1] < mat {\n\t\tnext := len(x)-1\n\t\tx = append(x, ax*x[next]+bx)\n\t\ty = append(y, ay*y[next]+by)\n\t}\n\n\tto := int64(0)\n\tans := 0\n\n\tdone := make([]bool, len(x))\n\n\tfor {\n\t\tmi := int64(1 << 63 -1)\n\t\tnext := -1\n\t\tfor i := 0; i < len(x); i++ {\n\t\t\tif done[i] {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif mi > abs(xs-x[i])+abs(ys-y[i]) {\n\t\t\t\tnext = i\n\t\t\t\tmi = abs(xs-x[i])+abs(ys-y[i])\n\t\t\t}\n\t\t}\n\n\t\tif next == -1 {\n\t\t\tbreak\n\t\t}\n\n\t\tif to+mi > t {\n\t\t\tbreak\n\t\t}\n\n\t\tans++\n\t\tto += mi\n\t\txs = x[next]\n\t\tys = y[next]\n\t\tdone[next] = true\n\t}\n\n\tfmt.Println(ans)\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)\n\nfunc scanInt() int {\n\tsc.Scan(); a,_ := strconv.Atoi(sc.Text()); return a\n}\n\nfunc scanInt64() int64 {\n\tsc.Scan(); a,_ := strconv.ParseInt(sc.Text(),10,64); return a\n}\n\nfunc scanFloat64() float64 {\n\tsc.Scan(); a,_ := strconv.ParseFloat(sc.Text(),64); return a\n}\n\nfunc scanInts(n int) []int {\n\tres := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }\n\treturn res\n}\n\nfunc scanString() string {\n\tsc.Scan(); return sc.Text()\n}\n\nfunc printInts(a ...int) {\n\tfor i, e := range a {\n\t\tfmt.Fprint(wr, e); if i != len(a)-1 { fmt.Fprint(wr, \" \") }\n\t}\n\tfmt.Fprintln(wr); wr.Flush()\n}\n\nfunc abs(a int64) int64 { if a<0 { return -a }; return a }\nfunc min(a,b int) int { if ab { return a }; return b }\n\n//•*¨*•.¸¸♪Main•*¨*•.¸¸♪( -ω-)ノ ( ・ω・)\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\tsc.Buffer(make([]byte, 10000), 1000000)\n\n\tx0 := scanInt64()\n\ty0 := scanInt64()\n\tax := scanInt64()\n\tay := scanInt64()\n\tbx := scanInt64()\n\tby :=scanInt64()\n\txs := scanInt64()\n\tys := scanInt64()\n\tt := scanInt64()\n\n\tx := []int64{x0}\n\ty := []int64{y0}\n\n\tconst mat = 1 << 60\n\n\tfor x[len(x)-1]*ax+bx <= mat && y[len(y)-1]*ay+by < mat {\n\t\tnext := len(x)-1\n\t\tx = append(x, ax*x[next]+bx)\n\t\ty = append(y, ay*y[next]+by)\n\t}\n\n\tans := 0\n\n\tfor i := 0; i < len(x); i++ {\n\t\tfor j := i; j < len(x); j++ {\n\t\t\tltor := x[j]-x[i]+y[j]-y[i]\n\t\t\ttol := abs(xs-x[i])+abs(ys-y[i])\n\t\t\ttor := abs(xs-x[j])+abs(ys-y[j])\n\n\t\t\tif t >= ltor+tor || t >= tol+ltor {\n\t\t\t\t// fmt.Println(ltor,tol,ltor+tor,j,i)\n\t\t\t\tans = max(ans, j-i+1)\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n\t// fmt.Println(x)\n\n}\n"}, {"source_code": "package main\n \nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n \n//=====I/O=====\n \nvar (\n\tsc = bufio.NewScanner(os.Stdin)\n\twr = bufio.NewWriter(os.Stdout)\n)\n \nfunc scanInt() int {\n\tsc.Scan()\n\ta,_ := strconv.Atoi(sc.Text())\n\treturn a\n}\n \nfunc scanInt64() int64 {\n\tsc.Scan()\n\ta,_ := strconv.ParseInt(sc.Text(),10,64)\n\treturn a\n}\n \nfunc scanFloat64() float64 {\n\tsc.Scan()\n\ta,_ := strconv.Atoi(sc.Text())\n\treturn float64(a)\n}\n \nfunc scanInts(n int) []int {\n\tres := make([]int, n)\n\tfor i := 0; i < n; i++ { res[i] = scanInt() }\n\treturn res\n}\n \nfunc scanText() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n \nfunc printInts(a ...int) {\n\tfor i, e := range a {\n\t\tfmt.Fprint(wr, e)\n\t\tif i != len(a)-1 { fmt.Fprint(wr, \" \") }\n\t}\n\tfmt.Fprintln(wr)\n\twr.Flush()\n}\n \n//•*¨*•.¸¸♪func•*¨*•.¸¸♪\n \nfunc calc(x,y,ax,ay,bx,by int64) (int64,int64) {\n\treturn ax*x+bx,ay*y+by\n}\n \nfunc dist(x1,y1,x2,y2 int64) int64 {\n\treturn abs(x1-x2)+abs(y1-y2)\n}\n \nfunc abs(a int64) int64 {\n\tif a<0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n \n//•*¨*•.¸¸♪main•*¨*•.¸¸♪\n \nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\t// sc.Buffer(make([]byte, 10000), 100000000)\n \n\tx0 := scanInt64()\n\ty0 := scanInt64()\n\tax := scanInt64()\n\tay := scanInt64()\n\tbx := scanInt64()\n\tby := scanInt64()\n \n\txs := scanInt64()\n\tys := scanInt64()\n\tt := scanInt64()\n \n\tcs := make([]coordinate, 0)\n\tcs = append(cs, coordinate{x0,y0})\n \n\tli := int64(10000000000000000)\n \n\tfor cs[len(cs)-1].x a[i] { res = a[i] }\n\t}\n\treturn res\n}\n\nfunc max(a ...int) int {\n\tres := a[0]\n\tfor i := 1; i < len(a); i++ {\n\t\tif res < a[i] { res = a[i] }\n\t}\n\treturn res\n}\n"}, {"source_code": "package main\n \nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n \n//=====I/O=====\n \nvar (\n\tsc = bufio.NewScanner(os.Stdin)\n\twr = bufio.NewWriter(os.Stdout)\n)\n \nfunc scanInt() int {\n\tsc.Scan()\n\ta,_ := strconv.Atoi(sc.Text())\n\treturn a\n}\n \nfunc scanInt64() int64 {\n\tsc.Scan()\n\ta,_ := strconv.ParseInt(sc.Text(),10,64)\n\treturn a\n}\n \nfunc scanFloat64() float64 {\n\tsc.Scan()\n\ta,_ := strconv.Atoi(sc.Text())\n\treturn float64(a)\n}\n \nfunc scanInts(n int) []int {\n\tres := make([]int, n)\n\tfor i := 0; i < n; i++ { res[i] = scanInt() }\n\treturn res\n}\n \nfunc scanText() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n \nfunc printInts(a ...int) {\n\tfor i, e := range a {\n\t\tfmt.Fprint(wr, e)\n\t\tif i != len(a)-1 { fmt.Fprint(wr, \" \") }\n\t}\n\tfmt.Fprintln(wr)\n\twr.Flush()\n}\n \n//•*¨*•.¸¸♪func•*¨*•.¸¸♪\n \nfunc calc(x,y,ax,ay,bx,by int64) (int64,int64) {\n\treturn ax*x+bx,ay*y+by\n}\n \nfunc dist(x1,y1,x2,y2 int64) int64 {\n\treturn abs(x1-x2)+abs(y1-y2)\n}\n \nfunc abs(a int64) int64 {\n\tif a<0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n \n//•*¨*•.¸¸♪main•*¨*•.¸¸♪\n \nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\t// sc.Buffer(make([]byte, 10000), 100000000)\n \n\tx0 := scanInt64()\n\ty0 := scanInt64()\n\tax := scanInt64()\n\tay := scanInt64()\n\tbx := scanInt64()\n\tby := scanInt64()\n \n\txs := scanInt64()\n\tys := scanInt64()\n\tt := scanInt64()\n \n\tcs := make([]coordinate, 0)\n\tcs = append(cs, coordinate{x0,y0})\n \n\tli := int64(100000000000000000)\n \n\tfor cs[len(cs)-1].x a[i] { res = a[i] }\n\t}\n\treturn res\n}\n\nfunc max(a ...int) int {\n\tres := a[0]\n\tfor i := 1; i < len(a); i++ {\n\t\tif res < a[i] { res = a[i] }\n\t}\n\treturn res\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)\n\nfunc scanInt() int {\n\tsc.Scan(); a,_ := strconv.Atoi(sc.Text()); return a\n}\n\nfunc scanInt64() int64 {\n\tsc.Scan(); a,_ := strconv.ParseInt(sc.Text(),10,64); return a\n}\n\nfunc scanFloat64() float64 {\n\tsc.Scan(); a,_ := strconv.ParseFloat(sc.Text(),64); return a\n}\n\nfunc scanInts(n int) []int {\n\tres := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }\n\treturn res\n}\n\nfunc scanString() string {\n\tsc.Scan(); return sc.Text()\n}\n\nfunc printInts(a ...int) {\n\tfor i, e := range a {\n\t\tfmt.Fprint(wr, e); if i != len(a)-1 { fmt.Fprint(wr, \" \") }\n\t}\n\tfmt.Fprintln(wr); wr.Flush()\n}\n\nfunc abs(a int64) int64 { if a<0 { return -a }; return a }\nfunc min(a,b int) int { if ab { return a }; return b }\n\n//•*¨*•.¸¸♪Main•*¨*•.¸¸♪( -ω-)ノ ( ・ω・)\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\tsc.Buffer(make([]byte, 10000), 1000000)\n\n\tx0 := scanInt64()\n\ty0 := scanInt64()\n\tax := scanInt64()\n\tay := scanInt64()\n\tbx := scanInt64()\n\tby :=scanInt64()\n\txs := scanInt64()\n\tys := scanInt64()\n\tt := scanInt64()\n\n\tx := []int64{x0}\n\ty := []int64{y0}\n\n\tconst mat = 100000000000000000\n\n\tfor x[len(x)-1] < mat && y[len(y)-1] < mat {\n\t\tnext := len(x)-1\n\t\tx = append(x, ax*x[next]+bx)\n\t\ty = append(y, ay*y[next]+by)\n\t}\n\n\tto := int64(0)\n\tans := 0\n\n\tmi := int64(1 << 63 -1)\n\tz := -1\n\tfor i := 0; i < len(x); i++ {\n\t\td := abs(x[i]-xs)+abs(y[i]-ys)\n\t\tif mi > d {\n\t\t\tz = i\n\t\t\tmi = d\n\t\t}\n\t}\n\n\tif mi > t {\n\t\tfmt.Println(0)\n\t\treturn\n\t}\n\n\tto += mi\n\tans++\n\n\tr := int64(0)\n\tfor i := z+1; i < len(x); i++ {\n\t\tr += abs(x[i]-x[i-1])+abs(y[i]-y[i-1])\n\t}\n\n\tl := int64(0)\n\tfor i := z-1; i >= 0; i-- {\n\t\tl += abs(x[i]-x[i+1])+abs(y[i]-y[i+1])\n\t}\n\n\tif l > r {\n\t\tfor i := z+1; i < len(x); i++ {\n\t\t\tnext := abs(x[i]-x[i-1])+abs(y[i]-y[i-1])\n\t\t\tif next+to > t {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tans++\n\t\t\tto += next\n\t\t}\n\t\tto += r\n\t\tfor i := z-1; i >= 0; i-- {\n\t\t\tnext := abs(x[i]-x[i+1])+abs(y[i]-y[i+1])\n\t\t\tif next+to > t {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tans++\n\t\t\tto += next\n\t\t}\n\t} else {\n\t\tfor i := z-1; i >= 0; i-- {\n\t\t\tnext := abs(x[i]-x[i+1])+abs(y[i]-y[i+1])\n\t\t\tif next+to > t {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tans++\n\t\t\tto += next\n\t\t}\n\t\tto += l\n\t\tfor i := z+1; i < len(x); i++ {\n\t\t\tnext := abs(x[i]-x[i-1])+abs(y[i]-y[i-1])\n\t\t\tif next+to > t {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tans++\n\t\t\tto += next\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)\n\nfunc scanInt() int {\n\tsc.Scan(); a,_ := strconv.Atoi(sc.Text()); return a\n}\n\nfunc scanInt64() int64 {\n\tsc.Scan(); a,_ := strconv.ParseInt(sc.Text(),10,64); return a\n}\n\nfunc scanFloat64() float64 {\n\tsc.Scan(); a,_ := strconv.ParseFloat(sc.Text(),64); return a\n}\n\nfunc scanInts(n int) []int {\n\tres := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }\n\treturn res\n}\n\nfunc scanString() string {\n\tsc.Scan(); return sc.Text()\n}\n\nfunc printInts(a ...int) {\n\tfor i, e := range a {\n\t\tfmt.Fprint(wr, e); if i != len(a)-1 { fmt.Fprint(wr, \" \") }\n\t}\n\tfmt.Fprintln(wr); wr.Flush()\n}\n\nfunc abs(a int64) int64 { if a<0 { return -a }; return a }\nfunc min(a,b int) int { if ab { return a }; return b }\n\n//•*¨*•.¸¸♪Main•*¨*•.¸¸♪( -ω-)ノ ( ・ω・)\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\tsc.Buffer(make([]byte, 10000), 1000000)\n\n\tx0 := scanInt64()\n\ty0 := scanInt64()\n\tax := scanInt64()\n\tay := scanInt64()\n\tbx := scanInt64()\n\tby :=scanInt64()\n\txs := scanInt64()\n\tys := scanInt64()\n\tt := scanInt64()\n\n\tx := []int64{x0}\n\ty := []int64{y0}\n\n\tconst mat = 100000000000000000\n\n\tfor x[len(x)-1] < mat && y[len(y)-1] < mat {\n\t\tnext := len(x)-1\n\t\tx = append(x, ax*x[next]+bx)\n\t\ty = append(y, ay*y[next]+by)\n\t}\n\n\tto := int64(0)\n\tans := 0\n\n\tmi := int64(1 << 63 -1)\n\tz := -1\n\tfor i := 0; i < len(x); i++ {\n\t\td := abs(x[i]-xs)+abs(y[i]-ys)\n\t\tif mi > d {\n\t\t\tz = i\n\t\t\tmi = d\n\t\t}\n\t}\n\n\tif mi > t {\n\t\tfmt.Println(0)\n\t\treturn\n\t}\n\n\tto += mi\n\tans++\n\n\tr := int64(0)\n\tfor i := z+1; i < len(x); i++ {\n\t\tr += abs(x[i]-x[i-1])+abs(y[i]-y[i-1])\n\t}\n\n\tl := int64(0)\n\tfor i := z-1; i >= 0; i-- {\n\t\tl += abs(x[i]-x[i+1])+abs(y[i]-y[i+1])\n\t}\n\n\tif l > r {\n\t\tfor i := z+1; i < len(x); i++ {\n\t\t\tnext := abs(x[i]-x[i-1])+abs(y[i]-y[i-1])\n\t\t\tif next+to > t {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tans++\n\t\t\tto += next\n\t\t}\n\t\tfor i := z-1; i >= 0; i-- {\n\t\t\tnext := abs(x[i]-x[i+1])+abs(y[i]-y[i+1])\n\t\t\tif next+to > t {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tans++\n\t\t\tto += next\n\t\t}\n\t} else {\n\t\tfor i := z-1; i >= 0; i-- {\n\t\t\tnext := abs(x[i]-x[i+1])+abs(y[i]-y[i+1])\n\t\t\tif next+to > t {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tans++\n\t\t\tto += next\n\t\t}\n\t\tfor i := z+1; i < len(x); i++ {\n\t\t\tnext := abs(x[i]-x[i-1])+abs(y[i]-y[i-1])\n\t\t\tif next+to > t {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tans++\n\t\t\tto += next\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n\n}\n"}, {"source_code": "package main\n \nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n \n//=====I/O=====\n \nvar (\n\tsc = bufio.NewScanner(os.Stdin)\n\twr = bufio.NewWriter(os.Stdout)\n)\n \nfunc scanInt() int {\n\tsc.Scan()\n\ta,_ := strconv.Atoi(sc.Text())\n\treturn a\n}\n \nfunc scanInt64() int64 {\n\tsc.Scan()\n\ta,_ := strconv.ParseInt(sc.Text(),10,64)\n\treturn a\n}\n \nfunc scanFloat64() float64 {\n\tsc.Scan()\n\ta,_ := strconv.Atoi(sc.Text())\n\treturn float64(a)\n}\n \nfunc scanInts(n int) []int {\n\tres := make([]int, n)\n\tfor i := 0; i < n; i++ { res[i] = scanInt() }\n\treturn res\n}\n \nfunc scanText() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n \nfunc printInts(a ...int) {\n\tfor i, e := range a {\n\t\tfmt.Fprint(wr, e)\n\t\tif i != len(a)-1 { fmt.Fprint(wr, \" \") }\n\t}\n\tfmt.Fprintln(wr)\n\twr.Flush()\n}\n \n//•*¨*•.¸¸♪func•*¨*•.¸¸♪\n \nfunc calc(x,y,ax,ay,bx,by int64) (int64,int64) {\n\treturn ax*x+bx,ay*y+by\n}\n \nfunc dist(x1,y1,x2,y2 int64) int64 {\n\treturn abs(x1-x2)+abs(y1-y2)\n}\n \nfunc abs(a int64) int64 {\n\tif a<0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n \n//•*¨*•.¸¸♪main•*¨*•.¸¸♪\n \nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\t// sc.Buffer(make([]byte, 10000), 100000000)\n \n\tx0 := scanInt64()\n\ty0 := scanInt64()\n\tax := scanInt64()\n\tay := scanInt64()\n\tbx := scanInt64()\n\tby := scanInt64()\n \n\txs := scanInt64()\n\tys := scanInt64()\n\tt := scanInt64()\n \n\tcs := make([]coordinate, 0)\n\tcs = append(cs, coordinate{x0,y0})\n \n\tli := int64(100000000000000000)\n \n\tfor cs[len(cs)-1].x t {\n\t\t\tbreak\n\t\t}\n\n\t\tf[index] = true\n\t\tnextx, nexty = x, y\n\t\tcnt += mi\n\t\tans++\n\t}\n \n\tfmt.Println(ans)\n}\n \ntype coordinate struct {\n\tx int64\n\ty int64\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)\n\nfunc scanInt() int {\n\tsc.Scan(); a,_ := strconv.Atoi(sc.Text()); return a\n}\n\nfunc scanInt64() int64 {\n\tsc.Scan(); a,_ := strconv.ParseInt(sc.Text(),10,64); return a\n}\n\nfunc scanFloat64() float64 {\n\tsc.Scan(); a,_ := strconv.ParseFloat(sc.Text(),64); return a\n}\n\nfunc scanInts(n int) []int {\n\tres := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }\n\treturn res\n}\n\nfunc scanString() string {\n\tsc.Scan(); return sc.Text()\n}\n\nfunc printInts(a ...int) {\n\tfor i, e := range a {\n\t\tfmt.Fprint(wr, e); if i != len(a)-1 { fmt.Fprint(wr, \" \") }\n\t}\n\tfmt.Fprintln(wr); wr.Flush()\n}\n\nfunc abs(a int64) int64 { if a<0 { return -a }; return a }\nfunc min(a,b int) int { if ab { return a }; return b }\n\n//•*¨*•.¸¸♪Main•*¨*•.¸¸♪( -ω-)ノ ( ・ω・)\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\tsc.Buffer(make([]byte, 10000), 1000000)\n\n\tx0 := scanInt64()\n\ty0 := scanInt64()\n\tax := scanInt64()\n\tay := scanInt64()\n\tbx := scanInt64()\n\tby :=scanInt64()\n\txs := scanInt64()\n\tys := scanInt64()\n\tt := scanInt64()\n\n\tx := []int64{x0}\n\ty := []int64{y0}\n\n\tconst mat = 1 << 61\n\n\tfor x[len(x)-1]*ax+bx < mat && y[len(y)-1]*ay+by < mat {\n\t\tnext := len(x)-1\n\t\tx = append(x, ax*x[next]+bx)\n\t\ty = append(y, ay*y[next]+by)\n\t}\n\n\tans := 0\n\n\tfor i := 0; i < len(x); i++ {\n\t\tfor j := i; j < len(x); j++ {\n\t\t\tltor := x[j]-x[i]+y[j]-y[i]\n\t\t\ttol := abs(xs-x[i])+abs(ys-y[i])\n\t\t\ttor := abs(xs-x[j])+abs(ys-y[j])\n\n\t\t\tif t >= ltor+tor || t >= tol+ltor {\n\t\t\t\t// fmt.Println(ltor+tol,ltor+tor,j,i)\n\t\t\t\tans = max(ans, j-i+1)\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\n//=====I/O=====\n\nvar (\n\tsc = bufio.NewScanner(os.Stdin)\n\twr = bufio.NewWriter(os.Stdout)\n)\n\nfunc scanInt() int {\n\tsc.Scan()\n\ta,_ := strconv.Atoi(sc.Text())\n\treturn a\n}\n\nfunc scanInt64() int64 {\n\tsc.Scan()\n\ta,_ := strconv.ParseInt(sc.Text(),10,64)\n\treturn a\n}\n\nfunc scanFloat64() float64 {\n\tsc.Scan()\n\ta,_ := strconv.Atoi(sc.Text())\n\treturn float64(a)\n}\n\nfunc scanInts(n int) []int {\n\tres := make([]int, n)\n\tfor i := 0; i < n; i++ { res[i] = scanInt() }\n\treturn res\n}\n\nfunc scanText() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc printInts(a ...int) {\n\tfor i, e := range a {\n\t\tfmt.Fprint(wr, e)\n\t\tif i != len(a)-1 { fmt.Fprint(wr, \" \") }\n\t}\n\tfmt.Fprintln(wr)\n\twr.Flush()\n}\n\n//•*¨*•.¸¸♪func•*¨*•.¸¸♪\n\nfunc calc(x,y,ax,ay,bx,by int64) (int64,int64) {\n\treturn ax*x+bx,ay*y+by\n}\n\nfunc dist(x1,y1,x2,y2 int64) int64 {\n\treturn abs(x1-x2)+abs(y1-y2)\n}\n\nfunc abs(a int64) int64 {\n\tif a<0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n//•*¨*•.¸¸♪main•*¨*•.¸¸♪\n\nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\t// sc.Buffer(make([]byte, 10000), 100000000)\n\n\tx0 := scanInt64()\n\ty0 := scanInt64()\n\tax := scanInt64()\n\tay := scanInt64()\n\tbx := scanInt64()\n\tby := scanInt64()\n\n\txs := scanInt64()\n\tys := scanInt64()\n\tt := scanInt64()\n\n\tcs := make([]coordinate, 0)\n\tcs = append(cs, coordinate{x0,y0})\n\n\tli := int64(100000000000000000)\n\n\tfor cs[len(cs)-1].x=0 ; i-- {\n\t\tif cnt+dist(x,y,cs[i].x,cs[i].y) <= t{\n\t\t\tcnt+=dist(x,y,cs[i].x,cs[i].y)\n\t\t\tx,y = cs[i].x,cs[i].y\n\t\t\tans++\n\t\t\t// fmt.Println(x,y,cnt)\n\t\t}\n\t}\n\n\tfor i := index+1; i < len(cs); i++ {\n\t\tif cnt+dist(x,y,cs[i].x,cs[i].y) <= t{\n\t\t\tcnt+=dist(x,y,cs[i].x,cs[i].y)\n\t\t\tx,y = cs[i].x,cs[i].y\n\t\t\tans++\n\t\t\t// fmt.Println(x,y,cnt)\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n}\n\ntype coordinate struct {\n\tx int64\n\ty int64\n}\n"}, {"source_code": "package main\n \nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n \n//=====I/O=====\n \nvar (\n\tsc = bufio.NewScanner(os.Stdin)\n\twr = bufio.NewWriter(os.Stdout)\n)\n \nfunc scanInt() int {\n\tsc.Scan()\n\ta,_ := strconv.Atoi(sc.Text())\n\treturn a\n}\n \nfunc scanInt64() int64 {\n\tsc.Scan()\n\ta,_ := strconv.ParseInt(sc.Text(),10,64)\n\treturn a\n}\n \nfunc scanFloat64() float64 {\n\tsc.Scan()\n\ta,_ := strconv.Atoi(sc.Text())\n\treturn float64(a)\n}\n \nfunc scanInts(n int) []int {\n\tres := make([]int, n)\n\tfor i := 0; i < n; i++ { res[i] = scanInt() }\n\treturn res\n}\n \nfunc scanText() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n \nfunc printInts(a ...int) {\n\tfor i, e := range a {\n\t\tfmt.Fprint(wr, e)\n\t\tif i != len(a)-1 { fmt.Fprint(wr, \" \") }\n\t}\n\tfmt.Fprintln(wr)\n\twr.Flush()\n}\n \n//•*¨*•.¸¸♪func•*¨*•.¸¸♪\n \nfunc calc(x,y,ax,ay,bx,by int64) (int64,int64) {\n\treturn ax*x+bx,ay*y+by\n}\n \nfunc dist(x1,y1,x2,y2 int64) int64 {\n\treturn abs(x1-x2)+abs(y1-y2)\n}\n \nfunc abs(a int64) int64 {\n\tif a<0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n \n//•*¨*•.¸¸♪main•*¨*•.¸¸♪\n \nfunc main() {\n\tsc.Split(bufio.ScanWords)\n\t// sc.Buffer(make([]byte, 10000), 100000000)\n \n\tx0 := scanInt64()\n\ty0 := scanInt64()\n\tax := scanInt64()\n\tay := scanInt64()\n\tbx := scanInt64()\n\tby := scanInt64()\n \n\txs := scanInt64()\n\tys := scanInt64()\n\tt := scanInt64()\n \n\tcs := make([]coordinate, 0)\n\tcs = append(cs, coordinate{x0,y0})\n \n\tli := int64(100000000000000000)\n \n\tfor cs[len(cs)-1].x t {\n\t\t\tbreak\n\t\t}\n\n\t\tf[index] = true\n\t\tcnt += mi\n\t\tans++\n\t}\n \n\tfmt.Println(ans)\n}\n \ntype coordinate struct {\n\tx int64\n\ty int64\n}\n"}], "src_uid": "d8a7ae2959b3781a8a4566a2f75a4e28"} {"nl": {"description": "Little Elephant loves magic squares very much.A magic square is a 3 × 3 table, each cell contains some positive integer. At that the sums of integers in all rows, columns and diagonals of the table are equal. The figure below shows the magic square, the sum of integers in all its rows, columns and diagonals equals 15. The Little Elephant remembered one magic square. He started writing this square on a piece of paper, but as he wrote, he forgot all three elements of the main diagonal of the magic square. Fortunately, the Little Elephant clearly remembered that all elements of the magic square did not exceed 105. Help the Little Elephant, restore the original magic square, given the Elephant's notes.", "input_spec": "The first three lines of the input contain the Little Elephant's notes. The first line contains elements of the first row of the magic square. The second line contains the elements of the second row, the third line is for the third row. The main diagonal elements that have been forgotten by the Elephant are represented by zeroes. It is guaranteed that the notes contain exactly three zeroes and they are all located on the main diagonal. It is guaranteed that all positive numbers in the table do not exceed 105.", "output_spec": "Print three lines, in each line print three integers — the Little Elephant's magic square. If there are multiple magic squares, you are allowed to print any of them. Note that all numbers you print must be positive and not exceed 105. It is guaranteed that there exists at least one magic square that meets the conditions.", "sample_inputs": ["0 1 1\n1 0 1\n1 1 0", "0 3 6\n5 0 5\n4 7 0"], "sample_outputs": ["1 1 1\n1 1 1\n1 1 1", "6 3 6\n5 5 5\n4 7 4"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar n00, n01, n02, n10, n11, n12, n20, n21, n22 int\n\tfmt.Scan(&n00, &n01, &n02)\n\tfmt.Scan(&n10, &n11, &n12)\n\tfmt.Scan(&n20, &n21, &n22)\n\tif n00 == 0 && n11 == 0 && n22 == 0 {\n\t\thasil := (n01 + n02 + n01 + n21 + n20 + n21)/2\n\t\tn00 = hasil - n01 - n02\n\t\tn11 = hasil - n10 - n12\n\t\tn22 = hasil - n20 - n21\n\t}\n\tfmt.Print(n00, n01, n02)\n\tfmt.Println()\n\tfmt.Print(n10, n11, n12)\n\tfmt.Println()\n\tfmt.Print(n20, n21, n22)\n\tfmt.Println()\n}\n"}, {"source_code": "package main\nimport (\n\t\"fmt\"\n\t//\"sort\"\n\t//\"unicode/utf8\"\n)\nfunc main() {\n\tvar a,b,c,d,e,f,g,h,i int\n\tfmt.Scan(&a,&b,&c,&d,&e,&f,&g,&h,&i)\n\ta=c+((f-d)/2)\n\ti=g+((d-f)/2)\n\te=b+c-g+((f-d)/2)\n\tfmt.Println(a,b,c)\n\tfmt.Println(d,e,f)\n\tfmt.Println(g,h,i)\n}\n\n\n\n"}, {"source_code": " // 259B-mic\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x1, x2, x3, x4, x5, x6, x7, x8, x9 int\n\tfmt.Scan(&x1, &x2, &x3, &x4, &x5, &x6, &x7, &x8, &x9)\n\tx1 = (x3 + x6 + x7 - x2) / 2\n\tx5 = (x1 + x2 + x3 - x4 - x6)\n\tx9 = (x3 + x7 - x1)\n\tfmt.Println(x1, x2, x3)\n\tfmt.Println(x4, x5, x6)\n\tfmt.Println(x7, x8, x9)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc check(d... int) bool {\n for _, v := range d {\n if v != d[0] { return false }\n }\n return true\n}\n\nfunc main() {\n var a [3][3]int\n total := 0\n for i := 0; i < 3; i++ {\n for j := 0; j < 3; j++ {\n fmt.Scan(&a[i][j])\n total += a[i][j]\n }\n }\n total /= 2\n for i := 0; i < 3; i++ {\n t := total\n for j := 0; j < 3; j++ { t -= a[i][j] }\n a[i][i] = t\n }\n for i := 0; i < 3; i++ {\n for j := 0; j < 3; j++ {\n fmt.Print(a[i][j])\n if j == 2 { fmt.Println() } else { fmt.Print(\" \") }\n }\n }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc check(d... int) bool {\n for _, v := range d {\n if v != d[0] { return false }\n }\n return true\n}\n\nfunc main() {\n var a [3][3]int\n total := 0\n for i := 0; i < 3; i++ {\n for j := 0; j < 3; j++ {\n fmt.Scan(&a[i][j])\n total += a[i][j]\n }\n }\n total /= 2\n for i := 0; i < 3; i++ {\n t := total\n for j := 0; j < 3; j++ { t -= a[i][j] }\n a[i][i] = t\n }\n for i := 0; i < 3; i++ {\n for j := 0; j < 3; j++ {\n fmt.Print(a[i][j])\n if j == 2 { fmt.Println() } else { fmt.Print(\" \") }\n }\n }\n}\n"}, {"source_code": "// 259B-mic\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var x1, x2, x3, x4, x5, x6, x7, x8, x9 int\n fmt.Scan(&x1, &x2, &x3, &x4, &x5, &x6, &x7, &x8, &x9)\n x1 = (x3 + x6 + x7 - x2) / 2\n x5 = (x1 + x2 + x3 - x4 - x6)\n x9 = (x3 + x7 - x1)\n fmt.Println(x1, x2, x3)\n fmt.Println(x4, x5, x6)\n fmt.Println(x7, x8, x9)\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar n00, n01, n02, n10, n11, n12, n20, n21, n22 int\n\tfmt.Scan(&n00, &n01, &n02)\n\tfmt.Scan(&n10, &n11, &n12)\n\tfmt.Scan(&n20, &n21, &n22)\n\tif n00 == 0 && n11 == 0 && n22 == 0 {\n\t\tn00 = n02\n\t\tn22 = n20\n\t\tif n00 + n01 + n02 == n20 + n21 + n22 {\n\t\t\tn11 = n00 + n01 + n02 - n00 - n22\n\t\t}\n\t}\n\tfmt.Print(n00, n01, n02)\n\tfmt.Println()\n\tfmt.Print(n10, n11, n12)\n\tfmt.Println()\n\tfmt.Print(n20, n21, n22)\n\tfmt.Println()\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc check(d... int) bool {\n for _, v := range d {\n if v != d[0] { return false }\n }\n return true\n}\n\nfunc main() {\n var a [3][3]int\n var x [3][2]int\n max := 0\n for i := 0; i < 3; i++ {\n for j := 0; j < 3; j++ {\n fmt.Scan(&a[i][j])\n x[i][0] += a[i][j]\n x[j][1] += a[i][j]\n if max < x[i][0] { max = x[i][0] }\n if max < x[j][0] { max = x[j][0] }\n }\n }\n if max > 100000 { max = 100000 }\n for i := 0; i <= max; i++ {\n for j := 0; j <= max; j++ {\n for k := 0; k <= max; k++ {\n if check((i+x[0][0]),(i+x[0][1]),(j+x[1][0]),(j+x[1][1]),(k+x[2][0]),(k+x[2][1])) {\n a[0][0] = i\n a[1][1] = j\n a[2][2] = k\n break\n }\n }\n }\n }\n for i := 0; i < 3; i++ {\n for j := 0; j < 3; j++ {\n fmt.Print(a[i][j])\n if j == 2 { fmt.Println() } else { fmt.Print(\" \") }\n }\n }\n}\n"}], "src_uid": "0c42eafb73d1e30f168958a06a0f9bca"} {"nl": {"description": "There are three points marked on the coordinate plane. The goal is to make a simple polyline, without self-intersections and self-touches, such that it passes through all these points. Also, the polyline must consist of only segments parallel to the coordinate axes. You are to find the minimum number of segments this polyline may consist of.", "input_spec": "Each of the three lines of the input contains two integers. The i-th line contains integers xi and yi ( - 109 ≤ xi, yi ≤ 109) — the coordinates of the i-th point. It is guaranteed that all points are distinct.", "output_spec": "Print a single number — the minimum possible number of segments of the polyline.", "sample_inputs": ["1 -1\n1 1\n1 2", "-1 -1\n-1 3\n4 3", "1 1\n2 3\n3 2"], "sample_outputs": ["1", "2", "3"], "notes": "NoteThe variant of the polyline in the first sample: The variant of the polyline in the second sample: The variant of the polyline in the third sample: "}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc max(a, b int) int {\n if a > b {\n return a\n } else { \n return b\n }\n}\n\nfunc min(a, b int) int {\n if a < b {\n return a\n } else { \n return b\n }\n}\n\nfunc isBetween(a, b, c int) bool {\n return min(a, b) <= c && c <= max(a, b)\n}\n\nfunc f(i, j, k int, x, y [3]int) bool {\n return (x[k] == x[i] || x[k] == x[j]) && isBetween(y[i], y[j], y[k]) || (y[k] == y[i] || y[k] == y[j]) && isBetween(x[i], x[j], x[k])\n}\n\nfunc main() {\n var x, y [3]int\n for i := 0; i < 3; i++ {\n fmt.Scanf(\"%d %d\\n\\r\", &x[i], &y[i])\n }\n// for i := 0; i < 3; i++ {\n// fmt.Printf(\"%d %d\\n\\r\", x[i], y[i])\n// }\n if (x[0] == x[1] && x[1] == x[2] || y[0] == y[1] && y[1] == y[2]) {\n fmt.Println(\"1\")\n } else if (f(0, 1, 2, x, y) || f(0, 2, 1, x, y) || f(1, 2, 0, x, y)) {\n fmt.Println(\"2\")\n } else {\n fmt.Println(\"3\")\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\ntype vec struct{ x, y int64 }\n\nfunc (a vec) sub(b vec) vec { return vec{a.x - b.x, a.y - b.y} }\nfunc (a vec) dot(b vec) int64 { return a.x*b.x + a.y*b.y }\nfunc (a vec) det(b vec) int64 { return a.x*b.y - a.y*b.x }\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF617D(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tf := func(a, b, c vec) bool {\n\t\ta, b = b.sub(a), c.sub(a)\n\t\treturn (a.x == 0 || a.y == 0 || b.x == 0 || b.y == 0) && a.dot(b) <= 0\n\t}\n\tvar a, b, c vec\n\tFscan(in, &a.x, &a.y, &b.x, &b.y, &c.x, &c.y)\n\tif d := b.sub(a); (d.x == 0 || d.y == 0) && d.det(c.sub(b)) == 0 {\n\t\tFprint(out, 1)\n\t} else if f(a, b, c) || f(b, a, c) || f(c, a, b) {\n\t\tFprint(out, 2)\n\t} else {\n\t\tFprint(out, 3)\n\t}\n}\n\nfunc main() { CF617D(os.Stdin, os.Stdout) }\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\ntype vec struct{ x, y int64 }\n\nfunc (a vec) sub(b vec) vec { return vec{a.x - b.x, a.y - b.y} }\nfunc (a vec) dot(b vec) int64 { return a.x*b.x + a.y*b.y }\nfunc (a vec) det(b vec) int64 { return a.x*b.y - a.y*b.x }\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF617D(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tf := func(a, b, c vec) bool {\n\t\ta, b = b.sub(a), c.sub(a)\n\t\treturn a.x == 0 && b.y == 0 || a.y == 0 && b.x == 0\n\t}\n\tvar a, b, c vec\n\tFscan(in, &a.x, &a.y, &b.x, &b.y, &c.x, &c.y)\n\tif b.sub(a).det(c.sub(b)) == 0 {\n\t\tFprint(out, 1)\n\t} else if f(a, b, c) || f(b, a, c) || f(c, a, b) {\n\t\tFprint(out, 2)\n\t} else {\n\t\tFprint(out, 3)\n\t}\n}\n\nfunc main() { CF617D(os.Stdin, os.Stdout) }\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\ntype vec struct{ x, y int64 }\n\nfunc (a vec) sub(b vec) vec { return vec{a.x - b.x, a.y - b.y} }\nfunc (a vec) dot(b vec) int64 { return a.x*b.x + a.y*b.y }\nfunc (a vec) det(b vec) int64 { return a.x*b.y - a.y*b.x }\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF617D(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tf := func(a, b, c vec) bool { return b.sub(a).dot(c.sub(a)) == 0 }\n\tvar a, b, c vec\n\tFscan(in, &a.x, &a.y, &b.x, &b.y, &c.x, &c.y)\n\tif b.sub(a).det(c.sub(b)) == 0 {\n\t\tFprint(out, 1)\n\t} else if f(a, b, c) || f(b, a, c) || f(c, a, b) {\n\t\tFprint(out, 2)\n\t} else {\n\t\tFprint(out, 3)\n\t}\n}\n\nfunc main() { CF617D(os.Stdin, os.Stdout) }\n"}], "src_uid": "36fe960550e59b046202b5811343590d"} {"nl": {"description": "As you have noticed, there are lovely girls in Arpa’s land.People in Arpa's land are numbered from 1 to n. Everyone has exactly one crush, i-th person's crush is person with the number crushi. Someday Arpa shouted Owf loudly from the top of the palace and a funny game started in Arpa's land. The rules are as follows.The game consists of rounds. Assume person x wants to start a round, he calls crushx and says: \"Oww...wwf\" (the letter w is repeated t times) and cuts off the phone immediately. If t > 1 then crushx calls crushcrushx and says: \"Oww...wwf\" (the letter w is repeated t - 1 times) and cuts off the phone immediately. The round continues until some person receives an \"Owf\" (t = 1). This person is called the Joon-Joon of the round. There can't be two rounds at the same time.Mehrdad has an evil plan to make the game more funny, he wants to find smallest t (t ≥ 1) such that for each person x, if x starts some round and y becomes the Joon-Joon of the round, then by starting from y, x would become the Joon-Joon of the round. Find such t for Mehrdad if it's possible.Some strange fact in Arpa's land is that someone can be himself's crush (i.e. crushi = i).", "input_spec": "The first line of input contains integer n (1 ≤ n ≤ 100) — the number of people in Arpa's land. The second line contains n integers, i-th of them is crushi (1 ≤ crushi ≤ n) — the number of i-th person's crush.", "output_spec": "If there is no t satisfying the condition, print -1. Otherwise print such smallest t.", "sample_inputs": ["4\n2 3 1 4", "4\n4 4 4 4", "4\n2 1 4 3"], "sample_outputs": ["3", "-1", "1"], "notes": "NoteIn the first sample suppose t = 3. If the first person starts some round:The first person calls the second person and says \"Owwwf\", then the second person calls the third person and says \"Owwf\", then the third person calls the first person and says \"Owf\", so the first person becomes Joon-Joon of the round. So the condition is satisfied if x is 1.The process is similar for the second and the third person.If the fourth person starts some round:The fourth person calls himself and says \"Owwwf\", then he calls himself again and says \"Owwf\", then he calls himself for another time and says \"Owf\", so the fourth person becomes Joon-Joon of the round. So the condition is satisfied when x is 4.In the last example if the first person starts a round, then the second person becomes the Joon-Joon, and vice versa."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\ntype crushes []int\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 lcmm(a ...int) int64 {\n\tl := int64(a[0])\n\tfor _, v := range a {\n\n\t\tl = lcm(l, int64(v))\n\t}\n\treturn l\n}\n\nfunc (cr crushes) CountStepsToReturn(start int) int {\n\tcnt := 1\n\tcur := start\n\tfor cnt <= len(cr) {\n\t\tcur = cr[cur]\n\t\tif cur == start {\n\t\t\tbreak\n\t\t}\n\t\tcnt++\n\t}\n\tif cnt > len(cr) {\n\t\treturn -1\n\t}\n\treturn cnt\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar cr crushes = make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&cr[i])\n\t\tcr[i]--\n\t}\n\tmin := make([]int, n)\n\tvar ans int64\n\tfor i := 0; i < n; i++ {\n\t\tm := cr.CountStepsToReturn(i)\n\t\tif m == -1 {\n\t\t\tans = -1\n\t\t\tbreak\n\t\t} else if m%2 == 0 {\n\t\t\tm = m / 2\n\t\t}\n\t\tmin[i] = m\n\t}\n\tif ans != -1 {\n\t\tans = lcmm(min...)\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math/big\"\n)\n\nfunc main() {\n\tn := 0\n\tfmt.Scanf(\"%d\\n\", &n)\n\tcrush := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &crush[i])\n\t\tcrush[i]--\n\t}\n\n\t// Checks zero in-degree.\n\tindeg := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tindeg[crush[i]]++\n\t}\n\tfor _, in := range indeg {\n\t\tif in == 0 {\n\t\t\tfmt.Println(-1)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Collects sizes of loops.\n\tsizes := make([]int, 0)\n\tvisited := make([]bool, n)\n\tfor first := 0; first < n; first++ {\n\t\tif !visited[first] {\n\t\t\tvisited[first] = true\n\t\t\tsize := 1\n\t\t\tfor x := crush[first]; !visited[x]; x = crush[x] {\n\t\t\t\tvisited[x] = true\n\t\t\t\tsize++\n\t\t\t}\n\t\t\tsizes = append(sizes, size)\n\t\t}\n\t}\n\n\tans := big.NewInt(1)\n\tfor _, size := range sizes {\n\t\tvar k *big.Int\n\t\tif size%2 == 0 {\n\t\t\tk = big.NewInt(int64(size / 2))\n\t\t} else {\n\t\t\tk = big.NewInt(int64(size))\n\t\t}\n\t\tg := new(big.Int).GCD(nil, nil, ans, k)\n\t\tans.Div(ans, g)\n\t\tans.Mul(ans, k)\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math/big\"\n)\n\nfunc main() {\n\tn := 0\n\tfmt.Scanf(\"%d\\n\", &n)\n\tcrush := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &crush[i])\n\t\tcrush[i]--\n\t}\n\n\tsizes := make([]int, 0)\n\tvisited := make([]bool, n)\n\tfor first := 0; first < n; first++ {\n\t\tif !visited[first] {\n\t\t\tvisited[first] = true\n\t\t\tsize := 1\n\t\t\tx := crush[first]\n\t\t\tfor !visited[x] {\n\t\t\t\tvisited[x] = true\n\t\t\t\tsize++\n\t\t\t\tx = crush[x]\n\t\t\t}\n\t\t\tif x != first {\n\t\t\t\tfmt.Println(-1)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsizes = append(sizes, size)\n\t\t}\n\t}\n\n\tans := big.NewInt(1)\n\tfor _, size := range sizes {\n\t\tvar k *big.Int\n\t\tif size%2 == 0 {\n\t\t\tk = big.NewInt(int64(size / 2))\n\t\t} else {\n\t\t\tk = big.NewInt(int64(size))\n\t\t}\n\t\tg := new(big.Int).GCD(nil, nil, ans, k)\n\t\tans.Div(ans, g)\n\t\tans.Mul(ans, k)\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc gcd(a, b int64) int64 {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn gcd(b, a%b)\n}\n\nfunc lcm(a, b int64) int64 {\n\treturn (a * b) / gcd(a, b)\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tcrush := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&crush[i])\n\t\tcrush[i]--\n\t}\n\tans := int64(1)\n\tfor i := 0; i < n; i++ {\n\t\tnode := i\n\t\tfor k := 1; k <= n; k++ {\n\t\t\tnode = crush[node]\n\t\t\tif node == i {\n\t\t\t\tif k%2 == 0 {\n\t\t\t\t\tk /= 2\n\t\t\t\t}\n\t\t\t\tans = lcm(ans, int64(k))\n\t\t\t\tgoto start\n\t\t\t}\n\t\t}\n\t\tans = -1\n\t\tbreak\n\tstart:\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReaderSize(os.Stdin, 1<<13)\n\twriter := bufio.NewWriterSize(os.Stdout, 1<<13)\n\tn := ReadInt(reader)\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\ta[i] = ReadInt(reader) - 1\n\t}\n\tfmt.Fprintln(writer, solve(a))\n\twriter.Flush()\n}\n\nfunc solve(a []int) int64 {\n\tn := len(a)\n\tres := int64(0)\n\treached := make([]bool, n)\n\tfor i := 0; i < n; i++ {\n\t\tif !reached[i] {\n\t\t\tk := i\n\t\t\tcount := int64(0)\n\t\t\tfor !reached[k] {\n\t\t\t\treached[k] = true\n\t\t\t\tk = a[k]\n\t\t\t\tcount++\n\t\t\t}\n\t\t\tif k != i {\n\t\t\t\treturn -1\n\t\t\t}\n\t\t\tif count == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif count%2 == 0 {\n\t\t\t\tcount /= 2\n\t\t\t}\n\t\t\tif res == 0 {\n\t\t\t\tres = count\n\t\t\t} else {\n\t\t\t\tres = lcm(res, count)\n\t\t\t}\n\t\t}\n\t}\n\treturn res\n}\n\nfunc gcd(a, b int64) int64 {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn gcd(b, a%b)\n}\n\nfunc lcm(a, b int64) int64 {\n\tg := gcd(a, b)\n\treturn (a / g) * b\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc ReadInt(reader *bufio.Reader) int {\n\treturn int(ReadInt64(reader))\n}\n\nfunc ReadInt64(reader *bufio.Reader) int64 {\n\tb, err := reader.ReadByte()\n\tfor !isValid(b, err) {\n\t\tb, err = reader.ReadByte()\n\t}\n\tsign := int64(1)\n\tif b == '-' {\n\t\tsign *= -1\n\t\tb, err = reader.ReadByte()\n\t}\n\tres := int64(0)\n\tfor isValid(b, err) {\n\t\tres = res*10 + int64(b-'0')\n\t\tb, err = reader.ReadByte()\n\t}\n\treturn res * sign\n}\n\nfunc isValid(b byte, err error) bool {\n\treturn err == nil && (('0' <= b && b <= '9') || b == '-')\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n n := readInt()\n a, was := readIntArray(n), make([]bool, n)\n c, ok := []int{}, true\n for i := range a {\n cur, cnt := i, 0\n for !was[cur] {\n was[cur] = true\n cur = a[cur]-1\n cnt++\n }\n\n if cnt%2 == 0 {\n cnt /= 2\n }\n\n if cur != i {\n ok = false\n } else {\n if cnt > 0 {\n c = append(c, cnt)\n }\n }\n }\n ans := -1\n if ok {\n ans = 1\n for d := 2; d < 101; d++ {\n mul := 1\n for i := range c {\n curMul := 1\n for c[i]%d == 0 {\n c[i] /= d\n curMul *= d\n }\n if curMul > mul {\n mul = curMul\n }\n }\n ans *= mul\n }\n }\n fmt.Println(ans)\n}\n\n// Helpers\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\n\nfunc main() {\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// Math\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n\n// Sort\n\ntype Ints64 []int64\n\nfunc (a Ints64) Len() int { return len(a) }\nfunc (a Ints64) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a Ints64) Less(i, j int) bool { return a[i] < a[j] }\n\n/* Sort tempalte\nfunc (a ) Len() int { return len(a) }\nfunc (a ) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a ) Less(i, j int) bool { return }\n*/\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\nvar n, cntGroup int\nvar crush, din, group []int\nvar t []int64\n\nfunc gcd(a, b int64) int64 {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn gcd(b, a%b)\n}\n\nfunc lcm(a, b int64) int64 {\n\td := gcd(a, b)\n\treturn a / d * b\n}\n\nfunc main() {\n\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\n\tfmt.Fscanf(bufin, \"%d\\n\", &n)\n\n\tcrush = make([]int, n+1)\n\tdin = make([]int, n+1)\n\tfor i := 1; i <= n; i++ {\n\t\tfmt.Fscanf(bufin, \"%d\\n\", &crush[i])\n\t\tdin[crush[i]]++\n\t}\n\n\tfor i := 1; i <= n; i++ {\n\t\tif din[i] != 1 {\n\t\t\tfmt.Fprintf(bufout, \"-1\\n\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tt = make([]int64, n+1)\n\tgroup = make([]int, n+1)\n\tcntGroup = 0\n\n\tfor i := 1; i <= n; i++ {\n\t\tif group[i] == 0 {\n\t\t\tcntGroup++\n\t\t\tcntMember := int64(1)\n\t\t\tgroup[i] = cntGroup\n\t\t\tfor j := crush[i]; group[j] == 0; j = crush[j] {\n\t\t\t\tcntMember++\n\t\t\t\tgroup[j] = cntGroup\n\t\t\t}\n\t\t\tif cntMember%2 == 1 {\n\t\t\t\tt[cntGroup] = cntMember\n\t\t\t} else {\n\t\t\t\tt[cntGroup] = cntMember / 2\n\t\t\t}\n\t\t}\n\t}\n\n\tr := t[1]\n\tfor i := 2; i <= cntGroup; i++ {\n\t\tr = lcm(r, t[i])\n\t}\n\n\tfmt.Fprintf(bufout, \"%d\\n\", r)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"runtime\"\n\t\"strings\"\n)\n\nfunc main() {\n\tb, _ := ioutil.ReadAll(os.Stdin)\n\tif len(b) == 0 {\n\t\ttest()\n\t} else {\n\t\tsolve(bytes.NewReader(b), os.Stdout)\n\t}\n}\n\nfunc solve(r io.Reader, w io.Writer) {\n\tvar n int\n\tfmt.Fscanln(r, &n)\n\n\tcs := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscan(r, &cs[i])\n\t}\n\n\tfmt.Fprintln(w, f(cs))\n}\n\nfunc f(cs []int) int {\n\tgs := graphs(cs)\n\n\tif len(gs) == 0 {\n\t\treturn -1\n\t}\n\n\tfor i, g := range gs {\n\t\tif g%2 == 0 {\n\t\t\tgs[i] = g / 2\n\t\t}\n\t}\n\n\tif len(gs) == 1 {\n\t\treturn gs[0]\n\t}\n\n\treturn lcmm(gs...)\n}\n\nfunc graphs(cs []int) []int {\n\tseen := make(map[int]bool, len(cs))\n\n\tvar ls []int\n\n\tfor j, c := range cs {\n\t\ti := j + 1\n\n\t\tif seen[i] {\n\t\t\tcontinue\n\t\t}\n\n\t\tif cs[i-1] == i {\n\t\t\tseen[i] = true\n\t\t\tseen[cs[i-1]] = true\n\t\t\tls = append(ls, 1)\n\t\t\tcontinue\n\t\t}\n\n\t\tl := 2\n\n\t\tfor ; ; l++ {\n\t\t\tseen[c] = true\n\t\t\tnext := cs[c-1]\n\t\t\tif next == i {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif seen[next] {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tc = next\n\t\t}\n\t\tseen[i] = true\n\t\tls = append(ls, l)\n\t}\n\treturn ls\n}\n\nfunc gcd(a, b int) int {\n\tfor b > 0 {\n\t\ta, b = b, a%b\n\t}\n\treturn a\n}\n\nfunc lcm(a, b int) int {\n\treturn a * b / gcd(a, b)\n}\n\nfunc lcmm(xs ...int) int {\n\tr := 1\n\tfor _, x := range xs {\n\t\tr = lcm(r, x)\n\t}\n\treturn r\n}\n\nfunc test() {\n\ttests := []struct {\n\t\tin string\n\t\twant string\n\t}{\n\t\t{\n\t\t\tin: `\n4\n2 3 1 4\n`,\n\t\t\twant: `3`,\n\t\t},\n\t\t{\n\t\t\tin: `\n4\n4 4 4 4\n`,\n\t\t\twant: `-1`,\n\t\t},\n\t\t{\n\t\t\tin: `\n4\n2 1 4 3\n`,\n\t\t\twant: `1`,\n\t\t},\n\t\t{\n\t\t\tin: `\n5\n2 3 1 5 4\n`,\n\t\t\twant: `3`,\n\t\t},\n\t\t{\n\t\t\tin: `\n7\n2 3 1 5 6 7 4\n`,\n\t\t\twant: `6`,\n\t\t},\n\t\t{\n\t\t\tin: `\n5\n2 4 3 1 2\n`,\n\t\t\twant: `-1`,\n\t\t},\n\t\t{\n\t\t\tin: `\n10\n8 10 4 3 2 1 9 6 5 7\n`,\n\t\t\twant: `15`,\n\t\t},\n\t}\n\tfor i, tt := range tests {\n\t\tfmt.Printf(\"=== TEST %d\\n\", i)\n\t\tbuf := new(bytes.Buffer)\n\t\tsolve(strings.NewReader(chomp(tt.in)), buf)\n\t\tif got, want := chomp(buf.String()), chomp(tt.want); got != want {\n\t\t\tfmt.Printf(\"%d: got %v, want %v\\n\", i, got, want)\n\t\t}\n\t}\n}\n\nfunc chomp(s string) string {\n\treturn strings.Trim(s, \"\\n\")\n}\n\nfunc assert(b bool) {\n\tif !b {\n\t\t_, file, line, ok := runtime.Caller(1)\n\t\tif ok {\n\t\t\tf, _ := os.Open(file)\n\t\t\tdefer f.Close()\n\t\t\ts := bufio.NewScanner(f)\n\t\t\tlnum := 0\n\t\t\tfor s.Scan() {\n\t\t\t\tlnum++\n\t\t\t\tif lnum == line {\n\t\t\t\t\twd, _ := os.Getwd()\n\t\t\t\t\tfname, _ := filepath.Rel(wd, file)\n\t\t\t\t\tfmt.Printf(\"assertion fails: %s:%d: %v\\n\", fname, line, s.Text())\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc pow(a, b int) int {\n\tr := 1\n\tfor i := 0; i < b; i++ {\n\t\tr *= a\n\t}\n\treturn r\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tN := sc.NextInt()\n\tA := sc.NextIntArray()\n\n\tgroup := make([]int, N + 1)\n\tgroupCount := make([]int, N + 1)\n\tg := 1\n\tfor i := 0; i < N; i++ {\n\t\tif group[i] == 0 {\n\t\t\tcount := 1\n\t\t\tgroup[i] = g\n\t\t\tk := A[i] - 1\n\t\t\tfor k != i {\n\t\t\t\tif (group[k] > 0) {\n\t\t\t\t\tfmt.Println(-1)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tgroup[k] = g\n\t\t\t\tk = A[k] - 1\n\t\t\t\tcount++\n\t\t\t}\n\t\t\tgroupCount[g] = count\n\t\t\tg++\n\t\t}\n\t}\n\tans := int64(1)\n\tfor i := 1; i < g; i++ {\n\t\tif groupCount[i] % 2 == 0 {\n\t\t\tans = lcm(ans, int64(groupCount[i] / 2))\n\t\t} else {\n\t\t\tans = lcm(ans, int64(groupCount[i]))\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n\nfunc lcm(a, b int64) int64 {\n\treturn a / gcd(a, b) * b\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\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"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc getCrush(x, t int, crush []int) int {\n\tfor i := 0; i < t; i++ {\n\t\tx = crush[x]\n\t}\n\treturn x\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tcrush := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&crush[i])\n\t\tcrush[i]--\n\t}\n\tans := -1\n\tfor t := 1; t <= n*n; t++ {\n\t\tflag := true\n\t\tfor x := 0; x < n; x++ {\n\t\t\ty := getCrush(x, t, crush)\n\t\t\tif x != getCrush(y, t, crush) {\n\t\t\t\tflag = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif flag {\n\t\t\tans = t\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\ntype crushes []int\n\nfunc gcd(a, b int) int {\n\tfor b != 0 {\n\t\ta, b = b, a%b\n\t}\n\treturn a\n}\n\nfunc lcm(a, b int) int {\n\treturn a * b / gcd(a, b)\n}\n\nfunc lcmm(a ...int) int {\n\tl := a[0]\n\tfor _, v := range a {\n\t\tl = lcm(l, v)\n\t}\n\treturn l\n}\n\nfunc (cr crushes) CountStepsToReturn(start int) int {\n\tcnt := 1\n\tcur := start\n\tfor cnt <= len(cr) {\n\t\tcur = cr[cur]\n\t\tif cur == start {\n\t\t\tbreak\n\t\t}\n\t\tcnt++\n\t}\n\tif cnt > len(cr) {\n\t\treturn -1\n\t}\n\treturn cnt\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar cr crushes = make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&cr[i])\n\t\tcr[i]--\n\t}\n\tmin := make([]int, n)\n\tvar ans int\n\tfor i := 0; i < n; i++ {\n\t\tm := cr.CountStepsToReturn(i)\n\t\tif m == -1 {\n\t\t\tans = -1\n\t\t\tbreak\n\t\t} else if m%2 == 0 {\n\t\t\tm = m / 2\n\t\t}\n\t\tmin[i] = m\n\t}\n\tif ans != -1 {\n\t\tans = lcmm(min...)\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\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\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tcrush := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&crush[i])\n\t\tcrush[i]--\n\t}\n\tans := 1\n\tfor i := 0; i < n; i++ {\n\t\tnode := i\n\t\tfor k := 0; k < n; k++ {\n\t\t\tnode = crush[node]\n\t\t\tif node == i {\n\t\t\t\tans = lcm(ans, (k+1)/2)\n\t\t\t\tgoto start\n\t\t\t}\n\t\t}\n\t\tans = -1\n\t\tbreak\n\tstart:\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\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\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tcrush := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&crush[i])\n\t\tcrush[i]--\n\t}\n\tans := 1\n\tfor i := 0; i < n; i++ {\n\t\tnode := i\n\t\tfor k := 1; k <= n; k++ {\n\t\t\tnode = crush[node]\n\t\t\tif node == i {\n\t\t\t\tif k%2 == 0 {\n\t\t\t\t\tk /= 2\n\t\t\t\t}\n\t\t\t\tans = lcm(ans, k)\n\t\t\t\tgoto start\n\t\t\t}\n\t\t}\n\t\tans = -1\n\t\tbreak\n\tstart:\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\n/*\nfunc getCrush(x, t int, crush []int) int {\n\tif t > 0 {\n\t\treturn getCrush(crush[x], t-1, crush)\n\t} else {\n\t\treturn x\n\t}\n}\n*/\n\nfunc getCrush(x, t int, crush []int) int {\n\tfor i := 0; i < t; i++ {\n\t\tx = crush[x]\n\t}\n\treturn x\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tcrush := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&crush[i])\n\t\tcrush[i]--\n\t}\n\tans := -1\n\tfor t := 1; t <= n; t++ {\n\t\tflag := true\n\t\tfor x := 0; x < n; x++ {\n\t\t\ty := getCrush(x, t, crush)\n\t\t\tif x != getCrush(y, t, crush) {\n\t\t\t\tflag = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif flag {\n\t\t\tans = t\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc getCrush(x, t int, crush []int) int {\n\tif t > 0 {\n\t\treturn getCrush(crush[x], t-1, crush)\n\t} else {\n\t\treturn x\n\t}\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tcrush := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&crush[i])\n\t\tcrush[i]--\n\t}\n\tans := -1\n\tfor t := 1; t <= n; t++ {\n\t\tflag := true\n\t\tfor x := 0; x < n; x++ {\n\t\t\ty := getCrush(x, t, crush)\n\t\t\tif x != getCrush(y, t, crush) {\n\t\t\t\tflag = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif flag {\n\t\t\tans = t\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"runtime\"\n\t\"strings\"\n)\n\nfunc main() {\n\tb, _ := ioutil.ReadAll(os.Stdin)\n\tif len(b) == 0 {\n\t\ttest()\n\t} else {\n\t\tsolve(bytes.NewReader(b), os.Stdout)\n\t}\n}\n\nfunc solve(r io.Reader, w io.Writer) {\n\tvar n int\n\tfmt.Fscanln(r, &n)\n\n\tcs := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscan(r, &cs[i])\n\t}\n\n\tfmt.Fprintln(w, f(cs))\n}\n\nfunc f(cs []int) int {\n\tgs := graphs(cs)\n\n\tif len(gs) == 0 {\n\t\treturn -1\n\t}\n\n\tif len(gs) == 1 {\n\t\treturn gs[0]\n\t}\n\n\tfor i, g := range gs {\n\t\tif g%2 == 0 {\n\t\t\tgs[i] = g / 2\n\t\t}\n\t}\n\n\treturn lcmm(gs...)\n}\n\nfunc graphs(cs []int) []int {\n\tseen := make(map[int]bool, len(cs))\n\n\tvar ls []int\n\n\tfor j, c := range cs {\n\t\ti := j + 1\n\n\t\tif seen[i] {\n\t\t\tcontinue\n\t\t}\n\n\t\tif cs[i-1] == i {\n\t\t\tseen[i] = true\n\t\t\tseen[cs[i-1]] = true\n\t\t\tls = append(ls, 1)\n\t\t\tcontinue\n\t\t}\n\n\t\tl := 2\n\n\t\tfor ; ; l++ {\n\t\t\tseen[c] = true\n\t\t\tnext := cs[c-1]\n\t\t\tif next == i {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif seen[next] {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tc = next\n\t\t}\n\t\tseen[i] = true\n\t\tls = append(ls, l)\n\t}\n\treturn ls\n}\n\nfunc gcd(a, b int) int {\n\tfor b > 0 {\n\t\ta, b = b, a%b\n\t}\n\treturn a\n}\n\nfunc lcm(a, b int) int {\n\treturn a * b / gcd(a, b)\n}\n\nfunc lcmm(xs ...int) int {\n\tr := 1\n\tfor _, x := range xs {\n\t\tr = lcm(r, x)\n\t}\n\treturn r\n}\n\nfunc test() {\n\ttests := []struct {\n\t\tin string\n\t\twant string\n\t}{\n\t\t{\n\t\t\tin: `\n4\n2 3 1 4\n`,\n\t\t\twant: `3`,\n\t\t},\n\t\t{\n\t\t\tin: `\n4\n4 4 4 4\n`,\n\t\t\twant: `-1`,\n\t\t},\n\t\t{\n\t\t\tin: `\n4\n2 1 4 3\n`,\n\t\t\twant: `1`,\n\t\t},\n\t\t{\n\t\t\tin: `\n5\n2 3 1 5 4\n`,\n\t\t\twant: `3`,\n\t\t},\n\t\t{\n\t\t\tin: `\n7\n2 3 1 5 6 7 4\n`,\n\t\t\twant: `6`,\n\t\t},\n\t\t{\n\t\t\tin: `\n5\n2 4 3 1 2\n`,\n\t\t\twant: `-1`,\n\t\t},\n\t\t{\n\t\t\tin: `\n10\n8 10 4 3 2 1 9 6 5 7\n`,\n\t\t\twant: `15`,\n\t\t},\n\t}\n\tfor i, tt := range tests {\n\t\tfmt.Printf(\"=== TEST %d\\n\", i)\n\t\tbuf := new(bytes.Buffer)\n\t\tsolve(strings.NewReader(chomp(tt.in)), buf)\n\t\tif got, want := chomp(buf.String()), chomp(tt.want); got != want {\n\t\t\tfmt.Printf(\"%d: got %v, want %v\\n\", i, got, want)\n\t\t}\n\t}\n}\n\nfunc chomp(s string) string {\n\treturn strings.Trim(s, \"\\n\")\n}\n\nfunc assert(b bool) {\n\tif !b {\n\t\t_, file, line, ok := runtime.Caller(1)\n\t\tif ok {\n\t\t\tf, _ := os.Open(file)\n\t\t\tdefer f.Close()\n\t\t\ts := bufio.NewScanner(f)\n\t\t\tlnum := 0\n\t\t\tfor s.Scan() {\n\t\t\t\tlnum++\n\t\t\t\tif lnum == line {\n\t\t\t\t\twd, _ := os.Getwd()\n\t\t\t\t\tfname, _ := filepath.Rel(wd, file)\n\t\t\t\t\tfmt.Printf(\"assertion fails: %s:%d: %v\\n\", fname, line, s.Text())\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc pow(a, b int) int {\n\tr := 1\n\tfor i := 0; i < b; i++ {\n\t\tr *= a\n\t}\n\treturn r\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"runtime\"\n\t\"strings\"\n)\n\nfunc main() {\n\tb, _ := ioutil.ReadAll(os.Stdin)\n\tif len(b) == 0 {\n\t\ttest()\n\t} else {\n\t\tsolve(bytes.NewReader(b), os.Stdout)\n\t}\n}\n\nfunc solve(r io.Reader, w io.Writer) {\n\tvar n int\n\tfmt.Fscanln(r, &n)\n\n\tcs := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscan(r, &cs[i])\n\t}\n\n\tfmt.Fprintln(w, f(cs))\n}\n\nfunc f(cs []int) int {\n\tgs := graphs(cs)\n\n\tif len(gs) == 0 {\n\t\treturn -1\n\t}\n\n\tif len(gs) == 1 {\n\t\treturn gs[0]\n\t}\n\n\tfor i, g := range gs {\n\t\tif g%2 == 0 {\n\t\t\tgs[i] = g / 2\n\t\t}\n\t}\n\n\treturn lcmm(gs...)\n}\n\nfunc graphs(cs []int) []int {\n\tseen := make(map[int]bool, len(cs))\n\n\tvar ls []int\n\n\tfor j, c := range cs {\n\t\ti := j + 1\n\n\t\tif seen[i-1] {\n\t\t\tcontinue\n\t\t}\n\n\t\tif cs[i-1] == i {\n\t\t\tseen[i] = true\n\t\t\tseen[cs[i-1]] = true\n\t\t\tls = append(ls, 1)\n\t\t\tcontinue\n\t\t}\n\n\t\tl := 2\n\n\t\tfor ; ; l++ {\n\t\t\tseen[c] = true\n\t\t\tnext := cs[c-1]\n\t\t\tif next == i {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif seen[next] {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tc = next\n\t\t}\n\t\tseen[i] = true\n\t\tls = append(ls, l)\n\t}\n\treturn ls\n}\n\nfunc gcd(a, b int) int {\n\tfor b > 0 {\n\t\ta, b = b, a%b\n\t}\n\treturn a\n}\n\nfunc lcm(a, b int) int {\n\treturn a * b / gcd(a, b)\n}\n\nfunc lcmm(xs ...int) int {\n\tr := 1\n\tfor _, x := range xs {\n\t\tr = lcm(r, x)\n\t}\n\treturn r\n}\n\nfunc test() {\n\ttests := []struct {\n\t\tin string\n\t\twant string\n\t}{\n\t\t{\n\t\t\tin: `\n4\n2 3 1 4\n`,\n\t\t\twant: `3`,\n\t\t},\n\t\t{\n\t\t\tin: `\n4\n4 4 4 4\n`,\n\t\t\twant: `-1`,\n\t\t},\n\t\t{\n\t\t\tin: `\n4\n2 1 4 3\n`,\n\t\t\twant: `1`,\n\t\t},\n\t\t{\n\t\t\tin: `\n5\n2 3 1 5 4\n`,\n\t\t\twant: `3`,\n\t\t},\n\t\t{\n\t\t\tin: `\n7\n2 3 1 5 6 7 4\n`,\n\t\t\twant: `6`,\n\t\t},\n\t\t{\n\t\t\tin: `\n5\n2 4 3 1 2\n`,\n\t\t\twant: `-1`,\n\t\t},\n\t}\n\tfor i, tt := range tests {\n\t\tfmt.Printf(\"=== TEST %d\\n\", i)\n\t\tbuf := new(bytes.Buffer)\n\t\tsolve(strings.NewReader(chomp(tt.in)), buf)\n\t\tif got, want := chomp(buf.String()), chomp(tt.want); got != want {\n\t\t\tfmt.Printf(\"%d: got %v, want %v\\n\", i, got, want)\n\t\t}\n\t}\n}\n\nfunc chomp(s string) string {\n\treturn strings.Trim(s, \"\\n\")\n}\n\nfunc assert(b bool) {\n\tif !b {\n\t\t_, file, line, ok := runtime.Caller(1)\n\t\tif ok {\n\t\t\tf, _ := os.Open(file)\n\t\t\tdefer f.Close()\n\t\t\ts := bufio.NewScanner(f)\n\t\t\tlnum := 0\n\t\t\tfor s.Scan() {\n\t\t\t\tlnum++\n\t\t\t\tif lnum == line {\n\t\t\t\t\twd, _ := os.Getwd()\n\t\t\t\t\tfname, _ := filepath.Rel(wd, file)\n\t\t\t\t\tfmt.Printf(\"assertion fails: %s:%d: %v\\n\", fname, line, s.Text())\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc pow(a, b int) int {\n\tr := 1\n\tfor i := 0; i < b; i++ {\n\t\tr *= a\n\t}\n\treturn r\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"runtime\"\n\t\"strings\"\n)\n\nfunc main() {\n\tb, _ := ioutil.ReadAll(os.Stdin)\n\tif len(b) == 0 {\n\t\ttest()\n\t} else {\n\t\tsolve(bytes.NewReader(b), os.Stdout)\n\t}\n}\n\nfunc solve(r io.Reader, w io.Writer) {\n\tvar n int\n\tfmt.Fscanln(r, &n)\n\n\tcs := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscan(r, &cs[i])\n\t}\n\n\tfmt.Fprintln(w, f(cs))\n}\n\nfunc f(cs []int) int {\n\tgs := graphs(cs)\n\n\tif len(gs) == 0 {\n\t\treturn -1\n\t}\n\n\tif len(gs) == 1 {\n\t\treturn gs[0]\n\t}\n\n\tfor i, g := range gs {\n\t\tif g%2 == 0 {\n\t\t\tgs[i] = g / 2\n\t\t}\n\t}\n\n\treturn lcmm(gs...)\n}\n\nfunc graphs(cs []int) []int {\n\tseen := make(map[int]bool, len(cs))\n\n\tvar ls []int\n\n\tfor j, c := range cs {\n\t\ti := j + 1\n\n\t\tif seen[cs[c-1]] {\n\t\t\tcontinue\n\t\t}\n\n\t\tif cs[i-1] == i {\n\t\t\tseen[i] = true\n\t\t\tseen[cs[i-1]] = true\n\t\t\tls = append(ls, 1)\n\t\t\tcontinue\n\t\t}\n\n\t\tl := 2\n\n\t\tfor ; ; l++ {\n\t\t\tseen[c] = true\n\t\t\tnext := cs[c-1]\n\t\t\tif next == i {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif seen[next] {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tc = next\n\t\t}\n\t\tseen[i] = true\n\t\tls = append(ls, l)\n\t}\n\treturn ls\n}\n\nfunc gcd(a, b uint64) uint64 {\n\tfor b > 0 {\n\t\ta, b = b, a%b\n\t}\n\treturn a\n}\n\nfunc lcm(a, b uint64) uint64 {\n\treturn a * b / gcd(a, b)\n}\n\nfunc lcmm(xs ...int) int {\n\tr := uint64(1)\n\tfor _, x := range xs {\n\t\tr = lcm(r, uint64(x))\n\t}\n\treturn int(r)\n}\n\nfunc test() {\n\ttests := []struct {\n\t\tin string\n\t\twant string\n\t}{\n\t\t{\n\t\t\tin: `\n4\n2 3 1 4\n`,\n\t\t\twant: `3`,\n\t\t},\n\t\t{\n\t\t\tin: `\n4\n4 4 4 4\n`,\n\t\t\twant: `-1`,\n\t\t},\n\t\t{\n\t\t\tin: `\n4\n2 1 4 3\n`,\n\t\t\twant: `1`,\n\t\t},\n\t\t{\n\t\t\tin: `\n5\n2 3 1 5 4\n`,\n\t\t\twant: `3`,\n\t\t},\n\t\t{\n\t\t\tin: `\n7\n2 3 1 5 6 7 4\n`,\n\t\t\twant: `6`,\n\t\t},\n\t}\n\tfor i, tt := range tests {\n\t\tfmt.Printf(\"=== TEST %d\\n\", i)\n\t\tbuf := new(bytes.Buffer)\n\t\tsolve(strings.NewReader(chomp(tt.in)), buf)\n\t\tif got, want := chomp(buf.String()), chomp(tt.want); got != want {\n\t\t\tfmt.Printf(\"%d: got %v, want %v\\n\", i, got, want)\n\t\t}\n\t}\n}\n\nfunc chomp(s string) string {\n\treturn strings.Trim(s, \"\\n\")\n}\n\nfunc assert(b bool) {\n\tif !b {\n\t\t_, file, line, ok := runtime.Caller(1)\n\t\tif ok {\n\t\t\tf, _ := os.Open(file)\n\t\t\tdefer f.Close()\n\t\t\ts := bufio.NewScanner(f)\n\t\t\tlnum := 0\n\t\t\tfor s.Scan() {\n\t\t\t\tlnum++\n\t\t\t\tif lnum == line {\n\t\t\t\t\twd, _ := os.Getwd()\n\t\t\t\t\tfname, _ := filepath.Rel(wd, file)\n\t\t\t\t\tfmt.Printf(\"assertion fails: %s:%d: %v\\n\", fname, line, s.Text())\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc pow(a, b int) int {\n\tr := 1\n\tfor i := 0; i < b; i++ {\n\t\tr *= a\n\t}\n\treturn r\n}\n"}], "src_uid": "149221131a978298ac56b58438df46c9"} {"nl": {"description": "Tonio has a keyboard with only two letters, \"V\" and \"K\".One day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.", "input_spec": "The first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.", "output_spec": "Output a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.", "sample_inputs": ["VK", "VV", "V", "VKKKKKKKKKVVVVVVVVVK", "KVKV"], "sample_outputs": ["1", "1", "0", "3", "1"], "notes": "NoteFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.For the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.For the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i ...interface{}) error {\n\t_, err := fmt.Fscan(r, i...)\n\treturn err\n}\n\nfunc O(o ...interface{}) {\n\tfmt.Fprint(w, o...)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.goC\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tvar s string\n\tfor I(&s) == nil {\n\t\tsolve(s)\n\t}\n}\n\nfunc solve(s string) {\n\tss := []byte(s)\n\tvk := []byte(\"VK\")\n\tmax := bytes.Count(ss, vk)\n\tfor i := range ss {\n\t\tif ss[i] == 'V' {\n\t\t\tss[i] = 'K'\n\t\t} else {\n\t\t\tss[i] = 'V'\n\t\t}\n\t\tmx := bytes.Count(ss, vk)\n\t\tif mx > max {\n\t\t\tmax = mx\n\t\t}\n\t\tif ss[i] == 'V' {\n\t\t\tss[i] = 'K'\n\t\t} else {\n\t\t\tss[i] = 'V'\n\t\t}\n\t}\n\tO(max, \"\\n\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tstr := readString()\n\ta := []byte(str)\n\tans := 0\n\tfor _, v := range []byte(\"VK\") {\n\t\tfor i := 0; i < len(a); i++ {\n\t\t\tprev := a[i]\n\t\t\ta[i] = v\n\t\t\tres := 0\n\t\t\tfor j := 0; j < len(a)-1; j++ {\n\t\t\t\tif a[j] == 'V' && a[j+1] == 'K' {\n\t\t\t\t\tres++\n\t\t\t\t\tj++\n\t\t\t\t}\n\t\t\t}\n\t\t\tans = max(ans, res)\n\t\t\ta[i] = prev\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc vk(s string) int {\n\treturn strings.Count(s, \"VK\")\n}\n\nfunc main() {\n\tvar arr []byte\n\tvar c byte\n\tvar max int\n\tfor {\n\t\tfmt.Scanf(\"%c\", &c)\n\t\tif c == '\\n' {\n\t\t\tbreak\n\t\t}\n\t\tarr = append(arr, c)\n\t}\n\tfor i := 0; i < len(arr); i++ {\n\t\tif arr[i] == 'V' {\n\t\t\tarr[i] = 'K'\n\t\t\tif vk(string(arr)) > max {\n\t\t\t\tmax = vk(string(arr))\n\t\t\t}\n\t\t\tarr[i] = 'V'\n\t\t} else {\n\t\t\tarr[i] = 'V'\n\t\t\tif vk(string(arr)) > max {\n\t\t\t\tmax = vk(string(arr))\n\t\t\t}\n\t\t\tarr[i] = 'K'\n\t\t}\n\t}\n\tfmt.Println(max)\n}"}], "negative_code": [], "src_uid": "578bae0fe6634882227ac371ebb38fc9"} {"nl": {"description": "Madoka decided to entrust the organization of a major computer game tournament \"OSU\"!In this tournament, matches are held according to the \"Olympic system\". In other words, there are $$$2^n$$$ participants in the tournament, numbered with integers from $$$1$$$ to $$$2^n$$$. There are $$$n$$$ rounds in total in the tournament. In the $$$i$$$-th round there are $$$2^{n - i}$$$ matches between two players (one of whom is right, the other is left), after which the winners go further along the tournament grid, and the losing participants are eliminated from the tournament. Herewith, the relative order in the next round does not change. And the winner of the tournament — is the last remaining participant.But the smaller the participant's number, the more he will pay Madoka if he wins, so Madoka wants the participant with the lowest number to win. To do this, she can arrange the participants in the first round as she likes, and also determine for each match who will win — the participant on the left or right.But Madoka knows that tournament sponsors can change the winner in matches no more than $$$k$$$ times. (That is, if the participant on the left won before the change, then the participant on the right will win after the change, and if the participant on the right won, then the participant on the left will win after the change). So, the first image shows the tournament grid that Madoka made, where the red lines denote who should win the match. And the second one shows the tournament grid, after one change in the outcome of the match by sponsors (a match between $$$1$$$ and $$$3$$$ players). Print the minimum possible number of the winner in the tournament, which Madoka can get regardless of changes in sponsors. But since the answer can be very large, output it modulo $$$10^9 + 7$$$. Note that we need to minimize the answer, and only then take it modulo.", "input_spec": "The first and the only line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le n \\le 10^5, 1 \\le k \\le \\min(2^n - 1, 10^9)$$$) — the number of rounds in the tournament and the number of outcomes that sponsors can change.", "output_spec": "Print exactly one integer — the minimum number of the winner modulo $$$10^9 + 7$$$", "sample_inputs": ["1 1", "2 1", "3 2"], "sample_outputs": ["2", "3", "7"], "notes": "NoteIn the first example, there is only one match between players $$$1$$$ and $$$2$$$, so the sponsors can always make player $$$2$$$ wins.The tournament grid from the second example is shown in the picture in the statement."}, "positive_code": [{"source_code": "package main\r\n\r\nimport (\r\n\t\"bufio\"\r\n\t\"fmt\"\r\n\t\"io\"\r\n\t\"os\"\r\n)\r\n\r\nfunc modpow(x, n, mod int) int {\r\n\tif n == 0 {\r\n\t\treturn 1 % mod\r\n\t}\r\n\tu := modpow(x, n/2, mod)\r\n\tu = (u * u) % mod\r\n\tif n&1 == 1 {\r\n\t\tu = (x * u) % mod\r\n\t}\r\n\r\n\treturn u\r\n}\r\n\r\nfunc Min(a, b int) int {\r\n\tif a < b {\r\n\t\treturn a\r\n\t}\r\n\treturn b\r\n}\r\n\r\nfunc Solve(reader io.Reader, writer io.Writer) {\r\n\tmod := 1000000007\r\n\r\n\tvar n, k int\r\n\tfmt.Fscanf(reader, \"%d %d\\n\", &n, &k)\r\n\tcomb := 1\r\n\tans := 1\r\n\tfor i := 1; i <= Min(n, k); i++ {\r\n\t\tcomb = (comb * (n - i + 1)) % mod\r\n\t\tcomb = (comb * modpow(i, mod-2, mod)) % mod\r\n\t\tans = (ans + comb) % mod\r\n\r\n\t}\r\n\tfmt.Fprintln(writer, ans)\r\n}\r\n\r\nfunc main() {\r\n\t// f, err := os.Open(\"data.txt\")\r\n\t// if err != nil {\r\n\t// \tos.Exit(1)\r\n\t// }\r\n\t// defer f.Close()\r\n\r\n\t// reader := bufio.NewReader(f)\r\n\treader := bufio.NewReader(os.Stdin)\r\n\twriter := bufio.NewWriter(os.Stdout)\r\n\tSolve(reader, writer)\r\n\twriter.Flush()\r\n\r\n}\r\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar P107 int = 1000000007\n\nfunc Max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc Min(a, b int) int {\n\tif a > b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc Abs(a int) int {\n\treturn Max(a, -a)\n}\n\nfunc Gcd(a, b int) int {\n\tmin := Min(a, b)\n\tmax := Max(a, b)\n\tif min == 0 {\n\t\treturn max\n\t}\n\n\tfor max%min != 0 {\n\t\tmin, max = max%min, min\n\t}\n\n\treturn min\n}\n\nfunc Lcm(a, b int) int {\n\treturn a / Gcd(a, b) * b\n}\n\nvar facs []int = make([]int, 100010)\n\nfunc FacP(n, p int) int {\n\tif facs[n] != 0 {\n\t\treturn facs[n]\n\t}\n\n\tresult := 1\n\tfacs[0] = 1\n\tfor i := 1; i <= n; i++ {\n\t\tresult = (result * i) % p\n\t\tfacs[i] = result\n\t}\n\n\treturn result\n}\n\nfunc ExpP(a, x, p int) int {\n\tif x == 0 {\n\t\treturn 1\n\t}\n\n\tif x%2 == 0 {\n\t\thalf := ExpP(a, x/2, p)\n\t\treturn (half * half) % p\n\t} else {\n\t\treturn ((a % p) * ExpP(a, x-1, p)) % p\n\t}\n}\n\nfunc CombP(n, c, p int) int {\n\treturn (FacP(n, p) * ((ExpP(FacP(n-c, p), p-2, p) * ExpP(FacP(c, p), p-2, p)) % p)) % p\n}\n\nfunc Solve(reader *bufio.Reader) {\n\tscanner := bufio.NewScanner(reader)\n\tscanner.Split(bufio.ScanWords)\n\twr := bufio.NewWriter(os.Stdout)\n\tdefer wr.Flush()\n\n\tscanner.Scan()\n\tn, _ := strconv.Atoi(scanner.Text())\n\tscanner.Scan()\n\tk, _ := strconv.Atoi(scanner.Text())\n\tk = Min(k, n)\n\n\tresult := 0\n\tfor i := 0; i <= k; i++ {\n\t\tresult = (result + CombP(n, i, P107)) % P107\n\t}\n\n\twr.WriteString(strconv.Itoa(result) + \"\\n\")\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tSolve(reader)\n}\n"}], "negative_code": [], "src_uid": "dc7b887afcc2e95c4e90619ceda63071"} {"nl": {"description": "A number is called almost prime if it has exactly two distinct prime divisors. For example, numbers 6, 18, 24 are almost prime, while 4, 8, 9, 42 are not. Find the amount of almost prime numbers which are between 1 and n, inclusive.", "input_spec": "Input contains one integer number n (1 ≤ n ≤ 3000).", "output_spec": "Output the amount of almost prime numbers between 1 and n, inclusive.", "sample_inputs": ["10", "21"], "sample_outputs": ["2", "8"], "notes": null}, "positive_code": [{"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\n\tvar n int\n\tfmt.Fscanf(reader, \"%d\", &n)\n\tcount := 0\n\tfor i := 6;i <= n;i ++ {\n\t\tprime_count := 0\n\t\tx := i\n\t\tfor j := 2;j <= i;j ++ {\n\t\t\tif x % j == 0 {\n\t\t\t\tprime_count ++\n\t\t\t\tfor x % j == 0 {\n\t\t\t\t\tx /= j\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif prime_count == 2 {\n\t\t\tcount ++\n\t\t}\n\t}\n\tfmt.Printf(\"%d\", count)\n}"}, {"source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"strconv\"\n\nfunc main(){\n\tvar n int\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tn, _ = strconv.Atoi(r.Text())\n\ta := make([]int, 3001)\n\tcount := 0\n\tfor i:=2; i<=n; i++ {\n\t\tfor j:=2; j max {\n break\n }\n primes = append(primes, pos)\n for i := 2*pos; i <= max; i += pos {\n notPrime[i] = true\n }\n }\n\n n := getI()\n result := 0\n for a := 1; a <= n; a++ {\n count := 0\n for _, b := range primes {\n if b >= a {\n break\n }\n if a%b == 0 {\n count++\n }\n }\n if count == 2 {\n result++\n }\n }\n writer.WriteString(fmt.Sprintf(\"%d\\n\", result))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc seive(n int64) int64 {\n\tvar isPrime []bool = []bool{}\n\tvar i int64\n\tvar j int64\n\tfor i = 0; i <= n; i++ {\n\t\tisPrime = append(isPrime, true)\n\t}\n\tvar num = make([]int64, n+1)\n\tfor i = 2; i <= (n); i++ {\n\t\tif isPrime[i] == true {\n\t\t\tfor j = 2; j*i <= n; j++ {\n\t\t\t\tisPrime[j*i] = false\n\t\t\t\tnum[j*i] += 1\n\t\t\t}\n\t\t}\n\t}\n\tvar result int64 = 0\n\tfor i = 2; i <= n; i++ {\n\t\tif num[i] == 2 {\n\t\t\tresult++\n\t\t}\n\t}\n\treturn result\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tn, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\tvar res int64\n\tres = seive(n)\n\tfmt.Println(res)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar w int\n\t_, _ = fmt.Scanf(\"%d\", &w)\n\tsimples := make([]int, w-1)\n\tfor i := 2; i < w+1; i++ {\n\t\tsimples[i-2] = i\n\t}\n\n\tfor _, i := range simples {\n\t\tif i != -1 {\n\t\t\tfor j := i * i; j <= w; j += i {\n\t\t\t\tsimples[j-2] = -1\n\t\t\t}\n\t\t}\n\t}\n\tans := 0\n\n\tfor i := 2; i <= w; i++ {\n\t\tcnt := 2\n\t\tfor _, v := range simples {\n\t\t\tif v != -1 && i%v == 0 {\n\t\t\t\tcnt--\n\t\t\t}\n\t\t}\n\n\t\tif cnt == 0 {\n\t\t\tans += 1\n\t\t}\n\t}\n\tfmt.Println(ans)\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nvar (\n\tpr = [...]int32{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71}\n\tnpr = int32(len(pr))\n)\n\n// num of prime factors\nfunc npf(x int32) (ret int32) {\n\ti := int32(0)\n\tfor i < npr && ret < 3 && x > 1 {\n\t\td := pr[i]\n\t\tif d*d > x {\n\t\t\tret++\n\t\t\tbreak\n\t\t}\n\t\tvolt := false\n\t\tfor x%d == 0 {\n\t\t\tvolt = true\n\t\t\tx = x / d\n\t\t}\n\t\tif volt {\n\t\t\tret++\n\t\t}\n\t\ti++\n\t}\n\treturn\n}\n\nfunc main() {\n\tvar n int32\n\tfmt.Scan(&n)\n\ts := int32(0)\n\tfor i := int32(6); i <= n; i++ {\n\t\t//println(i, npf(i))\n\t\tif 2 == npf(i) {\n\t\t\ts++\n\t\t}\n\t}\n\tfmt.Println(s)\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n fmt.Scan(&n)\n p := make([]int,n+1)\n ans := 0\n for i := 2; i <= n; i++ {\n if p[i] == 0 {\n for a := i; a <= n; a += i {\n p[a]++\n }\n } else if p[i] == 2 {\n ans++\n }\n }\n fmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n fmt.Scan(&n)\n p := make([]int,n+1)\n ans := 0\n for i := 2; i <= n; i++ {\n if p[i] == 0 {\n for a := i; a <= n; a += i {\n p[a]++\n }\n } else if p[i] == 2 {\n ans++\n }\n }\n fmt.Println(ans)\n}\n"}, {"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\tn := 0\n\tif scanner.Scan() {\n\t\tline := scanner.Text()\n\n\t\tfmt.Sscanf(line, \"%d\", &n)\n\t\tprimes := genPrime(n)\n\n\t\talmostPrime := 0\n\n\t\tfor i := 2; i <= n; i++ {\n\t\t\ttmp := i\n\t\t\tfactorCount := 0\n\t\t\tfor _, j := range primes {\n\t\t\t\tif tmp%j == 0 {\n\t\t\t\t\tfactorCount += 1\n\t\t\t\t\tif factorCount > 2 {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor tmp%j == 0 {\n\t\t\t\t\ttmp = tmp / j\n\t\t\t\t}\n\t\t\t}\n\t\t\tif factorCount == 2 {\n\t\t\t\talmostPrime += 1\n\t\t\t}\n\t\t}\n\n\t\tfmt.Println(almostPrime)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar inf int = 0x3f3f3f3f\nvar reader *bufio.Reader\n\nfunc init() {\n\tstdin := os.Stdin\n\t// stdin, _ = os.Open(\"1.in\")\n\treader = bufio.NewReaderSize(stdin, 1<<20)\n}\n\nvar n int\n\nfunc main() {\n\tfmt.Fscan(reader, &n)\n\n\tans := 0\n\tfor num := 0; num <= n; num++ {\n\t\ta := Divisor(num)\n\t\tsum := 0\n\t\tfor i := 0; i < len(a); i++ {\n\t\t\tif IsPrime(a[i]) {\n\t\t\t\tsum++\n\t\t\t}\n\t\t\tif sum > 2 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif sum == 2 {\n\t\t\tans++\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n}\n\n// IsPrime 素性测试\nfunc IsPrime(n int) bool {\n\tfor i := int(2); i*i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn n != 1\n}\n\n// Divisor 约数枚举\nfunc Divisor(n int) (res []int) {\n\tfor i := 1; i*i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\tres = append(res, i)\n\t\t\tif i != n/i {\n\t\t\t\tres = append(res, n/i)\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}\n"}, {"source_code": "// 26A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar d [3005]int\n\tvar n int\n\tfmt.Scan(&n)\n\tfor i := 2; i <= n; i++ {\n\t\tif d[i] != 0 {\n\t\t\tcontinue\n\t\t}\n\t\tfor j := i; j <= n; j += i {\n\t\t\td[j]++\n\t\t}\n\t}\n\tres := 0\n\tfor i := 6; i <= n; i++ {\n\t\tif d[i] == 2 {\n\t\t\tres++\n\t\t}\n\t}\n\tfmt.Println(res)\n}\n"}, {"source_code": "// 26A-mic_rizal\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar v []int\n\tvar cont, num, cou, l int\n\tv = append(v, 2)\n\tl++\n\tfor i := 3; i < 3000; i += 2 {\n\t\tfor j := 2; j < i; j++ {\n\t\t\tif i%j == 0 {\n\t\t\t\tcont++\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif cont <= 0 {\n\t\t\tv = append(v, i)\n\t\t\tl++\n\t\t}\n\t\tcont = 0\n\t}\n\tcont = 0\n\tfmt.Scan(&num)\n\tfor i := 1; i <= num; i++ {\n\t\tfor j := 0; j < l; j++ {\n\t\t\tif i%v[j] == 0 {\n\t\t\t\tcont++\n\t\t\t}\n\t\t}\n\t\tif cont == 2 {\n\t\t\tcou++\n\t\t}\n\t\tcont = 0\n\t}\n\tfmt.Println(cou)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nconst (\n\tBIG = 1024 * 1024 * 10\n)\n\nfunc readLine(r *bufio.Reader) string {\n\tbytes, _, err := r.ReadLine()\n\tif err != nil {\n\t\tlog.Fatalln(\"Failed to read line\")\n\t}\n\n\treturn string(bytes)\n}\n\nfunc readInts(r *bufio.Reader) []int {\n\telems := strings.Fields(readLine(r))\n\n\tret := make([]int, len(elems))\n\tfor i, el := range elems {\n\t\ttmp, err := strconv.ParseInt(el, 10, 64)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"Failed to parse number %v\", el)\n\t\t}\n\t\tret[i] = int(tmp)\n\t}\n\n\treturn ret\n}\n\ntype Sieve struct {\n\tn int\n\tfirst, primes []int\n}\n\ntype Factor struct {\n\tBase, Exp int\n}\n\nfunc NewSieve(n int) *Sieve {\n\tfirst := make([]int, n+1)\n\tprimes := make([]int, 0)\n\n\tfor i := 2; i <= n; i++ {\n\t\tif first[i] == 0 {\n\t\t\tfirst[i] = i\n\t\t\tprimes = append(primes, i)\n\t\t}\n\n\t\tfor j := 0; j < len(primes) && primes[j] <= first[i] && i*primes[j] <= n; j++ {\n\t\t\tfirst[i*primes[j]] = primes[j]\n\t\t}\n\t}\n\n\tret := Sieve{n, first, primes}\n\n\treturn &ret\n}\n\nfunc (s *Sieve) IsPrime(x int) (bool, error) {\n\tif s.n < x {\n\t\treturn false, errors.New(fmt.Sprintf(\"The largest supported number by this sieve is %v\", s.n))\n\t}\n\tif x < s.primes[0] || x > s.primes[len(s.primes)-1] {\n\t\treturn false, nil\n\t} else if x == s.primes[0] {\n\t\treturn true, nil\n\t}\n\tlow, high := 0, len(s.primes)-1\n\tfor high-low > 1 {\n\t\tmid := (low + high) / 2\n\t\tif s.primes[mid] < x {\n\t\t\tlow = mid\n\t\t} else {\n\t\t\thigh = mid\n\t\t}\n\t}\n\treturn s.primes[high] == x, nil\n}\n\nfunc (s *Sieve) Factors(x int) ([]Factor, error) {\n\tfactors := make([]Factor, 0)\n\n\tif s.n < x {\n\t\treturn factors, errors.New(fmt.Sprintf(\"The largest supported number by this sieve is %v\", s.n))\n\t}\n\n\tfor x > 1 {\n\t\tpi := s.first[x]\n\t\texp := 0\n\t\tfor x > 1 && s.first[x] == pi {\n\t\t\texp += 1\n\t\t\tx /= pi\n\t\t}\n\t\tfactors = append(factors, Factor{pi, exp})\n\t}\n\n\treturn factors, nil\n}\nfunc main() {\n\tr := bufio.NewReaderSize(os.Stdin, BIG)\n\n\tn := readInts(r)[0]\n\ts := NewSieve(n)\n\n\ttotal := 0\n\tfor i := 1; i <= n; i++ {\n\t\tfactors, _ := s.Factors(i)\n\t\tif len(factors) == 2 {\n\t\t\ttotal += 1\n\t\t}\n\t}\n\n\tfmt.Println(total)\n}\n"}], "negative_code": [{"source_code": "// 26A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar d [3005]int\n\tvar n int\n\tfmt.Scan(&n)\n\tfor i := 2; i <= n; i++ {\n\t\tif d[i] != 0 {\n\t\t\tcontinue\n\t\t}\n\t\tfor j := i; j <= n; j += i {\n\t\t\td[j]++\n\t\t}\n\t}\n\tres := 0\n\tfor i := 6; i <= n; i++ {\n\t\tif d[i] == 2 {\n\t\t\tres++\n\t\t}\n\t\tfmt.Println(res)\n\t}\n}\n"}], "src_uid": "356666366625bc5358bc8b97c8d67bd5"} {"nl": {"description": "Mahmoud has n line segments, the i-th of them has length ai. Ehab challenged him to use exactly 3 line segments to form a non-degenerate triangle. Mahmoud doesn't accept challenges unless he is sure he can win, so he asked you to tell him if he should accept the challenge. Given the lengths of the line segments, check if he can choose exactly 3 of them to form a non-degenerate triangle.Mahmoud should use exactly 3 line segments, he can't concatenate two line segments or change any length. A non-degenerate triangle is a triangle with positive area.", "input_spec": "The first line contains single integer n (3 ≤ n ≤ 105) — the number of line segments Mahmoud has. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the lengths of line segments Mahmoud has.", "output_spec": "In the only line print \"YES\" if he can choose exactly three line segments and form a non-degenerate triangle with them, and \"NO\" otherwise.", "sample_inputs": ["5\n1 5 3 2 4", "3\n4 1 2"], "sample_outputs": ["YES", "NO"], "notes": "NoteFor the first example, he can use line segments with lengths 2, 4 and 5 to form a non-degenerate triangle."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nfunc I(i ...interface{}) error {\n\t_, err := fmt.Fscan(r, i...)\n\treturn err\n}\n\nfunc O(o ...interface{}) {\n\tfmt.Fprint(w, o...)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.goC\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tvar n int\n\tfor I(&n) == nil {\n\t\tsolve(n)\n\t}\n}\n\nfunc solve(n int) {\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tI(&a[i])\n\t}\n\tsort.Ints(a)\n\tfor i := 0; i < len(a)-2; i++ {\n\t\tif a[i]+a[i+1] > a[i+2] {\n\t\t\tO(\"YES\\n\")\n\t\t\treturn\n\t\t}\n\t}\n\tO(\"NO\\n\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar n int\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\tarray := make([]int, n)\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tfor i := 0; scanner.Scan(); i++ {\n\t\ta, err := strconv.Atoi(scanner.Text())\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tarray[i] = a\n\t}\n\n\tmerge_sort(array, 0, n-1)\n\n\tfor i := n - 1; i >= 2; i-- {\n\t\tif array[i-1]+array[i-2] > array[i] {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n\nfunc merge(buffer []int, start, middle, end int) {\n\tsorted := make([]int, end-start+1)\n\n\ti := start\n\tj := middle + 1\n\tk := 0\n\tfor i <= middle && j <= end {\n\t\tif buffer[i] <= buffer[j] {\n\t\t\tsorted[k] = buffer[i]\n\t\t\ti++\n\t\t} else {\n\t\t\tsorted[k] = buffer[j]\n\t\t\tj++\n\t\t}\n\t\tk++\n\t}\n\tfor i <= middle {\n\t\tsorted[k] = buffer[i]\n\t\tk++\n\t\ti++\n\t}\n\tfor j <= end {\n\t\tsorted[k] = buffer[j]\n\t\tk++\n\t\tj++\n\t}\n\n\ti = start\n\tk = 0\n\tfor i <= end {\n\t\tbuffer[i] = sorted[k]\n\t\ti++\n\t\tk++\n\t}\n}\n\nfunc merge_sort(buffer []int, start, end int) {\n\tif end > start {\n\t\tmiddle := (end + start) / 2\n\t\tmerge_sort(buffer, start, middle)\n\t\tmerge_sort(buffer, middle+1, end)\n\t\tmerge(buffer, start, middle, end)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt()\n\tv := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tv[i] = readInt()\n\t}\n\tsort.Ints(v)\n\tfor i := 2; i < n; i++ {\n\t\ta := int64(v[i-2])\n\t\tb := int64(v[i-1])\n\t\tc := int64(v[i])\n\t\tif a+b > c && a+c > b && b+c > a {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc 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"}, {"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 CF766B(_r io.Reader, out io.Writer) {\n\tin := bufio.NewReader(_r)\n\tvar n int\n\tFscan(in, &n)\n\tif n > 44 {\n\t\tFprint(out, \"YES\")\n\t\treturn\n\t}\n\ta := make([]int, n)\n\tfor i := range a {\n\t\tFscan(in, &a[i])\n\t}\n\tsort.Ints(a)\n\tfor i, v := range a[2:] {\n\t\tif a[i]+a[i+1] > v {\n\t\t\tFprint(out, \"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tFprint(out, \"NO\")\n}\n\nfunc main() { CF766B(os.Stdin, os.Stdout) }\n"}, {"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 CF766B(_r io.Reader, out io.Writer) {\n\tin := bufio.NewReader(_r)\n\tvar n int\n\tFscan(in, &n)\n\ta := make([]int, n)\n\tfor i := range a {\n\t\tFscan(in, &a[i])\n\t}\n\tsort.Ints(a)\n\tfor i, v := range a[2:] {\n\t\tif a[i]+a[i+1] > v {\n\t\t\tFprint(out, \"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tFprint(out, \"NO\")\n}\n\nfunc main() { CF766B(os.Stdin, os.Stdout) }\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\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\tfor i := range maj {\n\t\tmaj[i] = readInt()\n\t}\n\tsort.Ints(maj)\n\tfor i := 0; i <= len(maj)-3; i++ {\n\t\tif maj[i]+maj[i+1] > maj[i+2] {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"sort\"\nimport \"bufio\"\nimport \"os\"\nimport \"strconv\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tnums := make([]int, n)\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\n\tfor i := 0; scanner.Scan(); i++ {\n\t\tnum, _ := strconv.Atoi(scanner.Text())\n\t\tnums[i] = num\n\t}\n\tsort.Ints(nums)\n\n\tvar canFormTriangle bool\n\tfor i := 2; i < n; i++ {\n\t\tif nums[i-2]+nums[i-1] > nums[i] {\n\t\t\tcanFormTriangle = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif canFormTriangle {\n\t\tfmt.Print(\"YES\")\n\t} else {\n\t\tfmt.Print(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"sort\"\n \"bufio\"\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 frst() {\n fmt.Println(\"YES\")\n}\nfunc scnd() {\n fmt.Println(\"NO\")\n}\n\nfunc check(a int, b int, c int) bool {\n if a + b > c && b + c > a && a + c > b {\n return true\n } else {\n return false\n }\n}\n\nfunc main() {\n var n int\n scanf(\"%d\\n\", &n)\n var a = make([]int, n)\n for i := 0; i < n; i++ {\n scanf(\"%d\", &a[i])\n }\n sort.Ints(a)\n for i := 0; i < n - 2; i++ {\n if check(a[i], a[i + 1], a[i + 2]) == true {\n frst()\n return\n }\n }\n if check(a[n - 2], a[n - 1], a[0]) == true {\n frst()\n return\n }\n if check(a[n - 1], a[0], a[1]) == true {\n frst()\n return\n }\n scnd()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nfunc Solve(io *FastIO) {\n\tN := io.NextInt()\n\tA := io.NextIntArray(N)\n\n\tsort.Ints(A)\n\n\tfor i := 0; i + 2 < N; i++ {\n\t\tif A[i] + A[i + 1] > A[i + 2] {\n\t\t\tio.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tio.Println(\"NO\")\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tSolve(&io)\n\tio.FlushOutput()\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"sort\"\n \"bufio\"\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 frst() {\n fmt.Println(\"YES\")\n}\nfunc scnd() {\n fmt.Println(\"NO\")\n}\n\nfunc check(a int, b int, c int) bool {\n if a + b > c && b + c > a && a + c > b {\n return true\n } else {\n return false\n }\n}\n\nfunc main() {\n var n int\n scanf(\"%d\\n\", &n)\n var a = make([]int, n)\n for i := 0; i < n; i++ {\n scanf(\"%d\", &a[i])\n }\n sort.Ints(a)\n for i := 0; i < n - 2; i++ {\n if check(a[i], a[i + 1], a[i + 2]) == true {\n frst()\n return\n }\n }\n if check(a[n - 2], a[n - 1], a[0]) == true {\n frst()\n return\n }\n if check(a[n - 1], a[0], a[1]) == true {\n frst()\n return\n }\n scnd()\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nfunc I(i ...interface{}) error {\n\t_, err := fmt.Fscan(r, i...)\n\treturn err\n}\n\nfunc O(o ...interface{}) {\n\tfmt.Fprint(w, o...)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.goC\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\nfunc main() {\n\tdefer w.Flush()\n\tvar n int\n\tfor I(&n) == nil {\n\t\tsolve(n)\n\t}\n}\n\nfunc solve(n int) {\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tI(&a[i])\n\t}\n\tsort.Ints(a)\n\tfor i := 0; i < len(a)-2; i++ {\n\t\tif a[i]+a[i+1] >= a[i+2] {\n\t\t\tO(\"YES\\n\")\n\t\t\treturn\n\t\t}\n\t}\n\tO(\"NO\\n\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\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\tfor i := range maj {\n\t\tmaj[i] = readInt()\n\t}\n\tsort.Ints(maj)\n\ta, b, c := int64(maj[len(maj)-3]), int64(maj[len(maj)-2]), int64(maj[len(maj)-1])\n\tif a*a+b*b < c*c {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\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\tfor i := range maj {\n\t\tmaj[i] = readInt()\n\t}\n\tsort.Ints(maj)\n\ta, b, c := int64(maj[0]), int64(maj[1]), int64(maj[len(maj)-1])\n\tif a*a+b*b < c*c {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\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\tfor i := range maj {\n\t\tmaj[i] = readInt()\n\t}\n\tsort.Ints(maj)\n\ta, b, c := int64(maj[0]), int64(maj[1]), int64(maj[len(maj)-1])\n\tfmt.Println(a*a+b*b < c*c)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\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\tfor i := range maj {\n\t\tmaj[i] = readInt()\n\t}\n\tsort.Ints(maj)\n\ta, b, c := int64(maj[len(maj)-3]), int64(maj[len(maj)-2]), int64(maj[len(maj)-1])\n\tif a*a+b*b > c*c {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}], "src_uid": "897bd80b79df7b1143b652655b9a6790"} {"nl": {"description": "On his free time, Chouti likes doing some housework. He has got one new task, paint some bricks in the yard.There are $$$n$$$ bricks lined in a row on the ground. Chouti has got $$$m$$$ paint buckets of different colors at hand, so he painted each brick in one of those $$$m$$$ colors.Having finished painting all bricks, Chouti was satisfied. He stood back and decided to find something fun with these bricks. After some counting, he found there are $$$k$$$ bricks with a color different from the color of the brick on its left (the first brick is not counted, for sure).So as usual, he needs your help in counting how many ways could he paint the bricks. Two ways of painting bricks are different if there is at least one brick painted in different colors in these two ways. Because the answer might be quite big, you only need to output the number of ways modulo $$$998\\,244\\,353$$$.", "input_spec": "The first and only line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \\leq n,m \\leq 2000, 0 \\leq k \\leq n-1$$$) — the number of bricks, the number of colors, and the number of bricks, such that its color differs from the color of brick to the left of it.", "output_spec": "Print one integer — the number of ways to color bricks modulo $$$998\\,244\\,353$$$.", "sample_inputs": ["3 3 0", "3 2 1"], "sample_outputs": ["3", "4"], "notes": "NoteIn the first example, since $$$k=0$$$, the color of every brick should be the same, so there will be exactly $$$m=3$$$ ways to color the bricks.In the second example, suppose the two colors in the buckets are yellow and lime, the following image shows all $$$4$$$ possible colorings. "}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\ntype key struct {\n\tlastIdx int\n\tnDifferent int\n}\n\nvar (\n\tn, m, k int\n\tcache = make(map[key]int64)\n)\n\n// colorings will calculate how many different colorings are at a[0]..a[lastIdx], so that nDifferent for 0..lastIdx holds.\nfunc colorings(lastIdx int, nDifferent int) (ret int64) {\n\tk := key{lastIdx, nDifferent}\n\tif r, ok := cache[k]; ok {\n\t\treturn r\n\t}\n\tdefer func() {\n\t\tcache[k] = ret\n\t}()\n\n\t// We have spent all our different brick possibilities.\n\tif nDifferent < 0 {\n\t\treturn 0\n\t}\n\n\tif lastIdx == 0 {\n\t\tif nDifferent == 0 {\n\t\t\t// If there is only one brick remaining, it can have m different colors.\n\t\t\treturn int64(m)\n\t\t}\n\t\t// But only, if there is exactly zero bricks different on its left.\n\t\treturn 0\n\t}\n\n\t// There are p combinations for 0..lastIdx-1. For each combination:\n\t// - there is (m-1) combinations with nDifferent that is the same\n\t// - one combination with nDifferent less.\n\tlastIdxDifferent := colorings(lastIdx-1, nDifferent-1) * int64(m-1)\n\tlastIdxSame := colorings(lastIdx-1, nDifferent)\n\t// dprintf(\"lastIdx=%d, nDifferent=%d, noDiff=%d, diff=%d\", lastIdx, nDifferent, noDiffChange, diffChange)\n\n\treturn (lastIdxDifferent + lastIdxSame) % 998244353\n\n\t// m combinations where [lastIdx-1, lastIdx are the same]\n\t// m**2 - m combinations where [lastIdx-1 and lastIdx are different]\n}\n\nfunc dprintf(i string, a ...interface{}) {\n\tif false {\n\t\tfmt.Printf(i+\"\\n\", a...)\n\t}\n}\n\nfunc main() {\n\tfmt.Scanf(\"%d %d %d\", &n, &m, &k)\n\tfmt.Println(colorings(n-1, k))\n\tdprintf(\"%v\", cache)\n}\n"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\n\nconst M int64 = 998244353\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) {\n fmt.Fprintf(writer, f, a...)\n}\n\nfunc scanf(f string, a ...interface{}) {\n fmt.Fscanf(reader, f, a...)\n}\n\nfunc sp(x, y int64) int64 {\n var mul, res int64 = x, 1\n for y != 0 {\n if y % 2 != 0 {\n res = (res * mul) % M\n }\n mul = (mul * mul) % M\n y /= 2\n }\n return res\n}\n\nfunc main() {\n defer writer.Flush()\n var n, m, k int\n scanf(\"%d%d%d\", &n, &m, &k)\n fac := make([]int64, n+1)\n fac[0] = 1\n for i := 1; i <= n; i += 1 {\n fac[i] = (fac[i-1] * int64(i)) % M\n }\n\n sol := fac[n-1]\n sol = (sol * sp(fac[n-1-k], M-2)) % M\n sol = (sol * sp(fac[k], M-2)) % M\n sol = (sol * sp(int64(m-1), int64(k))) % M\n sol = (sol * int64(m)) % M\n printf(\"%d\\n\", sol)\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nconst (\n\tmod = 998244353\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tn, m, k := 0, 0, 0\n\tfmt.Fscanf(in, \"%d %d %d\\n\", &n, &m, &k)\n\tf := make([][]int64, n+1)\n\tfor i := 0; i < n+1; i++ {\n\t\tf[i] = make([]int64, k+1)\n\t}\n\tf[1][0] = int64(m)\n\tfor i := 2; i < n+1; i++ {\n\t\tfor j := 0; j < k+1; j++ {\n\t\t\tif j == 0 {\n\t\t\t\tf[i][j] = f[i-1][j]\n\t\t\t} else {\n\t\t\t\tf[i][j] = f[i-1][j] + f[i-1][j-1]*int64(m-1)\n\t\t\t\tf[i][j] %= mod\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Fprintf(out, \"%d\\n\", f[n][k])\n\treturn\n}"}], "negative_code": [{"source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\n\nconst M int = 998244353\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) {\n fmt.Fprintf(writer, f, a...)\n}\n\nfunc scanf(f string, a ...interface{}) {\n fmt.Fscanf(reader, f, a...)\n}\n\nfunc sp(x, y int) int {\n var mul, res int = x, 1\n for y != 0 {\n if y % 2 != 0 {\n res = (res * mul) % M\n }\n mul = (mul * mul) % M\n y /= 2\n }\n return res\n}\n\nfunc main() {\n defer writer.Flush()\n var n, m, k int\n scanf(\"%d%d%d\", &n, &m, &k)\n\n fac := make([]int, n+1)\n fac[0] = 1\n for i := 1; i <= n; i += 1 {\n fac[i] = (fac[i-1] * i) % M\n }\n\n sol := fac[n-1]\n sol = (sol * sp(fac[n-1-k], M-2)) % M\n sol = (sol * sp(fac[k], M-2)) % M\n sol = (sol * sp(m-1, k)) % M\n sol = (sol * m) % M\n printf(\"%d\\n\", sol)\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nconst M int = 998244353\n\nfunc sp(x, y int) int {\n var mul, res int = x, 1\n for y != 0 {\n if y % 2 != 0 {\n res = (res * mul) % M\n }\n mul = (mul * mul) % M\n y /= 2\n }\n return res\n}\n\nfunc main() {\n var n, m, k int\n fmt.Scanf(\"%d %d %d\\n\", &n, &m, &k)\n\n fac := make([]int, n+1)\n fac[0] = 1\n for i := 1; i <= n; i += 1 {\n fac[i] = (fac[i-1] * i) % M\n }\n\n sol := fac[n-1]\n sol = (sol * sp(fac[n-1-k], M-2)) % M\n sol = (sol * sp(fac[k], M-2)) % M\n sol = (sol * sp(m-1, k)) % M\n sol = (sol * m) % M\n fmt.Printf(\"%d\\n\", sol)\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nconst M int = 998244353\n\nfunc sp(x, y int) int {\n var mul, res int = x, 1\n for y != 0 {\n if y % 2 != 0 {\n res = (res * mul) % M\n }\n mul = (mul * mul) % M\n y /= 2\n }\n return res\n}\n\nfunc main() {\n var n, m, k int\n fmt.Scanf(\"%d%d%d\\n\", &n, &m, &k)\n\n fac := make([]int, n+1)\n fac[0] = 1\n for i := 1; i <= n; i += 1 {\n fac[i] = (fac[i-1] * i) % M\n }\n\n sol := fac[n-1]\n sol = (sol * sp(fac[n-1-k], M-2)) % M\n sol = (sol * sp(fac[k], M-2)) % M\n sol = (sol * sp(m-1, k)) % M\n sol = (sol * m) % M\n fmt.Printf(\"%d\\n\", sol)\n}"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"os\"\n)\n\nconst M int = 998244353\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) {\n fmt.Fprintf(writer, f, a...)\n}\n\nfunc scanf(f string, a ...interface{}) {\n fmt.Fscanf(reader, f, a...)\n}\n\nfunc sp(x, y int) int {\n var mul, res int = x, 1\n for y != 0 {\n if y % 2 != 0 {\n res = (res * mul) % M\n }\n mul = (mul * mul) % M\n y /= 2\n }\n return res\n}\n\nfunc main() {\n defer writer.Flush()\n var n, m, k int\n scanf(\"%d%d%d\", &n, &m, &k)\n printf(\"%d %d %d\\n\", n, m, k);\n fac := make([]int, n+1)\n fac[0] = 1\n for i := 1; i <= n; i += 1 {\n fac[i] = (fac[i-1] * i) % M\n }\n\n sol := fac[n-1]\n sol = (sol * sp(fac[n-1-k], M-2)) % M\n sol = (sol * sp(fac[k], M-2)) % M\n sol = (sol * sp(m-1, k)) % M\n sol = (sol * m) % M\n printf(\"%d\\n\", sol)\n}"}], "src_uid": "b2b9bee53e425fab1aa4d5468b9e578b"} {"nl": {"description": "Kurt reaches nirvana when he finds the product of all the digits of some positive integer. Greater value of the product makes the nirvana deeper.Help Kurt find the maximum possible product of digits among all integers from $$$1$$$ to $$$n$$$.", "input_spec": "The only input line contains the integer $$$n$$$ ($$$1 \\le n \\le 2\\cdot10^9$$$).", "output_spec": "Print the maximum product of digits among all integers from $$$1$$$ to $$$n$$$.", "sample_inputs": ["390", "7", "1000000000"], "sample_outputs": ["216", "7", "387420489"], "notes": "NoteIn the first example the maximum product is achieved for $$$389$$$ (the product of digits is $$$3\\cdot8\\cdot9=216$$$).In the second example the maximum product is achieved for $$$7$$$ (the product of digits is $$$7$$$).In the third example the maximum product is achieved for $$$999999999$$$ (the product of digits is $$$9^9=387420489$$$)."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc main() {\n\tdefer writer.Flush()\n\tch := string(\"\")\n\tscanf(\"%s\", &ch)\n\tnum := []byte(ch)\n\ts1 := uint64(1)\n\tfor _, char := range num {\n\t\ts, _ := strconv.ParseUint(string(char), 10, 64)\n\t\ts1 *= s\n\t}\n\tfor i, char := range num {\n\t\tif char == '0' {\n\t\t\tbreak\n\t\t}\n\t\tnum1 := make([]byte, len(num))\n\t\tcopy(num1, num)\n\t\tnum1[i] = num[i] - 1\n\t\ts2 := uint64(1)\n\t\tfor j, char := range num1 {\n\t\t\tvar number uint64\n\t\t\tif j <= i {\n\t\t\t\tnumber, _ = strconv.ParseUint(string(char), 10, 64)\n\t\t\t\tif number == 0 {\n\t\t\t\t\tnumber = 1\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tnumber = 9\n\t\t\t}\n\t\t\ts2 *= number\n\t\t}\n\t\tif s2 > s1 {\n\t\t\ts1 = s2\n\t\t}\n\t}\n\tprintf(\"%d\\n\", s1)\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tbuf := bufio.NewReader(os.Stdin)\n\n\tvar n int64\n\tfmt.Fscanf(buf, \"%d\\n\", &n)\n\n\tmat := make([]int64, 20)\n\tlen := 0\n\tfor n > 0 {\n\t\tmat[len] = n % int64(10)\n\t\tn /= 10\n\t\tlen++\n\t}\n\t//for i := len - 1; i >= 0; i-- {\n\t//\tif mat[i] == 0 {\n\t//\t\tfor j := i + 1; j < len; j++ {\n\t//\t\t\tmat[j]--\n\t//\t\t\tif mat[j] > 0 || (mat[j] == 0 && j == len-1) {\n\t//\t\t\t\tfor k := j - 1; k >= 0; k-- {\n\t//\t\t\t\t\tmat[k] = 9\n\t//\t\t\t\t}\n\t//\t\t\t\tbreak\n\t//\t\t\t}\n\t//\t\t}\n\t//\t\tbreak\n\t//\t}\n\t//}\n\t//for i := len; i >= 0; i-- {\n\t//\tif mat[i] > 0 {\n\t//\t\tlen = i + 1\n\t//\t\tbreak\n\t//\t}\n\t//}\n\tvar le int64 = 1\n\tvar ans int64 = 1\n\tvar tmp int64 = 1\n\tfor i := 0; i < len; i++ {\n\t\tans *= mat[i]\n\t\tle *= 9\n\t}\n\t//fmt.Printf(\"-%d len=%d %v\\n\",ans,len,mat)\n\n\tfor i := len - 1; i >= 0; i-- {\n\t\tle /= 9\n\t\tif mat[i] > 1 {\n\t\t\tif tmp*(mat[i]-1)*le > ans {\n\t\t\t\tans = tmp * (mat[i] - 1) * le\n\t\t\t}\n\t\t} else if i == len-1 {\n\t\t\tif le > ans {\n\t\t\t\tans = le\n\t\t\t}\n\t\t}else {\n\t\t\tbreak\n\t\t}\n\t\ttmp *= mat[i]\n\t}\n\tfmt.Printf(\"%d\\n\", ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tbuf := bufio.NewReader(os.Stdin)\n\n\tvar n int64\n\tfmt.Fscanf(buf, \"%d\\n\", &n)\n\n\tmat := make([]int64, 20)\n\tlen := 0\n\tfor n > 0 {\n\t\tmat[len] = n % int64(10)\n\t\tn /= 10\n\t\tlen++\n\t}\n\tfor i := len - 1; i >= 0; i-- {\n\t\tif mat[i] == 0 {\n\t\t\tfor j := i + 1; j < len; j++ {\n\t\t\t\tmat[j]--\n\t\t\t\tif mat[j] > 0 || (mat[j] == 0 && j == len-1) {\n\t\t\t\t\tfor k := j - 1; k >= 0; k-- {\n\t\t\t\t\t\tmat[k] = 9\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n//\tfmt.Printf(\"%v\\n\",mat)\n\tfor i := len; i >= 0; i-- {\n\t\tif mat[i] > 0 {\n\t\t\tlen = i + 1\n\t\t\tbreak\n\t\t}\n\t}\n\tvar le int64 = 1\n\tvar ans int64 = 1\n\tvar tmp int64 = 1\n\tfor i := 0; i < len; i++ {\n\t\tans *= mat[i]\n\t\tle *= 9\n\t}\n\t//fmt.Printf(\"-%d len=%d %v\\n\",ans,len,mat)\n\n\tfor i:=len-1;i>=0;i--{\n\t\tle/=9\n\t\tif mat[i] > 1{\n\t\t\tif tmp*(mat[i]-1)*le > ans{\n\t\t\t\tans=tmp*(mat[i]-1)*le\n\t\t\t}\n\t\t}else if i==len-1{\n\t\t\tif le > ans{\n\t\t\t\tans =le\n\t\t\t}\n\t\t}\n\t\ttmp *= mat[i]\n\t}\n\tfmt.Printf(\"%d\\n\",ans)\n}"}, {"source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/1143/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 []rune\n\n\tdp [20][2]int64\n)\n\nfunc main() {\n\tN = ReadRuneSlice()\n\tn := len(N)\n\n\tdp[0][0] = 1\n\tfor i := 0; i < len(N); i++ {\n\t\td := int64(N[i] - '0')\n\n\t\tdp[i+1][0] = dp[i][0] * d\n\t\tChMax(&dp[i+1][1], dp[i][0]*(d-1))\n\t\tChMax(&dp[i+1][1], dp[i][0])\n\t\tChMax(&dp[i+1][1], dp[i][1]*9)\n\t}\n\n\tfmt.Println(Max(dp[n][0], dp[n][1]))\n}\n\n// Max returns the max integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Max(integers ...int64) int64 {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m < integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// 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 *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/*******************************************************************/\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"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tn := 0\n\tfmt.Fscanf(in, \"%d\\n\", &n)\n\tif n < 10 {\n\t\tfmt.Fprintf(out, \"%d\\n\", n)\n\t\treturn\n\t}\n\ta := make([]int, 0)\n\tfor n > 0 {\n\t\ta = append(a, n%10)\n\t\tn /= 10\n\t}\n\tb := make([]int, len(a))\n\tfor i := 0; i < len(a); i++ {\n\t\tb[i] = a[len(a)-i-1]\n\t}\n\tans := 1\n\tfor i := 0; i < len(a); i++ {\n\t\tans *= b[i]\n\t}\n\ttmp := 1\n\tfor i := 1; i < len(a); i++ {\n\t\ttmp *= 9\n\t}\n\tif tmp > ans {\n\t\tans = tmp\n\t}\n\t// c := make([]int, len(b))\n\t// for i := 0; i < len(b); i++ {\n\t// \tc[i] = b[i]\n\t// }\n\n\tfor i := 0; i < len(b); i++ {\n\t\tif b[i] > 1 {\n\t\t\ttmp := 1\n\t\t\tfor j := 0; j < i; j++ {\n\t\t\t\ttmp *= b[j]\n\t\t\t}\n\t\t\ttmp *= b[i] - 1\n\t\t\tfor j := i + 1; j < len(b); j++ {\n\t\t\t\ttmp *= 9\n\t\t\t}\n\t\t\tif tmp > ans {\n\t\t\t\tans = tmp\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Fprintf(out, \"%d\\n\", ans)\n\treturn\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc max(a, b int) (int) {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n\nfunc power(a int) (int) {\n\tif a < 10 {\n\t\treturn a\n\t}\n\t//fmt.Println(a)\n\n\torder := int(math.Floor(math.Log10(float64(a))))\n\taddition := max(a / int(math.Pow10(order)) - 1, 1)\n\ttop := int(math.Pow(9.0, float64(order))) * addition\n\n\t//fmt.Println(\"Versus\", top, \"order\", order, \"addition\", addition)\n\treturn max(top, (a / int(math.Pow10(order))) * power(a % int(math.Pow10(order))))\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tfmt.Println(power(n))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\n\nfunc reverseInts(input []int) []int {\n\tif len(input) == 0 {\n\t\treturn input\n\t}\n\treturn append(reverseInts(input[1:]), input[0])\n}\n\nfunc main(){\n\tvar n int\n\tfmt.Scan(&n)\n\tvar list []int\n\tans := 1;\n\tfor ;;{\n\t\tif n == 0{\n\t\t\tbreak\n\t\t}\n\t\tlist=append(list, n % 10)\n\t\tans *= n % 10\n\t\tn /= 10\n\t}\n\n\tfor index, each := range list{\n\t\ttmp := 1\n\t\tif each > 0{\n\t\t\tfor i := index - 1; i >= 0; i--{\n\t\t\t\ttmp *= 9\n\t\t\t}\n\t\t\tfor i := index + 1; i < len(list); i++{\n\t\t\t\ttmp *= list[i]\n\t\t\t}\n\t\t\t//fmt.Println(index, each)\n\t\t\tif each == 1 && index == len(list) - 1{\n\n\t\t\t}else{\n\t\t\t\ttmp *= each - 1\n\t\t\t}\n\t\t\tif tmp > ans{\n\t\t\t\tans = tmp\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "// Author: sighduck\n// URL: https://codeforces.com/contest/1143/problem/B\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc getLength(n int) int {\n\tlength := 0\n\tfor n > 0 {\n\t\tn /= 10\n\t\tlength += 1\n\n\t}\n\treturn length\n}\n\nfunc max(x int64, y int64) int64 {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc product(n int) int64 {\n\tproduct := int64(1)\n\tfor n > 0 {\n\t\tproduct *= int64(n % 10)\n\t\tn /= 10\n\t}\n\treturn product\n}\n\nfunc Solve(n int) int64 {\n\tbase := 10\n\tmaxProduct := int64(0)\n\tfor n > 0 {\n\t\tmaxProduct = max(maxProduct, product(n))\n\t\tn -= (n%base + 1)\n\t\tbase *= 10\n\t}\n\treturn maxProduct\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n int\n\tfmt.Fscanf(reader, \"%d\\n\", &n)\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(n))\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tch := string(\"\")\n\tfmt.Scanf(\"%s\", &ch)\n\tnum := []byte(ch)\n\ts1 := uint64(1)\n\tfor _, char := range num {\n\t\ts, _ := strconv.ParseUint(string(char), 10, 64)\n\t\ts1 *= s\n\t}\n\tfor i, char := range num {\n\t\tif char == '0' {\n\t\t\tbreak\n\t\t}\n\t\tnum1 := []byte{}\n\t\tnum1 = num\n\t\tnum1[i] = num[i] - 1\n\t\ts2 := uint64(1)\n\t\tfor j, char := range num1 {\n\t\t\tvar number uint64\n\t\t\tif j <= i {\n\t\t\t\tnumber, _ = strconv.ParseUint(string(char), 10, 64)\n\t\t\t\tif number == 0 {\n\t\t\t\t\tnumber = 1\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tnumber = 9\n\t\t\t}\n\t\t\ts2 *= number\n\t\t}\n\t\tif s2 > s1 {\n\t\t\ts1 = s2\n\t\t}\n\t}\n\tprintln(s1)\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc main() {\n\tdefer writer.Flush()\n\tch := string(\"\")\n\tscanf(\"%s\", &ch)\n\tnum := []byte(ch)\n\ts1 := uint64(1)\n\tfor _, char := range num {\n\t\ts, _ := strconv.ParseUint(string(char), 10, 64)\n\t\ts1 *= s\n\t}\n\tfor i, char := range num {\n\t\tif char == '0' {\n\t\t\tbreak\n\t\t}\n\t\tnum1 := []byte{}\n\t\tnum1 = num\n\t\tnum1[i] = num[i] - 1\n\t\ts2 := uint64(1)\n\t\tfor j, char := range num1 {\n\t\t\tvar number uint64\n\t\t\tif j <= i {\n\t\t\t\tnumber, _ = strconv.ParseUint(string(char), 10, 64)\n\t\t\t\tif number == 0 {\n\t\t\t\t\tnumber = 1\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tnumber = 9\n\t\t\t}\n\t\t\ts2 *= number\n\t\t}\n\t\tif s2 > s1 {\n\t\t\ts1 = s2\n\t\t}\n\t}\n\tprintf(\"%d\\n\", s1)\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tbuf := bufio.NewReader(os.Stdin)\n\n\tvar n int64\n\tfmt.Fscanf(buf, \"%d\\n\", &n)\n\n\tmat := make([]int64, 20)\n\tlen := 0\n\tfor n > 0 {\n\t\tmat[len] = n % int64(10)\n\t\tn /= 10\n\t\tlen++\n\t}\n\tfor i := len - 1; i >= 0; i-- {\n\t\tif mat[i] == 0 {\n\t\t\tfor j := i + 1; j < len; j++ {\n\t\t\t\tmat[j]--\n\t\t\t\tif mat[j] > 0 || (mat[j] == 0 && j == len-1) {\n\t\t\t\t\tfor k := j - 1; k >= 0; k-- {\n\t\t\t\t\t\tmat[k] = 9\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\t//fmt.Printf(\"%v\\n\",mat)\n\tfor i := len; i >= 0; i-- {\n\t\tif mat[i] > 0 {\n\t\t\tlen = i + 1\n\t\t\tbreak\n\t\t}\n\t}\n\tvar le int64 = 1\n\tvar ans int64 = 1\n\tvar tmp int64 = 1\n\tfor i := 0; i < len; i++ {\n\t\tans *= mat[i]\n\t\tle *= 9\n\t}\n\t//fmt.Printf(\"-%d len=%d %v\\n\",ans,len,mat)\n\n\tfor i:=len-1;i>=0;i--{\n\t\tle/=9\n\t\tif mat[i] > 1{\n\t\t\tif tmp*(mat[i]-1)*le > ans{\n\t\t\t\tans=tmp*(mat[i]-1)*le\n\t\t\t}\n\t\t}\n\t\ttmp *= mat[i]\n\t}\n\tfmt.Printf(\"%d\\n\",ans)\n}\n"}], "src_uid": "38690bd32e7d0b314f701f138ce19dfb"} {"nl": {"description": "You are given an array of $$$n$$$ integers: $$$a_1, a_2, \\ldots, a_n$$$. Your task is to find some non-zero integer $$$d$$$ ($$$-10^3 \\leq d \\leq 10^3$$$) such that, after each number in the array is divided by $$$d$$$, the number of positive numbers that are presented in the array is greater than or equal to half of the array size (i.e., at least $$$\\lceil\\frac{n}{2}\\rceil$$$). Note that those positive numbers do not need to be an integer (e.g., a $$$2.5$$$ counts as a positive number). If there are multiple values of $$$d$$$ that satisfy the condition, you may print any of them. In case that there is no such $$$d$$$, print a single integer $$$0$$$.Recall that $$$\\lceil x \\rceil$$$ represents the smallest integer that is not less than $$$x$$$ and that zero ($$$0$$$) is neither positive nor negative.", "input_spec": "The first line contains one integer $$$n$$$ ($$$1 \\le n \\le 100$$$) — the number of elements in the array. The second line contains $$$n$$$ space-separated integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$-10^3 \\le a_i \\le 10^3$$$).", "output_spec": "Print one integer $$$d$$$ ($$$-10^3 \\leq d \\leq 10^3$$$ and $$$d \\neq 0$$$) that satisfies the given condition. If there are multiple values of $$$d$$$ that satisfy the condition, you may print any of them. In case that there is no such $$$d$$$, print a single integer $$$0$$$.", "sample_inputs": ["5\n10 0 -7 2 6", "7\n0 0 1 -1 0 0 2"], "sample_outputs": ["4", "0"], "notes": "NoteIn the first sample, $$$n = 5$$$, so we need at least $$$\\lceil\\frac{5}{2}\\rceil = 3$$$ positive numbers after division. If $$$d = 4$$$, the array after division is $$$[2.5, 0, -1.75, 0.5, 1.5]$$$, in which there are $$$3$$$ positive numbers (namely: $$$2.5$$$, $$$0.5$$$, and $$$1.5$$$).In the second sample, there is no valid $$$d$$$, so $$$0$$$ should be printed."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc getNumFromOneLine(ir *bufio.Reader) int {\n\tstream, _ := ir.ReadString('\\n')\n\t// Trims the stream and then splits\n\ttrimmedStream := strings.TrimSpace(stream)\n\tnum, _ := strconv.Atoi(trimmedStream)\n\treturn num\n}\n\nfunc getNumsFromOneLine(ir *bufio.Reader) []int {\n\tstream, _ := ir.ReadString('\\n')\n\t// Trims the stream and then splits\n\ttrimmedStream := strings.TrimSpace(stream)\n\tsplitArr := strings.Split(trimmedStream, \" \")\n\t// convert strings to integers and store them in a slice\n\tnums := make([]int, len(splitArr))\n\tfor index, val := range splitArr {\n\t\tnums[index], _ = strconv.Atoi(val)\n\t}\n\treturn nums\n}\n\nfunc main() {\n\tir := bufio.NewReader(os.Stdin)\n\t_ = getNumFromOneLine(ir)\n\tnums := getNumsFromOneLine(ir)\n\n\tpos, neg := 0, 0\n\tfor _, num := range nums {\n\t\tif num > 0 {\n\t\t\tpos += 1\n\t\t} else if num < 0 {\n\t\t\tneg += 1\n\t\t}\n\t}\n\n\tif neg >= (len(nums)+1)/2 {\n\t\tfmt.Println(-1)\n\t} else if pos >= (len(nums)+1)/2 {\n\t\tfmt.Println(1)\n\t} else {\n\t\tfmt.Println(0)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc cleanString(stream string, seperator string) []int{\n\t// Trims the stream and then splits\n\ttrimmedStream := strings.TrimSpace(stream)\n\tsplitArr := strings.Split(trimmedStream, seperator)\n\t// convert strings to integers and store them in a slice\n\tnums := make([]int, len(splitArr))\n\tfor index,val := range splitArr{\n\t\tnums[index], _ = strconv.Atoi(val)\n\t}\n\treturn nums\n}\n\nfunc main() {\n\tir := bufio.NewReader(os.Stdin)\n\tinput, _ := ir.ReadString('\\n')\n\t_, _ = strconv.Atoi(strings.TrimSpace(input))\n\tvar nums []int\n\tlineInput, _ := ir.ReadString('\\n')\n\tnums = cleanString(lineInput, \" \")\n\tpos, neg := 0, 0\n\tfor _, num := range nums {\n\t\tif num > 0 {\n\t\t\tpos += 1\n\t\t} else if num < 0 {\n\t\t\tneg += 1\n\t\t}\n\t}\n\tif neg >= (len(nums) + 1) / 2 {\n\t\tfmt.Println(-1)\n\t} else if pos >= (len(nums) + 1) / 2 {\n\t\tfmt.Println(1)\n\t} else {\n\t\tfmt.Println(0)\n\t}\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var n int = 0;\n fmt.Scan(&n);\n var plus, minus, zero int = 0,0,0;\n for n > 0 {\n var x int = 0;\n fmt.Scan(&x);\n if (x < 0) {\n minus++;\n } else if (x > 0) {\n plus++;\n } else {\n zero++;\n }\n n--;\n }\n if (plus >= minus + zero) {\n fmt.Println(1);\n } else if (minus >= plus + zero) {\n fmt.Println(-1);\n } else {\n fmt.Println(0);\n }\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc calc(n,z,p,t int) int{\n\tvar val int\n\tif t&1==1{\n\t\tval = t/2 + 1\n\t}else{\n\t\tval = t/2\n\t}\n\n\tif n >=val{\n\t\treturn -1\n\t}else if p>=val{\n\t\treturn 1\n\t}\n\treturn 0\n}\n\nfunc main(){\n\tvar t int\n\tfmt.Scan(&t)\n\tvar neg int\n\tvar zero int\n\tvar pos int\n\n\tfor i:=0;i 0:\n\t\t\tpos++\n\t\t}\n\t}\n\n\tif pos >= (n+1)/2 {\n\t\tfmt.Println(1)\n\t} else if neg >= (n+1)/2 {\n\t\tfmt.Println(-1)\n\t} else {\n\t\tfmt.Println(0)\n\t}\n}"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"bytes\"\n \"fmt\"\n \"os\"\n)\n\ntype Seg struct {\n\n}\n\ntype Prob struct {\n in *bufio.Reader\n}\n\nfunc (prob *Prob) NextLine() string {\n line, _, _ := prob.in.ReadLine()\n return string(line[:])\n}\n\nfunc (prob *Prob) NextByte() byte {\n bt, _ := prob.in.ReadByte()\n return bt\n}\n\nfunc (prob *Prob) Next() string {\n var buff bytes.Buffer\n bt := prob.NextByte()\n for bt == '\\n' || bt == ' ' {\n bt = prob.NextByte()\n }\n for bt != '\\n' && bt != ' ' {\n buff.WriteByte(bt)\n bt = prob.NextByte()\n }\n return buff.String()\n}\n\nfunc (prob *Prob) NextInt() int {\n var x int\n bt := prob.NextByte()\n for bt > '9' || bt < '0' {\n if bt == '-' {\n return -prob.NextInt()\n }\n bt = prob.NextByte()\n }\n for bt >= '0' && bt <= '9' {\n x = x * 10 + int(bt - '0')\n bt = prob.NextByte()\n }\n return x\n}\n\nfunc (prob Prob) Solve() {\n n := prob.NextInt()\n po := 0\n ne := 0\n for i := 0; i < n; i++ {\n d := prob.NextInt()\n if d > 0 {\n po++\n } else if d < 0 {\n ne++\n }\n }\n if po >= (n + 1) / 2 {\n fmt.Println(\"1\")\n } else if ne >= (n + 1) / 2 {\n fmt.Println(\"-1\")\n } else {\n fmt.Println(0)\n }\n}\n\n\nfunc main() {\n Prob{in: bufio.NewReader(os.Stdin)}.Solve()\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tvar n int\n\tvar x int\n//\ta := make([]int,0)\n\tfmt.Fscanln(in,&n)\n\tps := 0\n\tmn := 0\n\tfor i := 0 ;i < n ;i++{\n\t\tfmt.Fscan(in,&x)\n\t\tif(x >= 1){\n\t\t\tps ++\n\t\t}else{\n\t\t\t\tif(x <= -1){\n\t\t\t\t\tmn ++\n\t\t\t\t}\n\t\t}\n\t}\n\tif(ps > mn){\n\t\tif(ps >= (n + 1) / 2){\n\t\t\tfmt.Fprint(out,1)\n\t\t}else{\n\t\t\tfmt.Fprint(out,0)\n\t\t}\n\t\treturn\n\t}else{\n\t\tif mn >= (n + 1) / 2{\n\t\t\tfmt.Fprint(out,-1)\n\t\t}else{\n\t\t\tfmt.Fprint(out,0)\n\t\t}\n\t\treturn\n\t}\n\n\n\n\n\n}\nfunc min1(x1,x2 int) int {\n\tif(x1 < x2){\n\t\treturn x1\n\t}else{\n\t\treturn x2\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, a, x, y int\n\tfmt.Scanf(\"%d\\n\", &n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &a)\n\t\tif a < 0 {\n\t\t\tx++\n\t\t} else if a > 0 {\n\t\t\ty++\n\t\t}\n\t}\n\tif x >= (int)((n + 1) / 2) {\n\t\tfmt.Println(\"-1\")\n\t} else if y >= (int)((n + 1) / 2) {\n\t\tfmt.Println(\"1\")\n\t} else {\n\t\tfmt.Println(\"0\")\n\t}\n}\n\n\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tn := 0\n\tfmt.Fscanf(in, \"%d\\n\", &n)\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(in, \"%d\", &a[i])\n\t}\n\tfmt.Fscanf(in, \"\\n\")\n\tneed := n/2 + n%2\n\tfor j := -1000; j <= 1000; j++ {\n\t\tif j != 0 {\n\t\t\tcur := float64(0)\n\t\t\tfor i := 0; i < n; i++ {\n\t\t\t\tif float64(a[i])/float64(j) > 0 {\n\t\t\t\t\tcur += 1\n\t\t\t\t}\n\t\t\t}\n\t\t\tif cur >= float64(need) {\n\t\t\t\tfmt.Fprintf(out, \"%d\\n\", j)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Fprintf(out, \"%d\\n\", 0)\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"}, {"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\ta := make([]int, n)\n\tfor i := range a {\n\t\ta[i] = readi()\n\t}\n\tvar pos, neg, zero int\n\tfor _, v := range a {\n\t\tif v == 0 {\n\t\t\tzero++\n\t\t} else if v < 0 {\n\t\t\tneg++\n\t\t} else {\n\t\t\tpos++\n\t\t}\n\t}\n\tm := n / 2\n\tif n%2 != 0 {\n\t\tm++\n\t}\n\tif m <= pos {\n\t\tprintln(1)\n\t} else if m <= neg {\n\t\tprintln(-1)\n\t} else {\n\t\tprintln(0)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n)\n\nfunc main() {\n\trbuf := bufio.NewReader(os.Stdin)\n\tvar n int\n\tfmt.Fscanf(rbuf, \"%d\\n\", &n)\n\n\tvar a []int = make([]int, n)\n\tpos, neg := 0, 0\n\tfor i := range a {\n\t\tfmt.Fscanf(rbuf, \"%d\", &a[i])\n\t\tif (a[i] > 0) {\n\t\t\tpos += 1\n\t\t}\n\t\tif (a[i] < 0) {\n\t\t\tneg += 1\n\t\t}\n\t}\n\n\tif pos * 2 >= n {\n\t\tfmt.Println(1)\n\t} else if neg * 2 >= n {\n\t\tfmt.Println(-1)\n\t} else {\n\t\tfmt.Println(0)\n\t}\n}"}, {"source_code": "// http://codeforces.com/problemset/problem/1130/A\npackage main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"strings\"\n\t\"os\"\n\t\"math\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar inputs int\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tinputs, _ = strconv.Atoi(scanner.Text())\n\tscanner.Scan()\n\tline := scanner.Text()\n\tvar zeros int = 0\n\tvar positives int = 0\n\tvar negatives int = 0\n\tfor _, num := range strings.Split(line, \" \") {\n\t\tif num == \"0\" {\n\t\t\tzeros++\n\t\t} else if strings.Count(num, \"-\") == 1 {\n\t\t\tnegatives++\n\t\t} else {\n\t\t\tpositives++\n\t\t}\n\t}\n\tc := math.Ceil(float64(inputs)/2)\n\tif float64(positives) >= c {\n\t\tfmt.Printf(\"1\")\n\t} else if float64(negatives) >= c {\n\t\tfmt.Printf(\"-1\")\n\t} else {\n\t\tfmt.Printf(\"0\")\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t`fmt`\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tpos := 0\n\tneg := 0\n\tfor i := 0; i < n; i++ {\n\t\tx := 0\n\t\tfmt.Scan(&x)\n\t\tif x > 0 {\n\t\t\tpos += 1\n\t\t}\n\t\tif x < 0 {\n\t\t\tneg += 1\n\t\t}\n\t}\n\tif float64(neg) >= float64(n) / 2 {\n\t\tfmt.Println(-1)\n\t} else if float64(pos) >= float64(n) / 2. {\n\t\tfmt.Println(1)\n\t} else {\n\t\tfmt.Println(0)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc readLine()(string,error) \t\t\t{ return reader.ReadString('\\n') }\n\nfunc main() {\n\tdefer writer.Flush()\n\tvar n int\n\tscanf(\"%d\\n\", &n)\n\tk := n/2 + n%2\n\ta := make([]int,n)\n\tfor i := 0; i < n; i++ {\n\t\tscanf(\"%d\", &a[i])\n\t}\n\tfor i := -1000; i <= 1000; i++ {\n\t\t\tx := 0\n\t\t\tfor _, j := range a {\n\t\t\t\tif ((i > 0 && j > 0) || (i < 0 && j < 0)) {\n\t\t\t\t\tx++\n\t\t\t\t}\n\t\t\t}\n\t\t\tif x >= k {\n\t\t\t\tfmt.Println(i)\n\t\t\t\treturn\n\t\t\t}\n\t\n\t}\n\tfmt.Println(0)\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var n int\n fmt.Scanf(\"%d\", &n)\n\n pos := 0\n neg := 0\n for i := 0; i <= n; i++ {\n var nmb int\n fmt.Scanf(\"%d\", &nmb)\n if nmb > 0 {\n pos++\n }\n if nmb < 0 {\n neg++\n }\n }\n\n if neg < (n + 1) / 2 && pos < (n + 1) / 2 {\n fmt.Println(0)\n } else if neg >= (n + 1) / 2 {\n fmt.Println(-1)\n } else if pos >= (n + 1) / 2 {\n fmt.Println(1)\n }\n\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var n int = 0;\n fmt.Scan(&n);\n var plus, minus, zero int = 0,0,0;\n for n > 0 {\n var x int = 0;\n fmt.Scan(&x);\n if (x < 0) {\n minus++;\n } else if (x > 0) {\n plus++;\n } else {\n zero++;\n }\n n--;\n }\n if (plus > minus + zero) {\n fmt.Println(1);\n } else if (minus > plus + zero) {\n fmt.Println(-1);\n } else {\n fmt.Println(0);\n }\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar n, tmp, neg, zer, pos int\n\n\n\tfmt.Scan(&n)\n\n\tfor i := 0 ; i < n ; i++ {\n\t\tfmt.Scan(&tmp)\n\n\t\tswitch {\n\t\tcase tmp < 0:\n\t\t\tneg++\n\t\tcase tmp == 0:\n\t\t\tzer++\n\t\tcase tmp > 0:\n\t\t\tpos++\n\t\t}\n\t}\n\n\tif pos >= n/2 {\n\t\tfmt.Println(1)\n\t} else if neg >= n/2 {\n\t\tfmt.Println(-1)\n\t} else {\n\t\tfmt.Println(0)\n\t}\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc solve() {\n var n int\n fmt.Scanf(\"%d\", &n)\n po := 0\n ne := 0\n for i := 0; i < n; i++ {\n var d int\n fmt.Scanf(\"%d\", &d)\n if d > 0 {\n po++\n } else if d < 0 {\n ne++\n }\n }\n if po >= (n + 1) / 2 {\n fmt.Println(\"1\")\n } else if ne >= (n + 1) / 2 {\n fmt.Println(\"-1\")\n } else {\n fmt.Println(0)\n }\n}\n\n\nfunc main() {\n solve()\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc solve() {\n var n int\n fmt.Scanf(\"%d\", &n)\n po := 0\n ne := 0\n for i := 0; i < n; i++ {\n var d int\n fmt.Scanf(\"%d\", &d)\n if d > 0 {\n po++\n } else if d < 0 {\n ne++\n }\n }\n fmt.Printf(\"%d %d %d\\n\", po, ne, (n + 1) / 2)\n if po >= (n + 1) / 2 {\n fmt.Println(\"1\")\n } else if ne >= (n + 1) / 2 {\n fmt.Println(\"-1\")\n } else {\n fmt.Println(0)\n }\n}\n\n\nfunc main() {\n solve()\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc solve() {\n var n int\n fmt.Scanf(\"%d\", &n)\n po := 0\n ne := 0\n for i := 0; i < n; i++ {\n var d int\n fmt.Scanf(\"%d\", &d)\n fmt.Printf(\"%d\\n\", d)\n if d > 0 {\n po++\n } else if d < 0 {\n ne++\n }\n }\n fmt.Printf(\"%d %d %d\\n\", po, ne, (n + 1) / 2)\n if po >= (n + 1) / 2 {\n fmt.Println(\"1\")\n } else if ne >= (n + 1) / 2 {\n fmt.Println(\"-1\")\n } else {\n fmt.Println(0)\n }\n}\n\n\nfunc main() {\n solve()\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tvar n int\n\tvar x int\n\ta := make([]int,0)\n\tfmt.Fscanln(in,&n)\n\tps := 0\n\tfor i := 0 ;i < n ;i++{\n\t\tfmt.Fscan(in,&x)\n\t\ta = append(a,x)\n\t\tif(x >= 1){\n\t\t\tps ++\n\t\t}\n\t}\n\tif(ps >= (n + 1) / 2){\n\t\tfmt.Fprint(out,1)\n\t}else{\n\t\tfmt.Fprint(out,0)\n\t}\n\n\n\n}\nfunc min1(x1,x2 int) int {\n\tif(x1 < x2){\n\t\treturn x1\n\t}else{\n\t\treturn x2\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, a, x, y int\n\tfmt.Scanf(\"%d\\n\", &n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &a)\n\t\tif a < 0 {\n\t\t\tx++\n\t\t} else if a > 0 {\n\t\t\ty++\n\t\t}\n\t}\n\tif x >= (n / 2) {\n\t\tfmt.Println(\"-1\")\n\t} else if y >= (n / 2) {\n\t\tfmt.Println(\"1\")\n\t} else {\n\t\tfmt.Println(\"0\")\n\t}\n}\n\n\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, a, x, y int\n\tfmt.Scanf(\"%d\\n\", &n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &a)\n\t\tif a < 0 {\n\t\t\tx++\n\t\t} else if a > 0 {\n\t\t\ty++\n\t\t}\n\t}\n\tif x > (n / 2) {\n\t\tfmt.Println(\"-1\")\n\t} else if y > (n / 2) {\n\t\tfmt.Println(\"1\")\n\t} else {\n\t\tfmt.Println(\"0\")\n\t}\n}\n\n\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tn := 0\n\tfmt.Fscanf(in, \"%d %d\\n\", &n)\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(in, \"%d\\n\", &a[i])\n\t}\n\tneed := n/2 + n%2\n\tfor j := -1000; j <= 1000; j++ {\n\t\tif j != 0 {\n\t\t\tcur := float64(0)\n\t\t\tfor i := 0; i < n; i++ {\n\t\t\t\tif float64(a[i])/float64(j) > 0 {\n\t\t\t\t\tcur += float64(a[i]) / float64(j)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif cur >= float64(need) {\n\t\t\t\tfmt.Fprintf(out, \"%d\\n\", j)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Fprintf(out, \"%d\\n\", 0)\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"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tn := 0\n\tfmt.Fscanf(in, \"%d\\n\", &n)\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(in, \"%d\", &a[i])\n\t}\n\tfmt.Fscanf(in, \"\\n\")\n\tneed := n/2 + n%2\n\tfor j := -1000; j <= 1000; j++ {\n\t\tif j != 0 {\n\t\t\tcur := float64(0)\n\t\t\tfor i := 0; i < n; i++ {\n\t\t\t\tif float64(a[i])/float64(j) > 0 {\n\t\t\t\t\tcur += float64(a[i]) / float64(j)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif cur >= float64(need) {\n\t\t\t\tfmt.Fprintf(out, \"%d\\n\", j)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Fprintf(out, \"%d\\n\", 0)\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"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tn := 0\n\tfmt.Fscanf(in, \"%d\\n\", &n)\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(in, \"%d\\n\", &a[i])\n\t}\n\tneed := n/2 + n%2\n\tfor j := -1000; j <= 1000; j++ {\n\t\tif j != 0 {\n\t\t\tcur := float64(0)\n\t\t\tfor i := 0; i < n; i++ {\n\t\t\t\tif float64(a[i])/float64(j) > 0 {\n\t\t\t\t\tcur += float64(a[i]) / float64(j)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif cur >= float64(need) {\n\t\t\t\tfmt.Fprintf(out, \"%d\\n\", j)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Fprintf(out, \"%d\\n\", 0)\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"}, {"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\ta := make([]int, n)\n\tfor i := range a {\n\t\ta[i] = readi()\n\t}\n\tvar pos, neg, zero int\n\tfor _, v := range a {\n\t\tif v == 0 {\n\t\t\tzero++\n\t\t} else if v < 0 {\n\t\t\tneg++\n\t\t} else {\n\t\t\tpos++\n\t\t}\n\t}\n\tm := n / 2\n\tif n%2 != 0 {\n\t\tm++\n\t}\n\tif m <= zero {\n\t\tprintln(0)\n\t} else if m <= pos {\n\t\tprintln(1)\n\t} else if m <= neg {\n\t\tprintln(-1)\n\t} else {\n\t\tprintln(0)\n\t}\n}\n"}, {"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\ta := make([]int, n)\n\tfor i := range a {\n\t\ta[i] = readi()\n\t}\n\tvar pos, neg, zero int\n\tfor _, v := range a {\n\t\tif v == 0 {\n\t\t\tzero++\n\t\t} else if v < 0 {\n\t\t\tneg++\n\t\t} else {\n\t\t\tpos++\n\t\t}\n\t}\n\tm := n / 2\n\tif n%2 != 0 {\n\t\tm++\n\t}\n\tif m <= zero {\n\t\tprintln(0)\n\t} else if m <= pos {\n\t\tprintln(1)\n\t} else {\n\t\tprintln(-1)\n\t}\n}\n"}, {"source_code": "// http://codeforces.com/problemset/problem/1130/A\npackage main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"strings\"\n\t\"os\"\n\t\"math\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar inputs int\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tinputs, _ = strconv.Atoi(scanner.Text())\n\tscanner.Scan()\n\tline := scanner.Text()\n\tvar zeros int = 0\n\tvar positives int = 0\n\tvar negatives int = 0\n\tfor _, num := range strings.Split(line, \" \") {\n\t\tif num == \"0\" {\n\t\t\tzeros++\n\t\t} else if strings.Count(num, \"-\") == 1 {\n\t\t\tnegatives++\n\t\t} else {\n\t\t\tpositives++\n\t\t}\n\t}\n\tc := math.Ceil(float64(inputs)/2)\n\tif float64(zeros) >= c {\n\t\tfmt.Printf(\"0\")\n\t} else if float64(negatives) >= c {\n\t\tfmt.Printf(\"-1\")\n\t} else {\n\t\tfmt.Printf(\"1\")\n\t}\n}"}, {"source_code": "// http://codeforces.com/problemset/problem/1130/A\npackage main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"strings\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar inputs int\n\tfmt.Scanf(\"%d\\n\", &inputs)\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tline := scanner.Text()\n\tvar zeros int = 0\n\tvar positives int = 0\n\tvar negatives int = 0\n\tfor _, num := range strings.Split(line, \" \") {\n\t\tif num == \"0\" {\n\t\t\tzeros++\n\t\t} else if strings.Count(num, \"-\") == 1 {\n\t\t\tnegatives++\n\t\t} else {\n\t\t\tpositives++\n\t\t}\n\t}\n\tif zeros >= inputs {\n\t\tfmt.Printf(\"0\")\n\t} else if negatives >= inputs {\n\t\tfmt.Printf(\"-1\")\n\t} else {\n\t\tfmt.Printf(\"1\")\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t`bufio`\n\t`fmt`\n\t`os`\n)\n\nfunc main() {\n\tbuf := bufio.NewReader(os.Stdin)\n\tvar n int\n\tfmt.Fscanf(buf, \"%d\", &n)\n\tpos := 0\n\tneg := 0\n\tfor i := 0; i < n; i++ {\n\t\tx := 0\n\t\tfmt.Fscanf(buf, \"%d\", &x)\n\t\tif x > 0 {\n\t\t\tpos += 1\n\t\t}\n\t\tif x < 0 {\n\t\t\tneg += 1\n\t\t}\n\t}\n\tif neg >= n / 2 {\n\t\tfmt.Println(-1)\n\t} else if pos >= n / 2 {\n\t\tfmt.Println(1)\n\t} else {\n\t\tfmt.Println(0)\n\t}\n}\n"}, {"source_code": "\npackage main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc readLine()(string,error) \t\t\t{ return reader.ReadString('\\n') }\n\nfunc main() {\n\tdefer writer.Flush()\n\tvar n int\n\tscanf(\"%d\\n\", &n)\n\tk := n/2 + n%2\n\ta := make([]int,n)\n\tfor i := 0; i < n; i++ {\n\t\tscanf(\"%d\", &a[i])\n\t}\n\tfor i := -1000; i <= 1000; i++ {\n\t\tif (i != 0){\n\t\t\tx := 0\n\t\t\tfor _, j := range a {\n\t\t\t\tif (((i > 0 && j > 0) || (i < 0 && j < 0)) && j%i != 0) {\n\t\t\t\t\tx++\n\t\t\t\t}\n\t\t\t}\n\t\t\tif x == k {\n\t\t\t\tfmt.Println(i)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(0)\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var n int\n fmt.Scanf(\"%d\", &n)\n\n pos := 0\n neg := 0\n for i := 0; i < n; i++ {\n var nmb int\n fmt.Scanf(\"%d\", &nmb)\n if nmb > 0 {\n pos++\n }\n if nmb < 0 {\n neg++\n }\n }\n\n if neg < (n + 1) / 2 && pos < (n + 1) / 2 {\n fmt.Println(0)\n } else if neg >= (n + 1) / 2 {\n fmt.Println(-1)\n } else if pos >= (n + 1) / 2 {\n fmt.Println(1)\n }\n\n}\n"}], "src_uid": "a13cb35197f896cd34614c6c0b369a49"} {"nl": {"description": "Today Patrick waits for a visit from his friend Spongebob. To prepare for the visit, Patrick needs to buy some goodies in two stores located near his house. There is a d1 meter long road between his house and the first shop and a d2 meter long road between his house and the second shop. Also, there is a road of length d3 directly connecting these two shops to each other. Help Patrick calculate the minimum distance that he needs to walk in order to go to both shops and return to his house. Patrick always starts at his house. He should visit both shops moving only along the three existing roads and return back to his house. He doesn't mind visiting the same shop or passing the same road multiple times. The only goal is to minimize the total distance traveled.", "input_spec": "The first line of the input contains three integers d1, d2, d3 (1 ≤ d1, d2, d3 ≤ 108) — the lengths of the paths. d1 is the length of the path connecting Patrick's house and the first shop; d2 is the length of the path connecting Patrick's house and the second shop; d3 is the length of the path connecting both shops. ", "output_spec": "Print the minimum distance that Patrick will have to walk in order to visit both shops and return to his house.", "sample_inputs": ["10 20 30", "1 1 5"], "sample_outputs": ["60", "4"], "notes": "NoteThe first sample is shown on the picture in the problem statement. One of the optimal routes is: house first shop second shop house.In the second sample one of the optimal routes is: house first shop house second shop house."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar d1, d2, d3 int\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &d1, &d2, &d3)\n\td1, d2, d3 = sorta(d1, d2, d3)\n\tif d1+d2 < d3 {\n\t\tfmt.Println((d1 + d2) * 2)\n\t} else {\n\t\tfmt.Println(d1 + d2 + d3)\n\t}\n}\n\nfunc sorta(a, b, c int) (int, int, int) {\n\taa := make([]int, 0)\n\taa = append(aa, a)\n\taa = append(aa, b)\n\taa = append(aa, c)\n\tsort.Slice(aa, func(i, j int) bool {\n\t\treturn aa[i] < aa[j]\n\t})\n\treturn aa[0], aa[1], aa[2]\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\td := []int{0, 0, 0}\n\tfmt.Scanf(\"%d %d %d \\n\", &d[0], &d[1], &d[2])\n\tsort.Ints(d)\n\tr := d[0] + d[1] + min(d[2], d[0]+d[1])\n\tfmt.Print(r)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc min(a ...int) int {\n r := a[0]\n for _, v := range a {\n if r > v {\n r = v\n }\n }\n return r\n}\n\nfunc main() {\n // 总共4种情况,求个min就行了。\n var d1, d2, d3 int\n fmt.Scanf(\"%d %d %d\", &d1, &d2, &d3);\n result := min(d1+d2+d3, 2*(d1+d2), 2*(d1+d3), 2*(d2+d3))\n fmt.Println(result)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar d [3]int\n\tfmt.Scan(&d[0], &d[1], &d[2])\n\n\tid := 0\n\tsum := d[0]\n\tfor i := 1; i < 3; i++ {\n\t\tif d[id] < d[i] {\n\t\t\tid = i\n\t\t}\n\t\tsum += d[i]\n\t}\n\n\tl := 0\n\tif 2*d[id] > sum {\n\t\tl = 2 * (sum - d[id])\n\t} else {\n\t\tl = sum\n\t}\n\n\tfmt.Println(l)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar d1, d2, d3, s uint32\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(in, \"%d %d %d\\n\", &d1, &d2, &d3)\n\tif d1 <= d2 {\n\t\tif d1+d1+d2+d2 <= d1+d3+d2 && d1+d1+d2+d2 <= d1+d3+d3+d1 {\n\t\t\ts += d1 + d1 + d2 + d2\n\t\t} else if d1+d3+d2 <= d1+d1+d2+d2 && d1+d3+d2 <= d1+d3+d3+d1 {\n\t\t\ts += d1 + d3 + d2\n\t\t} else {\n\t\t\ts += d1 + d3 + d3 + d1\n\t\t}\n\t} else {\n\t\tif d2+d2+d1+d1 <= d2+d3+d1 && d2+d2+d1+d1 <= d2+d3+d3+d2 {\n\t\t\ts += d2 + d2 + d1 + d1\n\t\t} else if d2+d3+d1 <= d2+d2+d1+d1 && d2+d3+d1 <= d2+d3+d3+d2 {\n\t\t\ts += d2 + d3 + d1\n\t\t} else {\n\t\t\ts += d2 + d3 + d3 + d2\n\t\t}\n\t}\n\tfmt.Println(s)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar d1, d2, d3 int\n\t_, err := fmt.Scanf(\"%d %d %d\", &d1, &d2, &d3)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tif d1+d3 < d2 {\n\t\tfmt.Println(2 * (d1 + d3))\n\t\treturn\n\t} else if d2+d3 < d1 {\n\t\tfmt.Println(2 * (d2 + d3))\n\t\treturn\n\t}\n\tfmt.Println(min(2*d1+2*d2, d1+d2+d3))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar d [3]int\n\tfmt.Fscanln(os.Stdin, &d[0], &d[1], &d[2])\n\n\tvar s [4]int\n\ts[0] = 2 * (d[0] + d[1])\n\ts[1] = 2 * (d[1] + d[2])\n\ts[2] = 2 * (d[0] + d[2])\n\ts[3] = d[1] + d[2] + d[0]\n\n\tmin := s[0]\n\tfor i := 1; i < len(s); i++ {\n\t\tif s[i] < min {\n\t\t\tmin = s[i]\n\t\t}\n\t}\n\n\tfmt.Println(min)\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar d1, d2, d3 int\n\tfmt.Scanf(\"%d %d %d\", &d1, &d2, &d3)\n\n\tdis := []int{\n\t\td1 + d2 + d3,\n\t\t2*d1 + 2*d2,\n\t\t2*d1 + 2*d3,\n\t\t2*d2 + 2*d3,\n\t}\n\n\tans := int(2e9)\n\tfor _, d := range dis {\n\t\tif ans > d {\n\t\t\tans = d\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar d1, d2, d3 int\n\tfmt.Scanf(\"%d%d%d\", &d1, &d2, &d3)\n\ts := d1+d2+d3\n\tt := 2*(d1+d3)\n\tif s > t{\n\t\ts = t\n\t}\n\tt = 2*(d2+d3)\n\tif s > t{\n\t\ts = t\n\t}\n\tt = 2*(d1+d2)\n\tif s > t{\n\t\ts = t\n\t}\n\tfmt.Printf(\"%d\\n\", s)\n}\n"}, {"source_code": "package main;\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var a, b, c int\n fmt.Scanf(\"%d%d%d\", &a, &b, &c)\n dis := []int{\n a + b + c,\n 2 * a + 2 * b,\n 2 * a + 2 * c,\n 2 * b + 2 * c,\n }\n \n ans := 0x3f3f3f3f\n for _, value := range dis {\n if value < ans {\n ans = value\n }\n }\n fmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n )\n\nfunc min(x, y uint) uint {\n if x < y {\n return x\n }\n return y\n}\n\nfunc main() {\n var d1, d2, d3 uint\n fmt.Scan(&d1, &d2, &d3)\n\n dis1 := d1 + d2 + d3\n dis2 := 2*d1 + 2*d2\n dist := min(dis1, dis2)\n dis3 := 2*d2 + 2*d3\n dist = min(dist, dis3)\n dis4 := 2*d1 + 2*d3\n dist = min(dist, dis4)\n\n fmt.Println(dist)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar d1, d2, d3 int\n\tfmt.Scanf(\"%d %d %d\", &d1, &d2, &d3)\n\n\tret := min(d1 + min(d1 + 2 * d2, d3 + min(d2, d3 + d1)),\n\t\t\t d2 + min(d2 + 2 * d1, d3 + min(d1, d3 + d2)))\n\tfmt.Printf(\"%d\", ret)\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar writer *bufio.Writer\nvar scanner *bufio.Scanner\n\ntype MySlice [][2]int\n\nfunc (slice MySlice) Len() int { return len(slice) }\nfunc (slice MySlice) Less(i, j int) bool { return slice[i][1] < slice[j][1] }\nfunc (slice MySlice) Swap(i, j int) {\n\tslice[i], slice[j] = slice[j], slice[i]\n}\n\nfunc main() {\n\tini()\n\tdefer writer.Flush()\n\n\td1 := scanInt()\n\td2 := scanInt()\n\td3 := scanInt()\n\n\tresult := min(d1 + d2 + d3, min(2 * (d1 + d2), min(2 * (d2 + d3), 2 * (d1 + d3))))\n\twriter.WriteString(strconv.Itoa(result))\n\n\treturn\n}\n\nfunc binSearch(a []int, key int) int {\n\tl := -1\n\tr := len(a)\n\tfor l < r-1 {\n\t\tm := (l + r) / 2\n\t\tif a[m] < key {\n\t\t\tl = m\n\t\t} else {\n\t\t\tr = m\n\t\t}\n\t}\n\n\tif a[r] != key {\n\t\treturn -1\n\t}\n\n\treturn r\n}\n\nfunc ini() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner.Split(bufio.ScanWords)\n}\n\nfunc min(a int, b int) int {\n\tif a > b {\n\t\treturn b\n\t} else {\n\t\treturn a\n\t}\n}\n\nfunc scanInt() int {\n\tscanner.Scan()\n\ti, _ := strconv.Atoi(scanner.Text())\n\treturn i\n}\n\nfunc scanString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar d1, d2, d3 int\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &d1, &d2, &d3)\n\tif d1+d2 < d3 {\n\t\tfmt.Println((d1 + d2) * 2)\n\t} else {\n\t\tfmt.Println(d1 + d2 + d3)\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar d [3]int\n\tfmt.Scan(&d[0], &d[1], &d[2])\n\n\tid := 0\n\tsum := d[0]\n\tfor i := 1; i < 3; i++ {\n\t\tif d[id] < d[i] {\n\t\t\tid = i\n\t\t}\n\t\tsum += d[i]\n\t}\n\n\tl := 0\n\tif 3*d[id] > 2*sum {\n\t\tl = 2 * (sum - d[id])\n\t} else {\n\t\tl = sum\n\t}\n\n\tfmt.Println(l)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar d1, d2 ,d3, s uint16\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscanf(in, \"%d %d %d\\n\", &d1,&d2, &d3)\n\tif d1 > d2 && d1 > d3{\n\t\ts += d2 * 2\n\t\ts += d3 * 2\n\t}else if d2 > d1 && d2 > d3{\n\t\ts += d1 * 2\n\t\ts += d3 * 2\n\t}else if d3 > d1 && d3 > d2{\n\t\ts += d1 * 2\n\t\ts += d2 * 2\n\t}else{\n\t\tif d2 >= d3{\n\t\t\ts += d1 * 2\n\t\t\ts += d2 * 2\n\t\t}\n\t}\n\tfmt.Println(s)\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar d1, d2, d3 int\n\t_, err := fmt.Scanf(\"%d %d %d\", &d1, &d2, &d3)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Println(min(2*d1+2*d2, d1+d2+d3))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar d [3]int\n\tfmt.Fscanln(os.Stdin, &d[0], &d[1], &d[2])\n\n\tif d[0]+d[1]+d[2] <= 2*(d[0]+d[1]) {\n\t\tfmt.Println(d[0] + d[1] + d[2])\n\t} else {\n\t\tfmt.Println(2 * (d[0] + d[1]))\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar d [3]int\n\tfmt.Fscanln(os.Stdin, &d[0], &d[1], &d[2])\n\n\tif d[0]+d[1]+d[2] < 2*(d[0]+d[1]) {\n\t\tfmt.Println(d[0] + d[1] + d[2])\n\t} else {\n\t\tfmt.Println(2 * (d[0] + d[1]))\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar d1, d2, d3 int\n\tfmt.Scanf(\"%d %d %d\", &d1, &d2, &d3)\n\n\tif d1*2+d2*2 < d1+d2+d3 {\n\t\tfmt.Println(d1*2 + d2*2)\n\t} else {\n\t\tfmt.Println(d1 + d2 + d3)\n\t}\n}\n"}, {"source_code": "package main;\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var a, b, c int\n fmt.Scanf(\"%d%d%d\", &a, &b, &c)\n x := 2 * a + 2 * b\n y := a + b + c\n if x < y {\n fmt.Println(x)\n } else {\n fmt.Println(y)\n }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar d1, d2, d3 int\n\tfmt.Scanf(\"%d %d %d\", &d1, &d2, &d3)\n\n\tret := min(d1 + min(d1 + 2 * d2, d3 + d2),\n\t\t\t d2 + min(d2 + 2 * d1, d3 + d1))\n\tfmt.Printf(\"%d\", ret)\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar writer *bufio.Writer\nvar scanner *bufio.Scanner\n\ntype MySlice [][2]int\n\nfunc (slice MySlice) Len() int { return len(slice) }\nfunc (slice MySlice) Less(i, j int) bool { return slice[i][1] < slice[j][1] }\nfunc (slice MySlice) Swap(i, j int) {\n\tslice[i], slice[j] = slice[j], slice[i]\n}\n\nfunc main() {\n\tini()\n\tdefer writer.Flush()\n\n\td1 := scanInt()\n\td2 := scanInt()\n\td3 := scanInt()\n\n\tif d3+d2+d1 < 2*(d1+d2) {\n\t\twriter.WriteString(strconv.Itoa(d3 + d2 + d1))\n\t} else {\n\t\twriter.WriteString(strconv.Itoa(2 * (d1 + d2)))\n\t}\n\n\treturn\n}\n\nfunc binSearch(a []int, key int) int {\n\tl := -1\n\tr := len(a)\n\tfor l < r-1 {\n\t\tm := (l + r) / 2\n\t\tif a[m] < key {\n\t\t\tl = m\n\t\t} else {\n\t\t\tr = m\n\t\t}\n\t}\n\n\tif a[r] != key {\n\t\treturn -1\n\t}\n\n\treturn r\n}\n\nfunc ini() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner.Split(bufio.ScanWords)\n}\n\nfunc scanInt() int {\n\tscanner.Scan()\n\ti, _ := strconv.Atoi(scanner.Text())\n\treturn i\n}\n\nfunc scanString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n"}], "src_uid": "26cd7954a21866dbb2824d725473673e"} {"nl": {"description": "Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word s. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word \"hello\". For example, if Vasya types the word \"ahhellllloou\", it will be considered that he said hello, and if he types \"hlelo\", it will be considered that Vasya got misunderstood and he didn't manage to say hello. Determine whether Vasya managed to say hello by the given word s.", "input_spec": "The first and only line contains the word s, which Vasya typed. This word consisits of small Latin letters, its length is no less that 1 and no more than 100 letters.", "output_spec": "If Vasya managed to say hello, print \"YES\", otherwise print \"NO\".", "sample_inputs": ["ahhellllloou", "hlelo"], "sample_outputs": ["YES", "NO"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\n//import \"strings\"\n\n//import \"math\"\n//import \"strconv\"\n//import \"sort\"\n\nfunc main() {\n\n\tstr := \"hello*\"\n\n\td := \"\"\n\n\tfmt.Scan(&d)\n\n\tcur := 0\n\n\tfor i := 0; i < len(d); i++ {\n\n\t\tif str[cur] == d[i] {\n\t\t\tcur++\n\t\t}\n\t\tif cur == 5 {\n\t\t\tfmt.Println(\"YES\")\n\t\t\tos.Exit(0)\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var s string\n h, e, l1, l2, o := false, false, false, false, false\n fmt.Scan(&s)\n for _,val := range s {\n switch ue := string(val); {\n case ue==\"h\":\n h = true\n case ue==\"e\"&&h:\n e = true\n case ue==\"l\"&&!l1&&h&&e:\n l1 = true\n case ue==\"l\"&&l1&&h&&e:\n l2 = true\n case ue==\"o\"&&h&&e&&l1&&l2:\n o = true\n }\n }\n if h && e && l1 && l2 && o {\n fmt.Print(\"YES\")\n } else {\n fmt.Print(\"NO\")\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\n// INPUT\n// ahhellllloou -> YES\n// hlelo -> NO\n// helhcludoo -> YES\n// pnnepelqomhhheollvlo -> YES\n\nfunc main() {\n\tvar word, greeting string\n\tvar greetingPos int\n\tgreeting = \"hello\"\n\n\tfmt.Scanf(\"%v\", &word)\n\n\tfor pos, char := range word {\n\t\tif greetingPos > 4 {\n\t\t\tbreak\n\t\t}\n\n\t\tif greeting[greetingPos] == word[pos] {\n\t\t\tif char == 'h' {\n\t\t\t\tgreetingPos = 0\n\t\t\t}\n\t\t\tgreetingPos++\n\t\t}\n\t}\n\n\tif greetingPos == 5 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc isOk(s string) bool {\n\tpattern := \"hello\"\n\ti := 0\n\t//j := 0\n\tfor si, _ := range s {\n\t\tif s[si] == pattern[i] {\n\t\t\ti++\n\t\t}\n\t\tif i >= len(pattern) {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn i == len(pattern)\n}\n\nfunc main() {\n\tvar str string\n\tfmt.Scanf(\"%s\", &str)\n\tif isOk(str) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\n\tvar str string\n\tfmt.Scan(&str)\n\n\thello := \"hello\"\n\tj := 0\n\n\tfor i := 0; i < len(str) && j < len(hello); i++ {\n\t\tif str[i] == hello[j] {\n\t\t\tj++\n\t\t}\n\t}\n\n\tif j == len(hello) {\n\t\tfmt.Print(\"YES\")\n\t\treturn\n\t}\n\tfmt.Print(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc foo(s string) bool {\n\tfor i := 0; i < len(s); i++ {\n\t\tfor j := i + 1; j < len(s); j++ {\n\t\t\tfor k := j + 1; k < len(s); k++ {\n\t\t\t\tfor l := k + 1; l < len(s); l++ {\n\t\t\t\t\tfor m := l + 1; m < len(s); m++ {\n\t\t\t\t\t\tif s[i] == 'h' && s[j] == 'e' && s[k] == 'l' && s[l] == 'l' && s[m] == 'o' {\n\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tif foo(s) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar s, target string = \"\", \"hello\"\n\tfmt.Scan(&s)\n\tvar j int\n\tfor i := range s {\n\t\tif s[i] == target[j] {\n\t\t\tj++\n\t\t} \n\t\tif j == 5 {\n\t\t\tfmt.Print(\"YES\")\n\t\t\tbreak\n\t\t}\n\t}\n\tif j != 5 {\n\t\tfmt.Print(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n)\n\nvar (\n\thi = []string{\"h\", \"e\", \"l\", \"l\", \"o\"}\n)\n\nfunc main() {\n\tvar (\n\t\ts string\n\t\tcounter int\n\t\tlength = len(hi)\n\t)\n\tif _, err := fmt.Scanf(\"%s\\n\", &s); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfor i := range s {\n\t\tif s[i:i+1] == hi[counter] {\n\t\t\tcounter++\n\t\t\tif counter == length {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\thello := []byte(\"hello\")\n\n\tvar input string\n\n\t_, _ = fmt.Scanln(&input)\n\n\tbyteinput := []byte(input)\n\n\tpos := 0\n\n\tfor i := 0; i < len(byteinput); i ++ {\n\t\tif pos >= len(hello) {\n\t\t\tbreak;\n\t\t}\n\t\tif byteinput[i] == hello[pos] {\n\t\t\tpos ++\n\t\t}\n\t}\n\n\tif pos >= len(hello) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"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\ts, _ := reader.ReadString('\\n')\n\tgoal := \"hello\"\n\tstate := 0\n\tfor i := 0; i < len(s)-1; i++ { //-1 newline\n\t\tif state == len(goal) { // early break\n\t\t\tbreak\n\t\t}\n\n\t\tif s[i] == goal[state] {\n\t\t\tstate++\n\t\t}\n\t}\n\n\tif state == len(goal) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"regexp\"\n)\n\nfunc main() {\n\tvar scanner *bufio.Scanner\n\n\tscanner = bufio.NewScanner(os.Stdin)\n\n\tscanner.Scan()\n\tif err := scanner.Err(); err == nil {\n\t\tif regexp.MustCompile(\"\\\\w*h\\\\w*e\\\\w*l\\\\w*l\\\\w*o\\\\w*\").MatchString(scanner.Text()) {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n h := \"hello\"\n var s string\n fmt.Scan(&s)\n in := 0\n for i := 0; (i < len(s)) && (in < 5); i++ {\n if s[i] == h[in] { in++ }\n }\n if in == 5 { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar scanner *bufio.Scanner\n\tvar line string\n\n\tscanner = bufio.NewScanner(os.Stdin)\n\n\tif scanner.Scan() {\n\t\tline = scanner.Text()\n\t\tif managed(line) {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t}\n}\n\nfunc managed(message string) bool {\n\tvar hello = []rune(\"hello\")\n\n\tfor _, letter := range message {\n\t\tif len(hello) == 0 {\n\t\t\treturn true\n\t\t}\n\t\tif letter == hello[0] {\n\t\t\thello = hello[1:]\n\t\t}\n\t}\n\n\tif len(hello) == 0 {\n\t\treturn true\n\t}\n\n\treturn false\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t\"regexp\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\n\tvar str, pat string\n\n\tfmt.Fscan(in, &str)\n\tpat = `h.*e.*l.*l.*o`\n\n\tmatched, _ := regexp.MatchString(pat, str)\n\tif matched {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\ntype input struct {\n\ta string\n}\n\nfunc (c *input) Read(scanner *bufio.Scanner) {\n\tfor scanner.Scan() {\n\t\tc.a = scanner.Text()\n\t\treturn\n\t}\n\n}\n\nfunc main() {\n\tvar inp input\n\tsc := bufio.NewScanner(os.Stdin)\n\tinp.Read(sc)\n\n\tvar v1 int\n\n\tfor _, b := range inp.a {\n\t\ts := string(b)\n\t\tif v1 == 0 && s == \"h\" {\n\t\t\tv1++\n\t\t}\n\n\t\tif v1 == 1 && s == \"e\" {\n\t\t\tv1++\n\t\t}\n\t\tif (v1 == 2 || v1 == 3) && s == \"l\" {\n\t\t\tv1++\n\n\t\t}\n\n\t\tif v1 == 4 && s == \"o\" {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\n\t\t}\n\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n\t\"regexp\"\n)\n\ntype input struct {\n\ta string\n}\n\nfunc (c *input) Read(scanner *bufio.Scanner) {\n\tfor scanner.Scan() {\n\t\tc.a = scanner.Text()\n\t\treturn\n\t}\n\n}\n\nfunc main() {\n\tvar inp input\n\tsc := bufio.NewScanner(os.Stdin)\n\tinp.Read(sc)\n\tif regexp.MustCompile(`.*h.*e.*l.*l.*o.*`).MatchString(inp.a){\n\t fmt.Println(\"YES\")\n\t} else{\n\t fmt.Println(\"NO\")\n\t}\n\t\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n h := \"hello\"\n var s string\n fmt.Scan(&s)\n in := 0\n for i := 0; (i < len(s)) && (in < 5); i++ {\n if s[i] == h[in] { in++ }\n }\n if in == 5 { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tfor _, r := range \"hello\" {\n\t\ti := strings.Index(s, string(r))\n\t\tif i == -1 {\n\t\t\tfmt.Printf(\"NO\")\n\t\t\treturn\n\t\t}\n\t\tif i != len(s)-1 {\n\t\t\ts = s[i+1:]\n\t\t}\n\t}\n\tfmt.Printf(\"YES\")\n}\n"}, {"source_code": "/* https://codeforces.com/problemset/problem/58/A\nA. Chat room\ntime limit per test1 second\nmemory limit per test256 megabytes\ninputstandard input\noutputstandard output\nVasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word s. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word \"hello\". For example, if Vasya types the word \"ahhellllloou\", it will be considered that he said hello, and if he types \"hlelo\", it will be considered that Vasya got misunderstood and he didn't manage to say hello. Determine whether Vasya managed to say hello by the given word s.\n\nInput\nThe first and only line contains the word s, which Vasya typed. This word consisits of small Latin letters, its length is no less that 1 and no more than 100 letters.\n\nOutput\nIf Vasya managed to say hello, print \"YES\", otherwise print \"NO\".\n\nExamples\ninputCopy\nahhellllloou\noutputCopy\nYES\ninputCopy\nhlelo\noutputCopy\nNO\n*/\n\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar hello_index int\n\tvar input_string string\n\thello := []rune(\"hello\")\n\tfmt.Scanln(&input_string)\n\tfor _, letter := range input_string {\n\t\tif letter == hello[hello_index] {\n\t\t\thello_index++\n\t\t\tif hello_index == 5 {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar h byte\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanRunes)\n\tfor scanner.Scan() {\n\t\tl := scanner.Text()\n\t\tswitch {\n\t\tcase l == \"h\" && h == 0: // 0b00000\n\t\t\th = 32 // 0b10000\n\t\tcase l == \"e\" && h == 32: // 0b10000\n\t\t\th = 48 // 0b11000\n\t\tcase l == \"l\" && h == 48: // 0b11000\n\t\t\th = 56 // 0b11100\n\t\tcase l == \"l\" && h == 56: // 0b11100\n\t\t\th = 60 // 0b11110\n\t\tcase l == \"o\" && h == 60: // 0b11110\n\t\t\th = 62 // 0b11111\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif h == 62 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x string\n\tvar ref string = \"hello\"\n\t_, _ = fmt.Scan(&x)\n\tref_index:= 0;\n\tfor _, char := range(x) {\n\t\tif uint8(char) == ref[ref_index] {\n\t\t\tref_index++\n\t\t\tif ref_index == 5 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tif ref_index == 5 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"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\n\tvar s string\n\tscanf(\"%s\\n\", &s)\n\th := \"hello\"\n\tj := 0\n\ti := 0\n\tfor i < len(s) && j < len(h) {\n\n\t\tif s[i] == h[j] {\n\t\t\tj++\n\t\t}\n\t\ti++\n\t}\n\tif j == len(h) {\n\t\tprintf(\"YES\\n\")\n\t} else {\n\t\tprintf(\"NO\\n\")\n\t}\n}\n"}, {"source_code": "/*\nChat room\ntime limit per test2 seconds\nmemory limit per test256 megabytes\ninputstandard input\noutputstandard output\nVasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word s. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word \"hello\". For example, if Vasya types the word \"ahhellllloou\", it will be considered that he said hello, and if he types \"hlelo\", it will be considered that Vasya got misunderstood and he didn't manage to say hello. Determine whether Vasya managed to say hello by the given word s.\n\nInput\nThe first and only line contains the word s, which Vasya typed. This word consisits of small Latin letters, its length is no less that 1 and no more than 100 letters.\n\nOutput\nIf Vasya managed to say hello, print \"YES\", otherwise print \"NO\".\n\nSample test(s)\ninput\nahhellllloou\noutput\nYES\ninput\nhlelo\noutput\nNO\n*/\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tS string\n\t\thello = []rune(\"hello\")\n\t)\n\tfmt.Scanf(\"%s\", &S)\n\ts := []rune(S)\n\tlens := len(s)\n\tlenHello := len(hello)\n\tif lens < lenHello {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tvar i, j int\n\tfor ; i < lenHello; {\n\t\tfor ; j < lens; j++ {\n\t\t\tif s[j] == hello[i] {\n\t\t\t\ti++\n\t\t\t\tj++\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif j >= lens {\n\t\t\tbreak\n\t\t}\n\t}\n\tif i == lenHello {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\thello := \"hello\"\n\tvar message string\n\tfmt.Scan(&message)\n\tvar offset int\n\tfor _, character := range message {\n\t\tif character == rune(hello[offset]) {\n\t\t\toffset += 1\n\t\t}\n\n\t\tif offset == len(hello) {\n\t\t\tfmt.Print(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Print(\"NO\")\n}"}, {"source_code": "package main\nimport \"fmt\"\nfunc main () {\n var n string\n h:=\"hello\"\n a:=\"NO\"\n fmt.Scan(&n)\n ph:=0\n for i:=0;i= cont[flag] {\n\t\t\t\thitNum = 0\n\t\t\t\tflag += 1\n\t\t\t}\n\t\t}\n\n\t\tif flag >= len(c) {\n\t\t\tfmt.Print(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Print(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\nvar r *bufio.Reader = bufio.NewReader(os.Stdin)\nvar w *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc print( a ...interface{}) { fmt.Fprint(w, a...) }\nfunc scan( a ...interface{}) { fmt.Fscan(r, a...) }\n\nfunc main() {\n\tdefer w.Flush()\n\t\n\tvar a string\n\tfmt.Scan(&a)\n\n\tvar h = \"hello\"\n\tvar index = 0\n\tfor i := 0; i < len(a) && index < 5; i++{\n\t\tif h[index] == a[i] {\n\t\t\tindex++\n\t\t}\n\t}\n\tif index >= 5 {\n\t\tprint(\"YES\")\n\t}else {\n\t\tprint(\"NO\")\n\t}\n}\n\n\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar s string\n\nfunc main() {\n\tstdin := os.Stdin\n\t// stdin, _ = os.Open(\"1.in\")\n\treader := bufio.NewReaderSize(stdin, 1<<20)\n\tfmt.Fscanf(reader, \"%s\\n\", &s)\n\n\tcnt := \"hello\"\n\tans := \"NO\"\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] == cnt[0] {\n\t\t\tif len(cnt) == 1 {\n\t\t\t\tans = \"YES\"\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcnt = cnt[1:len(cnt)]\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"strings\"\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tpos := strings.Index(s, \"h\")\n\tif pos == -1 {\n\t\tfmt.Print(\"NO\")\n\t\treturn\n\t}\n\ts = s[pos+1:]\n\tpos = strings.Index(s, \"e\")\n\tif pos == -1 {\n\t\tfmt.Print(\"NO\")\n\t\treturn\n\t}\n\ts = s[pos+1:]\n\tpos = strings.Index(s, \"l\")\n\tif pos == -1 {\n\t\tfmt.Print(\"NO\")\n\t\treturn\n\t}\n\ts = s[pos+1:]\n\tpos = strings.Index(s, \"l\")\n\tif pos == -1 {\n\t\tfmt.Print(\"NO\")\n\t\treturn\n\t}\n\ts = s[pos+1:]\n\tpos = strings.Index(s, \"o\")\n\tif pos == -1 {\n\t\tfmt.Print(\"NO\")\n\t\treturn\n\t}\n\tfmt.Print(\"YES\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar line string\n\tfmt.Scan(&line)\n\n\th := \"hello\"\n\tc := 0\n\tfor i := 0; i < len(line); i++ {\n\t\tif line[i] == h[c] {\n\t\t\tc++\n\t\t\tif c == len(h) {\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}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar line string\n\tfmt.Scan(&line)\n\n\tcount := 0\n\tfor _, c := range line {\n\t\tswitch c {\n\t\tcase 'h':\n\t\t\tif count == 0 {\n\t\t\t\tcount++\n\t\t\t}\n\t\tcase 'e':\n\t\t\tif count == 1 {\n\t\t\t\tcount++\n\t\t\t}\n\t\tcase 'l':\n\t\t\tif count == 2 || count == 3 {\n\t\t\t\tcount++\n\t\t\t}\n\t\tcase 'o':\n\t\t\tif count == 4 {\n\t\t\t\tcount++\n\t\t\t}\n\t\t}\n\t}\n\n\tif count == 5 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n h := \"hello\"\n var s string\n fmt.Scan(&s)\n in := 0\n for i := 0; (i < len(s)) && (in < 5); i++ {\n if s[i] == h[in] { in++ }\n }\n if in == 5 { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar hello = \"hello\"\n\tvar s string\n\tfmt.Scan(&s)\n\tidx := 0\n\tfor i := 0; i < len(s) && idx < 5; i ++ {\n\t\tif s[i] == hello[idx] {\n\t\t\tidx ++;\n\t\t}\n\t}\n\tif (idx >= 5) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\n// ahhellllloou\n\nfunc solve(s string) string {\n\ti := 0\n\tvar seen string = \"\"\n\tfor i < len(s) {\n\t\tif seen == \"\" && s[i] == 'h' {\n\t\t\tseen = \"h\"\n\t\t} else if seen == \"h\" && s[i] == 'e' {\n\t\t\tseen = \"he\"\n\t\t} else if seen == \"he\" && s[i] == 'l' {\n\t\t\tseen = \"hel\"\n\t\t} else if seen == \"hel\" && s[i] == 'l' {\n\t\t\tseen = \"hell\"\n\t\t} else if seen == \"hell\" && s[i] == 'o' {\n\t\t\tseen = \"hello\"\n\t\t\treturn \"YES\"\n\t\t}\n\t\ti++\n\t}\n\treturn \"NO\"\n}\n\nfunc main() {\n\tvar s string\n\tfmt.Scanln(&s)\n\tsol := solve(s)\n\tfmt.Println(sol)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\thi := \"hello\"\n\tans := false\n\tj := 0\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] == hi[j] {\n\t\t\tj += 1\n\t\t}\n\t\tif j == len(hi) {\n\t\t\tans = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif ans {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n\n var dst string = \"hello\"\n id := 0\n total := len(dst)\n for i := 0; i < len(s) && id < total; i++ {\n if s[i] == dst[id] {\n id++\n }\n }\n\n if id == total {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n"}, {"source_code": "// URL: http://codeforces.com/problemset/problem/58/A\n// ~ Basic Implementation Problem\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc isWordIn(w string, s string) string {\n\tif len(w) == 0 {\n\t\treturn \"YES\"\n\t}\n\tif len(s) == 0 {\n\t\treturn \"NO\"\n\t}\n\tif string(w[0]) != string(s[0]) {\n\t\treturn isWordIn(w, s[1:])\n\t} else {\n\t\treturn isWordIn(w[1:], s[1:])\n\t}\n}\n\n\nfunc main() {\n\treader, writer := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tvar s string\n\tfmt.Fscanf(reader, \"%s\\n\", &s)\n\tfmt.Fprintf(writer, \"%s\\n\", isWordIn(\"hello\", s))\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n t := \"hello\"\n ls, lt, i, j := len(s), 5, 0, 0\n for i < ls && j < lt {\n if s[i] == t[j] {\n i ++\n j ++\n } else {\n i ++\n }\n }\n if (j == lt) {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}"}, {"source_code": "package main\n\nimport ( \n \"fmt\"\n )\n\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n \n h := \"hello\"\n i := 0\n for _, c := range s {\n if i == len(h) {\n break\n }\n if c == rune(h[i]) {\n i++\n }\n } \n if i == len(h) {\n fmt.Println(\"YES\") \n return\n }\n fmt.Println(\"NO\") \n}"}, {"source_code": "package main\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var word string\n fmt.Scanf(\"%s\", &word)\n\n hello := \"hello\"\n counter := 0\n\n for _, r := range word {\n if counter < len(hello) {\n //fmt.Println(\"r: \",r,\", hello: \", hello[counter])\n if uint8(r) == hello[counter] {\n counter++\n }\n }\n }\n\n switch counter {\n case 5: fmt.Println(\"YES\")\n default: fmt.Println(\"NO\")\n }\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanRunes)\n\texpected := []rune{'h', 'e', 'l', 'l', 'o'}\n\tfor scanner.Scan() {\n\t\tb := scanner.Text()\n\t\tbr := rune(b[0])\n\t\tif br == expected[0] {\n\t\t\tif len(expected) == 1 {\n\t\t\t\texpected = expected[0:0]\n\t\t\t\tbreak\n\t\t\t}\n\t\t\texpected = expected[1:]\n\t\t}\n\t}\n\tif len(expected) == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println((\"NO\"))\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s, s2 string\n\tvar tmp int\n\tvar flag bool\n\tfmt.Scanf(\"%s\", &s)\n\tfor i := range s {\n\t\tif tmp == 0 {\n\t\t\tif s[i] == 'h' {\n\t\t\t\ts2 = s2 + string(s[i])\n\t\t\t\ttmp++\n\t\t\t}\n\t\t} else if tmp == 1 {\n\t\t\tif s[i] == 'e' {\n\t\t\t\ts2 = s2 + string(s[i])\n\t\t\t\ttmp++\n\t\t\t}\n\t\t} else if tmp == 2 {\n\t\t\tif s[i] == 'l' {\n\t\t\t\ts2 = s2 + string(s[i])\n\t\t\t\ttmp++\n\t\t\t}\n\t\t} else if tmp == 3 {\n\t\t\tif s[i] == 'l' {\n\t\t\t\ts2 = s2 + string(s[i])\n\t\t\t\ttmp++\n\t\t\t}\n\t\t} else if tmp == 4 {\n\t\t\tif s[i] == 'o' {\n\t\t\t\ts2 = s2 + string(s[i])\n\t\t\t\ttmp++\n\t\t\t}\n\t\t}\n\t\tif tmp == 5 {\n\t\t\tflag = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif flag {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tvar tmp int\n\tvar flag bool\n\tfmt.Scanf(\"%s\", &s)\n\tfor i := range s {\n\t\tif tmp == 0 {\n\t\t\tif s[i] == 'h' {\n\t\t\t\ttmp++\n\t\t\t}\n\t\t} else if tmp == 1 {\n\t\t\tif s[i] == 'e' {\n\t\t\t\ttmp++\n\t\t\t}\n\t\t} else if tmp == 2 {\n\t\t\tif s[i] == 'l' {\n\t\t\t\ttmp++\n\t\t\t}\n\t\t} else if tmp == 3 {\n\t\t\tif s[i] == 'l' {\n\t\t\t\ttmp++\n\t\t\t}\n\t\t} else if tmp == 4 {\n\t\t\tif s[i] == 'o' {\n\t\t\t\ttmp++\n\t\t\t}\n\t\t}\n\t\tif tmp == 5 {\n\t\t\tflag = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif flag {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvar str []byte\n\tstr, _, _ = reader.ReadLine()\n\tvar hello []byte = []byte{'h', 'e', 'l', 'l', 'o'}\n\tvar i byte\n\tfor _, v := range str {\n\t\tif v == hello[i] {\n\t\t\ti++\n\t\t\tif i == byte(len(hello)) {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n)\n\n//========== Implement Algorithm =======================\nfunc solution(str string) bool {\n\tif len(str) < 5 {\n\t\treturn false\n\t}\n\th := false\n\te := false\n\tl := false\n\to := false\n\tlcount := 0\n\tfor x := 0; x < len(str); x++ {\n\t\tif h && e && l && o {\n\t\t\treturn true\n\t\t}\n\n\t\tif string(str[x]) == \"h\" {\n\t\t\th = true\n\t\t} else if string(str[x]) == \"e\" && h {\n\t\t\te = true\n\t\t} else if string(str[x]) == \"l\" && h && e {\n\t\t\tlcount++\n\t\t\tif lcount == 2 {\n\t\t\t\tl = true\n\t\t\t}\n\n\t\t} else if string(str[x]) == \"o\" && h && e && l {\n\t\t\to = true\n\t\t}\n\t}\n\n\treturn h && e && l && o\n}\n\nfunc main() {\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\t//================== Variables used ====================\n\tvar str string\n\tvar ret bool\n\t//======================================================\n\n\t//============== Get return value from File ============\n\tif len(os.Args) >= 2 {\n\n\t\tfile, err := os.Open(os.Args[1])\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"failed opening file: %s\", err)\n\t\t}\n\t\tscanner = bufio.NewScanner(file)\n\t\tdefer file.Close()\n\n\t}\n\tscanner.Split(bufio.ScanWords)\n\t//======================= I/O ==========================\n\tscanner.Scan()\n\tstr = scanner.Text()\n\t//======================================================\n\tret = solution(str)\n\t//==================== OUTPUT ==========================\n\tif ret {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\"fmt\")\n\nfunc main(){\n\tvar line string\n\tb := \"hello\"\n\tscan(&line)\n\tp := 0\n\tfor i := 0; i < len(line); i++{\n\t\tif p < 5 && line[i] == b[p]{p++}\n\t}\n\tif p == 5 {\n\t\tsout(\"YES\")\n\t}else{\n\t\tsout(\"NO\")\n\t}\n}\n\nfunc scan(in ... interface{}){\n\tfor _,k := range in{\n\t\tfmt.Scan(k)\n\t}\n}\n\nfunc sout(obj ... interface{}){\n\tfor _, k := range obj{\n\t\tfmt.Print(k)\n\t}\n\t//fmt.Println()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\thell := \"hello\"\n\trecovered := 0\n\tfor i := range s {\n\t\tif s[i] == hell[recovered] {\n\t\t\trecovered++\n\t\t}\n\t\tif recovered == 5 {\n\t\t\tfmt.Print(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Print(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var s string\n word := \"hello\"\n var count, l int\n l = 4\n fmt.Scanf(\"%s\", &s)\n\n for i:=0; i < len(s); i++ {\n if (s[i] == word[count]) {\n count++ \n } \n if(count > l) {\n break\n }\n }\n\n if(count > l) {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvar str string\n\tfmt.Fscanln(reader, &str)\n\tslice := []rune(str)\n\tsym := []rune(\"hello\")\n\tindex := 0\n\tflag := false\n\tfor _, s := range slice {\n\t\tcheck := sym[index]\n\t\tif s == check {\n\t\t\tif index == 4 {\n\t\t\t\tflag = true\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\tindex++\n\t\t\t}\n\t\t}\n\t}\n\tif !flag {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\ts := \"\"\n\tfmt.Scanln(&s)\n\tw := []rune{'h', 'e', 'l', 'l', 'o'}\n\tlenw := len(w)\n\tnext := 0\n\tfor _, c := range s {\n\t\tif next >= lenw {\n\t\t\tbreak\n\t\t}\n\t\tif c == w[next] {\n\t\t\tnext++\n\t\t}\n\t}\n\tif next >= lenw {\n\t\tfmt.Println(\"YES\")\n\t\treturn\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\ts, _ := bufio.NewReader(os.Stdin).ReadBytes('\\n')\n\ti, h, ello := 0, byte('h'), []byte(\"ello\")\n\tfor _, b := range s {\n\t\tif h == b {\n\t\t\tif i == 4 {\n\t\t\t\tfmt.Print(\"YES\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\th = ello[i]\n\t\t\ti += 1\n\t\t}\n\t}\n\tfmt.Print(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s []byte\n\tfmt.Scan(&s)\n\ti, h, ello := -1, byte('h'), []byte{'e', 'l', 'l', 'o'}\n\tfor _, b := range s {\n\t\tif h == b {\n\t\t\ti++\n\t\t\tif i == 4 {\n\t\t\t\tfmt.Print(\"YES\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\th = ello[i]\n\t\t}\n\t}\n\tfmt.Print(\"NO\")\n}\n\n\n\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n h := \"hello\"\n var s string\n fmt.Scan(&s)\n in := 0\n for i := 0; (i < len(s)) && (in < 5); i++ {\n if s[i] == h[in] { in++ }\n }\n if in == 5 { fmt.Println(\"YES\") } else { fmt.Println(\"NO\") }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"bytes\"\nimport \"io/ioutil\"\nimport \"os\"\n\nfunc task_solution(line []byte) string {\n\tsub := []byte{'h', 'e', 'l', 'l', 'o'}\n\tvar i, j int\n\tfor i, j = 0, 0; i < len(sub) && j < len(line); j += 1 {\n\t\tif line[j] == sub[i] {\n\t\t\ti += 1\n\t\t}\n\t}\n\tif i == len(sub) && j <= len(line) {\n\t\treturn \"YES\"\n\t}\n\treturn \"NO\"\n}\n\nfunc main() {\n\tin_raw, err := ioutil.ReadAll(os.Stdin)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(task_solution(bytes.TrimSpace(in_raw)))\n}\n"}, {"source_code": "package main\n\n// https://codeforces.com/problemset/problem/58/A\n\nimport \"fmt\"\n\nconst sub = \"hello\"\n\nfunc task_solution(line string) string {\n\tvar i, j int\n\tfor i, j = 0, 0; i < len(sub) && j < len(line); j += 1 {\n\t\tif sub[i] == line[j] {\n\t\t\ti += 1\n\t\t}\n\t}\n\tif i == len(sub) && j <= len(line) {\n\t\treturn \"YES\"\n\t}\n\treturn \"NO\"\n}\n\nfunc main() {\n\tvar line string\n\tif _, err := fmt.Scan(&line); err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(task_solution(line))\n}\n"}, {"source_code": "// Author: sighduck\n// URL: https://codeforces.com/problemset/problem/58/A\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Solve(s string) string {\n\torder := \"hello\"\n\ti := 0\n\tj := 0\n\tfor i < 5 && j < len(s) {\n\t\tif s[j] == order[i] {\n\t\t\tj += 1\n\t\t\ti += 1\n\t\t} else {\n\t\t\tj += 1\n\t\t}\n\t}\n\tif i == 5 {\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 s string\n\tfmt.Fscanf(reader, \"%s\\n\", &s)\n\n\tfmt.Fprintf(writer, \"%s\\n\", Solve(s))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"regexp\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scanln(&s)\n\n\tvar hello = regexp.MustCompile(`h.*e.*l.*l.*o`)\n\n\tif hello.MatchString(s) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\n// Snippet: isSubSeq\nfunc isSubseq(s1 string, s2 string) bool {\n\tvar k = 0\n\tfor i := 0; i < len(s2); i++ {\n\t\tif s2[i] == s1[k] {\n\t\t\tk++\n\t\t\tif k == len(s1) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tif isSubseq(\"hello\", s) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar s string\n\thello := \"hello\"\n\tfmt.Scan(&s)\n\tfor i := range s {\n\t\tif s[i] == hello[0] {\n\t\t\thello = hello[1:]\n\t\t\tif len(hello) == 0 {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar w, res string\n\tfmt.Scanln(&w)\n\tfor _, y := range w {\n\t\tswitch string(y) {\n\t\tcase \"h\":\n\t\t\tif res == \"\" {\n\t\t\t\tres = \"h\"\n\t\t\t}\n\t\tcase \"e\":\n\t\t\tif res == \"h\" {\n\t\t\t\tres = \"he\"\n\t\t\t}\n\t\tcase \"l\":\n\t\t\tif res == \"he\" {\n\t\t\t\tres = \"hel\"\n\t\t\t} else if res == \"hel\" {\n\t\t\t\tres = \"hell\"\n\t\t\t}\n\t\tcase \"o\":\n\t\t\tif res == \"hell\" {\n\t\t\t\tres = \"hello\"\n\t\t\t}\n\n\t\t}\n\t}\n\n\tif res == \"hello\" {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar istring string\n\t_, _ = fmt.Scan(&istring)\n\tvar check = []string{\"h\",\"e\",\"l\",\"l\",\"o\"}\n\tj:=0\n\tcount :=0\n\ttemp := strings.Split(istring,\"\")\n\tfor i:=0; i= 0 && index4 >= 0 && index3 >= 0 && index2 >= 0 && index1 >= 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar palabra string\n\n\thelloArray := []string{\"h\",\"e\",\"l\",\"l\",\"o\"}\n\thello := make(map[string]bool)\n\n\tfor _, item := range helloArray{\n\t\thello[item] = false\n\t}\n\n\tfmt.Scanln(&palabra)\n\tstrings.Split(\"\", palabra)\n\n\tindexCounter := 0\n\n\tfor i := 0; i < len(palabra); i++{\n\t\tif indexCounter < len(helloArray) {\n\t\t\tif string(palabra[i]) == helloArray[indexCounter] {\n\t\t\t\thello[helloArray[indexCounter]] = true\n\n\t\t\t\tindexCounter++\n\t\t\t}\n\t\t}else{\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfor _, item := range helloArray{\n\t\t//fmt.Println(item, hello[item])\n\n\t\tif hello[item] == false{\n\t\t\tfmt.Println(\"NO\")\n\t\t\tos.Exit(0)\n\t\t}\n\t}\n\tfmt.Println(\"YES\")\n}\n"}, {"source_code": "package main\n\nimport (\n\"fmt\"\n)\n\nfunc main() {\n\tvar inp,hello string\n\thello = \"hello\"\n\tfmt.Scan(&inp)\n\tit := 0\n\tfor i:=0;i 0 && len(word) > 0 {\n\t\tfirst, wanted = string(wanted[0]), wanted[1:]\n\t\tindex := strings.Index(word, first)\n\t\tif index == -1 {\n\t\t\treturn false\n\t\t}\n\t\tword = word[index+1:]\n\t}\n\treturn len(wanted) == 0\n}\n\nfunc main() {\n\tvar word string\n\n\twanted := \"hello\"\n\n\tfmt.Scan(&word)\n\tif find(wanted, word) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar st string\n\tfmt.Scan(&st)\n\thello := \"hello\"\n\tcur := 0\n\tfor i := 0; cur < len(hello) && i < len(st); i++ {\n\t\tif st[i] == hello[cur] {\n\t\t\tcur++\n\t\t}\n\t}\n\tif cur == len(hello) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar st string\n\tfmt.Scan(&st)\n\tif contain(st, \"hello\") {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nfunc contain(st string, pattern string) bool {\n\tif pattern == \"\" {\n\t\treturn true\n\t}\n\ti := strings.IndexByte(st, pattern[0])\n\tif i == -1 {\n\t\treturn false\n\t}\n\treturn contain(st[i+1:], pattern[1:])\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\n//import \"strings\"\n\n//import \"math\"\n//import \"strconv\"\n//import \"sort\"\n\nfunc main() {\n\n\tstr := \"hello*\"\n\n\td := \"\"\n\n\tfmt.Scan(&d)\n\n\tcur := 0\n\n\tfor i := 0; i < len(d); i++ {\n\n\t\tif str[cur] == d[i] {\n\t\t\tfmt.Println(i)\n\t\t\tcur++\n\t\t}\n\t\tif cur == 5 {\n\t\t\tos.Exit(0)\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\n//import \"strings\"\n\n//import \"math\"\n//import \"strconv\"\n//import \"sort\"\n\nfunc main() {\n\n\tstr := \"hello\"\n\n\td := \"\"\n\n\tfmt.Scan(&d)\n\n\tcur := 0\n\n\tfor i := 0; i < len(d); i++ {\n\n\t\tif str[cur] == d[i] {\n\t\t\tcur++\n\t\t}\n\t\tif cur == 4 {\n\t\t\tfmt.Println(\"YES\")\n\t\t\tos.Exit(0)\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\n//import \"strings\"\n\n//import \"math\"\n//import \"strconv\"\n//import \"sort\"\n\nfunc main() {\n\n\tstr := \"hello*\"\n\n\td := \"\"\n\n\tfmt.Scan(&d)\n\n\tcur := 0\n\n\tfor i := 0; i < len(d); i++ {\n\n\t\tif str[cur] == d[i] {\n\t\t\tfmt.Println(i)\n\t\t\tcur++\n\t\t}\n\t\tif cur == 4 {\n\t\t\tos.Exit(0)\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\n// INPUT\n// ahhellllloou -> YES\n// hlelo -> NO\n// helhcludoo -> YES\n\nfunc main() {\n\tvar word, wholeWord string\n\n\tfmt.Scanf(\"%v\", &word)\n\n\tfor _, char := range word {\n\t\tif wholeWord == \"\" || !strings.Contains(wholeWord, string(char)) && (char == 'h' || char == 'e' || char == 'l' || char == 'o') {\n\t\t\twholeWord += string(char)\n\t\t}\n\t}\n\n\tif strings.Contains(wholeWord, \"helo\") {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\n// INPUT\n// ahhellllloou -> YES\n// hlelo -> NO\n// helhcludoo -> YES\n\nfunc main() {\n\tvar word, wholeWord string\n\n\tfmt.Scanf(\"%v\", &word)\n\n\tfor _, char := range word {\n\t\tif wholeWord == \"\" || !strings.Contains(wholeWord, string(char)) && (char == 'h' || char == 'e' || char == 'l' || char == 'o') {\n\t\t\twholeWord += string(char)\n\t\t}\n\t}\n\n\tfmt.Println(wholeWord)\n\n\tif strings.Contains(wholeWord, \"helo\") {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\n// INPUT\n// ahhellllloou -> YES\n// hlelo -> NO\n\nfunc main() {\n\tvar word, wholeWord string\n\n\tfmt.Scanf(\"%v\", &word)\n\n\tfor _, char := range word {\n\t\tif wholeWord == \"\" || wholeWord[len(wholeWord)-1] != byte(char) {\n\t\t\twholeWord += string(char)\n\t\t}\n\t}\n\n\tif strings.Contains(wholeWord, \"helo\") {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"strings\"\n\nfunc foo(s string) bool {\n\tvar i int\n\tif i = strings.Index(s, \"h\"); i == -1 {\n\t\treturn false\n\t}\n\tif i = strings.Index(s, \"e\"); i == -1 {\n\t\treturn false\n\t}\n\tif i = strings.Index(s, \"l\"); i == -1 {\n\t\treturn false\n\t}\n\tif i = strings.Index(s, \"l\"); i == -1 {\n\t\treturn false\n\t}\n\tif i = strings.Index(s, \"o\"); i == -1 {\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tif foo(s) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"strings\"\n\nfunc foo(s string) bool {\n\tconst l = \"hello\"\n\tfor i, j := 0, 0; j < len(l); j++ {\n\t\ts = s[i:]\n\t\tif i = strings.Index(s[i:], string(l[j])); i == -1 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n\t/*for i := 0; i < len(s); i++ {\n\t\tfor j := i + 1; j < len(s); j++ {\n\t\t\tfor k := j + 1; k < len(s); k++ {\n\t\t\t\tfor l := k + 1; l < len(s); l++ {\n\t\t\t\t\tfor m := l + 1; m < len(s); m++ {\n\t\t\t\t\t\tif s[i] == 'h' && s[j] == 'e' && s[k] == 'l' && s[l] == 'l' && s[m] == 'o' {\n\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}*/\n}\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tif foo(s) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"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\ts, _ := reader.ReadString('\\n')\n\tgoal := \"hello\"\n\tstate := 0\n\tgood := false\n\tfor i := 0; i < len(s); i++ {\n\t\tif state == len(goal)-1 {\n\t\t\tgood = true\n\t\t\tbreak\n\t\t}\n\n\t\tif s[i] == goal[state] {\n\t\t\tstate++\n\t\t}\n\t}\n\n\tif good {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"regexp\"\n)\n\nfunc main() {\n\tvar scanner *bufio.Scanner\n\n\tscanner = bufio.NewScanner(os.Stdin)\n\n\tscanner.Scan()\n\tif err := scanner.Err(); err == nil {\n\t\tif regexp.MustCompile(\"\\\\w*[h ]+[e ]+[l ]+[l ]+[o ]+\\\\w*\").MatchString(scanner.Text()) {\n\t\t\tfmt.Println(\"YES\")\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\ntype input struct {\n\ta string\n}\n\nfunc (c *input) Read(scanner *bufio.Scanner) {\n\tfor scanner.Scan() {\n\t\tc.a = scanner.Text()\n\t\treturn\n\t}\n\n}\n\n\n\nfunc main() {\n\tvar inp input\n\tsc := bufio.NewScanner(os.Stdin)\n\tinp.Read(sc)\n\n\tvar h, e, l, l2 bool\n\n\tfor _, b := range inp.a {\n\t\ts := string(b)\n\t\tif s == \"h\" {\n\t\t\th = true\n\t\t}\n\n\n\t\tif h && s == \"e\" {\n\t\t\te = true\n\t\t}\n\t\tif h && e && s == \"l\" {\n\t\t\tl = true\n\n\t\t}\n\t\tif h && e && l && s==\"l\" {\n\t\t\tl2 = true\n\n\t\t}\n\t\tif h && e && l && l2 && s == \"o\" {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\ntype input struct {\n\ta string\n}\n\nfunc (c *input) Read(scanner *bufio.Scanner) {\n\tfor scanner.Scan() {\n\t\tc.a = scanner.Text()\n\t\treturn\n\t}\n\n}\n\n\n\nfunc main() {\n\tvar inp input\n\tsc := bufio.NewScanner(os.Stdin)\n\tinp.Read(sc)\n\n\tvar h, e, l, l2 bool\n\n\tfor _, b := range inp.a {\n\t\ts := string(b)\n\t\tif s == \"h\" {\n\t\t\th = true\n\t\t}\n\n\n\t\tif h && s == \"e\" {\n\t\t\te = true\n\t\t}\n\t\tif h && e && s == \"l\" {\n\t\t\tl = true\n\n\t\t}\n\t\tif h && e && l && s==\"l\" {\n\t\t\tl2 = true\n\n\t\t}\n\t\tif h && e && l && l2 && s == \"o\" {\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\ntype input struct {\n\ta string\n}\n\nfunc (c *input) Read(scanner *bufio.Scanner) {\n\tfor scanner.Scan() {\n\t\tc.a = scanner.Text()\n\t\treturn\n\t}\n\n}\n\n\n\nfunc main() {\n\tvar inp input\n\tsc := bufio.NewScanner(os.Stdin)\n\tinp.Read(sc)\n\n\tvar h, e, l, l2 bool\n\n\n\tfor i, b := range inp.a {\n\t\tvar v1 int\n\t\ts := string(b)\n\t\tif s == \"h\" {\n\t\t\tv1 = i\n\t\t\th = true\n\t\t}\n\n\n\t\tif v1 > i && h && s == \"e\" {\n\t\t\tv1 = i\n\t\t\te = true\n\t\t}\n\t\tif v1 > i && h && e && s == \"l\" {\n\t\t\tv1 = i\n\n\t\t\tl = true\n\n\t\t}\n\t\tif v1 > i && h && e && l && s==\"l\" {\n\t\t\tv1 = i\n\n\t\t\tl2 = true\n\n\t\t}\n\t\tif v1 > i && h && e && l && l2 && s == \"o\" {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\ntype input struct {\n\ta string\n}\n\nfunc (c *input) Read(scanner *bufio.Scanner) {\n\tfor scanner.Scan() {\n\t\tc.a = scanner.Text()\n\t\treturn\n\t}\n\n}\n\n\n\nfunc main() {\n\tvar inp input\n\tsc := bufio.NewScanner(os.Stdin)\n\tinp.Read(sc)\n\n\tvar h, e, l, l2 bool\n\n\tfor _, b := range inp.a {\n\t\ts := string(b)\n\t\tif s == \"h\" {\n\t\t\th = true\n\t\t\tif h && s == \"e\" {\n\t\t\t\te = true\n\t\t\t\tif h && e && s == \"l\" {\n\t\t\t\t\tl = true\n\t\t\t\t\tif h && e && l && s==\"l\" {\n\t\t\t\t\t\tl2 = true\n\t\t\t\t\t\tif h && e && l && l2 && s == \"o\" {\n\t\t\t\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\ntype input struct {\n\ta string\n}\n\nfunc (c *input) Read(scanner *bufio.Scanner) {\n\tfor scanner.Scan() {\n\t\tc.a = scanner.Text()\n\t\treturn\n\t}\n\n}\n\n\n\nfunc main() {\n\tvar inp input\n\tsc := bufio.NewScanner(os.Stdin)\n\tinp.Read(sc)\n\n\tvar h, e, l, l2 bool\n\n\tfor _, b := range inp.a {\n\t\ts := string(b)\n\t\tif s == \"h\" {\n\t\t\th = true\n\t\t}\n\t\tif h && s == \"e\" {\n\t\t\te = true\n\t\t}\n\t\tif h && e && s == \"l\" {\n\t\t\tl = true\n\t\t}\n\t\tif h && e && l && s==\"l\" {\n\t\t\tl2 = true\n\t\t}\n\t\tif h && e && l && l2 && s == \"o\" {\n\t\t\tfmt.Println(\"YES\")\n\t\t\treturn \n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}, {"source_code": "/*\nChat room\ntime limit per test2 seconds\nmemory limit per test256 megabytes\ninputstandard input\noutputstandard output\nVasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word s. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word \"hello\". For example, if Vasya types the word \"ahhellllloou\", it will be considered that he said hello, and if he types \"hlelo\", it will be considered that Vasya got misunderstood and he didn't manage to say hello. Determine whether Vasya managed to say hello by the given word s.\n\nInput\nThe first and only line contains the word s, which Vasya typed. This word consisits of small Latin letters, its length is no less that 1 and no more than 100 letters.\n\nOutput\nIf Vasya managed to say hello, print \"YES\", otherwise print \"NO\".\n\nSample test(s)\ninput\nahhellllloou\noutput\nYES\ninput\nhlelo\noutput\nNO\n*/\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tS string\n\t\thello = []rune(\"hello\")\n\t)\n\tfmt.Scanf(\"%s\", &S)\n\ts := []rune(S)\n\tlens := len(s)\n\tlenHello := len(hello)\n\tif lens < lenHello {\n\t\tprintln(\"NO\")\n\t\treturn\n\t}\n\tvar i, j int\n\tfor ; i < lenHello; {\n\t\tfor ; j < lens; j++ {\n\t\t\tif s[j] == hello[i] {\n\t\t\t\ti++\n\t\t\t\tj++\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif j >= lens {\n\t\t\tbreak\n\t\t}\n\t}\n\tif i == lenHello {\n\t\tprintln(\"YES\")\n\t} else {\n\t\tprintln(\"NO\")\n\t}\n}\n"}, {"source_code": "/*\nChat room\ntime limit per test2 seconds\nmemory limit per test256 megabytes\ninputstandard input\noutputstandard output\nVasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word s. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word \"hello\". For example, if Vasya types the word \"ahhellllloou\", it will be considered that he said hello, and if he types \"hlelo\", it will be considered that Vasya got misunderstood and he didn't manage to say hello. Determine whether Vasya managed to say hello by the given word s.\n\nInput\nThe first and only line contains the word s, which Vasya typed. This word consisits of small Latin letters, its length is no less that 1 and no more than 100 letters.\n\nOutput\nIf Vasya managed to say hello, print \"YES\", otherwise print \"NO\".\n\nSample test(s)\ninput\nahhellllloou\noutput\nYES\ninput\nhlelo\noutput\nNO\n*/\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tS string\n\t\thello = []rune(\"hello\")\n\t)\n\tfmt.Scanf(\"%s\\n\", &S)\n\ts := []rune(S)\n\tlens := len(s)\n\tlenHello := len(hello)\n\tif lens < lenHello {\n\t\tprintln(\"NO\")\n\t\treturn\n\t}\n\tvar i, j int\n\tfor ; i < lenHello; {\n\t\tfor ; j < lens; j++ {\n\t\t\tif s[j] == hello[i] {\n\t\t\t\ti++\n\t\t\t\tj++\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif j >= lens {\n\t\t\tbreak\n\t\t}\n\t}\n\tif i == lenHello {\n\t\tprintln(\"YES\")\n\t} else {\n\t\tprintln(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar word string\n\tfmt.Scan(&word)\n\n\tc := []byte{'h', 'e', 'l', 'o'}\n\tcont := []int{1, 1, 2, 1}\n\tflag := 0\n\thitNum := 0\n\n\tfor i := 0; i < len(word); i++ {\n\t\tif word[i] == c[flag] {\n\t\t\thitNum += 1\n\t\t} else {\n\t\t\tif hitNum < cont[flag] {\n\t\t\t\tflag = 0\n\t\t\t} else {\n\t\t\t\tflag += 1\n\t\t\t\ti--\n\t\t\t}\n\t\t\thitNum = 0\n\t\t}\n\n\t\tif flag >= len(c) {\n\t\t\tfmt.Print(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Print(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a string\n\tfmt.Scan(&a)\n\n \tvar h = \"hello\"\n \tvar index = 0\n \tfor i := 0; i < len(a) && index < 5; i++{\n\t\tif h[index] == a[i] {\n\t\t\tindex++\n\t\t}\n\t}\n\tif index >= 5 {\n\t\tprint(\"YES\")\n\t}else {\n\t\tprint(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\nvar r *bufio.Reader = bufio.NewReader(os.Stdin)\nvar w *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc print( a ...interface{}) { fmt.Fprint(w, a...) }\nfunc scan( a ...interface{}) { fmt.Fscan(r, a...) }\n\nfunc main() {\n\tvar a string\n\tfmt.Scan(&a)\n\n\tvar h = \"hello\"\n\tvar index = 0\n\tfor i := 0; i < len(a) && index < 5; i++{\n\t\tif h[index] == a[i] {\n\t\t\tindex++\n\t\t}\n\t}\n\tif index >= 5 {\n\t\tprint(\"YES\")\n\t}else {\n\t\tprint(\"NO\")\n\t}\n}\n\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar line string\n\tfmt.Scan(&line)\n\n\tcount := 0\n\tfor _, c := range line {\n\t\tswitch c {\n\t\tcase 'h':\n\t\t\tcount++\n\t\tcase 'e':\n\t\t\tif count == 1 {\n\t\t\t\tcount++\n\t\t\t}\n\t\tcase 'l':\n\t\t\tif count == 2 || count == 3 {\n\t\t\t\tcount++\n\t\t\t}\n\t\tcase 'o':\n\t\t\tif count == 4 {\n\t\t\t\tcount++\n\t\t\t}\n\t\t}\n\t}\n\n\tif count == 5 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\n// ahhellllloou\n\nfunc solve(s string) string {\n\ti := 0\n\tfor i < len(s) {\n\t\tif s[i] == 'h' {\n\t\t\ti++\n\t\t\tfor s[i] == 'h' {\n\t\t\t\ti++\n\t\t\t}\n\t\t\tif s[i] == 'e' {\n\t\t\t\ti++\n\t\t\t\tfor s[i] == 'e' {\n\t\t\t\t\ti++\n\t\t\t\t}\n\t\t\t\tif s[i] == 'l' {\n\t\t\t\t\ti++\n\t\t\t\t\tfor s[i] == 'l' {\n\t\t\t\t\t\ti++\n\t\t\t\t\t}\n\t\t\t\t\tif s[i] == 'o' {\n\t\t\t\t\t\ti++\n\t\t\t\t\t\tfor s[i] == 'o' {\n\t\t\t\t\t\t\treturn \"YES\"\n\t\t\t\t\t\t\ti++\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\ti++\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ti++\n\t\t\t}\n\t\t} else {\n\t\t\ti++\n\t\t}\n\t}\n\treturn \"NO\"\n}\n\nfunc main() {\n\tvar s string\n\tfmt.Scanln(&s)\n\tsol := solve(s)\n\tfmt.Println(sol)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\thi := \"hello\"\n\tans := false\n\tj := 0\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] == hi[j] {\n\t\t\tj += 1\n\t\t}\n\t\tif j == len(hi) {\n\t\t\tans = true\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanRunes)\n\texpected := []rune{'h', 'e', 'l', 'l', 'o'}\n\tfor scanner.Scan() {\n\t\tb := scanner.Text()\n\t\tbr := rune(b[0])\n\t\tif br == expected[0] {\n\t\t\tif len(expected) == 1 {\n\t\t\t\texpected = expected[:]\n\t\t\t\tbreak\n\t\t\t}\n\t\t\texpected = expected[1:]\n\t\t}\n\t}\n\tif len(expected) == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println((\"NO\"))\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanRunes)\n\texpected := []rune{'h', 'e', 'l', 'l', 'o'}\n\tfor scanner.Scan() {\n\t\tb := scanner.Text()\n\t\tbr := rune(b[0])\n\t\tif br == expected[0] {\n\t\t\tif len(expected) > 1 {\n\t\t\t\texpected = expected[1:]\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\tif len(expected) == 0 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println((\"NO\"))\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s, s2 string\n\tvar tmp int\n\tvar flag bool\n\tfmt.Scanf(\"%s\", &s)\n\tfor i := range s {\n\t\tif tmp == 0 {\n\t\t\tif s[i] == 'h' {\n\t\t\t\ts2 = s2 + string(s[i])\n\t\t\t\ttmp++\n\t\t\t}\n\t\t} else if tmp == 1 {\n\t\t\tif s[i] == 'e' {\n\t\t\t\ts2 = s2 + string(s[i])\n\t\t\t\ttmp++\n\t\t\t}\n\t\t} else if tmp == 2 {\n\t\t\tif s[i] == 'l' {\n\t\t\t\ts2 = s2 + string(s[i])\n\t\t\t\ttmp++\n\t\t\t}\n\t\t} else if tmp == 3 {\n\t\t\tif s[i] == 'l' {\n\t\t\t\ts2 = s2 + string(s[i])\n\t\t\t\ttmp++\n\t\t\t}\n\t\t} else if tmp == 4 {\n\t\t\tif s[i] == 'l' {\n\t\t\t\ts2 = s2 + string(s[i])\n\t\t\t\ttmp++\n\t\t\t}\n\t\t}\n\t\tif tmp == 5 {\n\t\t\tflag = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif flag {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"strings\"\n)\n\n//========== Implement Algorithm =======================\nfunc solution(str string) bool {\n\tif len(str) < 6 {\n\t\treturn false\n\t}\n\th := strings.Count(str, \"h\") >= 1\n\te := strings.Count(str, \"e\") >= 1\n\tl := strings.Count(str, \"l\") >= 2\n\to := strings.Count(str, \"o\") >= 1\n\treturn h && e && l && o\n}\n\nfunc main() {\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\t//================== Variables used ====================\n\tvar str string\n\tvar ret bool\n\t//======================================================\n\n\t//============== Get return value from File ============\n\tif len(os.Args) >= 2 {\n\n\t\tfile, err := os.Open(os.Args[1])\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"failed opening file: %s\", err)\n\t\t}\n\t\tscanner = bufio.NewScanner(file)\n\t\tdefer file.Close()\n\n\t}\n\tscanner.Split(bufio.ScanWords)\n\t//======================= I/O ==========================\n\tscanner.Scan()\n\tstr = scanner.Text()\n\t//======================================================\n\tret = solution(str)\n\t//==================== OUTPUT ==========================\n\tif ret {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n)\n\n//========== Implement Algorithm =======================\nfunc solution(str string) bool {\n\tif len(str) < 6 {\n\t\treturn false\n\t}\n\th := false\n\te := false\n\tl := false\n\to := false\n\tlcount := 0\n\tfor x := 0; x < len(str); x++ {\n\t\tif h && e && l && o {\n\t\t\treturn true\n\t\t}\n\t\tif string(str[x]) == \"h\" {\n\t\t\th = true\n\t\t} else if string(str[x]) == \"e\" && h {\n\t\t\te = true\n\t\t} else if string(str[x]) == \"l\" && h && e {\n\t\t\tlcount++\n\t\t\tif lcount == 2 {\n\t\t\t\tl = true\n\t\t\t}\n\n\t\t} else if string(str[x]) == \"o\" && h && e && l {\n\t\t\to = true\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc main() {\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\t//================== Variables used ====================\n\tvar str string\n\tvar ret bool\n\t//======================================================\n\n\t//============== Get return value from File ============\n\tif len(os.Args) >= 2 {\n\n\t\tfile, err := os.Open(os.Args[1])\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"failed opening file: %s\", err)\n\t\t}\n\t\tscanner = bufio.NewScanner(file)\n\t\tdefer file.Close()\n\n\t}\n\tscanner.Split(bufio.ScanWords)\n\t//======================= I/O ==========================\n\tscanner.Scan()\n\tstr = scanner.Text()\n\t//======================================================\n\tret = solution(str)\n\t//==================== OUTPUT ==========================\n\tif ret {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n)\n\n//========== Implement Algorithm =======================\nfunc solution(str string) bool {\n\tif len(str) < 6 {\n\t\treturn false\n\t}\n\th := false\n\te := false\n\tl := false\n\to := false\n\tlcount := 0\n\tfor x := 0; x < len(str); x++ {\n\t\tif h && e && l && o {\n\t\t\treturn true\n\t\t}\n\n\t\tif string(str[x]) == \"h\" {\n\t\t\th = true\n\t\t} else if string(str[x]) == \"e\" && h {\n\t\t\te = true\n\t\t} else if string(str[x]) == \"l\" && h && e {\n\t\t\tlcount++\n\t\t\tif lcount == 2 {\n\t\t\t\tl = true\n\t\t\t}\n\n\t\t} else if string(str[x]) == \"o\" && h && e && l {\n\t\t\to = true\n\t\t}\n\t}\n\n\treturn h && e && l && o\n}\n\nfunc main() {\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\t//================== Variables used ====================\n\tvar str string\n\tvar ret bool\n\t//======================================================\n\n\t//============== Get return value from File ============\n\tif len(os.Args) >= 2 {\n\n\t\tfile, err := os.Open(os.Args[1])\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"failed opening file: %s\", err)\n\t\t}\n\t\tscanner = bufio.NewScanner(file)\n\t\tdefer file.Close()\n\n\t}\n\tscanner.Split(bufio.ScanWords)\n\t//======================= I/O ==========================\n\tscanner.Scan()\n\tstr = scanner.Text()\n\t//======================================================\n\tret = solution(str)\n\t//==================== OUTPUT ==========================\n\tif ret {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n)\n\n//========== Implement Algorithm =======================\nfunc solution(str string) bool {\n\tif len(str) < 6 {\n\t\treturn false\n\t}\n\th := false\n\te := false\n\tl := false\n\to := false\n\tlcount := 0\n\tfor x := 0; x < len(str); x++ {\n\t\tif h && e && l && o {\n\t\t\treturn true\n\t\t}\n\t\tif string(str[x]) == \"h\" {\n\t\t\th = true\n\t\t} else if string(str[x]) == \"o\" {\n\t\t\to = true\n\t\t} else if string(str[x]) == \"l\" {\n\t\t\tlcount++\n\t\t\tif lcount == 2 {\n\t\t\t\tl = true\n\t\t\t}\n\n\t\t} else if string(str[x]) == \"e\" {\n\t\t\te = true\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc main() {\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\t//================== Variables used ====================\n\tvar str string\n\tvar ret bool\n\t//======================================================\n\n\t//============== Get return value from File ============\n\tif len(os.Args) >= 2 {\n\n\t\tfile, err := os.Open(os.Args[1])\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"failed opening file: %s\", err)\n\t\t}\n\t\tscanner = bufio.NewScanner(file)\n\t\tdefer file.Close()\n\n\t}\n\tscanner.Split(bufio.ScanWords)\n\t//======================= I/O ==========================\n\tscanner.Scan()\n\tstr = scanner.Text()\n\t//======================================================\n\tret = solution(str)\n\t//==================== OUTPUT ==========================\n\tif ret {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\"fmt\")\n\nfunc main(){\n\tvar line string\n\tb := \"hello\"\n\tscan(&line)\n\tp := 0\n\tfor i := 0; i < len(line); i++{\n\t\tif line[i] == b[p] && p < 4 {p++}\n\t}\n\tif p == 4 {\n\t\tsout(\"YES\")\n\t}else{\n\t\tsout(\"NO\")\n\t}\n}\n\nfunc scan(in ... interface{}){\n\tfor _,k := range in{\n\t\tfmt.Scan(k)\n\t}\n}\n\nfunc sout(obj ... interface{}){\n\tfor _, k := range obj{\n\t\tfmt.Print(k)\n\t}\n\t//fmt.Println()\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var s string\n word := \"hello\"\n var count, l int\n l = 4\n fmt.Scanf(\"%s\", &s)\n\n for i:=0; i < len(s); i++ {\n if (s[i] == word[count]) {\n count++ \n } \n if(count > l) {\n break\n }\n }\n\n if(count >= l) {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s []byte\n\tfmt.Scan(&s)\n\ti, h, ello := 0, byte('h'), []byte{'e', 'l', 'l', 'o'}\n\tfor _, b := range s {\n\t\tif h == b {\n\t\t\tif i == 3 {\n\t\t\t\tfmt.Print(\"YES\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\th = ello[i]\n\t\t\ti++\n\t\t}\n\t}\n\tfmt.Print(\"NO\")\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"bytes\"\nimport \"io/ioutil\"\nimport \"os\"\n\nfunc task_solution(line []byte) string {\n\tsubstr := []byte{'h', 'e', 'l', 'l', 'o'}\n\tpos := 0\n\tfor _, c := range substr {\n\t\tfor pos < len(line) && line[pos] != c {\n\t\t\tpos += 1\n\t\t}\n\t\t// found char\n\t\tif pos < len(line) {\n\t\t\tpos += 1\n\t\t}\n\t}\n\tif pos < len(line) {\n\t\treturn \"YES\"\n\t}\n\treturn \"NO\"\n}\n\nfunc main() {\n\tin_raw, err := ioutil.ReadAll(os.Stdin)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(task_solution(bytes.TrimSpace(in_raw)))\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"bytes\"\nimport \"io/ioutil\"\nimport \"os\"\n\nfunc task_solution(line []byte) string {\n\tsubstr := []byte{'h', 'e', 'l', 'l', 'o'}\n\tpos := 0\n\tfor _, c := range substr {\n\t\tfor pos < len(line) && line[pos] != c {\n\t\t\tpos += 1\n\t\t}\n\t\t// found char\n\t\tif pos < len(line) {\n\t\t\tpos += 1\n\t\t}\n\t}\n\tif pos <= len(line) {\n\t\treturn \"YES\"\n\t}\n\treturn \"NO\"\n}\n\nfunc main() {\n\tin_raw, err := ioutil.ReadAll(os.Stdin)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(task_solution(bytes.TrimSpace(in_raw)))\n}\n"}], "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838"} {"nl": {"description": "One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks.According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blue one on the right foot.Every day Vasya puts on new socks in the morning and throws them away before going to bed as he doesn't want to wash them.Vasya wonders, what is the maximum number of days when he can dress fashionable and wear different socks, and after that, for how many days he can then wear the same socks until he either runs out of socks or cannot make a single pair from the socks he's got.Can you help him?", "input_spec": "The single line of the input contains two positive integers a and b (1 ≤ a, b ≤ 100) — the number of red and blue socks that Vasya's got.", "output_spec": "Print two space-separated integers — the maximum number of days when Vasya can wear different socks and the number of days when he can wear the same socks until he either runs out of socks or cannot make a single pair from the socks he's got. Keep in mind that at the end of the day Vasya throws away the socks that he's been wearing on that day.", "sample_inputs": ["3 1", "2 3", "7 3"], "sample_outputs": ["1 1", "2 0", "3 2"], "notes": "NoteIn the first sample Vasya can first put on one pair of different socks, after that he has two red socks left to wear on the second day."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"fmt\"\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()\n\tfmt.Printf(\"%d %d\", min(a, b), (a + b - 2 * min(a, b)) / 2)\n}\n\nfunc min(x, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc nextInt() int {\n\tin.Scan()\n\tres, _ := strconv.Atoi(in.Text())\n\treturn res\n}\n\nfunc next() string {\n\tin.Scan()\n\treturn in.Text()\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"bufio\"\n)\n\nfunc main(){\n\tvar r,b int\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in,&r,&b)\n\tmin,max := minmax(r,b)\n\tfmt.Println(min,(max-min)/2)\n}\nfunc minmax(a,b int)(int,int){\n\tif a b {\n\t\tprintln(b, (a-b)/2)\n\t} else {\n\t\tprintln(a, (b-a)/2)\n\t}\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n"}, {"source_code": "package main\n\nimport(\n \"fmt\"\n)\n\ntype u32 uint32\n\nfunc min(a,b *u32)u32{\n if *a>*b{\n return *b\n }\n return *a\n}\n\nfunc max(a,b *u32)u32{\n if *a>*b{\n return *a\n }\n return *b\n}\n\nfunc main(){\n var(\n a,b u32\n )\n fmt.Scan(&a,&b)\n fmt.Println(min(&a,&b),(max(&a,&b)-min(&a,&b))/2)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar a,b int\n\t_, _ = fmt.Scan(&a, &b)\n\ta, b = min(a,b), max(a, b)\n\tfmt.Println(a, (b - a) / 2)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar r, b int\n\tfmt.Scan(&r, &b)\n\n\tdif := min(r, b)\n\tsam := (max(r, b) - dif) / 2\n\n\tfmt.Println(dif, sam)\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc min(a, b int) int {\n if (a < b) {\n return a \n }\n return b \n}\n\nfunc main() {\n var a, b int\n fmt.Scanf(\"%d %d\", &a, &b)\n\n both := min(a, b)\n a -= both\n b -= both\n single := a/2 + b/2\n\n fmt.Println(both, single)\n}\n"}, {"source_code": "package main\n \nimport \"fmt\"\n\n\n\n\nfunc diff(red int,blue int) (val1 int,val2 int) {\nfor{\n if (red!=0)&&(blue!=0) {\n\t val1++\n\t\n }else{\n\t // fmt.Printf(\"the value of red and blue before being passed to same :%d %d\\n\",red,blue)\n if red>1 {\n\t val2=same(red)\n\t break\n }else if blue>1{\n\t val2=same(blue)\n\t break\n }else{\n\t break\n }\n \n}\nred--;blue--;\n}\nreturn\n}\n\nfunc main() {\n\tvar red,blue int\n\tfmt.Scan(&red)\n\tfmt.Scan(&blue)\n\tval1,val2:=diff(red,blue)\n\tfmt.Print(val1,val2)\n\t}\n\n\nfunc same(col int)(val2 int){\n\n\tfor{\n\t\t\n\t\tif col>1{\n\t\t\tval2++\n\t\t}else{\n\t\t\treturn\n\t\t}\n\t\tcol=col-2\n\t}\n\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar red, blue, min, max int\n\tfmt.Scanf(\"%d %d\", &red, &blue)\n\tif red < blue {\n\t\tmin = red\n\t\tmax = blue\n\t} else {\n\t\tmin = blue\n\t\tmax = red\n\t}\n\tfmt.Println(min, (max-min)/2)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scanf(\"%d %d \\n\", &a, &b)\n\tif a > b {\n\t\ta, b = b, a\n\t}\n\n\tfmt.Println(a, (b-a)/2)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReaderSize(os.Stdin, 1024*1024)\n\tline := readLine(reader)\n\tvar a, b int64 = 0, 0\n\tfmt.Sscanf(line, \"%d %d\", &a, &b)\n\tfmt.Println(min(a, b), abs(a-b)/2)\n}\n\nfunc readLine(reader *bufio.Reader) string {\n\tstr, _, err := reader.ReadLine()\n\tif err == io.EOF {\n\t\treturn \"\"\n\t}\n\n\treturn strings.TrimRight(string(str), \"\\r\\n\")\n}\n\nfunc min(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc abs(x int64) int64 {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n"}, {"source_code": "package main\n\nimport \"bufio\"\nimport \"os\"\nimport \"fmt\"\n\nfunc Read(s *bufio.Reader) string {\n line, _ := s.ReadString('\\n')\n return line\n}\n\nfunc Write(s *bufio.Writer, a ...interface{}) {\n fmt.Fprintln(s, a...)\n s.Flush()\n}\n\nfunc Max(a, b int) (int, int) {\n if b > a {\n b, a = a, b\n }\n return a, b\n}\n\nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n \n var a, b int\n line, _ := reader.ReadString(' ')\n fmt.Sscanln(line, &a)\n fmt.Sscanln(Read(reader), &b)\n\n a, b = Max(a, b)\n \n writer := bufio.NewWriter(os.Stdout)\n Write(writer, b, (a - b) / 2) \n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar red, blue int\n\tfmt.Scan(&red, &blue)\n\tvar array = []int{red, blue}\n\tsort.Ints(array)\n\tday1 := array[0]\n\tday2 := (array[1] - array[0]) / 2\n\tfmt.Println(day1, day2)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nvar r, b int\n\nfunc main() {\n\tfmt.Scan(&r, &b)\n\tif r > b {\n\t\tfmt.Println(b, \" \", (r-b)/2)\n\t} else {\n\t\tfmt.Println(r, \" \", (b-r)/2)\n\t}\n}\n"}, {"source_code": "package main\n \nimport \"fmt\"\n\nfunc sock1 (a int, b int) int {\n\tres1 := 0\n\tif a < b {\n\t\tres1 = a\n\t} else if a > b {\n\t\tres1 = b\n\t} else if b == a {\n\t\tres1 = a\n\t}\n\treturn res1\n}\nfunc sock2 (a int, b int) int {\n\tres2 := 0\n\tif a < b {\n\t\tres2 = (b-a)/2\n\t} else if a > b {\n\t\tres2 = (a-b)/2\n\t} else if b == a {\n\t\tres2 = 0\n\t}\n\treturn res2\n}\n \nfunc main() {\n\tvar a, b int\n\tfmt.Scan(&a, &b)\n\tfmt.Print(sock1(a, b), sock2(a, b))\n}"}, {"source_code": "package main\nimport (\n \"fmt\"\n)\nfunc min(c int, d int) int {\n if d > c {\n return c\n } else {\n return d\n }\n}\nfunc main() {\n var a, b int = 0, 0\n fmt.Scanf(\"%d%d\", &a, &b)\n var f int = min(a, b)\n var h int = (a + b - 2 * f) / 2\n fmt.Println(f, h)\n}"}, {"source_code": "package main\n \nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n \nfunc main() {\n\tvar a, b int\n\tfmt.Scan(&a, &b)\n\tsp := []int{a, b}\n\tsort.Ints(sp)\n\tk := sp[0]\n\tk2 := (sp[1] - sp[0]) / 2\n\tfmt.Println(k, k2)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scan(&a, &b)\n\n\tif a > b {\n\t\tfmt.Printf(\"%d \", b)\n\t\tfmt.Print((a - b) / 2)\n\t} else {\n\t\tfmt.Printf(\"%d \", a)\n\t\tfmt.Print((b - a) / 2)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader\n\nfunc init() {\n\tstdin := os.Stdin\n\t// stdin, _ = os.Open(\"1.in\")\n\treader = bufio.NewReaderSize(stdin, 1<<20)\n}\n\nvar a, b int\n\nfunc main() {\n\tfmt.Fscan(reader, &a, &b)\n\tif a > b {\n\t\ta, b = b, a\n\t}\n\tfmt.Println(a, (b-a)/2)\n}\n"}, {"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 a, b uint8\n\tfmt.Fscanf(in, \"%d %d\\n\", &a, &b)\n\tif a > b {\n\t\tfmt.Println(b, (a-b)/2)\n\n\t} else if a < b {\n\t\tfmt.Println(a, (b-a)/2)\n\t} else if a == b {\n\t\tfmt.Println(a, 0)\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scan(&a, &b)\n\tif a < b {\n\t\tfmt.Print(a, (b-a)/2)\n\t} else if a > b {\n\t\tfmt.Print(b, (a-b)/2)\n\t} else if b == a {\n\t\tfmt.Print(a, 0)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar a, b float64\n\tfmt.Scanf(\"%f %f\", &a, &b)\n\tfirstDay := math.Min(a, b)\n\tsecondDay := (math.Max(a, b) - firstDay) / 2\n\tfmt.Print(firstDay, \" \", int(secondDay))\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc max(a int, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar a, b int\n\n\tfmt.Scanf(\"%d %d\\n\", &a, &b)\n\n\tmax := max(a, b)\n\tmin := min(a, b)\n\n\tfmt.Printf(\"%d %d\", min, (max - min) / 2)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scan(&a, &b)\n\ts := []int{a, b}\n\tsort.Ints(s)\n\tm := s[0]\n\tm2 := (s[1] - s[0]) / 2\n\tfmt.Println(m, m2)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scanf(\"%d %d\", &a, &b)\n\tif a < b {\n\t\ta, b = b, a\n\t}\n\tfmt.Println(b, (a-b)/2)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scanf(\"%d %d\", &a, &b)\n\tdays := a\n\tif a > b {\n\t\tdays = b\n\t}\n\tfmt.Printf(\"%d %d\\n\", days, (a+b)/2-days)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\tscanner.Scan()\n\tab := scanner.Text()\n\tvar chList []int\n\tfor _, ch := range strings.Split(ab, \" \") {\n\t\tch, err := strconv.Atoi(ch)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tchList = append(chList, ch)\n\t}\n\ta, b := chList[0], chList[1]\n\tvar c int\n\tc = a - b\n\tif c < 0 {\n\t\tb, c, a = -c, a, 0\n\t\tb = b / 2\n\t\tfmt.Println(c, b)\n\t} else if c == 0 {\n\t\tc = a\n\t\tb = 0\n\t\tfmt.Println(c, b)\n\t} else {\n\t\ta, c, b = c, b, 0\n\t\ta = a / 2\n\t\tfmt.Println(c, a)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar red, blue, same, different int\n\n\tfmt.Scan(&red, &blue)\n\n\tif red > blue {\n\t\tdifferent = blue\n\t\tsame = (red - different) / 2\n\t} else {\n\t\tdifferent = red\n\t\tsame = (blue - different) / 2\n\t}\n\n\tfmt.Println(different, same)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scan(&a, &b)\n\tmas := []int{a, b}\n\tsort.Ints(mas)\n\tr := mas[0]\n\tr2 := (mas[1] - mas[0]) / 2\n\tfmt.Println(r, r2)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\n// https://codeforces.com/problemset/problem/581/A\n// A. Vasya the Hipster\n// time limit per test\n// 1 second\n// memory limit per test\n// 256 megabytes\n// input\n// standard input\n// output\n// standard output\n\n// One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks.\n\n// According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blue one on the right foot.\n\n// Every day Vasya puts on new socks in the morning and throws them away before going to bed as he doesn't want to wash them.\n\n// Vasya wonders, what is the maximum number of days when he can dress fashionable and wear different socks, and after that, for how many days he can then wear the same socks until he either runs out of socks or cannot make a single pair from the socks he's got.\n\n// Can you help him?\n// Input\n\n// The single line of the input contains two positive integers a and b (1 ≤ a, b ≤ 100) — the number of red and blue socks that Vasya's got.\n// Output\n\n// Print two space-separated integers — the maximum number of days when Vasya can wear different socks and the number of days when he can wear the same socks until he either runs out of socks or cannot make a single pair from the socks he's got.\n\n// Keep in mind that at the end of the day Vasya throws away the socks that he's been wearing on that day.\n\nfunc main() {\n\tvar a, b int\n\t_, _ = fmt.Scan(&a, &b)\n\n\thipsterDays := intMin(a, b)\n\n\ta -= hipsterDays\n\tb -= hipsterDays\n\n\tnonHipsterDays := (a + b) / 2\n\n\tfmt.Print(hipsterDays, nonHipsterDays)\n}\n\nfunc intMin(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n var a, b int\n fmt.Scanf(\"%d %d\", &a, &b)\n if a > b {\n a, b = b, a\n }\n fmt.Print(a, \" \")\n fmt.Println((b - a) / 2)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// https://codeforces.com/problemset/problem/581/A\n// комментарии к решению\n// Для того, чтобы определить кол-во дней, во время которых Вася\n// будет в разноцветных носках необходимо определить наименьшее\n// из двух представленных чисел.\n// Для того, чтобы определить кол-во дней, во время которых Вася\n// будет в одноцветных (оставшихся) носках необходимо оставшиеся\n// разбить на пары\nfunc taskSolution(n int, m int) string {\n\treturn fmt.Sprint(min(n, m), abs(n-m)/2)\n}\n\nfunc main() {\n\tvar n, m int\n\tif _, err := fmt.Scan(&n, &m); err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(taskSolution(n, m))\n}\n"}], "negative_code": [{"source_code": "// A. Vasya the Hipster\n/*\nOne day Vasya the Hipster decided to count how many socks he had. It turned out\nthat he had a red socks and b blue socks.\n\nAccording to the latest fashion, hipsters should wear the socks of different\ncolors: a red one on the left foot, a blue one on the right foot.\n\nEvery day Vasya puts on new socks in the morning and throws them away before\ngoing to bed as he doesn't want to wash them.\n\nVasya wonders, what is the maximum number of days when he can dress\nfashionable and wear different socks, and after that, for how many days he\ncan then wear the same socks until he either runs out of socks or cannot make\na single pair from the socks he's got.\n\nCan you help him?\n\nInput\nThe single line of the input contains two positive integers a and b\n(1 ≤ a, b ≤ 100) — the number of red and blue socks that Vasya's got.\n\nOutput\nPrint two space-separated integers — the maximum number of days when Vasya can\nwear different socks and the number of days when he can wear the same socks\nuntil he either runs out of socks or cannot make a single pair from the socks\nhe's got.\n\nKeep in mind that at the end of the day Vasya throws away the socks that he's\nbeen wearing on that day.\n\nExamples\nInput\n3 1\n\nOutput\n1 1\n\nInput\n2 3\n\nOutput\n2 0\n\nInput\n7 3\n\nOutput\n3 2\n\nNote\nIn the first sample Vasya can first put on one pair of different socks,\nafter that he has two red socks left to wear on the second day.\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\tinputArr := strings.Split(strings.TrimSpace(input), \" \")\n\ta, _ := strconv.Atoi(inputArr[0])\n\tb, _ := strconv.Atoi(inputArr[1])\n\n\to1, o2 := 0, 0\n\tif a < b {\n\t\to1 = a % b\n\t\to2 = (b - o1) / 2\n\t} else {\n\t\to1 = b % a\n\t\to2 = (a - o1) / 2\n\t}\n\tfmt.Printf(\"%v %v\", o1, o2)\n}\n"}, {"source_code": "package main\n \nimport \"fmt\"\n\n\n\n\nfunc diff(red int,blue int) (val1 int,val2 int) {\nfor{\n if (red!=0)&&(blue!=0) {\n\t val1++\n\t\n }else{\n\t // fmt.Printf(\"the value of red and blue before being passed to same :%d %d\\n\",red,blue)\n if red>1 {\n\t val2=same(red)\n\t break\n }else if blue>1{\n\t val2=same(blue)\n\t break\n }else{\n\t break\n }\n \n}\nred--;blue--;\n}\nreturn\n}\n\nfunc main() {\n\tvar red,blue int\n\tfmt.Scan(&red)\n\tfmt.Scan(&blue)\n\tval1,val2:=diff(red,blue)\n\tfmt.Print(val1,val2)\n\t}\n\n\nfunc same(col int)(val2 int){\n\n\tfor{\n\t\t\n\t\tif col>0 {\n\t\t\tval2++\n\t\t}else{\n\t\t\treturn\n\t\t}\n\t\tcol=col-2\n\t}\n\n}"}, {"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 a, b, c, d uint8\n\tc = 0\n\td = 0\n\tfmt.Fscanf(in, \"%d %d\\n\", &a, &b)\n\tfor i := b; i > 0 && a > 0; i-- {\n\t\ta--\n\t\tb--\n\t\tc++\n\t}\n\td = a / 2\n\tfmt.Println(c, d)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scan(&a, &b)\n\tif a < b {\n\t\tfmt.Print(a, b/2)\n\t} else if b < a {\n\t\tfmt.Print(b, a/2)\n\t} else if b == a {\n\t\tfmt.Print(a, 0)\n\t}\n}\n"}], "src_uid": "775766790e91e539c1cfaa5030e5b955"} {"nl": {"description": "Let's call a string good if and only if it consists of only two types of letters — 'a' and 'b' and every two consecutive letters are distinct. For example \"baba\" and \"aba\" are good strings and \"abb\" is a bad string.You have $$$a$$$ strings \"a\", $$$b$$$ strings \"b\" and $$$c$$$ strings \"ab\". You want to choose some subset of these strings and concatenate them in any arbitrarily order.What is the length of the longest good string you can obtain this way?", "input_spec": "The first line contains three positive integers $$$a$$$, $$$b$$$, $$$c$$$ ($$$1 \\leq a, b, c \\leq 10^9$$$) — the number of strings \"a\", \"b\" and \"ab\" respectively.", "output_spec": "Print a single number — the maximum possible length of the good string you can obtain.", "sample_inputs": ["1 1 1", "2 1 2", "3 5 2", "2 2 1", "1000000000 1000000000 1000000000"], "sample_outputs": ["4", "7", "11", "6", "4000000000"], "notes": "NoteIn the first example the optimal string is \"baba\".In the second example the optimal string is \"abababa\".In the third example the optimal string is \"bababababab\".In the fourth example the optimal string is \"ababab\"."}, "positive_code": [{"source_code": "// A. Another One Bites The Dust\n/*\nLet's call a string good if and only if it consists of only two types of letters — 'a' and 'b' and every two consecutive letters are distinct. For example \"baba\" and \"aba\" are good strings and \"abb\" is a bad string.\n\nYou have 𝑎 strings \"a\", 𝑏 strings \"b\" and 𝑐 strings \"ab\". You want to choose some subset of these strings and concatenate them in any arbitrarily order.\n\nWhat is the length of the longest good string you can obtain this way?\n\nInput\nThe first line contains three positive integers 𝑎, 𝑏, 𝑐 (1≤𝑎,𝑏,𝑐≤109) — the number of strings \"a\", \"b\" and \"ab\" respectively.\n\nOutput\nPrint a single number — the maximum possible length of the good string you can obtain.\n\nExamples\nInput\n1 1 1\n\nOutput\n4\n\nInput\n2 1 2\n\nOutput\n7\n\nInput\n3 5 2\n\nOutput\n11\n\nInput\n2 2 1\n\nOutput\n6\n\nInput\n1000000000 1000000000 1000000000\n\nOutput\n4000000000\n\nNote\nIn the first example the optimal string is \"baba\".\n\nIn the second example the optimal string is \"abababa\".\n\nIn the third example the optimal string is \"bababababab\".\n\nIn the fourth example the optimal string is \"ababab\".\n*/\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput, _ := reader.ReadString('\\n')\n\tarr := strings.Split(strings.TrimSpace(input), \" \")\n\ta, _ := strconv.ParseInt(arr[0], 10, 64)\n\tb, _ := strconv.ParseInt(arr[1], 10, 64)\n\tc, _ := strconv.ParseInt(arr[2], 10, 64)\n\n\ttotal := c * 2\n\tif a > b {\n\t\ttotal += (2 * b) + 1\n\t} else if a < b {\n\t\ttotal += (2 * a) + 1\n\t} else {\n\t\ttotal += 2 * a\n\t}\n\tfmt.Print(total)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\ta, b, c := int64(0), int64(0), int64(0)\n\tfmt.Fscanf(in, \"%d %d %d\\n\", &a, &b, &c)\n\tabs := min(a, b)\n\ta -= abs\n\tb -= abs\n\tans := int64(0)\n\tif a > 0 || b > 0 {\n\t\tans++\n\t}\n\tans += c*2 + abs*2\n\tfmt.Fprintf(out, \"%d\\n\", ans)\n\treturn\n}\n\nfunc min(a, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n"}, {"source_code": "package main\n \nimport (\n\t\"fmt\"\n)\n \nfunc queen(x int64, y int64, z int64) int64 {\n\tres := z * 2\n\tif x == y {\n\t\tres += x * 2\n\t\treturn res\n\t} else if x > y {\n\t\tres += y * 2 + 1\n\t\treturn res\n\t} else {\n\t\tres += x * 2 + 1\n\t\treturn res\n\t}\n}\n \nfunc main() {\n\tvar a int64\n\tvar b int64\n\tvar c int64\n\tfmt.Scan(&a, &b, &c)\n\tfmt.Println(queen(a, b, c))\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar reader = bufio.NewReader(os.Stdin)\n\nfunc main() {\n\tin := readString()\n\tparts := strings.Split(in, \" \")\n\ta := Atoi(parts[0])\n\tb := Atoi(parts[1])\n\tab := Atoi(parts[2])\n\n\taabb := Min(a, b)\n\tres := ab*2 + aabb*2\n\tif Abs(a-b) != 0 {\n\t\tres++\n\t}\n\tfmt.Println(res)\n}\n\nfunc readInteger() int64 {\n\ts, _, _ := reader.ReadLine()\n\tn, _ := strconv.ParseInt(string(s), 0, 64)\n\treturn n\n}\n\nfunc readString() string {\n\ts, _, _ := reader.ReadLine()\n\treturn string(s)\n}\n\nfunc Abs(x int64) int64 {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc Min(x, y int64) int64 {\n\tif x < y {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc Max(x, y int64) int64 {\n\tif x > y {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}\n\nfunc Atoi(s string) int64 {\n\ti, _ := strconv.ParseInt(s, 10, 64)\n\treturn i\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc solve(a, b, c uint64) uint64 {\n\tres := a\n\tif b < a {\n\t\tres = b\n\t}\n\n\tres += c\n\tres *= 2\n\n\tif a != b {\n\t\tres++\n\t}\n\n\treturn res\n}\n\nfunc main() {\n\tvar a, b, c uint64\n\n\tfmt.Scan(&a, &b, &c)\n\n\tres := solve(a, b, c)\n\tfmt.Println(res)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc solve(first int64, second int64, third int64) int64 {\n\tans := third * 2\n\tif first == second {\n\t\tans += first * 2\n\t\treturn ans\n\t} else if first > second {\n\t\tans += second * 2 + 1\n\t\treturn ans\n\t} else {\n\t\tans += first * 2 + 1\n\t\treturn ans\n\t}\n}\n\nfunc main() {\n\tvar a, b, c int64\n\tfmt.Scan(&a, &b, &c)\n\tfmt.Println(solve(a, b, c))\n}"}, {"source_code": "package main\nimport \"fmt\"\nfunc main() {\n\tvar a, b, c, res uint64\n\tfmt.Scan(&a, &b, &c)\n res = a\n\tif b < a {\n\t res = b\n\t}\n\tres = res + c\n\tres = res * 2\n\tif a != b {\n\t\tres++\n\t}\n\tfmt.Println(res)\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc fun(x int64, y int64, z int64) int64 {\n\tans := z * 2\n\tif x == y {\n\t\tans += x * 2\n\t\treturn ans\n\t} else if x > y {\n\t\tans += y * 2 + 1\n\t\treturn ans\n\t} else {\n\t\tans += x * 2 + 1\n\t\treturn ans\n\t}\n}\n\nfunc main() {\n\tvar a, b, c int64\n\tfmt.Scan(&a, &b, &c)\n\tfmt.Println(fun(a, b, c))\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tvar a , b ,c int\n\tfmt.Fscan(in,&a,&b,&c)\n\t//3 2\n\tvar total int64\n\ttotal = int64(min1(a,b) + c) * 2\n\tif(a != b){\n\t\ttotal += 1\n\t}\n\tfmt.Fprint(out,int64(total))\n\n\n\n\n\n\n}\nfunc min1(x1,x2 int) int {\n\tif(x1 < x2){\n\t\treturn x1\n\t}else{\n\t\treturn x2\n\t}\n}\n"}], "negative_code": [{"source_code": "// A. Another One Bites The Dust\n/*\nLet's call a string good if and only if it consists of only two types of letters — 'a' and 'b' and every two consecutive letters are distinct. For example \"baba\" and \"aba\" are good strings and \"abb\" is a bad string.\n\nYou have 𝑎 strings \"a\", 𝑏 strings \"b\" and 𝑐 strings \"ab\". You want to choose some subset of these strings and concatenate them in any arbitrarily order.\n\nWhat is the length of the longest good string you can obtain this way?\n\nInput\nThe first line contains three positive integers 𝑎, 𝑏, 𝑐 (1≤𝑎,𝑏,𝑐≤109) — the number of strings \"a\", \"b\" and \"ab\" respectively.\n\nOutput\nPrint a single number — the maximum possible length of the good string you can obtain.\n\nExamples\nInput\n1 1 1\n\nOutput\n4\n\nInput\n2 1 2\n\nOutput\n7\n\nInput\n3 5 2\n\nOutput\n11\n\nInput\n2 2 1\n\nOutput\n6\n\nInput\n1000000000 1000000000 1000000000\n\nOutput\n4000000000\n\nNote\nIn the first example the optimal string is \"baba\".\n\nIn the second example the optimal string is \"abababa\".\n\nIn the third example the optimal string is \"bababababab\".\n\nIn the fourth example the optimal string is \"ababab\".\n*/\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput, _ := reader.ReadString('\\n')\n\tarr := strings.Split(strings.TrimSpace(input), \" \")\n\ta, _ := strconv.Atoi(arr[0])\n\tb, _ := strconv.Atoi(arr[1])\n\tc, _ := strconv.Atoi(arr[2])\n\n\ttotal := c * 2\n\tif a > b {\n\t\ttotal += (2 * b) + 1\n\t} else if a < b {\n\t\ttotal += (2 * a) + 1\n\t} else {\n\t\ttotal += 2 * a\n\t}\n\tfmt.Print(total)\n}\n"}, {"source_code": "// A. Another One Bites The Dust\n/*\nLet's call a string good if and only if it consists of only two types of letters — 'a' and 'b' and every two consecutive letters are distinct. For example \"baba\" and \"aba\" are good strings and \"abb\" is a bad string.\n\nYou have 𝑎 strings \"a\", 𝑏 strings \"b\" and 𝑐 strings \"ab\". You want to choose some subset of these strings and concatenate them in any arbitrarily order.\n\nWhat is the length of the longest good string you can obtain this way?\n\nInput\nThe first line contains three positive integers 𝑎, 𝑏, 𝑐 (1≤𝑎,𝑏,𝑐≤109) — the number of strings \"a\", \"b\" and \"ab\" respectively.\n\nOutput\nPrint a single number — the maximum possible length of the good string you can obtain.\n\nExamples\nInput\n1 1 1\n\nOutput\n4\n\nInput\n2 1 2\n\nOutput\n7\n\nInput\n3 5 2\n\nOutput\n11\n\nInput\n2 2 1\n\nOutput\n6\n\nInput\n1000000000 1000000000 1000000000\n\nOutput\n4000000000\n\nNote\nIn the first example the optimal string is \"baba\".\n\nIn the second example the optimal string is \"abababa\".\n\nIn the third example the optimal string is \"bababababab\".\n\nIn the fourth example the optimal string is \"ababab\".\n*/\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput, _ := reader.ReadString('\\n')\n\tarr := strings.Split(strings.TrimSpace(input), \" \")\n\ta, _ := strconv.Atoi(arr[0])\n\tb, _ := strconv.Atoi(arr[1])\n\tc, _ := strconv.Atoi(arr[2])\n\n\ttotal := c * 2\n\tif a > b {\n\t\ttotal += 2*b + 1\n\t} else if a < b {\n\t\ttotal += 2*a + 1\n\t} else {\n\t\ttotal += 2 * a\n\t}\n\tfmt.Print(total)\n}\n"}, {"source_code": "package main\n \nimport (\n\t\"fmt\"\n)\n \nfunc queen(x int, y int, z int) int {\n\tres := z * 2\n\tif x == y {\n\t\tres += x * 2\n\t\treturn res\n\t} else if x > y {\n\t\tres += y * 2 + 1\n\t\treturn res\n\t} else {\n\t\tres += x * 2 + 1\n\t\treturn res\n\t}\n}\n \nfunc main() {\n\tvar a int\n\tvar b int\n\tvar c int\n\tfmt.Scan(&a, &b, &c)\n\tfmt.Println(queen(a, b, c))\n}"}, {"source_code": "package main\n \nimport (\n\t\"fmt\"\n)\n \nfunc queen(x int, y int, z int) int {\n\tres := z * 2\n\tif x == y {\n\t\tres += x * 2\n\t\treturn res\n\t} \n\tif x > y {\n\t\tres += y * 2 + 1\n\t\treturn res\n\t}\n\tif x < y {\n\t\tres += x * 2 + 1\n\t\treturn res\n\t} else {\n\t\treturn res\n\t}\n}\n \nfunc main() {\n\tvar a int\n\tvar b int\n\tvar c int\n\tfmt.Scan(&a, &b, &c)\n\tfmt.Println(queen(a, b, c))\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc solve(a, b, c uint64) uint64 {\n\tres := a\n\tif b < a {\n\t\tres = b\n\t}\n\n\treturn 2*res + 2*c\n}\n\nfunc main() {\n\tvar a, b, c uint64\n\n\tfmt.Scan(&a, &b, &c)\n\n\tres := solve(a, b, c)\n\tfmt.Println(res)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc solve(first int, second int, third int) int {\n\tans := third * 2\n\tif first == second {\n\t\tans += first * 2\n\t\treturn ans\n\t} else if first > second {\n\t\tans += second * 2 + 1\n\t\treturn ans\n\t} else {\n\t\tans += first * 2 + 1\n\t\treturn ans\n\t}\n}\n\nfunc main() {\n\tvar a, b, c int\n\tfmt.Scan(&a, &b, &c)\n\tfmt.Println(solve(a, b, c))\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc fun(x int, y int, z int) int {\n\tans := z * 2\n\tif x == y {\n\t\tans += x * 2\n\t\treturn ans\n\t} else if x > y {\n\t\tans += y * 2 + 1\n\t\treturn ans\n\t} else {\n\t\tans += x * 2 + 1\n\t\treturn ans\n\t}\n}\n\nfunc main() {\n\tvar a, b, c int\n\tfmt.Scan(&a, &b, &c)\n\tfmt.Println(fun(a, b, c))\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc fun(x int, y int, z int) int {\n\tans:=z * 2\n\tif x == y {\n\t\tans += x * 2\n\t\treturn ans\n\t} else if x > y {\n\t\tans += y * 2 + 1\n\t\treturn ans\n\t} else {\n\t\tans += x * 2 + 1\n\t\treturn ans\n\t}\n}\n\nfunc main() {\n\tvar a, b, c int\n\tfmt.Scan(&a, &b, &c)\n\tfmt.Println(fun(a, b, c))\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tvar a , b ,c int\n\tfmt.Fscan(in,&a,&b,&c)\n\t//3 2\n\ttotal := (min1(a,b) + c) * 2\n\tif(a != b){\n\t\ttotal += 1\n\t}\n\tfmt.Fprint(out,int64(total))\n\n\n\n\n\n\n}\nfunc min1(x1,x2 int) int {\n\tif(x1 < x2){\n\t\treturn x1\n\t}else{\n\t\treturn x2\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tvar a , b ,c int\n\tfmt.Fscan(in,&a,&b,&c)\n\t//3 2\n\ttotal := (min1(a,b) + c) * 2\n\tif(a != b){\n\t\ttotal += 1\n\t}\n\tfmt.Fprint(out,total)\n\n\n\n\n\n\n}\nfunc min1(x1,x2 int) int {\n\tif(x1 < x2){\n\t\treturn x1\n\t}else{\n\t\treturn x2\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tvar a , b ,c int\n\tfmt.Fscan(in,&a,&b,&c)\n\t//3 2\n\ttotal := min1(a,b) + c * 2\n\tif(a != b){\n\t\ttotal += 1\n\t}\n\tfmt.Fprint(out,total)\n\n\n\n\n\n\n}\nfunc min1(x1,x2 int) int {\n\tif(x1 < x2){\n\t\treturn x1\n\t}else{\n\t\treturn x2\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\tvar a , b ,c int\n\tfmt.Fscan(in,&a,&b,&c)\n\t//3 2\n\tfmt.Fprint(out,int64(a + b + c * 2))\n\n\n\n\n\n\n}\nfunc min1(x1,x2 int) int {\n\tif(x1 < x2){\n\t\treturn x1\n\t}else{\n\t\treturn x2\n\t}\n}\n"}], "src_uid": "609f131325c13213aedcf8d55fc3ed77"} {"nl": {"description": "Recently Vasya found a golden ticket — a sequence which consists of $$$n$$$ digits $$$a_1a_2\\dots a_n$$$. Vasya considers a ticket to be lucky if it can be divided into two or more non-intersecting segments with equal sums. For example, ticket $$$350178$$$ is lucky since it can be divided into three segments $$$350$$$, $$$17$$$ and $$$8$$$: $$$3+5+0=1+7=8$$$. Note that each digit of sequence should belong to exactly one segment.Help Vasya! Tell him if the golden ticket he found is lucky or not.", "input_spec": "The first line contains one integer $$$n$$$ ($$$2 \\le n \\le 100$$$) — the number of digits in the ticket. The second line contains $$$n$$$ digits $$$a_1 a_2 \\dots a_n$$$ ($$$0 \\le a_i \\le 9$$$) — the golden ticket. Digits are printed without spaces.", "output_spec": "If the golden ticket is lucky then print \"YES\", otherwise print \"NO\" (both case insensitive).", "sample_inputs": ["5\n73452", "4\n1248"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first example the ticket can be divided into $$$7$$$, $$$34$$$ and $$$52$$$: $$$7=3+4=5+2$$$.In the second example it is impossible to divide ticket into segments with equal sum."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tscanner.Scan()\n\tans := strings.Split(scanner.Text(), \"\")\n\n\ttotal := 0\n\tfor i := 0; i < len(ans)-1; i++ {\n\t\ta, _ := strconv.Atoi(ans[i])\n\t\ttotal += a\n\t\tif findGolden(total, ans[i+1:]) {\n\t\t\tfmt.Print(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Print(\"NO\")\n}\n\nfunc findGolden(cut int, rem []string) bool {\n\ttotal := 0\n\tfor i := 0; i < len(rem); i++ {\n\t\ta, _ := strconv.Atoi(rem[i])\n\n\t\ttotal += a\n\t\tif total > cut {\n\t\t\treturn false\n\t\t}\n\t\tif total == cut {\n\t\t\treturn i+1 == len(rem) || findGolden(cut, rem[i+1:]) || findGolden(0, rem[i+1:])\n\n\t\t}\n\t}\n\treturn false\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF1030C(_r io.Reader, out io.Writer) {\n\tvar n, s int\n\tvar a []byte\n\tFscan(bufio.NewReader(_r), &n, &a)\no:\n\tfor i, v := range a[:n-1] {\n\t\ts += int(v & 15)\n\t\tfor j := i + 1; j < n; {\n\t\t\ts2 := int(a[j] & 15)\n\t\t\tfor j++; j < n && (s2 < s || s2 == s && a[j] == '0'); j++ {\n\t\t\t\ts2 += int(a[j] & 15)\n\t\t\t}\n\t\t\tif s2 != s {\n\t\t\t\tcontinue o\n\t\t\t}\n\t\t}\n\t\tFprintln(out, \"YES\")\n\t\treturn\n\t}\n\tFprintln(out, \"NO\")\n}\n\nfunc main() { CF1030C(os.Stdin, os.Stdout) }\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tscanner.Scan()\n\tans := strings.Split(scanner.Text(), \"\")\n\n\ttotal := 0\n\tfor i := 0; i < len(ans)-1; i++ {\n\t\ta, _ := strconv.Atoi(ans[i])\n\t\ttotal += a\n\t\tif findGolden(total, ans[i+1:]) {\n\t\t\tfmt.Print(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Print(\"NO\")\n}\n\nfunc findGolden(cut int, rem []string) bool {\n\ttotal := 0\n\tfor i := 0; i < len(rem); i++ {\n\t\ta, _ := strconv.Atoi(rem[i])\n\n\t\ttotal += a\n\t\tif total > cut {\n\t\t\treturn false\n\t\t}\n\t\tif total == cut {\n\t\t\treturn i+1 == len(rem) || findGolden(cut, rem[i+1:])\n\n\t\t}\n\t}\n\treturn false\n}\n"}], "src_uid": "410296a01b97a0a39b6683569c84d56c"} {"nl": {"description": "Kolya got string s for his birthday, the string consists of small English letters. He immediately added k more characters to the right of the string.Then Borya came and said that the new string contained a tandem repeat of length l as a substring. How large could l be?See notes for definition of a tandem repeat.", "input_spec": "The first line contains s (1 ≤ |s| ≤ 200). This string contains only small English letters. The second line contains number k (1 ≤ k ≤ 200) — the number of the added characters.", "output_spec": "Print a single number — the maximum length of the tandem repeat that could have occurred in the new string.", "sample_inputs": ["aaba\n2", "aaabbbb\n2", "abracadabra\n10"], "sample_outputs": ["6", "6", "20"], "notes": "NoteA tandem repeat of length 2n is string s, where for any position i (1 ≤ i ≤ n) the following condition fulfills: si = si + n.In the first sample Kolya could obtain a string aabaab, in the second — aaabbbbbb, in the third — abracadabrabracadabra."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\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\ts, k := next(), nextInt()\n\n\tif k >= len(s) {\n\t\tprintln((len(s) + k) / 2 * 2) \n\t\treturn\n\t}\n\n\ts += strings.Repeat(\".\", k)\n\tresult := k * 2\n\t// length := 0\n\n\tfor i := 0; i < len(s); i++ {\n\t\tfor j := i + 1; j <= len(s); j++ {\n\t\t\tstr := s[i:j]\n\t\t\tif len(str) % 2 == 0 && len(str) > result && isTandemRepeat(str) {\n\t\t\t\tresult = len(str)\n\t\t\t\t// println(str, result)\n\t\t\t}\n\t\t}\n\t}\n\n\t// println(s, len(s))\n\tprintln(result)\n}\n\nfunc isTandemRepeat(s string) bool {\n\tif len(s) % 2 == 1 {\n\t\treturn false\n\t}\n\n\tfor i := 0; i < len(s) / 2; i++ {\n\t\tif s[i] != s[i + len(s) / 2] && s[i + len(s) / 2] != '.' {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt() int {\n\tn, err := strconv.Atoi(next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, err := strconv.ParseFloat(next(), 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}\n\nfunc println(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}\n\nfunc print(a ...interface{}) {\n\tfmt.Fprint(writer, a...)\n}\n\nfunc printf(format string, a ...interface{}) {\n\tfmt.Fprintf(writer, format, a...)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tline, _ := reader.ReadString('\\n')\n\n\ts := strings.TrimSpace(line)\n\tstringLength := len(s)\n\n\tline, _ = reader.ReadString('\\n')\n\tvar k int\n\n\tfmt.Sscanf(line, \"%d\", &k)\n\n\tnewString := make([]rune, stringLength+k)\n\tcopy(newString, []rune(s))\n\n\tbestRepeat := 0\n\tfor i := 0; i < stringLength+k; i++ {\n\t\tcurrentRepeat := 0\n\t\tfor currentRepeat <= (stringLength+k-i)/2 {\n\t\t\ttandemRepeat := true\n\t\t\tfor j := i; j < i+currentRepeat; j++ {\n\t\t\t\tif newString[j+currentRepeat] != newString[j] && newString[j+currentRepeat] != 0 {\n\t\t\t\t\ttandemRepeat = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif tandemRepeat && currentRepeat > bestRepeat {\n\t\t\t\tbestRepeat = currentRepeat\n\t\t\t}\n\t\t\tcurrentRepeat++\n\t\t}\n\t}\n\tfmt.Println(2*bestRepeat - 0)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tline, _ := reader.ReadString('\\n')\n\n\ts := strings.TrimSpace(line)\n\tstringLength := len(s)\n\n\tline, _ = reader.ReadString('\\n')\n\tvar k int\n\n\tfmt.Sscanf(line, \"%d\", &k)\n\n\tnewString := make([]rune, stringLength+k)\n\tcopy(newString, []rune(s))\n\n\tbestRepeat := 0\n\tfor i := 0; i < stringLength+k; i++ {\n\t\tfor currentRepeat := 0; currentRepeat <= (stringLength+k-i)/2; currentRepeat++ {\n\t\t\ttandemRepeat := true\n\t\t\tfor j := i; j < i+currentRepeat; j++ {\n\t\t\t\tif newString[j+currentRepeat] != newString[j] && newString[j+currentRepeat] != 0 {\n\t\t\t\t\ttandemRepeat = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif tandemRepeat && currentRepeat > bestRepeat {\n\t\t\t\tbestRepeat = currentRepeat\n\t\t\t}\n\n\t\t}\n\t}\n\tfmt.Println(2*bestRepeat - 0)\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc Judge(line *string, n, k, l int) bool {\n for i := 0; i <= n+k-l*2; i++ {\n var flag bool = true\n for j := 0; j < l; j++ {\n if i+j+l < n && (*line)[i+j] != (*line)[i+j+l] {\n flag = false\n break\n }\n }\n if flag {\n return true\n }\n }\n return false\n}\n\nfunc main() {\n var line string\n var k int\n fmt.Scan(&line, &k)\n var n int = len(line)\n var res int = 0\n for i := (n + k) / 2; i > 0; i-- {\n if Judge(&line, n, k, i) {\n res = i * 2\n break\n }\n }\n fmt.Println(res)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tsc := NewScanner(os.Stdin)\n\ts, _ := sc.NextLine()\n\tm := len(s)\n\tk, _ := sc.NextLong()\n\tn := m + int(k)\n\n\tisTandemRepeat := func(i, j int) bool {\n\t\tres := true\n\t\tfor k := 0; i+j+k < m && k < j; k++ {\n\t\t\tif s[i+k] != s[i+j+k] {\n\t\t\t\tres = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\treturn res\n\t}\n\tres := 0\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 1; i+2*j <= n; j++ {\n\t\t\tif isTandemRepeat(i, j) {\n\t\t\t\tres = maxInt(res, j)\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(res * 2)\n}\n\n////////////////////////////////////////////////////////////////\n//\n// gojus: retrieved from https://github.com/tnoda/gojus\n//\n\n// NewScanner returns a new Scanner to read from r.\nfunc NewScanner(rdr io.Reader) *Scanner {\n\tsc := Scanner{bufio.NewScanner(rdr), 10}\n\treturn &sc\n}\n\n// Errors returned by Scanner\nvar (\n\tErrNoSuchElement = errors.New(\"gojus.Scanner: input is exhausted.\")\n)\n\n// Scanner provides a similar interface to the java.util.Scaner's one.\ntype Scanner struct {\n\t*bufio.Scanner\n\tradix int\n}\n\n// Next scans and returns the next token of the input.\nfunc (sc *Scanner) Next() (string, error) {\n\tsc.Split(bufio.ScanWords)\n\tif !sc.Scan() {\n\t\treturn \"\", ErrNoSuchElement\n\t}\n\treturn sc.Text(), nil\n}\n\n// UseRadix sets the scanner's default radix to the specified one.\nfunc (sc *Scanner) UseRadix(radix int) *Scanner {\n\tsc.radix = radix\n\treturn sc\n}\n\nfunc (sc *Scanner) nextLong() (int64, error) {\n\tt, e := sc.Next()\n\tif e != nil {\n\t\treturn 0, e\n\t}\n\treturn strconv.ParseInt(t, sc.radix, 64)\n}\n\n// NextLong scans and returns the next token of the input as an int64.\nfunc (sc *Scanner) NextLong() (int64, error) {\n\treturn sc.nextLong()\n}\n\n// NextDouble scans and returns the next token of the input as a float64\nfunc (sc *Scanner) NextDouble() (float64, error) {\n\tt, e := sc.Next()\n\tif e != nil {\n\t\treturn 0, e\n\t}\n\treturn strconv.ParseFloat(t, 64)\n}\n\n// NextLine advances this scanner past the current line and returns\n// the input that was skipped.\nfunc (sc *Scanner) NextLine() (string, error) {\n\tsc.Split(bufio.ScanLines)\n\tif !sc.Scan() {\n\t\treturn \"\", ErrNoSuchElement\n\t}\n\treturn sc.Text(), nil\n}\n\n////////////////////////////////////////////////////////////////\n//\n// int/int64 utilities\n//\nfunc minInt(a, b int) int {\n\tif b < a {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc maxInt(a, b int) int {\n\tif b > a {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc absInt(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc minInt64(a, b int64) int64 {\n\tif b < a {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc maxInt64(a, b int64) int64 {\n\tif b > a {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc absInt64(x int64) int64 {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n"}, {"source_code": "// 443B\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc count(s *string, n, k, l int) bool {\n\tfor i := 0; i <= n+k-l*2; i++ {\n\t\tstat := true\n\t\tfor j := 0; j < l; j++ {\n\t\t\tif i+j+l < n && (*s)[i+j] != (*s)[i+j+l] {\n\t\t\t\tstat = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif stat {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc main() {\n\tvar s string\n\tvar k int\n\tfmt.Scan(&s, &k)\n\tn := len(s)\n\tans := 0\n\tfor i := (n + k) / 2; i > 0; i-- {\n\t\tif count(&s, n, k, i) {\n\t\t\tans = i * 2\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tline, _ := reader.ReadString('\\n')\n\n\ts := strings.TrimSpace(line)\n\tstringLength := len(s)\n\n\tline, _ = reader.ReadString('\\n')\n\tvar k int\n\n\tfmt.Sscanf(line, \"%d\", &k)\n\n\tnewString := make([]rune, stringLength+k)\n\tcopy(newString, []rune(s))\n\n\tbestRepeat := 0\n\tfor i := 0; i < stringLength+k; i++ {\n\t\tcurrentRepeat := 0\n\t\tfor i+currentRepeat < stringLength+k && currentRepeat <= (stringLength+k-i)/2 {\n\t\t\tif newString[i+currentRepeat] == newString[i] || newString[i+currentRepeat] == 0 {\n\t\t\t\tif currentRepeat > bestRepeat {\n\t\t\t\t\tbestRepeat = currentRepeat\n\t\t\t\t}\n\t\t\t}\n\t\t\tcurrentRepeat++\n\t\t}\n\t}\n\tfmt.Println(2 * (bestRepeat - 0))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tsc := NewScanner(os.Stdin)\n\ts, _ := sc.NextLine()\n\tm := len(s)\n\tk, _ := sc.NextLong()\n\tn := m + int(k)\n\n\tisTandemRepeat := func(i, j int) bool {\n\t\tres := true\n\t\tfor k := 0; i+2*k < m; k++ {\n\t\t\tif s[i+k] != s[i+2*k] {\n\t\t\t\tres = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\treturn res\n\t}\n\tres := 0\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 1; i+2*j <= n; j++ {\n\t\t\tif isTandemRepeat(i, j) {\n\t\t\t\tres = maxInt(res, j)\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(res * 2)\n}\n\n////////////////////////////////////////////////////////////////\n//\n// gojus: retrieved from https://github.com/tnoda/gojus\n//\n\n// NewScanner returns a new Scanner to read from r.\nfunc NewScanner(rdr io.Reader) *Scanner {\n\tsc := Scanner{bufio.NewScanner(rdr), 10}\n\treturn &sc\n}\n\n// Errors returned by Scanner\nvar (\n\tErrNoSuchElement = errors.New(\"gojus.Scanner: input is exhausted.\")\n)\n\n// Scanner provides a similar interface to the java.util.Scaner's one.\ntype Scanner struct {\n\t*bufio.Scanner\n\tradix int\n}\n\n// Next scans and returns the next token of the input.\nfunc (sc *Scanner) Next() (string, error) {\n\tsc.Split(bufio.ScanWords)\n\tif !sc.Scan() {\n\t\treturn \"\", ErrNoSuchElement\n\t}\n\treturn sc.Text(), nil\n}\n\n// UseRadix sets the scanner's default radix to the specified one.\nfunc (sc *Scanner) UseRadix(radix int) *Scanner {\n\tsc.radix = radix\n\treturn sc\n}\n\nfunc (sc *Scanner) nextLong() (int64, error) {\n\tt, e := sc.Next()\n\tif e != nil {\n\t\treturn 0, e\n\t}\n\treturn strconv.ParseInt(t, sc.radix, 64)\n}\n\n// NextLong scans and returns the next token of the input as an int64.\nfunc (sc *Scanner) NextLong() (int64, error) {\n\treturn sc.nextLong()\n}\n\n// NextDouble scans and returns the next token of the input as a float64\nfunc (sc *Scanner) NextDouble() (float64, error) {\n\tt, e := sc.Next()\n\tif e != nil {\n\t\treturn 0, e\n\t}\n\treturn strconv.ParseFloat(t, 64)\n}\n\n// NextLine advances this scanner past the current line and returns\n// the input that was skipped.\nfunc (sc *Scanner) NextLine() (string, error) {\n\tsc.Split(bufio.ScanLines)\n\tif !sc.Scan() {\n\t\treturn \"\", ErrNoSuchElement\n\t}\n\treturn sc.Text(), nil\n}\n\n////////////////////////////////////////////////////////////////\n//\n// int/int64 utilities\n//\nfunc minInt(a, b int) int {\n\tif b < a {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc maxInt(a, b int) int {\n\tif b > a {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc absInt(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n\nfunc minInt64(a, b int64) int64 {\n\tif b < a {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc maxInt64(a, b int64) int64 {\n\tif b > a {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc absInt64(x int64) int64 {\n\tif x < 0 {\n\t\treturn -x\n\t}\n\treturn x\n}\n"}, {"source_code": "// 443B\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar st string\n\tvar ans, i, j, k, n, length, flag, max int\n\tin := bufio.NewScanner(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tin.Split(bufio.ScanWords)\n\tin.Scan()\n\tst = in.Text()\n\tlength = len(st)\n\tfmt.Scan(&n)\n\tans = n + length\n\tmax = 0\n\tfor i = 0; i < ans; i++ {\n\t\tfor j = 0; i+2*j-1 < ans; j++ {\n\t\t\tflag = 0\n\t\t\tfor k = i; k < i+j; k++ {\n\t\t\t\tif k >= length || j+k >= length || st[k] == st[j+k] {\n\t\t\t\t\tcontinue\n\t\t\t\t} else {\n\t\t\t\t\tflag = 1\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif flag == 0 {\n\t\t\t\tif 2*j > max {\n\t\t\t\t\tmax = 2 * j\n\t\t\t\t}\n\t\t\t}\n\t\t\tmax = 2 * j\n\t\t}\n\t}\n\tfmt.Fprintln(out, max)\n\tout.Flush()\n}\n"}, {"source_code": "// 443B\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar st [500]string\n\tvar ans, i, j, k, n, length, flag, max int\n\tfmt.Scan(&st)\n\tlength = len(st)\n\tfmt.Scan(&n)\n\tans = n + length\n\tmax = 0\n\tfor i = 0; i < ans; i++ {\n\t\tfor j = 0; i+2*j-1 < ans; j++ {\t\t\t\nflag = 0\n\t\t\tfor k = i; k < i+j; k++ {\n\t\t\t\tif k >= length || j+k >= length || st[k] == st[j+k] {\n\t\t\t\t\tcontinue\n\t\t\t\t} else {\n\t\t\t\t\tflag = 1\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif flag == 0 {\n\t\t\t\tif 2*j > max {\n\t\t\t\t\tmax = 2 * j\n\t\t\t\t}\n\t\t\t}\n\t\t\tmax = 2 * j\n\t\t}\n\t}\n\tfmt.Println(max)\n}\n"}], "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab"} {"nl": {"description": "Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 109) of the equation:x = b·s(x)a + c,  where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits in the decimal representation of number x.The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem.", "input_spec": "The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000).", "output_spec": "Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 109.", "sample_inputs": ["3 2 8", "1 2 -18", "2 2 -1"], "sample_outputs": ["3\n10 2008 13726", "0", "4\n1 31 337 967"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc sum(x int64) int64 {\n\tres := int64(0)\n\tfor x > 0 {\n\t\tres += x % 10\n\t\tx /= 10\n\t}\n\treturn res\n}\n\nfunc main() {\n\tvar b, c int64\n\tvar a int\n\tfmt.Scan(&a, &b, &c)\n\tvar res []int\n\tfor s := int64(1); s <= 9*9; s++ {\n\t\tr := s\n\t\tfor i := 1; i < a; i++ {\n\t\t\tr *= s\n\t\t}\n\t\tr = b*r + c\n\t\tif sum(r) == s && r < 1000000000 {\n\t\t\tres = append(res, int(r))\n\t\t}\n\t}\n\n\tsort.Ints(res)\n\tfmt.Println(len(res))\n\tfor i, r := range res {\n\t\tfmt.Print(r)\n\t\tif i == len(res)-1 {\n\t\t\tfmt.Print(\"\\n\")\n\t\t} else {\n\t\t\tfmt.Print(\" \")\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n// x = b·s(x)^a + c\n\nfunc main() {\n\tconst max_x int64 = 1000000000\n\tconst max_digits int64 = 9\n\n\tvar a, b, c int64\n\tif _, err := fmt.Scanf(\"%d %d %d\\n\", &a, &b, &c); err != nil {\n\t\treturn\n\t}\n\n\tcnt := 0\n\tvar all_res []string\n\n\tfor i := int64(1); i <= 9*max_digits; i++ {\n\t\ty := b*power(i, a) + c\n\t\tif y < max_x && s(y) == i {\n\t\t\tcnt++\n\t\t\tall_res = append(all_res, strconv.FormatInt(y, 10))\n\t\t}\n\t}\n\n\tfmt.Println(cnt)\n\tfmt.Println(strings.Join(all_res, \" \"))\n}\n\nfunc s(x int64) int64 {\n\tres := int64(0)\n\tfor x > 0 {\n\t\tres += x % 10\n\t\tx /= 10\n\t}\n\treturn res\n}\n\nfunc power(sx, n int64) int64 {\n\tres := sx\n\tfor i := int64(1); i < n; i++ {\n\t\tres *= sx\n\t}\n\treturn res\n}\n"}, {"source_code": "package main\n\nimport \"bufio\"\nimport \"os\"\nimport \"fmt\"\nimport \"math\"\n\nfunc Read(s *bufio.Reader) string {\n line, _ := s.ReadString('\\n')\n return line\n}\n\nfunc Write(s *bufio.Writer, a ...interface{}) {\n fmt.Fprintln(s, a...)\n s.Flush()\n}\n\nfunc Sum(x int64) int64 {\n var result int64\n for x != 0 {\n result += int64(math.Mod(float64(x), 10.0))\n x = x / 10\n }\n\n return result\n}\n\nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n \n var a, b, c int64\n line, _ := reader.ReadString(' ')\n fmt.Sscanln(line, &a)\n line, _ = reader.ReadString(' ')\n fmt.Sscanln(line, &b)\n fmt.Sscanln(Read(reader), &c)\n\n writer := bufio.NewWriter(os.Stdout)\n // s(x) can be from 1 to 81\n var result []int64\n for i := 1; i <= 81; i++ {\n right := b * int64(math.Pow(float64(i), float64(a))) + c\n if right < 1000000000 {\n left := Sum(right)\n\n if left == int64(i) {\n result = append(result, right)\n } \n }\n }\n\n \n Write(writer, len(result))\n for i := range result {\n fmt.Fprint(writer, result[i]) \n fmt.Fprint(writer, \" \") \n }\n \n writer.Flush()\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc S(x int64) int64 {\n\tvar res int64 = 0\n\tfor x != 0 {\n\t\tres += x % 10\n\t\tx /= 10\n\t}\n\treturn res\n}\n\nfunc Pow(x, a int64) int64 {\n\tvar res int64 = 1\n\tfor i := 0; int64(i) < a; i++ {\n\t\tres *= x\n\t}\n\treturn res\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tvar a, b, c int64\n\tfmt.Fscan(reader, &a, &b, &c)\n\tvar num_res = 0\n\tvar res []int64 = make([]int64, 40)\n\tfor i := 1; i < 82; i++ {\n\t\tvar x int64 = b*Pow(int64(i), a) + c\n\t\tif x < 1000000000 && S(x) == int64(i) {\n\t\t\tres[num_res] = x\n\t\t\tnum_res++\n\t\t}\n\t}\n\tfmt.Fprintln(writer, num_res)\n\tfor i := 0; i < num_res; i++ {\n\t\tfmt.Fprintf(writer, \"%d \", res[i])\n\t}\n\tfmt.Fprintln(writer)\n\twriter.Flush()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc pow(x, y int) uint64 {\n\tvar ans uint64\n\tans = 1\n\tfor i := 0; i < y; i++ {\n\t\tans *= uint64(x)\n\t}\n\treturn ans\n}\n\nfunc calc_s(x uint64) uint64 {\n\tvar ans uint64\n\tans = 0\n\tfor x != 0 {\n\t\tans += x % 10\n\t\tx /= 10\n\t}\n\treturn ans\n}\n\nfunc main() {\n\tvar a, b, c int\n\tfmt.Scan(&a, &b, &c)\n\n\tans := make([]int, 81, 81)\n\ti := 0\n\tfor s := 1; s <= 81; s++ {\n\t\tvar x uint64\n\t\tx = uint64(b)*pow(s, a) + uint64(c)\n\t\tif x < uint64(1000000000) && uint64(s) == calc_s(x) {\n\t\t\tans[i] = int(x)\n\t\t\ti++\n\t\t}\n\t}\n\n\tfmt.Println(i)\n\tif i > 0 {\n\t\tfor j := 0; j < i; j++ {\n\t\t\tfmt.Print(ans[j], \" \")\n\t\t}\n\t\tfmt.Println()\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc sum(x int64) int64 {\n\tres := int64(0)\n\tfor x > 0 {\n\t\tres += x % 10\n\t\tx /= 10\n\t}\n\treturn res\n}\n\nfunc main() {\n\tvar b, c int64\n\tvar a int\n\tfmt.Scan(&a, &b, &c)\n\tvar res []int\n\tfor s := int64(1); s <= 9*9; s++ {\n\t\tr := s\n\t\tfor i := 1; i < a; i++ {\n\t\t\tr *= s\n\t\t}\n\t\tr = b*r + c\n\t\tif sum(r) == s {\n\t\t\tres = append(res, int(r))\n\t\t}\n\t}\n\n\tsort.Ints(res)\n\tfmt.Println(len(res))\n\tfor i, r := range res {\n\t\tfmt.Print(r)\n\t\tif i == len(res)-1 {\n\t\t\tfmt.Print(\"\\n\")\n\t\t} else {\n\t\t\tfmt.Print(\" \")\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n// x = b·s(x)^a + c\n\nfunc main() {\n\tconst max_digits int64 = 9\n\n\tvar a, b, c int64\n\tif _, err := fmt.Scanf(\"%d %d %d\\n\", &a, &b, &c); err != nil {\n\t\treturn\n\t}\n\n\tcnt := 0\n\tvar all_res []string\n\n\tfor i := int64(1); i < max_digits*max_digits; i++ {\n\t\ty := b*power(i, a) + c\n\t\tif s(y) == i {\n\t\t\tcnt++\n\t\t\tall_res = append(all_res, strconv.FormatInt(y, 10))\n\t\t}\n\t}\n\n\tfmt.Println(cnt)\n\tfmt.Println(strings.Join(all_res, \" \"))\n}\n\nfunc s(x int64) int64 {\n\tres := int64(0)\n\tfor x > 0 {\n\t\tres += x % 10\n\t\tx /= 10\n\t}\n\treturn res\n}\n\nfunc power(sx, n int64) int64 {\n\tres := sx\n\tfor i := int64(1); i < n; i++ {\n\t\tres *= sx\n\t}\n\treturn res\n}\n"}, {"source_code": "package main\n\nimport \"bufio\"\nimport \"os\"\nimport \"fmt\"\nimport \"math\"\n\nfunc Read(s *bufio.Reader) string {\n line, _ := s.ReadString('\\n')\n return line\n}\n\nfunc Write(s *bufio.Writer, a ...interface{}) {\n fmt.Fprintln(s, a...)\n s.Flush()\n}\n\nfunc Sum(x int) int {\n var result int\n for x != 0 {\n result += int(math.Mod(float64(x), 10.0))\n x = x / 10\n }\n\n return result\n}\n\nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n \n var a, b, c int\n line, _ := reader.ReadString(' ')\n fmt.Sscanln(line, &a)\n line, _ = reader.ReadString(' ')\n fmt.Sscanln(line, &b)\n fmt.Sscanln(Read(reader), &c)\n\n // s(x) can be from 1 to 81\n var result []int\n for i := 1; i <= 81; i++ {\n right := b * int(math.Pow(float64(i), float64(a))) + c\n left := Sum(right)\n\n if left == i {\n result = append(result, right)\n }\n }\n\n writer := bufio.NewWriter(os.Stdout)\n Write(writer, len(result))\n for i := range result {\n fmt.Fprint(writer, result[i]) \n fmt.Fprint(writer, \" \") \n }\n \n writer.Flush()\n}"}, {"source_code": "package main\n\nimport \"bufio\"\nimport \"os\"\nimport \"fmt\"\nimport \"math\"\n\nfunc Read(s *bufio.Reader) string {\n line, _ := s.ReadString('\\n')\n return line\n}\n\nfunc Write(s *bufio.Writer, a ...interface{}) {\n fmt.Fprintln(s, a...)\n s.Flush()\n}\n\nfunc Sum(x int) int {\n var result int\n for x != 0 {\n result += int(math.Mod(float64(x), 10.0))\n x = x / 10\n }\n\n return result\n}\n\nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n \n var a, b, c int\n line, _ := reader.ReadString(' ')\n fmt.Sscanln(line, &a)\n line, _ = reader.ReadString(' ')\n fmt.Sscanln(line, &b)\n fmt.Sscanln(Read(reader), &c)\n\n // s(x) can be from 1 to 81\n var result []int\n for i := 1; i <= 81; i++ {\n right := b * int(math.Pow(float64(i), float64(a))) + c\n if right < 1000000000 {\n left := Sum(right)\n\n if left == i {\n result = append(result, right)\n } \n }\n }\n\n writer := bufio.NewWriter(os.Stdout)\n Write(writer, len(result))\n for i := range result {\n fmt.Fprint(writer, result[i]) \n fmt.Fprint(writer, \" \") \n }\n \n writer.Flush()\n}"}, {"source_code": "package main\n\nimport \"bufio\"\nimport \"os\"\nimport \"fmt\"\nimport \"math\"\n\nfunc Read(s *bufio.Reader) string {\n line, _ := s.ReadString('\\n')\n return line\n}\n\nfunc Write(s *bufio.Writer, a ...interface{}) {\n fmt.Fprintln(s, a...)\n s.Flush()\n}\n\nfunc Sum(x int64) int64 {\n var result int64\n for x != 0 {\n result += int64(math.Mod(float64(x), 10.0))\n x = x / 10\n }\n\n return result\n}\n\nfunc main() {\n reader := bufio.NewReader(os.Stdin)\n \n var a, b, c int64\n line, _ := reader.ReadString(' ')\n fmt.Sscanln(line, &a)\n line, _ = reader.ReadString(' ')\n fmt.Sscanln(line, &b)\n fmt.Sscanln(Read(reader), &c)\n\n writer := bufio.NewWriter(os.Stdout)\n // s(x) can be from 1 to 81\n var result []int64\n for i := 1; i <= 81; i++ {\n right := b * int64(math.Pow(float64(i), float64(a))) + c\n if right < 1000000000 {\n left := Sum(right)\n\n if left == int64(i) {\n Write(writer, left, right)\n result = append(result, right)\n } \n }\n }\n\n \n Write(writer, len(result))\n for i := range result {\n fmt.Fprint(writer, result[i]) \n fmt.Fprint(writer, \" \") \n }\n \n writer.Flush()\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc S(x int64) int64 {\n\tvar res int64 = 0\n\tfor x != 0 {\n\t\tres += x % 10\n\t\tx /= 10\n\t}\n\treturn res\n}\n\nfunc Pow(x, a int64) int64 {\n\tvar res int64 = 1\n\tfor i := 0; int64(i) < a; i++ {\n\t\tres *= x\n\t}\n\treturn res\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tvar a, b, c int64\n\tfmt.Fscan(reader, &a, &b, &c)\n\tvar num_res = 0\n\tvar res []int64 = make([]int64, 40)\n\tfor i := 0; i < 40; i++ {\n\t\tvar x int64 = b*Pow(int64(i), a) + c\n\t\tif x < 1000000000 && S(x) == int64(i) {\n\t\t\tres[num_res] = x\n\t\t\tnum_res++\n\t\t}\n\t}\n\tfmt.Fprintln(writer, num_res)\n\tfor i := 0; i < num_res; i++ {\n\t\tfmt.Fprintf(writer, \"%d \", res[i])\n\t}\n\tfmt.Fprintln(writer)\n\twriter.Flush()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc S(x int64) int64 {\n\tvar res int64 = 0\n\tfor x != 0 {\n\t\tres += x % 10\n\t\tx /= 10\n\t}\n\treturn res\n}\n\nfunc Pow(x, a int64) int64 {\n\tvar res int64 = 1\n\tfor i := 0; int64(i) < a; i++ {\n\t\tres *= x\n\t}\n\treturn res\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tvar a, b, c int64\n\tfmt.Fscan(reader, &a, &b, &c)\n\tvar num_res = 0\n\tvar res []int64 = make([]int64, 40)\n\tfor i := 1; i < 40; i++ {\n\t\tvar x int64 = b*Pow(int64(i), a) + c\n\t\tif x < 1000000000 && S(x) == int64(i) {\n\t\t\tres[num_res] = x\n\t\t\tnum_res++\n\t\t}\n\t}\n\tfmt.Fprintln(writer, num_res)\n\tfor i := 0; i < num_res; i++ {\n\t\tfmt.Fprintf(writer, \"%d \", res[i])\n\t}\n\tfmt.Fprintln(writer)\n\twriter.Flush()\n}\n"}], "src_uid": "e477185b94f93006d7ae84c8f0817009"} {"nl": {"description": "Anadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For every $$$a$$$ and $$$b$$$ such that $$$1 \\leq a \\leq b \\leq 6$$$, there is exactly one domino with $$$a$$$ dots on one half and $$$b$$$ dots on the other half. The set contains exactly $$$21$$$ dominoes. Here is an exact illustration of his set: Also, Anadi has an undirected graph without self-loops and multiple edges. He wants to choose some dominoes and place them on the edges of this graph. He can use at most one domino of each type. Each edge can fit at most one domino. It's not necessary to place a domino on each edge of the graph.When placing a domino on an edge, he also chooses its direction. In other words, one half of any placed domino must be directed toward one of the endpoints of the edge and the other half must be directed toward the other endpoint. There's a catch: if there are multiple halves of dominoes directed toward the same vertex, each of these halves must contain the same number of dots.How many dominoes at most can Anadi place on the edges of his graph?", "input_spec": "The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\leq n \\leq 7$$$, $$$0 \\leq m \\leq \\frac{n\\cdot(n-1)}{2}$$$) — the number of vertices and the number of edges in the graph. The next $$$m$$$ lines contain two integers each. Integers in the $$$i$$$-th line are $$$a_i$$$ and $$$b_i$$$ ($$$1 \\leq a, b \\leq n$$$, $$$a \\neq b$$$) and denote that there is an edge which connects vertices $$$a_i$$$ and $$$b_i$$$. The graph might be disconnected. It's however guaranteed that the graph doesn't contain any self-loops, and that there is at most one edge between any pair of vertices.", "output_spec": "Output one integer which denotes the maximum number of dominoes which Anadi can place on the edges of the graph.", "sample_inputs": ["4 4\n1 2\n2 3\n3 4\n4 1", "7 0", "3 1\n1 3", "7 21\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n2 3\n2 4\n2 5\n2 6\n2 7\n3 4\n3 5\n3 6\n3 7\n4 5\n4 6\n4 7\n5 6\n5 7\n6 7"], "sample_outputs": ["4", "0", "1", "16"], "notes": "NoteHere is an illustration of Anadi's graph from the first sample test: And here is one of the ways to place a domino on each of its edges: Note that each vertex is faced by the halves of dominoes with the same number of dots. For instance, all halves directed toward vertex $$$1$$$ have three dots."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc init() {\n\tReadString = newReadString(os.Stdin)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc newReadString(ior io.Reader) func() string {\n\tr := bufio.NewScanner(ior)\n\t// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\t// Split sets the split function for the Scanner. The default split function is ScanLines.\n\t// Split panics if it is called after scanning has started.\n\tr.Split(bufio.ScanWords)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n/*********** DP sub-functions ***********/\n\n// ChMin accepts a pointer of integer and a target value.\n// If target value is SMALLER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMin(updatedValue *int, target int) bool {\n\tif *updatedValue > target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// ChMax accepts a pointer of integer and a target value.\n// If target value is LARGER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMax(updatedValue *int, target int) bool {\n\tif *updatedValue < target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// NthBit returns nth bit value of an argument.\n// n starts from 0.\nfunc NthBit(num, nth int) int {\n\treturn num >> uint(nth) & 1\n}\n\n// OnBit returns the integer that has nth ON bit.\n// If an argument has nth ON bit, OnBit returns the argument.\nfunc OnBit(num, nth int) int {\n\treturn num | (1 << uint(nth))\n}\n\n// OffBit returns the integer that has nth OFF bit.\n// If an argument has nth OFF bit, OffBit returns the argument.\nfunc OffBit(num, nth int) int {\n\treturn num & ^(1 << uint(nth))\n}\n\n// PopCount returns the number of ON bit of an argument.\nfunc PopCount(num int) int {\n\tres := 0\n\n\tfor i := 0; i < 70; i++ {\n\t\tif ((num >> uint(i)) & 1) == 1 {\n\t\t\tres++\n\t\t}\n\t}\n\n\treturn res\n}\n\n/*********** Arithmetic ***********/\n\n// Max returns the max integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Max(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m < integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// Min returns the min integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Min(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// DigitSum returns digit sum of a decimal number.\n// DigitSum only accept a positive integer.\nfunc DigitSum(n int) int {\n\tif n < 0 {\n\t\treturn -1\n\t}\n\n\tres := 0\n\n\tfor n > 0 {\n\t\tres += n % 10\n\t\tn /= 10\n\t}\n\n\treturn res\n}\n\n// DigitNumOfDecimal returns digits number of n.\n// n is non negative number.\nfunc DigitNumOfDecimal(n int) int {\n\tres := 0\n\n\tfor n > 0 {\n\t\tn /= 10\n\t\tres++\n\t}\n\n\treturn res\n}\n\n// Sum returns multiple integers sum.\nfunc Sum(integers ...int) int {\n\ts := 0\n\n\tfor _, i := range integers {\n\t\ts += i\n\t}\n\n\treturn s\n}\n\n// Kiriage returns Ceil(a/b)\n// a >= 0, b > 0\nfunc Kiriage(a, b int) int {\n\treturn (a + (b - 1)) / b\n}\n\n// PowInt is integer version of math.Pow\n// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).\nfunc PowInt(a, e int) int {\n\tif a < 0 || e < 0 {\n\t\tpanic(errors.New(\"[argument error]: PowInt does not accept negative integers\"))\n\t}\n\n\tif e == 0 {\n\t\treturn 1\n\t}\n\n\tif e%2 == 0 {\n\t\thalfE := e / 2\n\t\thalf := PowInt(a, halfE)\n\t\treturn half * half\n\t}\n\n\treturn a * PowInt(a, e-1)\n}\n\n// AbsInt is integer version of math.Abs\nfunc AbsInt(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// Gcd returns the Greatest Common Divisor of two natural numbers.\n// Gcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Gcd uses the Euclidean Algorithm.\nfunc Gcd(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\tif a < b {\n\t\ta, b = b, a\n\t}\n\n\t// Euclidean Algorithm\n\tfor b > 0 {\n\t\tdiv := a % b\n\t\ta, b = b, div\n\t}\n\n\treturn a\n}\n\n// Lcm returns the Least Common Multiple of two natural numbers.\n// Lcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Lcd uses the Euclidean Algorithm indirectly.\nfunc Lcm(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\n\t// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2\n\t// a' and b' are relatively prime numbers\n\t// gcd consists of prime numbers, that are included in a and b\n\tgcd := Gcd(a, b)\n\n\t// not (a * b / gcd), because of reducing a probability of overflow\n\treturn (a / gcd) * b\n}\n\n// Strtoi is a wrapper of `strconv.Atoi()`.\n// If `strconv.Atoi()` returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst MOD = 1000000000 + 7\nconst ALPHABET_NUM = 26\nconst INF_INT64 = math.MaxInt64\nconst INF_BIT60 = 1 << 60\n\nvar n, m int\n\nvar adjMatrix [10][10]int\nvar dominoMatrix [10][10]int\n\nfunc main() {\n\tn, m = ReadInt2()\n\tfor i := 0; i < m; i++ {\n\t\ta, b := ReadInt2()\n\t\t// 常にaをbより小さくする\n\t\tif a > b {\n\t\t\ta, b = b, a\n\t\t}\n\t\tadjMatrix[a][b] = 1\n\t\tadjMatrix[b][a] = 1\n\t}\n\n\tif n <= 6 {\n\t\tfmt.Println(m)\n\t} else {\n\t\tfmt.Println(sub())\n\t}\n}\n\nfunc sub() int {\n\tres := 0\n\n\t// i, jを同じ数字とする\n\tfor i := 1; i <= n; i++ {\n\t\tfor j := i + 1; j <= n; j++ {\n\t\t\t// ノードにサイコロの目を割り振る\n\t\t\tmemo := make(map[int]int)\n\t\t\tdice := 1\n\t\t\tfor k := 1; k <= n; k++ {\n\t\t\t\tif k == j {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tmemo[k] = dice\n\t\t\t\tdice++\n\t\t\t}\n\t\t\tmemo[j] = memo[i]\n\n\t\t\ttmp := 0\n\t\t\tinitialize()\n\t\t\tfor l := 1; l <= n; l++ {\n\t\t\t\tfor m := l + 1; m <= n; m++ {\n\t\t\t\t\tll, mm := memo[l], memo[m]\n\t\t\t\t\tif ll > mm {\n\t\t\t\t\t\tll, mm = mm, ll\n\t\t\t\t\t}\n\t\t\t\t\tif adjMatrix[l][m] == 1 && dominoMatrix[ll][mm] == 1 {\n\t\t\t\t\t\ttmp++\n\t\t\t\t\t\tdominoMatrix[ll][mm] = 0\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tChMax(&res, tmp)\n\t\t}\n\t}\n\n\treturn res\n}\n\nfunc initialize() {\n\tfor i := 1; i <= 6; i++ {\n\t\tdominoMatrix[i][i] = 1\n\t\tfor j := i + 1; j <= 6; j++ {\n\t\t\tdominoMatrix[i][j] = 1\n\t\t}\n\t}\n}\n\n// MODはとったか?\n// 遷移だけじゃなくて最後の最後でちゃんと取れよ?\n\n/*******************************************************************/\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc init() {\n\tReadString = newReadString(os.Stdin)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc newReadString(ior io.Reader) func() string {\n\tr := bufio.NewScanner(ior)\n\t// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\t// Split sets the split function for the Scanner. The default split function is ScanLines.\n\t// Split panics if it is called after scanning has started.\n\tr.Split(bufio.ScanWords)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n/*********** DP sub-functions ***********/\n\n// ChMin accepts a pointer of integer and a target value.\n// If target value is SMALLER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMin(updatedValue *int, target int) bool {\n\tif *updatedValue > target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// ChMax accepts a pointer of integer and a target value.\n// If target value is LARGER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMax(updatedValue *int, target int) bool {\n\tif *updatedValue < target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// NthBit returns nth bit value of an argument.\n// n starts from 0.\nfunc NthBit(num, nth int) int {\n\treturn num >> uint(nth) & 1\n}\n\n// OnBit returns the integer that has nth ON bit.\n// If an argument has nth ON bit, OnBit returns the argument.\nfunc OnBit(num, nth int) int {\n\treturn num | (1 << uint(nth))\n}\n\n// OffBit returns the integer that has nth OFF bit.\n// If an argument has nth OFF bit, OffBit returns the argument.\nfunc OffBit(num, nth int) int {\n\treturn num & ^(1 << uint(nth))\n}\n\n// PopCount returns the number of ON bit of an argument.\nfunc PopCount(num int) int {\n\tres := 0\n\n\tfor i := 0; i < 70; i++ {\n\t\tif ((num >> uint(i)) & 1) == 1 {\n\t\t\tres++\n\t\t}\n\t}\n\n\treturn res\n}\n\n/*********** Arithmetic ***********/\n\n// Max returns the max integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Max(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m < integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// Min returns the min integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Min(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// DigitSum returns digit sum of a decimal number.\n// DigitSum only accept a positive integer.\nfunc DigitSum(n int) int {\n\tif n < 0 {\n\t\treturn -1\n\t}\n\n\tres := 0\n\n\tfor n > 0 {\n\t\tres += n % 10\n\t\tn /= 10\n\t}\n\n\treturn res\n}\n\n// DigitNumOfDecimal returns digits number of n.\n// n is non negative number.\nfunc DigitNumOfDecimal(n int) int {\n\tres := 0\n\n\tfor n > 0 {\n\t\tn /= 10\n\t\tres++\n\t}\n\n\treturn res\n}\n\n// Sum returns multiple integers sum.\nfunc Sum(integers ...int) int {\n\ts := 0\n\n\tfor _, i := range integers {\n\t\ts += i\n\t}\n\n\treturn s\n}\n\n// Kiriage returns Ceil(a/b)\n// a >= 0, b > 0\nfunc Kiriage(a, b int) int {\n\treturn (a + (b - 1)) / b\n}\n\n// PowInt is integer version of math.Pow\n// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).\nfunc PowInt(a, e int) int {\n\tif a < 0 || e < 0 {\n\t\tpanic(errors.New(\"[argument error]: PowInt does not accept negative integers\"))\n\t}\n\n\tif e == 0 {\n\t\treturn 1\n\t}\n\n\tif e%2 == 0 {\n\t\thalfE := e / 2\n\t\thalf := PowInt(a, halfE)\n\t\treturn half * half\n\t}\n\n\treturn a * PowInt(a, e-1)\n}\n\n// AbsInt is integer version of math.Abs\nfunc AbsInt(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// Gcd returns the Greatest Common Divisor of two natural numbers.\n// Gcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Gcd uses the Euclidean Algorithm.\nfunc Gcd(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\tif a < b {\n\t\ta, b = b, a\n\t}\n\n\t// Euclidean Algorithm\n\tfor b > 0 {\n\t\tdiv := a % b\n\t\ta, b = b, div\n\t}\n\n\treturn a\n}\n\n// Lcm returns the Least Common Multiple of two natural numbers.\n// Lcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Lcd uses the Euclidean Algorithm indirectly.\nfunc Lcm(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\n\t// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2\n\t// a' and b' are relatively prime numbers\n\t// gcd consists of prime numbers, that are included in a and b\n\tgcd := Gcd(a, b)\n\n\t// not (a * b / gcd), because of reducing a probability of overflow\n\treturn (a / gcd) * b\n}\n\n// Strtoi is a wrapper of `strconv.Atoi()`.\n// If `strconv.Atoi()` returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\t// str := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst MOD = 1000000000 + 7\nconst ALPHABET_NUM = 26\nconst INF_INT64 = math.MaxInt64\nconst INF_BIT60 = 1 << 60\n\nvar n, m int\n\nvar ans int\nvar edges []Edge\n\ntype Edge struct {\n\ts, t int\n}\n\nfunc main() {\n\tn, m = ReadInt2()\n\tfor i := 0; i < m; i++ {\n\t\ts, t := ReadInt2()\n\t\ts--\n\t\tt--\n\t\tedges = append(edges, Edge{s, t})\n\t}\n\n\tv := []int{}\n\tdfs(v)\n\tfmt.Println(ans)\n}\n\nfunc dfs(v []int) {\n\tif len(v) == n {\n\t\tA := [6][6]int{}\n\t\tfor i := 0; i < 6; i++ {\n\t\t\tfor j := 0; j < 6; j++ {\n\t\t\t\tA[i][j] = 1\n\t\t\t}\n\t\t}\n\n\t\tcnt := 0\n\t\tfor _, e := range edges {\n\t\t\tl, r := v[e.s], v[e.t]\n\t\t\tif A[l][r] == 1 {\n\t\t\t\tA[l][r], A[r][l] = 0, 0\n\t\t\t\tcnt++\n\t\t\t}\n\t\t}\n\t\tChMax(&ans, cnt)\n\t} else {\n\t\tfor i := 0; i <= 5; i++ {\n\t\t\ttmp := CopySlice(v)\n\t\t\ttmp = append(tmp, i)\n\t\t\tdfs(tmp)\n\t\t}\n\t}\n}\n\nfunc CopySlice(v []int) []int {\n\tres := make([]int, len(v))\n\tfor i := 0; i < len(v); i++ {\n\t\tres[i] = v[i]\n\t}\n\treturn res\n}\n\n// MODはとったか?\n// 遷移だけじゃなくて最後の最後でちゃんと取れよ?\n\n/*******************************************************************/\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc init() {\n\tReadString = newReadString(os.Stdin)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc newReadString(ior io.Reader) func() string {\n\tr := bufio.NewScanner(ior)\n\t// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\t// Split sets the split function for the Scanner. The default split function is ScanLines.\n\t// Split panics if it is called after scanning has started.\n\tr.Split(bufio.ScanWords)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n/*********** DP sub-functions ***********/\n\n// ChMin accepts a pointer of integer and a target value.\n// If target value is SMALLER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMin(updatedValue *int, target int) bool {\n\tif *updatedValue > target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// ChMax accepts a pointer of integer and a target value.\n// If target value is LARGER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMax(updatedValue *int, target int) bool {\n\tif *updatedValue < target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// NthBit returns nth bit value of an argument.\n// n starts from 0.\nfunc NthBit(num, nth int) int {\n\treturn num >> uint(nth) & 1\n}\n\n// OnBit returns the integer that has nth ON bit.\n// If an argument has nth ON bit, OnBit returns the argument.\nfunc OnBit(num, nth int) int {\n\treturn num | (1 << uint(nth))\n}\n\n// OffBit returns the integer that has nth OFF bit.\n// If an argument has nth OFF bit, OffBit returns the argument.\nfunc OffBit(num, nth int) int {\n\treturn num & ^(1 << uint(nth))\n}\n\n// PopCount returns the number of ON bit of an argument.\nfunc PopCount(num int) int {\n\tres := 0\n\n\tfor i := 0; i < 70; i++ {\n\t\tif ((num >> uint(i)) & 1) == 1 {\n\t\t\tres++\n\t\t}\n\t}\n\n\treturn res\n}\n\n/*********** Arithmetic ***********/\n\n// Max returns the max integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Max(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m < integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// Min returns the min integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Min(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// DigitSum returns digit sum of a decimal number.\n// DigitSum only accept a positive integer.\nfunc DigitSum(n int) int {\n\tif n < 0 {\n\t\treturn -1\n\t}\n\n\tres := 0\n\n\tfor n > 0 {\n\t\tres += n % 10\n\t\tn /= 10\n\t}\n\n\treturn res\n}\n\n// DigitNumOfDecimal returns digits number of n.\n// n is non negative number.\nfunc DigitNumOfDecimal(n int) int {\n\tres := 0\n\n\tfor n > 0 {\n\t\tn /= 10\n\t\tres++\n\t}\n\n\treturn res\n}\n\n// Sum returns multiple integers sum.\nfunc Sum(integers ...int) int {\n\ts := 0\n\n\tfor _, i := range integers {\n\t\ts += i\n\t}\n\n\treturn s\n}\n\n// Kiriage returns Ceil(a/b)\n// a >= 0, b > 0\nfunc Kiriage(a, b int) int {\n\treturn (a + (b - 1)) / b\n}\n\n// PowInt is integer version of math.Pow\n// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).\nfunc PowInt(a, e int) int {\n\tif a < 0 || e < 0 {\n\t\tpanic(errors.New(\"[argument error]: PowInt does not accept negative integers\"))\n\t}\n\n\tif e == 0 {\n\t\treturn 1\n\t}\n\n\tif e%2 == 0 {\n\t\thalfE := e / 2\n\t\thalf := PowInt(a, halfE)\n\t\treturn half * half\n\t}\n\n\treturn a * PowInt(a, e-1)\n}\n\n// AbsInt is integer version of math.Abs\nfunc AbsInt(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// Gcd returns the Greatest Common Divisor of two natural numbers.\n// Gcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Gcd uses the Euclidean Algorithm.\nfunc Gcd(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\tif a < b {\n\t\ta, b = b, a\n\t}\n\n\t// Euclidean Algorithm\n\tfor b > 0 {\n\t\tdiv := a % b\n\t\ta, b = b, div\n\t}\n\n\treturn a\n}\n\n// Lcm returns the Least Common Multiple of two natural numbers.\n// Lcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Lcd uses the Euclidean Algorithm indirectly.\nfunc Lcm(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\n\t// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2\n\t// a' and b' are relatively prime numbers\n\t// gcd consists of prime numbers, that are included in a and b\n\tgcd := Gcd(a, b)\n\n\t// not (a * b / gcd), because of reducing a probability of overflow\n\treturn (a / gcd) * b\n}\n\n// Strtoi is a wrapper of `strconv.Atoi()`.\n// If `strconv.Atoi()` returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\t// str := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst MOD = 1000000000 + 7\nconst ALPHABET_NUM = 26\nconst INF_INT64 = math.MaxInt64\nconst INF_BIT60 = 1 << 60\n\nvar n, m int\n\nvar edges []Edge\n\ntype Edge struct {\n\ts, t int\n}\n\nfunc main() {\n\tn, m = ReadInt2()\n\tfor i := 0; i < m; i++ {\n\t\ts, t := ReadInt2()\n\t\ts--\n\t\tt--\n\t\tedges = append(edges, Edge{s, t})\n\t}\n\n\tans := 0\n\tpatterns := DuplicatePatterns([]int{0, 1, 2, 3, 4, 5}, n)\n\tfor _, p := range patterns {\n\t\tA := [6][6]int{}\n\t\tfor i := 0; i < 6; i++ {\n\t\t\tfor j := 0; j < 6; j++ {\n\t\t\t\tA[i][j] = 1\n\t\t\t}\n\t\t}\n\n\t\tcnt := 0\n\t\tfor _, e := range edges {\n\t\t\tl, r := p[e.s], p[e.t]\n\t\t\tif A[l][r] == 1 {\n\t\t\t\tA[l][r], A[r][l] = 0, 0\n\t\t\t\tcnt++\n\t\t\t}\n\t\t}\n\t\tChMax(&ans, cnt)\n\t}\n\n\tfmt.Println(ans)\n}\n\n// DuplicatePatterns returns all patterns of n^k of elems([]int).\nfunc DuplicatePatterns(elems []int, k int) [][]int {\n\treturn dupliRec([]int{}, elems, k)\n}\n\n// DFS function for DuplicatePatterns.\nfunc dupliRec(pattern, elems []int, k int) [][]int {\n\tif len(pattern) == k {\n\t\treturn [][]int{pattern}\n\t}\n\n\tres := [][]int{}\n\tfor _, e := range elems {\n\t\tnewPattern := make([]int, len(pattern))\n\t\tcopy(newPattern, pattern)\n\t\tnewPattern = append(newPattern, e)\n\n\t\tres = append(res, dupliRec(newPattern, elems, k)...)\n\t}\n\n\treturn res\n}\n\n// func dfs(v []int) {\n// \tif len(v) == n {\n// \t\tA := [6][6]int{}\n// \t\tfor i := 0; i < 6; i++ {\n// \t\t\tfor j := 0; j < 6; j++ {\n// \t\t\t\tA[i][j] = 1\n// \t\t\t}\n// \t\t}\n\n// \t\tcnt := 0\n// \t\tfor _, e := range edges {\n// \t\t\tl, r := v[e.s], v[e.t]\n// \t\t\tif A[l][r] == 1 {\n// \t\t\t\tA[l][r], A[r][l] = 0, 0\n// \t\t\t\tcnt++\n// \t\t\t}\n// \t\t}\n// \t\tChMax(&ans, cnt)\n// \t} else {\n// \t\tfor i := 0; i <= 5; i++ {\n// \t\t\ttmp := CopySlice(v)\n// \t\t\ttmp = append(tmp, i)\n// \t\t\tdfs(tmp)\n// \t\t}\n// \t}\n// }\n\n// func CopySlice(v []int) []int {\n// \tres := make([]int, len(v))\n// \tfor i := 0; i < len(v); i++ {\n// \t\tres[i] = v[i]\n// \t}\n// \treturn res\n// }\n\n// MODはとったか?\n// 遷移だけじゃなくて最後の最後でちゃんと取れよ?\n\n/*******************************************************************/\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc Sol1230C(reader io.Reader, writer io.Writer) {\n\tin := bufio.NewReader(reader)\n\tout := bufio.NewWriter(writer)\n\tdefer out.Flush()\n\n\tvar n, m int\n\tFscan(in, &n, &m)\n\tedges := make([][]int, n+1)\n\tshown := map[int]int{}\n\tfor i := 0; i < m; i++ {\n\t\tvar v, w int\n\t\tFscan(in, &v, &w)\n\t\tedges[v] = append(edges[v], w)\n\t\tedges[w] = append(edges[w], v)\n\t\tshown[v] = 1\n\t\tshown[w] = 1\n\t}\n\tif len(shown) <= 6 {\n\t\tFprintln(out, m)\n\t\treturn\n\t}\n\n\tans := 0\n\tfor v, e := range edges {\n\t\tif len(e) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tfor w, e2 := range edges {\n\t\t\tif w == v || len(e2) == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tdelta := 0\n\t\t\tfor _, u := range e2 {\n\t\t\t\tif u == v {\n\t\t\t\t\tdelta = 1\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tmp := map[int]int{}\n\t\t\tfor _, u := range append(e, e2...) {\n\t\t\t\tif u == v {\n\t\t\t\t\tu = w\n\t\t\t\t}\n\t\t\t\tmp[u] = 1\n\t\t\t}\n\t\t\tdelta = len(e) + len(e2) - delta - len(mp)\n\t\t\tif newAns := m - delta; newAns > ans {\n\t\t\t\tans = newAns\n\t\t\t}\n\t\t}\n\t}\n\tFprintln(out, ans)\n}\n\nfunc main() {\n\tSol1230C(os.Stdin, os.Stdout)\n}\n"}, {"source_code": "// Author: sighduck\n// URL: https://codeforces.com/contest/1230/problem/C\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\ntype Edge struct {\n\tA int\n\tB int\n}\n\nfunc createMatrix(n int, m int, edges []Edge) [][]bool {\n\tmatrix := make([][]bool, n)\n\tfor i := 0; i < n; i++ {\n\t\tmatrix[i] = make([]bool, n)\n\t}\n\tfor _, edge := range edges {\n\t\tmatrix[edge.A-1][edge.B-1] = true\n\t\tmatrix[edge.B-1][edge.A-1] = true\n\t}\n\treturn matrix\n}\n\nfunc Solve(n int, m int, edges []Edge) int {\n\tif n < 7 {\n\t\treturn m\n\t}\n\tmatrix := createMatrix(n, m, edges)\n\tminMutualNeighbors := n + 1\n\tfor i := 0; i < n; i++ {\n\t\tfor j := i + 1; j < n; j++ {\n\t\t\tmutualNeighbors := 0\n\t\t\tfor z := 0; z < n; z++ {\n\t\t\t\tif z != i && z != j && matrix[i][z] && matrix[j][z] {\n\t\t\t\t\tmutualNeighbors += 1\n\t\t\t\t}\n\t\t\t}\n\t\t\tif mutualNeighbors < minMutualNeighbors {\n\t\t\t\tminMutualNeighbors = mutualNeighbors\n\t\t\t}\n\t\t}\n\t}\n\treturn m - minMutualNeighbors\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n, m int\n\tfmt.Fscanf(reader, \"%d %d\\n\", &n, &m)\n\tedges := make([]Edge, m)\n\tfor i := 0; i < m; i++ {\n\t\tfmt.Fscanf(reader, \"%d %d\\n\", &edges[i].A, &edges[i].B)\n\t}\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(n, m, edges))\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc init() {\n\tReadString = newReadString(os.Stdin)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc newReadString(ior io.Reader) func() string {\n\tr := bufio.NewScanner(ior)\n\t// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\t// Split sets the split function for the Scanner. The default split function is ScanLines.\n\t// Split panics if it is called after scanning has started.\n\tr.Split(bufio.ScanWords)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n/*********** DP sub-functions ***********/\n\n// ChMin accepts a pointer of integer and a target value.\n// If target value is SMALLER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMin(updatedValue *int, target int) bool {\n\tif *updatedValue > target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// ChMax accepts a pointer of integer and a target value.\n// If target value is LARGER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMax(updatedValue *int, target int) bool {\n\tif *updatedValue < target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// NthBit returns nth bit value of an argument.\n// n starts from 0.\nfunc NthBit(num, nth int) int {\n\treturn num >> uint(nth) & 1\n}\n\n// OnBit returns the integer that has nth ON bit.\n// If an argument has nth ON bit, OnBit returns the argument.\nfunc OnBit(num, nth int) int {\n\treturn num | (1 << uint(nth))\n}\n\n// OffBit returns the integer that has nth OFF bit.\n// If an argument has nth OFF bit, OffBit returns the argument.\nfunc OffBit(num, nth int) int {\n\treturn num & ^(1 << uint(nth))\n}\n\n// PopCount returns the number of ON bit of an argument.\nfunc PopCount(num int) int {\n\tres := 0\n\n\tfor i := 0; i < 70; i++ {\n\t\tif ((num >> uint(i)) & 1) == 1 {\n\t\t\tres++\n\t\t}\n\t}\n\n\treturn res\n}\n\n/*********** Arithmetic ***********/\n\n// Max returns the max integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Max(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m < integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// Min returns the min integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Min(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// DigitSum returns digit sum of a decimal number.\n// DigitSum only accept a positive integer.\nfunc DigitSum(n int) int {\n\tif n < 0 {\n\t\treturn -1\n\t}\n\n\tres := 0\n\n\tfor n > 0 {\n\t\tres += n % 10\n\t\tn /= 10\n\t}\n\n\treturn res\n}\n\n// DigitNumOfDecimal returns digits number of n.\n// n is non negative number.\nfunc DigitNumOfDecimal(n int) int {\n\tres := 0\n\n\tfor n > 0 {\n\t\tn /= 10\n\t\tres++\n\t}\n\n\treturn res\n}\n\n// Sum returns multiple integers sum.\nfunc Sum(integers ...int) int {\n\ts := 0\n\n\tfor _, i := range integers {\n\t\ts += i\n\t}\n\n\treturn s\n}\n\n// Kiriage returns Ceil(a/b)\n// a >= 0, b > 0\nfunc Kiriage(a, b int) int {\n\treturn (a + (b - 1)) / b\n}\n\n// PowInt is integer version of math.Pow\n// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).\nfunc PowInt(a, e int) int {\n\tif a < 0 || e < 0 {\n\t\tpanic(errors.New(\"[argument error]: PowInt does not accept negative integers\"))\n\t}\n\n\tif e == 0 {\n\t\treturn 1\n\t}\n\n\tif e%2 == 0 {\n\t\thalfE := e / 2\n\t\thalf := PowInt(a, halfE)\n\t\treturn half * half\n\t}\n\n\treturn a * PowInt(a, e-1)\n}\n\n// AbsInt is integer version of math.Abs\nfunc AbsInt(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// Gcd returns the Greatest Common Divisor of two natural numbers.\n// Gcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Gcd uses the Euclidean Algorithm.\nfunc Gcd(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\tif a < b {\n\t\ta, b = b, a\n\t}\n\n\t// Euclidean Algorithm\n\tfor b > 0 {\n\t\tdiv := a % b\n\t\ta, b = b, div\n\t}\n\n\treturn a\n}\n\n// Lcm returns the Least Common Multiple of two natural numbers.\n// Lcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Lcd uses the Euclidean Algorithm indirectly.\nfunc Lcm(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\n\t// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2\n\t// a' and b' are relatively prime numbers\n\t// gcd consists of prime numbers, that are included in a and b\n\tgcd := Gcd(a, b)\n\n\t// not (a * b / gcd), because of reducing a probability of overflow\n\treturn (a / gcd) * b\n}\n\n// Strtoi is a wrapper of `strconv.Atoi()`.\n// If `strconv.Atoi()` returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst MOD = 1000000000 + 7\nconst ALPHABET_NUM = 26\nconst INF_INT64 = math.MaxInt64\nconst INF_BIT60 = 1 << 60\n\nvar n, m int\n\nvar adjMatrix [10][10]int\nvar dominoMatrix [10][10]int\n\nfunc main() {\n\tn, m = ReadInt2()\n\tfor i := 0; i < m; i++ {\n\t\ta, b := ReadInt2()\n\t\t// 常にaをbより小さくする\n\t\tif a > b {\n\t\t\ta, b = b, a\n\t\t}\n\t\tadjMatrix[a][b] = 1\n\t\tadjMatrix[b][a] = 1\n\t}\n\n\tif n <= 6 {\n\t\tfmt.Println(m)\n\t} else {\n\t\tfmt.Println(sub())\n\t}\n}\n\nfunc sub() int {\n\tres := 0\n\n\t// i, jを同じ数字とする\n\tfor i := 1; i <= n; i++ {\n\t\tfor j := i + 1; j <= n; j++ {\n\t\t\t// ノードにサイコロの目を割り振る\n\t\t\tmemo := make(map[int]int)\n\t\t\tdice := 1\n\t\t\tfor k := 1; k <= n; k++ {\n\t\t\t\tif k == j {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tmemo[k] = dice\n\t\t\t\tdice++\n\t\t\t}\n\t\t\tmemo[j] = memo[i]\n\n\t\t\ttmp := 0\n\t\t\tinitialize()\n\t\t\tfor l := 1; l <= n; l++ {\n\t\t\t\tfor m := l + 1; m <= n; m++ {\n\t\t\t\t\tll, mm := memo[l], memo[m]\n\t\t\t\t\tif adjMatrix[l][m] == 1 && dominoMatrix[ll][mm] == 1 {\n\t\t\t\t\t\ttmp++\n\t\t\t\t\t\tdominoMatrix[ll][mm] = 0\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tChMax(&res, tmp)\n\t\t}\n\t}\n\n\treturn res\n}\n\nfunc initialize() {\n\tfor i := 1; i <= 6; i++ {\n\t\tdominoMatrix[i][i] = 1\n\t\tfor j := i + 1; j <= 6; j++ {\n\t\t\tdominoMatrix[i][j] = 1\n\t\t}\n\t}\n}\n\n// MODはとったか?\n// 遷移だけじゃなくて最後の最後でちゃんと取れよ?\n\n/*******************************************************************/\n"}, {"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\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// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n/*********** DP sub-functions ***********/\n\n// ChMin accepts a pointer of integer and a target value.\n// If target value is SMALLER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMin(updatedValue *int, target int) bool {\n\tif *updatedValue > target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// ChMax accepts a pointer of integer and a target value.\n// If target value is LARGER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMax(updatedValue *int, target int) bool {\n\tif *updatedValue < target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// NthBit returns nth bit value of an argument.\n// n starts from 0.\nfunc NthBit(num, nth int) int {\n\treturn num >> uint(nth) & 1\n}\n\n// OnBit returns the integer that has nth ON bit.\n// If an argument has nth ON bit, OnBit returns the argument.\nfunc OnBit(num, nth int) int {\n\treturn num | (1 << uint(nth))\n}\n\n// OffBit returns the integer that has nth OFF bit.\n// If an argument has nth OFF bit, OffBit returns the argument.\nfunc OffBit(num, nth int) int {\n\treturn num & ^(1 << uint(nth))\n}\n\n// PopCount returns the number of ON bit of an argument.\nfunc PopCount(num int) int {\n\tres := 0\n\n\tfor i := 0; i < 70; i++ {\n\t\tif ((num >> uint(i)) & 1) == 1 {\n\t\t\tres++\n\t\t}\n\t}\n\n\treturn res\n}\n\n/*********** Arithmetic ***********/\n\n// Max returns the max integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Max(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m < integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// Min returns the min integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Min(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// DigitSum returns digit sum of a decimal number.\n// DigitSum only accept a positive integer.\nfunc DigitSum(n int) int {\n\tif n < 0 {\n\t\treturn -1\n\t}\n\n\tres := 0\n\n\tfor n > 0 {\n\t\tres += n % 10\n\t\tn /= 10\n\t}\n\n\treturn res\n}\n\n// DigitNumOfDecimal returns digits number of n.\n// n is non negative number.\nfunc DigitNumOfDecimal(n int) int {\n\tres := 0\n\n\tfor n > 0 {\n\t\tn /= 10\n\t\tres++\n\t}\n\n\treturn res\n}\n\n// Sum returns multiple integers sum.\nfunc Sum(integers ...int) int {\n\ts := 0\n\n\tfor _, i := range integers {\n\t\ts += i\n\t}\n\n\treturn s\n}\n\n// Kiriage returns Ceil(a/b)\n// a >= 0, b > 0\nfunc Kiriage(a, b int) int {\n\treturn (a + (b - 1)) / b\n}\n\n// PowInt is integer version of math.Pow\n// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).\nfunc PowInt(a, e int) int {\n\tif a < 0 || e < 0 {\n\t\tpanic(errors.New(\"[argument error]: PowInt does not accept negative integers\"))\n\t}\n\n\tif e == 0 {\n\t\treturn 1\n\t}\n\n\tif e%2 == 0 {\n\t\thalfE := e / 2\n\t\thalf := PowInt(a, halfE)\n\t\treturn half * half\n\t}\n\n\treturn a * PowInt(a, e-1)\n}\n\n// AbsInt is integer version of math.Abs\nfunc AbsInt(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// Gcd returns the Greatest Common Divisor of two natural numbers.\n// Gcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Gcd uses the Euclidean Algorithm.\nfunc Gcd(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\tif a < b {\n\t\ta, b = b, a\n\t}\n\n\t// Euclidean Algorithm\n\tfor b > 0 {\n\t\tdiv := a % b\n\t\ta, b = b, div\n\t}\n\n\treturn a\n}\n\n// Lcm returns the Least Common Multiple of two natural numbers.\n// Lcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Lcd uses the Euclidean Algorithm indirectly.\nfunc Lcm(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\n\t// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2\n\t// a' and b' are relatively prime numbers\n\t// gcd consists of prime numbers, that are included in a and b\n\tgcd := Gcd(a, b)\n\n\t// not (a * b / gcd), because of reducing a probability of overflow\n\treturn (a / gcd) * b\n}\n\n// Strtoi is a wrapper of `strconv.Atoi()`.\n// If `strconv.Atoi()` returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst MOD = 1000000000 + 7\nconst ALPHABET_NUM = 26\nconst INF_INT64 = math.MaxInt64\nconst INF_BIT60 = 1 << 60\n\nvar n, m int\n\nvar adjMatrix [10][10]int\nvar dominoMatrix [7][7]int\n\nfunc main() {\n\tn, m = ReadInt2()\n\tfor i := 0; i < m; i++ {\n\t\ta, b := ReadInt2()\n\t\t// 常にaをbより小さくする\n\t\tif a > b {\n\t\t\ta, b = b, a\n\t\t}\n\t\tadjMatrix[a][b] = 1\n\t\tadjMatrix[b][a] = 1\n\t}\n\t// for i := 1; i <= n; i++ {\n\t// \tfmt.Println(adjMatrix[i])\n\t// }\n\t// initialize()\n\t// for i := 1; i <= 6; i++ {\n\t// \tfmt.Println(dominoMatrix[i])\n\t// }\n\n\tif n == 7 {\n\t\tans := 0\n\t\tfor i := 1; i <= n; i++ {\n\t\t\tinitialize()\n\t\t\ttmp := sub(i)\n\t\t\tChMax(&ans, tmp)\n\t\t}\n\t\tfmt.Println(ans)\n\t} else {\n\t\tfmt.Println(subsub())\n\t}\n}\n\nfunc subsub() int {\n\tres := 0\n\tfor i := 1; i <= n; i++ {\n\t\tfor j := i + 1; j <= n; j++ {\n\t\t\tif adjMatrix[i][j] == 1 {\n\t\t\t\tres++\n\t\t\t}\n\t\t}\n\t}\n\treturn res\n}\n\n// sevenId を 7としたときの置けるドミノの数\nfunc sub(sevenId int) int {\n\tres := 0\n\n\t// memo: ノードIDからドミノの数へのマップ\n\tmemo := make(map[int]int)\n\tdominoNum := 1\n\tfor i := 1; i <= n; i++ {\n\t\tif i == sevenId {\n\t\t\tcontinue\n\t\t}\n\t\tmemo[i] = dominoNum\n\t\tdominoNum++\n\t}\n\tmemo[sevenId] = dominoNum\n\t// memoの逆引き\n\trevMemo := make(map[int]int)\n\tfor k, v := range memo {\n\t\trevMemo[v] = k\n\t}\n\n\t// sevenId以外のノードについて、割り当てられたドミノ数に基づいてドミノをおいていく\n\tfor i := 1; i <= n; i++ {\n\t\tfor j := i + 1; j <= n; j++ {\n\t\t\t// i, jは通常のノード番号\n\t\t\tif i == sevenId || j == sevenId {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif adjMatrix[i][j] == 1 {\n\t\t\t\tres++\n\n\t\t\t\t// i, jをドミノ数に変換\n\t\t\t\t// diのほうを常に小さく\n\t\t\t\tdi := memo[i]\n\t\t\t\tdj := memo[j]\n\t\t\t\tif di > dj {\n\t\t\t\t\tdi, dj = dj, di\n\t\t\t\t}\n\t\t\t\tdominoMatrix[di][dj] = 0 // ドミノを消費\n\t\t\t}\n\t\t}\n\t}\n\n\t// i: sevenId のドミノ数をiとする\n\tresres := 0\n\tfor i := 1; i <= 6; i++ {\n\t\tdi := i\n\t\ttmpRes := 0\n\n\t\t// 他方のノードすべてを調べる\n\t\tfor j := 1; j <= 6; j++ {\n\t\t\tdj := j\n\t\t\tni, nj := sevenId, revMemo[dj]\n\t\t\tif di > dj {\n\t\t\t\tdi, dj = dj, di\n\t\t\t}\n\n\t\t\t// ドミノが未使用かつエッジがアレばドミノを設置できる\n\t\t\tif dominoMatrix[di][dj] == 1 && adjMatrix[ni][nj] == 1 {\n\t\t\t\ttmpRes++\n\t\t\t}\n\t\t}\n\n\t\tChMax(&resres, tmpRes)\n\t}\n\n\treturn res + resres\n}\n\nfunc initialize() {\n\tfor i := 1; i <= 6; i++ {\n\t\tfor j := i; j <= 6; j++ {\n\t\t\tdominoMatrix[i][j] = 1\n\t\t}\n\t}\n}\n\n// MODはとったか?\n// 遷移だけじゃなくて最後の最後でちゃんと取れよ?\n\n/*******************************************************************/\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc init() {\n\tReadString = newReadString(os.Stdin)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc newReadString(ior io.Reader) func() string {\n\tr := bufio.NewScanner(ior)\n\t// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\t// Split sets the split function for the Scanner. The default split function is ScanLines.\n\t// Split panics if it is called after scanning has started.\n\tr.Split(bufio.ScanWords)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n/*********** DP sub-functions ***********/\n\n// ChMin accepts a pointer of integer and a target value.\n// If target value is SMALLER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMin(updatedValue *int, target int) bool {\n\tif *updatedValue > target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// ChMax accepts a pointer of integer and a target value.\n// If target value is LARGER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMax(updatedValue *int, target int) bool {\n\tif *updatedValue < target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// NthBit returns nth bit value of an argument.\n// n starts from 0.\nfunc NthBit(num, nth int) int {\n\treturn num >> uint(nth) & 1\n}\n\n// OnBit returns the integer that has nth ON bit.\n// If an argument has nth ON bit, OnBit returns the argument.\nfunc OnBit(num, nth int) int {\n\treturn num | (1 << uint(nth))\n}\n\n// OffBit returns the integer that has nth OFF bit.\n// If an argument has nth OFF bit, OffBit returns the argument.\nfunc OffBit(num, nth int) int {\n\treturn num & ^(1 << uint(nth))\n}\n\n// PopCount returns the number of ON bit of an argument.\nfunc PopCount(num int) int {\n\tres := 0\n\n\tfor i := 0; i < 70; i++ {\n\t\tif ((num >> uint(i)) & 1) == 1 {\n\t\t\tres++\n\t\t}\n\t}\n\n\treturn res\n}\n\n/*********** Arithmetic ***********/\n\n// Max returns the max integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Max(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m < integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// Min returns the min integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Min(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// DigitSum returns digit sum of a decimal number.\n// DigitSum only accept a positive integer.\nfunc DigitSum(n int) int {\n\tif n < 0 {\n\t\treturn -1\n\t}\n\n\tres := 0\n\n\tfor n > 0 {\n\t\tres += n % 10\n\t\tn /= 10\n\t}\n\n\treturn res\n}\n\n// DigitNumOfDecimal returns digits number of n.\n// n is non negative number.\nfunc DigitNumOfDecimal(n int) int {\n\tres := 0\n\n\tfor n > 0 {\n\t\tn /= 10\n\t\tres++\n\t}\n\n\treturn res\n}\n\n// Sum returns multiple integers sum.\nfunc Sum(integers ...int) int {\n\ts := 0\n\n\tfor _, i := range integers {\n\t\ts += i\n\t}\n\n\treturn s\n}\n\n// Kiriage returns Ceil(a/b)\n// a >= 0, b > 0\nfunc Kiriage(a, b int) int {\n\treturn (a + (b - 1)) / b\n}\n\n// PowInt is integer version of math.Pow\n// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).\nfunc PowInt(a, e int) int {\n\tif a < 0 || e < 0 {\n\t\tpanic(errors.New(\"[argument error]: PowInt does not accept negative integers\"))\n\t}\n\n\tif e == 0 {\n\t\treturn 1\n\t}\n\n\tif e%2 == 0 {\n\t\thalfE := e / 2\n\t\thalf := PowInt(a, halfE)\n\t\treturn half * half\n\t}\n\n\treturn a * PowInt(a, e-1)\n}\n\n// AbsInt is integer version of math.Abs\nfunc AbsInt(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// Gcd returns the Greatest Common Divisor of two natural numbers.\n// Gcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Gcd uses the Euclidean Algorithm.\nfunc Gcd(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\tif a < b {\n\t\ta, b = b, a\n\t}\n\n\t// Euclidean Algorithm\n\tfor b > 0 {\n\t\tdiv := a % b\n\t\ta, b = b, div\n\t}\n\n\treturn a\n}\n\n// Lcm returns the Least Common Multiple of two natural numbers.\n// Lcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Lcd uses the Euclidean Algorithm indirectly.\nfunc Lcm(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\n\t// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2\n\t// a' and b' are relatively prime numbers\n\t// gcd consists of prime numbers, that are included in a and b\n\tgcd := Gcd(a, b)\n\n\t// not (a * b / gcd), because of reducing a probability of overflow\n\treturn (a / gcd) * b\n}\n\n// Strtoi is a wrapper of `strconv.Atoi()`.\n// If `strconv.Atoi()` returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst MOD = 1000000000 + 7\nconst ALPHABET_NUM = 26\nconst INF_INT64 = math.MaxInt64\nconst INF_BIT60 = 1 << 60\n\nvar n, m int\n\nvar adjMatrix [10][10]int\nvar dominoMatrix [7][7]int\n\nfunc main() {\n\tn, m = ReadInt2()\n\tfor i := 0; i < m; i++ {\n\t\ta, b := ReadInt2()\n\t\t// 常にaをbより小さくする\n\t\tif a > b {\n\t\t\ta, b = b, a\n\t\t}\n\t\tadjMatrix[a][b] = 1\n\t\tadjMatrix[b][a] = 1\n\t}\n\n\tif n <= 6 {\n\t\tfmt.Println(m)\n\t} else {\n\t\tfmt.Println(sub())\n\t}\n}\n\nfunc sub() int {\n\tres := 0\n\n\t// i, jを同じ数字とする\n\tfor i := 1; i <= n; i++ {\n\t\tfor j := i + 1; j <= n; j++ {\n\t\t\t// j は除外して置けるドミノの数をカウントし、最後にi, jに辺があれば一つ加算する\n\t\t\ttmp := 0\n\t\t\tfor l := 1; l <= n; l++ {\n\t\t\t\tfor m := l + 1; m <= n; m++ {\n\t\t\t\t\tif l == j || m == j {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tif adjMatrix[l][m] == 1 {\n\t\t\t\t\t\ttmp++\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif adjMatrix[i][j] == 1 {\n\t\t\t\ttmp++\n\t\t\t}\n\n\t\t\tChMax(&res, tmp)\n\t\t}\n\t}\n\n\treturn res\n}\n\n// MODはとったか?\n// 遷移だけじゃなくて最後の最後でちゃんと取れよ?\n\n/*******************************************************************/\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc init() {\n\tReadString = newReadString(os.Stdin)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nfunc newReadString(ior io.Reader) func() string {\n\tr := bufio.NewScanner(ior)\n\t// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\t// Split sets the split function for the Scanner. The default split function is ScanLines.\n\t// Split panics if it is called after scanning has started.\n\tr.Split(bufio.ScanWords)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n/*********** DP sub-functions ***********/\n\n// ChMin accepts a pointer of integer and a target value.\n// If target value is SMALLER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMin(updatedValue *int, target int) bool {\n\tif *updatedValue > target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// ChMax accepts a pointer of integer and a target value.\n// If target value is LARGER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMax(updatedValue *int, target int) bool {\n\tif *updatedValue < target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// NthBit returns nth bit value of an argument.\n// n starts from 0.\nfunc NthBit(num, nth int) int {\n\treturn num >> uint(nth) & 1\n}\n\n// OnBit returns the integer that has nth ON bit.\n// If an argument has nth ON bit, OnBit returns the argument.\nfunc OnBit(num, nth int) int {\n\treturn num | (1 << uint(nth))\n}\n\n// OffBit returns the integer that has nth OFF bit.\n// If an argument has nth OFF bit, OffBit returns the argument.\nfunc OffBit(num, nth int) int {\n\treturn num & ^(1 << uint(nth))\n}\n\n// PopCount returns the number of ON bit of an argument.\nfunc PopCount(num int) int {\n\tres := 0\n\n\tfor i := 0; i < 70; i++ {\n\t\tif ((num >> uint(i)) & 1) == 1 {\n\t\t\tres++\n\t\t}\n\t}\n\n\treturn res\n}\n\n/*********** Arithmetic ***********/\n\n// Max returns the max integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Max(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m < integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// Min returns the min integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Min(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// DigitSum returns digit sum of a decimal number.\n// DigitSum only accept a positive integer.\nfunc DigitSum(n int) int {\n\tif n < 0 {\n\t\treturn -1\n\t}\n\n\tres := 0\n\n\tfor n > 0 {\n\t\tres += n % 10\n\t\tn /= 10\n\t}\n\n\treturn res\n}\n\n// DigitNumOfDecimal returns digits number of n.\n// n is non negative number.\nfunc DigitNumOfDecimal(n int) int {\n\tres := 0\n\n\tfor n > 0 {\n\t\tn /= 10\n\t\tres++\n\t}\n\n\treturn res\n}\n\n// Sum returns multiple integers sum.\nfunc Sum(integers ...int) int {\n\ts := 0\n\n\tfor _, i := range integers {\n\t\ts += i\n\t}\n\n\treturn s\n}\n\n// Kiriage returns Ceil(a/b)\n// a >= 0, b > 0\nfunc Kiriage(a, b int) int {\n\treturn (a + (b - 1)) / b\n}\n\n// PowInt is integer version of math.Pow\n// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).\nfunc PowInt(a, e int) int {\n\tif a < 0 || e < 0 {\n\t\tpanic(errors.New(\"[argument error]: PowInt does not accept negative integers\"))\n\t}\n\n\tif e == 0 {\n\t\treturn 1\n\t}\n\n\tif e%2 == 0 {\n\t\thalfE := e / 2\n\t\thalf := PowInt(a, halfE)\n\t\treturn half * half\n\t}\n\n\treturn a * PowInt(a, e-1)\n}\n\n// AbsInt is integer version of math.Abs\nfunc AbsInt(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// Gcd returns the Greatest Common Divisor of two natural numbers.\n// Gcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Gcd uses the Euclidean Algorithm.\nfunc Gcd(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\tif a < b {\n\t\ta, b = b, a\n\t}\n\n\t// Euclidean Algorithm\n\tfor b > 0 {\n\t\tdiv := a % b\n\t\ta, b = b, div\n\t}\n\n\treturn a\n}\n\n// Lcm returns the Least Common Multiple of two natural numbers.\n// Lcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Lcd uses the Euclidean Algorithm indirectly.\nfunc Lcm(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\n\t// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2\n\t// a' and b' are relatively prime numbers\n\t// gcd consists of prime numbers, that are included in a and b\n\tgcd := Gcd(a, b)\n\n\t// not (a * b / gcd), because of reducing a probability of overflow\n\treturn (a / gcd) * b\n}\n\n// Strtoi is a wrapper of `strconv.Atoi()`.\n// If `strconv.Atoi()` returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst MOD = 1000000000 + 7\nconst ALPHABET_NUM = 26\nconst INF_INT64 = math.MaxInt64\nconst INF_BIT60 = 1 << 60\n\nvar n, m int\n\nvar adjMatrix [10][10]int\nvar dominoMatrix [10][10]int\n\nfunc main() {\n\tn, m = ReadInt2()\n\tfor i := 0; i < m; i++ {\n\t\ta, b := ReadInt2()\n\t\t// 常にaをbより小さくする\n\t\tif a > b {\n\t\t\ta, b = b, a\n\t\t}\n\t\tadjMatrix[a][b] = 1\n\t\tadjMatrix[b][a] = 1\n\t}\n\n\tif n <= 6 {\n\t\tfmt.Println(m)\n\t} else {\n\t\tfmt.Println(sub())\n\t}\n}\n\nfunc sub() int {\n\tres := 0\n\n\t// i, jを同じ数字とする\n\tfor i := 1; i <= n; i++ {\n\t\tfor j := i + 1; j <= n; j++ {\n\t\t\tmemo := make(map[int]int)\n\t\t\tdice := 1\n\t\t\tfor k := 1; k <= n; k++ {\n\t\t\t\tif k == j {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tmemo[k] = dice\n\t\t\t\tdice++\n\t\t\t}\n\t\t\tmemo[j] = memo[i]\n\n\t\t\ttmp := 0\n\t\t\tinitialize()\n\t\t\tfor l := 1; l <= n; l++ {\n\t\t\t\tfor m := l + 1; m <= n; m++ {\n\t\t\t\t\tll, mm := memo[l], memo[m]\n\t\t\t\t\tif adjMatrix[l][m] == 1 && dominoMatrix[ll][mm] == 1 {\n\t\t\t\t\t\ttmp++\n\t\t\t\t\t\tdominoMatrix[ll][mm] = 0\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif adjMatrix[i][j] == 1 {\n\t\t\t\ttmp++\n\t\t\t}\n\n\t\t\tChMax(&res, tmp)\n\t\t}\n\t}\n\n\treturn res\n}\n\nfunc initialize() {\n\tfor i := 1; i <= 6; i++ {\n\t\tfor j := i + 1; j <= 6; j++ {\n\t\t\tdominoMatrix[i][j] = 1\n\t\t}\n\t}\n}\n\n// MODはとったか?\n// 遷移だけじゃなくて最後の最後でちゃんと取れよ?\n\n/*******************************************************************/\n"}, {"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\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// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n/*********** DP sub-functions ***********/\n\n// ChMin accepts a pointer of integer and a target value.\n// If target value is SMALLER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMin(updatedValue *int, target int) bool {\n\tif *updatedValue > target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// ChMax accepts a pointer of integer and a target value.\n// If target value is LARGER than the first argument,\n//\tthen the first argument will be updated by the second argument.\nfunc ChMax(updatedValue *int, target int) bool {\n\tif *updatedValue < target {\n\t\t*updatedValue = target\n\t\treturn true\n\t}\n\treturn false\n}\n\n// NthBit returns nth bit value of an argument.\n// n starts from 0.\nfunc NthBit(num, nth int) int {\n\treturn num >> uint(nth) & 1\n}\n\n// OnBit returns the integer that has nth ON bit.\n// If an argument has nth ON bit, OnBit returns the argument.\nfunc OnBit(num, nth int) int {\n\treturn num | (1 << uint(nth))\n}\n\n// OffBit returns the integer that has nth OFF bit.\n// If an argument has nth OFF bit, OffBit returns the argument.\nfunc OffBit(num, nth int) int {\n\treturn num & ^(1 << uint(nth))\n}\n\n// PopCount returns the number of ON bit of an argument.\nfunc PopCount(num int) int {\n\tres := 0\n\n\tfor i := 0; i < 70; i++ {\n\t\tif ((num >> uint(i)) & 1) == 1 {\n\t\t\tres++\n\t\t}\n\t}\n\n\treturn res\n}\n\n/*********** Arithmetic ***********/\n\n// Max returns the max integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Max(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m < integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// Min returns the min integer among input set.\n// This function needs at least 1 argument (no argument causes panic).\nfunc Min(integers ...int) int {\n\tm := integers[0]\n\tfor i, integer := range integers {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif m > integer {\n\t\t\tm = integer\n\t\t}\n\t}\n\treturn m\n}\n\n// DigitSum returns digit sum of a decimal number.\n// DigitSum only accept a positive integer.\nfunc DigitSum(n int) int {\n\tif n < 0 {\n\t\treturn -1\n\t}\n\n\tres := 0\n\n\tfor n > 0 {\n\t\tres += n % 10\n\t\tn /= 10\n\t}\n\n\treturn res\n}\n\n// DigitNumOfDecimal returns digits number of n.\n// n is non negative number.\nfunc DigitNumOfDecimal(n int) int {\n\tres := 0\n\n\tfor n > 0 {\n\t\tn /= 10\n\t\tres++\n\t}\n\n\treturn res\n}\n\n// Sum returns multiple integers sum.\nfunc Sum(integers ...int) int {\n\ts := 0\n\n\tfor _, i := range integers {\n\t\ts += i\n\t}\n\n\treturn s\n}\n\n// Kiriage returns Ceil(a/b)\n// a >= 0, b > 0\nfunc Kiriage(a, b int) int {\n\treturn (a + (b - 1)) / b\n}\n\n// PowInt is integer version of math.Pow\n// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).\nfunc PowInt(a, e int) int {\n\tif a < 0 || e < 0 {\n\t\tpanic(errors.New(\"[argument error]: PowInt does not accept negative integers\"))\n\t}\n\n\tif e == 0 {\n\t\treturn 1\n\t}\n\n\tif e%2 == 0 {\n\t\thalfE := e / 2\n\t\thalf := PowInt(a, halfE)\n\t\treturn half * half\n\t}\n\n\treturn a * PowInt(a, e-1)\n}\n\n// AbsInt is integer version of math.Abs\nfunc AbsInt(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\n// Gcd returns the Greatest Common Divisor of two natural numbers.\n// Gcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Gcd uses the Euclidean Algorithm.\nfunc Gcd(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\tif a < b {\n\t\ta, b = b, a\n\t}\n\n\t// Euclidean Algorithm\n\tfor b > 0 {\n\t\tdiv := a % b\n\t\ta, b = b, div\n\t}\n\n\treturn a\n}\n\n// Lcm returns the Least Common Multiple of two natural numbers.\n// Lcd only accepts two natural numbers (a, b >= 1).\n// 0 or negative number causes panic.\n// Lcd uses the Euclidean Algorithm indirectly.\nfunc Lcm(a, b int) int {\n\tif a <= 0 || b <= 0 {\n\t\tpanic(errors.New(\"[argument error]: Gcd only accepts two NATURAL numbers\"))\n\t}\n\n\t// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2\n\t// a' and b' are relatively prime numbers\n\t// gcd consists of prime numbers, that are included in a and b\n\tgcd := Gcd(a, b)\n\n\t// not (a * b / gcd), because of reducing a probability of overflow\n\treturn (a / gcd) * b\n}\n\n// Strtoi is a wrapper of `strconv.Atoi()`.\n// If `strconv.Atoi()` returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst MOD = 1000000000 + 7\nconst ALPHABET_NUM = 26\nconst INF_INT64 = math.MaxInt64\nconst INF_BIT60 = 1 << 60\n\nvar n, m int\n\nvar adjMatrix [10][10]int\nvar dominoMatrix [7][7]int\n\nfunc main() {\n\tn, m = ReadInt2()\n\tfor i := 0; i < m; i++ {\n\t\ta, b := ReadInt2()\n\t\t// 常にaをbより小さくする\n\t\tif a > b {\n\t\t\ta, b = b, a\n\t\t}\n\t\tadjMatrix[a][b] = 1\n\t\tadjMatrix[b][a] = 1\n\t}\n\t// for i := 1; i <= n; i++ {\n\t// \tfmt.Println(adjMatrix[i])\n\t// }\n\t// initialize()\n\t// for i := 1; i <= 6; i++ {\n\t// \tfmt.Println(dominoMatrix[i])\n\t// }\n\n\tans := 0\n\tfor i := 1; i <= n; i++ {\n\t\tinitialize()\n\t\ttmp := sub(i)\n\t\tChMax(&ans, tmp)\n\t}\n\n\tfmt.Println(ans)\n}\n\n// sevenId を 7としたときの置けるドミノの数\nfunc sub(sevenId int) int {\n\tres := 0\n\n\t// memo: ノードIDからドミノの数へのマップ\n\tmemo := make(map[int]int)\n\tdominoNum := 1\n\tfor i := 1; i <= n; i++ {\n\t\tif i == sevenId {\n\t\t\tcontinue\n\t\t}\n\t\tmemo[i] = dominoNum\n\t\tdominoNum++\n\t}\n\tmemo[sevenId] = dominoNum\n\t// memoの逆引き\n\trevMemo := make(map[int]int)\n\tfor k, v := range memo {\n\t\trevMemo[v] = k\n\t}\n\n\t// sevenId以外のノードについて、割り当てられたドミノ数に基づいてドミノをおいていく\n\tfor i := 1; i <= n; i++ {\n\t\tfor j := i + 1; j <= n; j++ {\n\t\t\t// i, jは通常のノード番号\n\t\t\tif i == sevenId || j == sevenId {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif adjMatrix[i][j] == 1 {\n\t\t\t\tres++\n\n\t\t\t\t// i, jをドミノ数に変換\n\t\t\t\t// diのほうを常に小さく\n\t\t\t\tdi := memo[i]\n\t\t\t\tdj := memo[j]\n\t\t\t\tif di > dj {\n\t\t\t\t\tdi, dj = dj, di\n\t\t\t\t}\n\t\t\t\tdominoMatrix[di][dj] = 0 // ドミノを消費\n\t\t\t}\n\t\t}\n\t}\n\n\t// i: sevenId のドミノ数をiとする\n\tresres := 0\n\tfor i := 1; i <= 6; i++ {\n\t\tdi := i\n\t\ttmpRes := 0\n\n\t\t// 他方のノードすべてを調べる\n\t\tfor j := 1; j <= 6; j++ {\n\t\t\tdj := j\n\t\t\tni, nj := sevenId, revMemo[dj]\n\t\t\tif di > dj {\n\t\t\t\tdi, dj = dj, di\n\t\t\t}\n\n\t\t\t// ドミノが未使用かつエッジがアレばドミノを設置できる\n\t\t\tif dominoMatrix[di][dj] == 1 && adjMatrix[ni][nj] == 1 {\n\t\t\t\ttmpRes++\n\t\t\t}\n\t\t}\n\n\t\tChMax(&resres, tmpRes)\n\t}\n\n\treturn res + resres\n}\n\nfunc initialize() {\n\tfor i := 1; i <= 6; i++ {\n\t\tfor j := i; j <= 6; j++ {\n\t\t\tdominoMatrix[i][j] = 1\n\t\t}\n\t}\n}\n\n// MODはとったか?\n// 遷移だけじゃなくて最後の最後でちゃんと取れよ?\n\n/*******************************************************************/\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc Sol1230C(reader io.Reader, writer io.Writer) {\n\tin := bufio.NewReader(reader)\n\tout := bufio.NewWriter(writer)\n\tdefer out.Flush()\n\n\tvar n, m int\n\tFscan(in, &n, &m)\n\tedges := make([][]int, n+1)\n\tshown := map[int]int{}\n\tfor i := 0; i < m; i++ {\n\t\tvar v, w int\n\t\tFscan(in, &v, &w)\n\t\tedges[v] = append(edges[v], w)\n\t\tedges[w] = append(edges[w], v)\n\t\tshown[v] = 1\n\t\tshown[w] = 1\n\t}\n\tif len(shown) <= 6 {\n\t\tFprintln(out, m)\n\t\treturn\n\t}\n\tminDeg := 100\n\tfor _, e := range edges {\n\t\tif len(e) > 0 && len(e) < minDeg {\n\t\t\tminDeg = len(e)\n\t\t}\n\t}\n\tans := m - minDeg + 1\n\tfor v, e := range edges {\n\t\tif len(e) != minDeg {\n\t\t\tcontinue\n\t\t}\n\t\tfor w, e2 := range edges {\n\t\t\tif len(e2) <= minDeg {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tdelta := 0\n\t\t\tfor _, ee := range e2 {\n\t\t\t\tif ee == v {\n\t\t\t\t\tdelta = 1\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tmp := map[int]int{}\n\t\t\tfor _, ee := range append(e, e2...) {\n\t\t\t\tif ee == v {\n\t\t\t\t\tee = w\n\t\t\t\t}\n\t\t\t\tmp[ee] = 1\n\t\t\t}\n\t\t\tif newAns := m - (len(e) + len(e2) - delta - len(mp)); newAns > ans {\n\t\t\t\tans = newAns\n\t\t\t}\n\t\t}\n\t}\n\tFprintln(out, ans)\n}\n\nfunc main() {\n\tSol1230C(os.Stdin, os.Stdout)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc Sol1230C(reader io.Reader, writer io.Writer) {\n\tin := bufio.NewReader(reader)\n\tout := bufio.NewWriter(writer)\n\tdefer out.Flush()\n\n\tvar n, m, v, w int\n\tFscan(in, &n, &m)\n\tedges := make([][]int, n+1)\n\tshown := map[int]int{}\n\tfor i := 0; i < m; i++ {\n\t\tFscan(in, &v, &w)\n\t\tedges[v] = append(edges[v], w)\n\t\tedges[w] = append(edges[w], v)\n\t\tshown[v] = 1\n\t\tshown[w] = 1\n\t}\n\tif len(shown) <= 6 {\n\t\tFprintln(out, m)\n\t\treturn\n\t}\n\tminDeg := 100\n\t//var idx int\n\tfor _, e := range edges {\n\t\tif len(e) > 0 && len(e) < minDeg {\n\t\t\tminDeg = len(e)\n\t\t\t//idx = i + 1\n\t\t}\n\t}\n\tans := m - minDeg + 1\n\tfor _, e := range edges {\n\t\tif len(e) != minDeg {\n\t\t\tcontinue\n\t\t}\n\t\tfor _, e2 := range edges {\n\t\t\tif len(e2) <= minDeg {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tmp := map[int]int{}\n\t\t\tfor _, ee := range append(e, e2...) {\n\t\t\t\tmp[ee] = 1\n\t\t\t}\n\t\t\tif newAns := m - (len(e) + len(e2) - len(mp)); newAns > ans {\n\t\t\t\tans = newAns\n\t\t\t}\n\t\t}\n\t}\n\tFprintln(out, ans)\n}\n\nfunc main() {\n\tSol1230C(os.Stdin, os.Stdout)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc Sol1230C(reader io.Reader, writer io.Writer) {\n\tin := bufio.NewReader(reader)\n\tout := bufio.NewWriter(writer)\n\tdefer out.Flush()\n\n\tvar n, m, v, w int\n\tFscan(in, &n, &m)\n\tedges := make([][]int, n+1)\n\tshown := map[int]int{}\n\tfor i := 0; i < m; i++ {\n\t\tFscan(in, &v, &w)\n\t\tedges[v] = append(edges[v], w)\n\t\tedges[w] = append(edges[w], v)\n\t\tshown[v] = 1\n\t\tshown[w] = 1\n\t}\n\tif len(shown) <= 6 {\n\t\tFprintln(out, m)\n\t\treturn\n\t}\n\tminDeg := m\n\tfor _, e := range edges {\n\t\tif len(e) > 0 && len(e) < minDeg {\n\t\t\tminDeg = len(e)\n\t\t}\n\t}\n\tFprintln(out, m-minDeg+1)\n}\n\nfunc main() {\n\tSol1230C(os.Stdin, os.Stdout)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc Sol1230C(reader io.Reader, writer io.Writer) {\n\tin := bufio.NewReader(reader)\n\tout := bufio.NewWriter(writer)\n\tdefer out.Flush()\n\n\tvar n, m int\n\tFscan(in, &n, &m)\n\tedges := make([][]int, n+1)\n\tshown := map[int]int{}\n\tfor i := 0; i < m; i++ {\n\t\tvar v, w int\n\t\tFscan(in, &v, &w)\n\t\tedges[v] = append(edges[v], w)\n\t\tedges[w] = append(edges[w], v)\n\t\tshown[v] = 1\n\t\tshown[w] = 1\n\t}\n\tif len(shown) <= 6 {\n\t\tFprintln(out, m)\n\t\treturn\n\t}\n\n\tminDeg := 7\n\tfor _, e := range edges {\n\t\tif len(e) > 0 && len(e) < minDeg {\n\t\t\tminDeg = len(e)\n\t\t}\n\t}\n\tans := 0\n\tfor v, e := range edges {\n\t\tif len(e) != minDeg {\n\t\t\tcontinue\n\t\t}\n\t\tfor w, e2 := range edges {\n\t\t\tif w == v || len(e2) == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tdelta := 0\n\t\t\tfor _, ee := range e2 {\n\t\t\t\tif ee == v {\n\t\t\t\t\tdelta = 1\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tmp := map[int]int{}\n\t\t\tfor _, ee := range append(e, e2...) {\n\t\t\t\tif ee == v {\n\t\t\t\t\tee = w\n\t\t\t\t}\n\t\t\t\tmp[ee] = 1\n\t\t\t}\n\t\t\tdelta = len(e) + len(e2) - delta - len(mp)\n\t\t\tif newAns := m - delta; newAns > ans {\n\t\t\t\tans = newAns\n\t\t\t}\n\t\t}\n\t}\n\tFprintln(out, ans)\n}\n\nfunc main() {\n\tSol1230C(os.Stdin, os.Stdout)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc Sol1230C(reader io.Reader, writer io.Writer) {\n\tin := bufio.NewReader(reader)\n\tout := bufio.NewWriter(writer)\n\tdefer out.Flush()\n\n\tvar n, m, v, w int\n\tFscan(in, &n, &m)\n\tedges := make([][]int, n+1)\n\tshown := map[int]int{}\n\tfor i := 0; i < m; i++ {\n\t\tFscan(in, &v, &w)\n\t\tedges[v] = append(edges[v], w)\n\t\tedges[w] = append(edges[w], v)\n\t\tshown[v] = 1\n\t\tshown[w] = 1\n\t}\n\tif len(shown) <= 6 {\n\t\tFprintln(out, m)\n\t\treturn\n\t}\n\tminDeg := 100\n\tvar idx int\n\tfor i, e := range edges {\n\t\tif len(e) > 0 && len(e) < minDeg {\n\t\t\tminDeg = len(e)\n\t\t\tidx = i + 1\n\t\t}\n\t}\n\tans := m - minDeg + 1\n\tfor i, e := range edges {\n\t\tif i == idx || len(e) != minDeg {\n\t\t\tcontinue\n\t\t}\n\t\tfor _, e2 := range edges {\n\t\t\tif len(e2) <= minDeg {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tmp := map[int]int{}\n\t\t\tfor _, ee := range append(e, e2...) {\n\t\t\t\tmp[ee] = 1\n\t\t\t}\n\t\t\tif newAns := m - (len(e) + len(e2) - len(mp)); newAns > ans {\n\t\t\t\tans = newAns\n\t\t\t}\n\t\t}\n\t}\n\tFprintln(out, ans)\n}\n\nfunc main() {\n\tSol1230C(os.Stdin, os.Stdout)\n}\n"}, {"source_code": "// Author: sighduck\n// URL: https://codeforces.com/contest/1230/problem/C\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\ntype Edge struct {\n\tA int\n\tB int\n}\n\nfunc min(x int, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc max(x int, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc Solve(n int, m int, edges []Edge) int {\n\tif n < 7 {\n\t\treturn m\n\t}\n\tdegreeCount := make([]int, n)\n\tfor _, edge := range edges {\n\t\tdegreeCount[edge.A-1] += 1\n\t\tdegreeCount[edge.B-1] += 1\n\t}\n\tmaxDominoes := 0\n\tfor _, degree := range degreeCount {\n\t\tmaxDominoes = max(maxDominoes, m-degree+min(degree, 1))\n\t}\n\treturn min(maxDominoes, 16)\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n, m int\n\tfmt.Fscanf(reader, \"%d %d\\n\", &n, &m)\n\tedges := make([]Edge, m)\n\tfor i := 0; i < m; i++ {\n\t\tfmt.Fscanf(reader, \"%d %d\\n\", &edges[i].A, &edges[i].B)\n\t}\n\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(n, m, edges))\n}\n"}], "src_uid": "11e6559cfb71b8f6ca88242094b17a2b"} {"nl": {"description": "One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the results. Find out how the deminations of the coins differ or if Vasya has a mistake in the weighting results. No two coins are equal.", "input_spec": "The input data contains the results of all the weighting, one result on each line. It is guaranteed that every coin pair was weighted exactly once. Vasya labelled the coins with letters «A», «B» and «C». Each result is a line that appears as (letter)(> or < sign)(letter). For example, if coin \"A\" proved lighter than coin \"B\", the result of the weighting is A<B.", "output_spec": "It the results are contradictory, print Impossible. Otherwise, print without spaces the rearrangement of letters «A», «B» and «C» which represent the coins in the increasing order of their weights.", "sample_inputs": ["A>B\nC<B\nA>C", "A<B\nB>C\nC>A"], "sample_outputs": ["CBA", "ACB"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar Ss [3]string\n\tvar m map[byte]int = map[byte]int{'A': 0, 'B': 1, 'C': 2}\n\tvar a [3]rune = [3]rune{'A', 'B', 'C'}\n\tvar tmpR rune\n\tvar tmpI int\n\n\tfor i := 0; i < 3; i++ {\n\t\tfmt.Scanf(\"%s\\n\", &Ss[i])\n\t}\n\t// fmt.Println(Ss)\n\t// fmt.Println(m)\n\t// fmt.Println(a)\n\n\tfor i := 0; i < 3; i++ {\n\t\tif Ss[i][1] == '<' {\n\t\t\tif !(m[Ss[i][0]] < m[Ss[i][2]]) {\n\t\t\t\ttmpR = a[m[Ss[i][0]]]\n\t\t\t\ta[m[Ss[i][0]]] = a[m[Ss[i][2]]]\n\t\t\t\ta[m[Ss[i][2]]] = tmpR\n\t\t\t\ttmpI = m[Ss[i][0]]\n\t\t\t\tm[Ss[i][0]] = m[Ss[i][2]]\n\t\t\t\tm[Ss[i][2]] = tmpI\n\t\t\t}\n\t\t} else {\n\t\t\tif !(m[Ss[i][0]] > m[Ss[i][2]]) {\n\t\t\t\ttmpR = a[m[Ss[i][0]]]\n\t\t\t\ta[m[Ss[i][0]]] = a[m[Ss[i][2]]]\n\t\t\t\ta[m[Ss[i][2]]] = tmpR\n\t\t\t\ttmpI = m[Ss[i][0]]\n\t\t\t\tm[Ss[i][0]] = m[Ss[i][2]]\n\t\t\t\tm[Ss[i][2]] = tmpI\n\t\t\t}\n\t\t}\n\t}\n\tif Ss[0][1] == '<' {\n\t\tif !(m[Ss[0][0]] < m[Ss[0][2]]) {\n\t\t\ttmpR = a[m[Ss[0][0]]]\n\t\t\ta[m[Ss[0][0]]] = a[m[Ss[0][2]]]\n\t\t\ta[m[Ss[0][2]]] = tmpR\n\t\t\ttmpI = m[Ss[0][0]]\n\t\t\tm[Ss[0][0]] = m[Ss[0][2]]\n\t\t\tm[Ss[0][2]] = tmpI\n\t\t}\n\t} else {\n\t\tif !(m[Ss[0][0]] > m[Ss[0][2]]) {\n\t\t\ttmpR = a[m[Ss[0][0]]]\n\t\t\ta[m[Ss[0][0]]] = a[m[Ss[0][2]]]\n\t\t\ta[m[Ss[0][2]]] = tmpR\n\t\t\ttmpI = m[Ss[0][0]]\n\t\t\tm[Ss[0][0]] = m[Ss[0][2]]\n\t\t\tm[Ss[0][2]] = tmpI\n\t\t}\n\t}\n\tif Ss[1][1] == '<' {\n\t\tif !(m[Ss[1][0]] < m[Ss[1][2]]) {\n\t\t\tfmt.Println(\"Impossible\")\n\t\t} else {\n\t\t\tfor i := 0; i < 3; i++ {\n\t\t\t\tfmt.Printf(\"%c\", a[i])\n\t\t\t}\n\t\t\tfmt.Println()\n\t\t}\n\t} else {\n\t\tif !(m[Ss[1][0]] > m[Ss[1][2]]) {\n\t\t\tfmt.Println(\"Impossible\")\n\t\t} else {\n\t\t\tfor i := 0; i < 3; i++ {\n\t\t\t\tfmt.Printf(\"%c\", a[i])\n\t\t\t}\n\t\t\tfmt.Println()\n\t\t}\n\t}\n}\n"}], "negative_code": [], "src_uid": "97fd9123d0fb511da165b900afbde5dc"} {"nl": {"description": "The princess is going to escape the dragon's cave, and she needs to plan it carefully.The princess runs at vp miles per hour, and the dragon flies at vd miles per hour. The dragon will discover the escape after t hours and will chase the princess immediately. Looks like there's no chance to success, but the princess noticed that the dragon is very greedy and not too smart. To delay him, the princess decides to borrow a couple of bijous from his treasury. Once the dragon overtakes the princess, she will drop one bijou to distract him. In this case he will stop, pick up the item, return to the cave and spend f hours to straighten the things out in the treasury. Only after this will he resume the chase again from the very beginning.The princess is going to run on the straight. The distance between the cave and the king's castle she's aiming for is c miles. How many bijous will she need to take from the treasury to be able to reach the castle? If the dragon overtakes the princess at exactly the same moment she has reached the castle, we assume that she reached the castle before the dragon reached her, and doesn't need an extra bijou to hold him off.", "input_spec": "The input data contains integers vp, vd, t, f and c, one per line (1 ≤ vp, vd ≤ 100, 1 ≤ t, f ≤ 10, 1 ≤ c ≤ 1000).", "output_spec": "Output the minimal number of bijous required for the escape to succeed.", "sample_inputs": ["1\n2\n1\n1\n10", "1\n2\n1\n1\n8"], "sample_outputs": ["2", "1"], "notes": "NoteIn the first case one hour after the escape the dragon will discover it, and the princess will be 1 mile away from the cave. In two hours the dragon will overtake the princess 2 miles away from the cave, and she will need to drop the first bijou. Return to the cave and fixing the treasury will take the dragon two more hours; meanwhile the princess will be 4 miles away from the cave. Next time the dragon will overtake the princess 8 miles away from the cave, and she will need the second bijou, but after this she will reach the castle without any further trouble.The second case is similar to the first one, but the second time the dragon overtakes the princess when she has reached the castle, and she won't need the second bijou."}, "positive_code": [{"source_code": "// 148B\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, c, d, e, s, i float64\n\tfmt.Scan(&a, &b, &c, &d, &e)\n\tif a < b {\n\t\ts = b * a * c / (b - a)\n\t\tfor i = 0; s < e; i++ {\n\t\t\ts = b * (s + a*(s/b+d)) / (b - a)\n\t\t}\n\t}\n\tfmt.Println(i)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var p, d, t, f, c float32\n fmt.Scan(&p, &d, &t, &f, &c)\n var k, x, r float32\n k = d - p\n x = p * t\n r = 0\n if k > 0 {\n x += x / k * p\n for x < c {\n r++\n x += p * (x / d + f)\n x += x / k * p\n }\n }\n fmt.Println(r)\n}"}], "negative_code": [], "src_uid": "c9c03666278acec35f0e273691fe0fff"} {"nl": {"description": "Two little greedy bears have found two pieces of cheese in the forest of weight a and b grams, correspondingly. The bears are so greedy that they are ready to fight for the larger piece. That's where the fox comes in and starts the dialog: \"Little bears, wait a little, I want to make your pieces equal\" \"Come off it fox, how are you going to do that?\", the curious bears asked. \"It's easy\", said the fox. \"If the mass of a certain piece is divisible by two, then I can eat exactly a half of the piece. If the mass of a certain piece is divisible by three, then I can eat exactly two-thirds, and if the mass is divisible by five, then I can eat four-fifths. I'll eat a little here and there and make the pieces equal\". The little bears realize that the fox's proposal contains a catch. But at the same time they realize that they can not make the two pieces equal themselves. So they agreed to her proposal, but on one condition: the fox should make the pieces equal as quickly as possible. Find the minimum number of operations the fox needs to make pieces equal.", "input_spec": "The first line contains two space-separated integers a and b (1 ≤ a, b ≤ 109). ", "output_spec": "If the fox is lying to the little bears and it is impossible to make the pieces equal, print -1. Otherwise, print the required minimum number of operations. If the pieces of the cheese are initially equal, the required number is 0.", "sample_inputs": ["15 20", "14 8", "6 6"], "sample_outputs": ["3", "-1", "0"], "notes": null}, "positive_code": [{"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 abs(a int)int {\n\tif a<0 {\n\t\ta*=(-1)\n\t}\n\treturn a\n}\nfunc main() {\n var a,b int\n var na,nb [10]int\n fmt.Scan(&a,&b)\n\n for ;a%2==0; {\n \ta/=2\n \tna[0]++\n }\n for ;a%3==0; {\n \ta/=3\n \tna[1]++\n }\n for ;a%5==0; {\n \ta/=5\n \tna[2]++\n }\n for ;b%2==0; {\n \tb/=2\n \tnb[0]++\n }\n for ;b%3==0; {\n \tb/=3\n \tnb[1]++\n }\n for ;b%5==0; {\n \tb/=5\n \tnb[2]++\n }\n if a!=b {\n \tfmt.Println(\"-1\")\n } else {\n ans:=0\n for i:=0;i<3;i++ {\n \tans+=abs(na[i]-nb[i])\n }\n fmt.Println(ans)\n }\n}\n\n\n\n\n\n\n\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n abs := func(a int) int { if a < 0 { return -a } else { return a } }\n\n var a,b,a2,a3,a5,b2,b3,b5 int\n fmt.Scan(&a,&b)\n for ; a%2 == 0; a/=2 { a2++ }\n for ; a%3 == 0; a/=3 { a3++ }\n for ; a%5 == 0; a/=5 { a5++ }\n for ; b%2 == 0; b/=2 { b2++ }\n for ; b%3 == 0; b/=3 { b3++ }\n for ; b%5 == 0; b/=5 { b5++ }\n if a != b { fmt.Println(-1) } else { fmt.Println(abs(a2-b2)+abs(a3-b3)+abs(a5-b5)) }\n}\n"}, {"source_code": "package main\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar a, b, c, d int\n\tvar i, j, k, l, m, n, x float64\n\tfmt.Scan(&a, &b)\n\tfor a!=0 {\n\t\tif a%2==0 {\n\t\t\ta=a/2\n\t\t\ti++\n\t\t} else if a%3==0 {\n\t\t\ta=a-(a/3*2)\n\t\t\tj++\n\t\t} else if a%5==0 {\n\t\t\ta=a-(a/5*4)\n\t\t\tk++\n\t\t} else {\n\t\t\tc=a\n\t\t\tbreak\n\t\t}\n\t}\n\tfor b!=0 {\n\t\tif b%2==0 {\n\t\t\tb=b/2\n\t\t\tl++\n\t\t} else if b%3==0 {\n\t\t\tb=b-(b/3*2)\n\t\t\tm++\n\t\t} else if b%5==0 {\n\t\t\tb=b-(b/5*4)\n\t\t\tn++\n\t\t} else {\n\t\t\td=b\n\t\t\tbreak\n\t\t}\n\t}\n\tif c==d {\n\t\tx=math.Abs(i-l)+math.Abs(j-m)+math.Abs(k-n)\n\t\tfmt.Println(x)\n\t} else {\n\t\tfmt.Println(\"-1\")\n\t}\n}"}, {"source_code": "//371B\npackage main\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar a, b, c, d int\n\tvar i, j, k, l, m, n, x float64\n\tfmt.Scan(&a, &b)\n\tfor a!=0 {\n\t\tif a%2==0 {\n\t\t\ta=a/2\n\t\t\ti++\n\t\t} else if a%3==0 {\n\t\t\ta=a-(a/3*2)\n\t\t\tj++\n\t\t} else if a%5==0 {\n\t\t\ta=a-(a/5*4)\n\t\t\tk++\n\t\t} else {\n\t\t\tc=a\n\t\t\tbreak\n\t\t}\n\t}\n\tfor b!=0 {\n\t\tif b%2==0 {\n\t\t\tb=b/2\n\t\t\tl++\n\t\t} else if b%3==0 {\n\t\t\tb=b-(b/3*2)\n\t\t\tm++\n\t\t} else if b%5==0 {\n\t\t\tb=b-(b/5*4)\n\t\t\tn++\n\t\t} else {\n\t\t\td=b\n\t\t\tbreak\n\t\t}\n\t}\n\tif c==d {\n\t\tx=math.Abs(i-l)+math.Abs(j-m)+math.Abs(k-n)\n\t\tfmt.Println(x)\n\t} else {\n\t\tfmt.Println(\"-1\")\n\t}\n}\n"}, {"source_code": "//371B\npackage main\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar a, b, c, d int\n\tvar i, j, k, l, m, n, x float64\n\tfmt.Scan(&a, &b)\n\tfor a!=0 {\n\t\tif a%2==0 {\n\t\t\ta=a/2\n\t\t\ti++\n\t\t} else if a%3==0 {\n\t\t\ta=a-(a/3*2)\n\t\t\tj++\n\t\t} else if a%5==0 {\n\t\t\ta=a-(a/5*4)\n\t\t\tk++\n\t\t} else {\n\t\t\tc=a\n\t\t\tbreak\n\t\t}\n\t}\n\tfor b!=0 {\n\t\tif b%2==0 {\n\t\t\tb=b/2\n\t\t\tl++\n\t\t} else if b%3==0 {\n\t\t\tb=b-(b/3*2)\n\t\t\tm++\n\t\t} else if b%5==0 {\n\t\t\tb=b-(b/5*4)\n\t\t\tn++\n\t\t} else {\n\t\t\td=b\n\t\t\tbreak\n\t\t}\n\t}\n\tif c==d {\n\t\tx=math.Abs(i-l)+math.Abs(j-m)+math.Abs(k-n)\n\t\tfmt.Println(x)\n\t} else {\n\t\tfmt.Println(\"-1\")\n\t}\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n abs := func(a int) int { if a < 0 { return -a } else { return a } }\n\n var a,b,a2,a3,a5,b2,b3,b5 int\n fmt.Scan(&a,&b)\n for ; a%2 == 0; a/=2 { a2++ }\n for ; a%3 == 0; a/=3 { a3++ }\n for ; a%5 == 0; a/=5 { a5++ }\n for ; b%2 == 0; b/=2 { b2++ }\n for ; b%3 == 0; b/=3 { b3++ }\n for ; b%5 == 0; b/=5 { b5++ }\n if a != b { fmt.Println(-1) } else { fmt.Println(abs(a2-b2)+abs(a3-b3)+abs(a5-b5)) }\n}\n"}, {"source_code": "// 371B\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nvar x, y, k1, k2, ans int\n\nfunc kol(d int) int {\n\tk1 = 0\n\tk2 = 0\n\tfor x%d == 0 {\n\t\tx /= d\n\t\tk1++\n\t}\n\tfor y%d == 0 {\n\t\ty /= d\n\t\tk2++\n\t}\n\tif k1 > k2 {\n\t\treturn k1 - k2\n\t} else {\n\t\treturn k2 - k1\n\t}\n}\n\nfunc main() {\n\tfmt.Scan(&x, &y)\n\tans = kol(2) + kol(3) + kol(5)\n\tif x == y {\n\t\tfmt.Print(ans)\n\t} else {\n\t\tfmt.Print(-1)\n\t}\n}\n"}, {"source_code": "// 371B-mic\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc gcd(x, y int) int {\n\tfor y != 0 {\n\t\tx, y = y, x%y\n\t}\n\treturn x\n}\n\nfunc main() {\n\tvar a, b, k int\n\tfmt.Scan(&a, &b)\n\tx := gcd(a, b)\n\tif x != 1 {\n\t\ta /= x\n\t\tb /= x\n\t}\n\tfor {\n\t\tif a == b {\n\t\t\tbreak\n\t\t}\n\t\tif a < b {\n\t\t\ta, b = b, a\n\t\t} else if a > b && a%2 != 0 && a%3 != 0 && a%5 != 0 {\n\t\t\tb, a = a, b\n\t\t}\n\t\tif a%2 != 0 && a%3 != 0 && a%5 != 0 && b%2 != 0 && b%3 != 0 && b%5 != 0 {\n\t\t\tfmt.Println(\"-1\")\n\t\t\treturn\n\t\t}\n\t\tif a%2 == 0 {\n\t\t\ta /= 2\n\t\t\tk++\n\t\t} else if a%3 == 0 {\n\t\t\ta /= 3\n\t\t\tk++\n\t\t} else if a%5 == 0 {\n\t\t\ta /= 5\n\t\t\tk++\n\t\t}\n\t}\n\tfmt.Println(k)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc abs(x int) int {\n\tif x >= 0 {\n\t\treturn x\n\t}\n\treturn -x\n}\n\nfunc div(n, d int) (m, ans int) {\n\tans = 0\n\tm = n\n\tfor m % d == 0 {\n\t\tm /= d\n\t\tans += 1\n\t}\n\treturn\n}\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scanf(\"%d %d\\n\", &a, &b)\n\ta, a2 := div(a, 2)\n\ta, a3 := div(a, 3)\n\ta, a5 := div(a, 5)\n\tb, b2 := div(b, 2)\n\tb, b3 := div(b, 3)\n\tb, b5 := div(b, 5)\n\tans := abs(a2 - b2) + abs(a3 - b3) + abs(a5 - b5)\n\tif a != b {\n\t\tans = -1\n\t}\n\tfmt.Println(ans)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc abs(x int) int {\n\tif x >= 0 {\n\t\treturn x\n\t}\n\treturn -x\n}\n\nfunc div(n *int, d int) int {\n\tans := 0\n\tfor (*n) % d == 0 {\n\t\t(*n) /= d\n\t\tans += 1\n\t}\n\treturn ans\n}\n\nfunc main() {\n\tvar a, b int\n\tfmt.Scanf(\"%d %d\\n\", &a, &b)\n\ta2 := div(&a, 2)\n\ta3 := div(&a, 3)\n\ta5 := div(&a, 5)\n\tb2 := div(&b, 2)\n\tb3 := div(&b, 3)\n\tb5 := div(&b, 5)\n\tans := abs(a2 - b2) + abs(a3 - b3) + abs(a5 - b5)\n\tif a != b {\n\t\tans = -1\n\t}\n\tfmt.Println(ans)\n}\n"}], "negative_code": [{"source_code": "// 371B-mic\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, k int\n\tfmt.Scan(&a, &b)\n\tfor {\n\t\tif a == b {\n\t\t\tbreak\n\t\t}\n\t\tif a < b {\n\t\t\ta, b = b, a\n\t\t} else {\n\t\t\tb, a = a, b\n\t\t}\n\t\tif a%2 == 0 {\n\t\t\ta /= 2\n\t\t\tk++\n\t\t} else if a%3 == 0 {\n\t\t\ta /= 3\n\t\t\tk++\n\t\t} else if a%5 == 0 {\n\t\t\ta /= 5\n\t\t\tk++\n\t\t}\n\t\tif a%2 != 0 && a%3 != 0 && a%5 != 0 && b%2 != 0 && b%3 != 0 && b%5 != 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(k)\n}\n"}, {"source_code": "// 371B-mic\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, k int\n\tfmt.Scan(&a, &b)\n\tfor {\n\t\tif a == b {\n\t\t\tbreak\n\t\t}\n\t\tif a < b {\n\t\t\ta, b = b, a\n\t\t} else if a > b && a%2 != 0 && a%3 != 0 && a%5 != 0 {\n\t\t\tb, a = a, b\n\t\t}\n\t\tif a%2 != 0 && a%3 != 0 && a%5 != 0 && b%2 != 0 && b%3 != 0 && b%5 != 0 {\n\t\t\tfmt.Println(\"-1\")\n\t\t\treturn\n\t\t}\n\t\tif a%2 == 0 {\n\t\t\ta /= 2\n\t\t\tk++\n\t\t} else if a%3 == 0 {\n\t\t\ta /= 3\n\t\t\tk++\n\t\t} else if a%5 == 0 {\n\t\t\ta /= 5\n\t\t\tk++\n\t\t}\n\t}\n\tfmt.Println(k)\n}\n"}, {"source_code": "// 371B-mic\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, k int\n\tfmt.Scan(&a, &b)\n\tfor {\n\t\tif a == b {\n\t\t\tbreak\n\t\t}\n\t\tif a < b {\n\t\t\ta, b = b, a\n\t\t} else {\n\t\t\tb, a = a, b\n\t\t}\n\t\tif a%2 == 0 {\n\t\t\ta /= 2\n\t\t\tk++\n\t\t} else if a%3 == 0 {\n\t\t\ta /= 3\n\t\t\tk++\n\t\t} else if a%5 == 0 {\n\t\t\ta /= 5\n\t\t\tk++\n\t\t}\n\t\tif a%2 != 0 && a%3 != 0 && a%5 != 0 && a != b {\n\t\t\tfmt.Println(\"-1\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(k)\n}\n"}, {"source_code": "// 371B-mic\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, k int\n\tfmt.Scan(&a, &b)\n\tfor {\n\t\tif a == b {\n\t\t\tbreak\n\t\t}\n\t\tif a%2 != 0 && a%3 != 0 && a%5 != 0 && b%2 != 0 && b%3 != 0 && b%5 != 0 {\n\t\t\tfmt.Println(\"-1\")\n\t\t\treturn\n\t\t}\n\t\tif a < b {\n\t\t\ta, b = b, a\n\t\t} else {\n\t\t\tb, a = a, b\n\t\t}\n\t\tif a%2 == 0 {\n\t\t\ta /= 2\n\t\t\tk++\n\t\t} else if a%3 == 0 {\n\t\t\ta /= 3\n\t\t\tk++\n\t\t} else if a%5 == 0 {\n\t\t\ta /= 5\n\t\t\tk++\n\t\t}\n\t}\n\tfmt.Println(k)\n}\n"}, {"source_code": "// 371B-mic\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, k int\n\tfmt.Scan(&a, &b)\n\tfor {\n\t\tif a < b {\n\t\t\ta, b = b, a\n\t\t} else {\n\t\t\tb, a = a, b\n\t\t}\n\t\tif a%2 == 0 {\n\t\t\ta /= 2\n\t\t\tk++\n\t\t} else if a%3 == 0 {\n\t\t\ta /= 3\n\t\t\tk++\n\t\t} else if a%5 == 0 {\n\t\t\ta /= 5\n\t\t\tk++\n\t\t}\n\t\tif a == b {\n\t\t\tbreak\n\t\t}\n\t\tif a%2 != 0 && a%3 != 0 && a%5 != 0 && b%2 != 0 && b%3 != 0 && b%5 != 0 {\n\t\t\tfmt.Println(\"-1\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(k)\n}\n"}], "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49"} {"nl": {"description": "Vasily has a number a, which he wants to turn into a number b. For this purpose, he can do two types of operations: multiply the current number by 2 (that is, replace the number x by 2·x); append the digit 1 to the right of current number (that is, replace the number x by 10·x + 1). You need to help Vasily to transform the number a into the number b using only the operations described above, or find that it is impossible.Note that in this task you are not required to minimize the number of operations. It suffices to find any way to transform a into b.", "input_spec": "The first line contains two positive integers a and b (1 ≤ a < b ≤ 109) — the number which Vasily has and the number he wants to have.", "output_spec": "If there is no way to get b from a, print \"NO\" (without quotes). Otherwise print three lines. On the first line print \"YES\" (without quotes). The second line should contain single integer k — the length of the transformation sequence. On the third line print the sequence of transformations x1, x2, ..., xk, where: x1 should be equal to a, xk should be equal to b, xi should be obtained from xi - 1 using any of two described operations (1 < i ≤ k). If there are multiple answers, print any of them.", "sample_inputs": ["2 162", "4 42", "100 40021"], "sample_outputs": ["YES\n5\n2 4 8 81 162", "NO", "YES\n5\n100 200 2001 4002 40021"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\nvar a, b int\nvar trace map[int]int\n\nfunc dfs(x int) bool {\n\tif x == b {\n\t\treturn true\n\t}\n\tif x <= b/2 {\n\t\ty := x * 2\n\t\t_, found := trace[y]\n\t\tif !found {\n\t\t\ttrace[y] = x\n\t\t\tif dfs(y) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\tif x <= (b-1)/10 {\n\t\ty := x*10 + 1\n\t\t_, found := trace[y]\n\t\tif !found {\n\t\t\ttrace[y] = x\n\t\t\tif dfs(y) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\nfunc main() {\n\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\n\tfmt.Fscanf(bufin, \"%d %d\\n\", &a, &b)\n\ttrace = make(map[int]int)\n\n\ttrace[a] = a\n\tif dfs(a) {\n\t\tfmt.Fprintf(bufout, \"YES\\n\")\n\n\t\tvar res []int\n\t\tfor b != a {\n\t\t\tres = append(res, b)\n\t\t\tb = trace[b]\n\t\t}\n\t\tres = append(res, a)\n\n\t\tn := len(res)\n\t\tfmt.Fprintf(bufout, \"%d\\n\", n)\n\t\tfor i := n - 1; i >= 0; i-- {\n\t\t\tfmt.Fprintf(bufout, \"%d \", res[i])\n\t\t}\n\t} else {\n\t\tfmt.Fprintf(bufout, \"NO\\n\")\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\n// Node to store in queue\ntype Node struct {\n\tvalue int64\n\tprev *Node\n}\n\n// NewNode to create node with value is n.\nfunc NewNode(n int64) *Node {\n\treturn &Node{\n\t\tvalue: n,\n\t}\n}\n\nfunc main() {\n\tvar stdin *bufio.Reader\n\t// LOCAL\n\tf, _ := os.Open(\"input.txt\")\n\tstdin = bufio.NewReader(f)\n\n\t// ONLINE JUDGE\n\tstdin = bufio.NewReader(os.Stdin)\n\n\tvar a, b int64\n\tfmt.Fscan(stdin, &a, &b)\n\n\tvar queue = []*Node{NewNode(a)}\n\tvar seen = make(map[int64]bool)\n\tfor len(queue) > 0 {\n\t\tvar top = queue[0]\n\t\tqueue = queue[1:]\n\t\tseen[top.value] = true\n\n\t\tif top.value == b {\n\t\t\t// Trace\n\t\t\tfmt.Println(\"YES\")\n\t\t\tvar res []int64\n\t\t\tfor n := top; n != nil; n = n.prev {\n\t\t\t\tres = append(res, n.value)\n\t\t\t}\n\t\t\tfmt.Println(len(res))\n\t\t\tfor i := len(res) - 1; i >= 0; i-- {\n\t\t\t\tfmt.Print(res[i], \" \")\n\t\t\t}\n\n\t\t\treturn\n\t\t}\n\n\t\tif top.value*2 <= b && !seen[top.value*2] {\n\t\t\tvar n = NewNode(top.value * 2)\n\t\t\tn.prev = top\n\t\t\tqueue = append(queue, n)\n\t\t}\n\t\tif top.value*10+1 <= b && !seen[top.value*10+1] {\n\t\t\tvar n = NewNode(top.value*10 + 1)\n\t\t\tn.prev = top\n\t\t\tqueue = append(queue, n)\n\t\t}\n\n\t}\n\n\tfmt.Println(\"NO\")\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\n\nfunc main() {\n var a, b, steps int\n t := make([]int, 0)\n fmt.Scanf(\"%d %d\", &a, &b)\n t = append(t, b)\n steps = steps + 1\n for {\n if a == b || b < a {\n break\n } else {\n if b % 2 == 0 {\n b = b / 2\n t = append(t, b)\n steps = steps + 1\n } else if (b - 1) % 10 == 0 {\n b = (b - 1) / 10\n t = append(t, b)\n steps = steps + 1\n } else {\n break\n }\n }\n }\n if a == b {\n fmt.Printf(\"YES\\n\")\n fmt.Printf(\"%d\\n\", steps)\n for idx := len(t) - 1; idx >= 0; idx--{\n if idx == 0 {\n fmt.Printf(\"%d\\n\", t[idx])\n } else {\n fmt.Printf(\"%d \", t[idx])\n }\n }\n } else {\n fmt.Printf(\"NO\\n\")\n }\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\ntype node struct {\n\tvalue int\n\tcount int\n\tprev *node\n}\n\nfunc newNode(n int) *node {\n\treturn &node{\n\t\tvalue: n,\n\t}\n}\n\nfunc main() {\n\tseen := make(map[int]bool)\n\tvar a, b int\n\tfmt.Fscanf(os.Stdin, \"%d %d\", &a, &b)\n\tqueue := []*node{newNode(b)}\n\n\tfor len(queue) > 0 {\n\t\tcurr := queue[0]\n\t\tqueue = queue[1:]\n\n\t\tif curr.value == a {\n\t\t\tfmt.Println(\"YES\")\n\t\t\tfmt.Println(curr.count + 1)\n\t\t\tfor n := curr; n != nil; n = n.prev {\n\t\t\t\tfmt.Printf(\"%d \", n.value)\n\t\t\t}\n\t\t\tfmt.Println()\n\t\t\treturn\n\t\t}\n\t\tif curr.value < a || seen[curr.value] {\n\t\t\tcontinue\n\t\t}\n\t\tseen[curr.value] = true\n\n\t\tif curr.value%2 == 0 {\n\t\t\tn := newNode(curr.value >> 1)\n\t\t\tn.count = curr.count + 1\n\t\t\tn.prev = curr\n\t\t\tqueue = append(queue, n)\n\t\t}\n\t\tif curr.value%10 == 1 {\n\t\t\tn := newNode(curr.value / 10)\n\t\t\tn.count = curr.count + 1\n\t\t\tn.prev = curr\n\t\t\tqueue = append(queue, n)\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\n// Node to store in queue\ntype Node struct {\n\tvalue int64\n\tprev *Node\n}\n\n// NewNode to create node with value is n.\nfunc NewNode(n int64) *Node {\n\treturn &Node{\n\t\tvalue: n,\n\t}\n}\n\nfunc main() {\n\tvar stdin *bufio.Reader\n\t// LOCAL\n\tf, _ := os.Open(\"input.txt\")\n\tstdin = bufio.NewReader(f)\n\n\t// ONLINE JUDGE\n\t// stdin = bufio.NewReader(os.Stdin)\n\n\tvar a, b int64\n\tfmt.Fscan(stdin, &a, &b)\n\n\tvar queue = []*Node{NewNode(a)}\n\tvar seen = make(map[int64]bool)\n\tfor len(queue) > 0 {\n\t\tvar top = queue[0]\n\t\tqueue = queue[1:]\n\t\tseen[top.value] = true\n\n\t\tif top.value == b {\n\t\t\t// Trace\n\t\t\tfmt.Println(\"YES\")\n\t\t\tvar res []int64\n\t\t\tfor n := top; n != nil; n = n.prev {\n\t\t\t\tres = append(res, n.value)\n\t\t\t}\n\t\t\tfmt.Println(len(res))\n\t\t\tfor i := len(res) - 1; i >= 0; i-- {\n\t\t\t\tfmt.Print(res[i], \" \")\n\t\t\t}\n\n\t\t\treturn\n\t\t}\n\n\t\tif top.value*2 <= b && !seen[top.value*2] {\n\t\t\tvar n = NewNode(top.value * 2)\n\t\t\tn.prev = top\n\t\t\tqueue = append(queue, n)\n\t\t}\n\t\tif top.value*10+1 <= b && !seen[top.value*10+1] {\n\t\t\tvar n = NewNode(top.value*10 + 1)\n\t\t\tn.prev = top\n\t\t\tqueue = append(queue, n)\n\t\t}\n\n\t}\n\n\tfmt.Println(\"NO\")\n\n}\n"}, {"source_code": "package main\n \nimport \"fmt\"\n \n \nfunc main() {\n var a, b, steps int\n t := make([]int, 0)\n fmt.Scanf(\"%d %d\", &a, &b)\n fmt.Println(a, b)\n t = append(t, b)\n for {\n if a == b {\n break\n } else {\n if b % 2 == 0 {\n b = b / 2\n t = append(t, b)\n steps = steps + 1\n } else if (b - 1) % 10 == 0 {\n b = (b - 1) / 10\n t = append(t, b)\n steps = steps + 1\n } else {\n break\n }\n }\n }\n if a == b {\n fmt.Printf(\"YES\\n\")\n fmt.Printf(\"%d\\n\", steps)\n for idx := len(t) - 1; idx >= 0; idx--{\n if idx == 0 {\n fmt.Printf(\"%d\\n\", t[idx])\n } else {\n fmt.Printf(\"%d \", t[idx])\n }\n }\n } else {\n fmt.Printf(\"No\\n\")\n }\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\n\nfunc main() {\n var a, b int\n fmt.Scanf(\"%d %d\", &a, &b)\n fmt.Println(a, b)\n}\n"}, {"source_code": "package main\n \nimport \"fmt\"\n \n \nfunc main() {\n var a, b, steps int\n t := make([]int, 0)\n fmt.Scanf(\"%d %d\", &a, &b)\n t = append(t, b)\n for {\n if a == b {\n break\n } else {\n if b % 2 == 0 {\n b = b / 2\n t = append(t, b)\n steps = steps + 1\n } else if (b - 1) % 10 == 0 {\n b = (b - 1) / 10\n t = append(t, b)\n steps = steps + 1\n } else {\n break\n }\n }\n }\n if a == b {\n fmt.Printf(\"YES\\n\")\n fmt.Printf(\"%d\\n\", steps)\n for idx := len(t) - 1; idx >= 0; idx--{\n if idx == 0 {\n fmt.Printf(\"%d\\n\", t[idx])\n } else {\n fmt.Printf(\"%d \", t[idx])\n }\n }\n } else {\n fmt.Printf(\"No\\n\")\n }\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\n\nfunc main() {\n var a, b, steps int\n t := make([]int, 0)\n fmt.Scanf(\"%d %d\", &a, &b)\n t = append(t, b)\n steps = steps + 1\n for {\n if a == b || b < a {\n break\n } else {\n if b % 2 == 0 {\n b = b / 2\n t = append(t, b)\n steps = steps + 1\n } else if (b - 1) % 10 == 0 {\n b = (b - 1) / 10\n t = append(t, b)\n steps = steps + 1\n } else {\n break\n }\n }\n }\n if a == b {\n fmt.Printf(\"YES\\n\")\n fmt.Printf(\"%d\\n\", steps)\n for idx := len(t) - 1; idx >= 0; idx--{\n if idx == 0 {\n fmt.Printf(\"%d\\n\", t[idx])\n } else {\n fmt.Printf(\"%d \", t[idx])\n }\n }\n } else {\n fmt.Printf(\"No\\n\")\n }\n}"}, {"source_code": "package main\n \nimport \"fmt\"\n \n \nfunc main() {\n var a, b, steps int\n t := make([]int, 0)\n fmt.Scanf(\"%d %d\", &a, &b)\n fmt.Println(a, b)\n t = append(t, b)\n for {\n if a == b {\n break\n } else {\n if b % 2 == 0 {\n b = b / 2\n t = append(t, b)\n steps = steps + 1\n } else if (b - 1) % 10 == 0 {\n b = (b - 1) / 10\n t = append(t, b)\n steps = steps + 1\n } else {\n break\n }\n }\n }\n if a == b {\n fmt.Printf(\"YES\\n\")\n fmt.Printf(\"%d\\n\", steps)\n for idx, val := range t {\n if idx == len(t) - 1 {\n fmt.Printf(\"%d\\n\", val)\n } else {\n fmt.Printf(\"%d \", val)\n }\n }\n } else {\n fmt.Printf(\"No\\n\")\n }\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\ntype node struct {\n\tvalue int\n\tcount int\n\tprev *node\n}\n\nfunc newNode(n int) *node {\n\treturn &node{\n\t\tvalue: n,\n\t}\n}\n\nfunc main() {\n\tseen := make(map[int]bool)\n\tvar a, b int\n\tfmt.Fscanf(os.Stdin, \"%d %d\", &a, &b)\n\tqueue := []*node{newNode(b)}\n\n\tfor len(queue) > 0 {\n\t\tcurr := queue[0]\n\t\tqueue = queue[1:]\n\n\t\tif curr.value == a {\n\t\t\tfmt.Println(\"YES\")\n\t\t\tfmt.Println(curr.count + 1)\n\t\t\tfor n := curr; n != nil; n = n.prev {\n\t\t\t\tfmt.Printf(\"%d \", n.value)\n\t\t\t}\n\t\t\tfmt.Println()\n\t\t\treturn\n\t\t}\n\t\tif curr.value < a || seen[curr.value] {\n\t\t\tcontinue\n\t\t}\n\t\tseen[curr.value] = true\n\n\t\tn := newNode(curr.value >> 1)\n\t\tn.count = curr.count + 1\n\t\tn.prev = curr\n\t\tqueue = append(queue, n)\n\t\tif curr.value%10 == 1 {\n\t\t\tn := newNode(curr.value / 10)\n\t\t\tn.count = curr.count + 1\n\t\t\tn.prev = curr\n\t\t\tqueue = append(queue, n)\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}], "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3"} {"nl": {"description": "Our good friend Mole is trying to code a big message. He is typing on an unusual keyboard with characters arranged in following way:qwertyuiopasdfghjkl;zxcvbnm,./Unfortunately Mole is blind, so sometimes it is problem for him to put his hands accurately. He accidentally moved both his hands with one position to the left or to the right. That means that now he presses not a button he wants, but one neighboring button (left or right, as specified in input).We have a sequence of characters he has typed and we want to find the original message.", "input_spec": "First line of the input contains one letter describing direction of shifting ('L' or 'R' respectively for left or right). Second line contains a sequence of characters written by Mole. The size of this sequence will be no more than 100. Sequence contains only symbols that appear on Mole's keyboard. It doesn't contain spaces as there is no space on Mole's keyboard. It is guaranteed that even though Mole hands are moved, he is still pressing buttons on keyboard and not hitting outside it.", "output_spec": "Print a line that contains the original message.", "sample_inputs": ["R\ns;;upimrrfod;pbr"], "sample_outputs": ["allyouneedislove"], "notes": null}, "positive_code": [{"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\n\tkeys := \"qwertyuiopasdfghjkl;zxcvbnm,./\"\n\n\tdx := 1\n\tif next() == \"R\" {\n\t\tdx = -1\n\t}\n\t\n\tfor _, k := range next() {\n\t\tif strings.IndexRune(keys, k) > -1 {\n\t\t\tfmt.Print(string(keys[strings.IndexRune(keys, k) + dx]))\n\t\t}\n\t}\n}\n\nfunc next() string {\n\tin.Scan()\n\treturn in.Text()\n}"}, {"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\tmove := next()\n\ts := next()\n\tk := \"qwertyuiopasdfghjkl;zxcvbnm,./\"\n\tm := make(map[rune]int)\n\tret := make([]rune, 0)\n\tpos := 0\n\n\tfor i, v := range k {\n\t\tm[v] = i\n\t}\n\n\tfor _, v := range s {\n\t\tif move == \"L\" {\n\t\t\tswitch v {\n\t\t\t\tcase 'p':\n\t\t\t\t\tpos = m['p']\n\t\t\t\tcase ';':\n\t\t\t\t\tpos = m[';']\n\t\t\t\tcase '/':\n\t\t\t\t\tpos = m['/']\n\t\t\t\tdefault:\n\t\t\t\t\tpos = m[v] + 1\n\t\t\t}\n\n\t\t} else {\n\t\t\tswitch v {\n\t\t\tcase 'q':\n\t\t\t\tpos = m['q']\n\t\t\tcase 'a':\n\t\t\t\tpos = m['a']\n\t\t\tcase 'z':\n\t\t\t\tpos = m['z']\n\t\t\tdefault:\n\t\t\t\tpos = m[v] - 1\n\t\t\t}\n\t\t}\n\t\tret = append(ret, rune(k[pos]))\n\t\t// println(v, string(v), pos, string(k[pos]))\n\t\t// println(ret)\n\t}\n\n\tprintln(string(ret))\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}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tupperRow := map[string]int{\"q\": 1, \"w\": 2, \"e\": 3, \"r\": 4, \"t\": 5, \"y\": 6, \"u\": 7, \"i\": 8, \"o\": 9, \"p\": 10}\n\tlookUpUpperRow := map[int]string{1: \"q\", 2: \"w\", 3: \"e\", 4: \"r\", 5: \"t\", 6: \"y\", 7: \"u\", 8: \"i\", 9: \"o\", 10: \"p\"}\n\n\tmiddleRow := map[string]int{\"a\": 1, \"s\": 2, \"d\": 3, \"f\": 4, \"g\": 5, \"h\": 6, \"j\": 7, \"k\": 8, \"l\": 9, \";\": 10}\n\tlookUpMiddleRow := map[int]string{1: \"a\", 2: \"s\", 3: \"d\", 4: \"f\", 5: \"g\", 6: \"h\", 7: \"j\", 8: \"k\", 9: \"l\", 10: \";\"}\n\n\tlowerRow := map[string]int{\"z\": 1, \"x\": 2, \"c\": 3, \"v\": 4, \"b\": 5, \"n\": 6, \"m\": 7, \",\": 8, \".\": 9, \"/\": 10}\n\tlookUpLowerRow := map[int]string{1: \"z\", 2: \"x\", 3: \"c\", 4: \"v\", 5: \"b\", 6: \"n\", 7: \"m\", 8: \",\", 9: \".\", 10: \"/\"}\n\n\tvar shiftDirection, inputString string\n\n\tfmt.Scanf(\"%s\\n\", &shiftDirection)\n\n\tfmt.Scanf(\"%s\\n\", &inputString)\n\n\tstrSize := len(inputString)\n\n\tfor i := 0; i < strSize; i++ {\n\t\tif upperRow[string(inputString[i])] != 0 {\n\t\t\ttargetPos := upperRow[string(inputString[i])]\n\t\t\tif shiftDirection == \"R\" {\n\t\t\t\tfmt.Print(lookUpUpperRow[targetPos-1])\n\t\t\t} else {\n\t\t\t\tfmt.Print(lookUpUpperRow[targetPos+1])\n\t\t\t}\n\t\t} else if middleRow[string(inputString[i])] != 0 {\n\t\t\ttargetPos := middleRow[string(inputString[i])]\n\t\t\tif shiftDirection == \"R\" {\n\t\t\t\tfmt.Print(lookUpMiddleRow[targetPos-1])\n\t\t\t} else {\n\t\t\t\tfmt.Print(lookUpMiddleRow[targetPos+1])\n\t\t\t}\n\t\t} else {\n\t\t\ttargetPos := lowerRow[string(inputString[i])]\n\t\t\tif shiftDirection == \"R\" {\n\t\t\t\tfmt.Print(lookUpLowerRow[targetPos-1])\n\t\t\t} else {\n\t\t\t\tfmt.Print(lookUpLowerRow[targetPos+1])\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println()\n\n}\n"}, {"source_code": "// test project main.go\npackage main\n\nimport (\n \"fmt\"\n)\n\nfunc main() {\n key := []string{\"qwertyuiop\", \"asdfghjkl;\", \"zxcvbnm,./\"}\n ch := \"\"\n str := \"\"\n fmt.Scan(&ch)\n fmt.Scan(&str)\n add := 0\n if \"R\" == ch {\n add = -1\n } else {\n add = 1\n }\n for k := 0; k < len(str); k++ {\n for i := 0; i < 3; i++ {\n for j := 0; j < len(key[i]); j++ {\n if key[i][j] == str[k] {\n fmt.Printf(\"%c\", key[i][j+add])\n }\n }\n }\n }\n fmt.Println()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\trep := \"qwertyuiopasdfghjkl;zxcvbnm,./\"\n\tvar d, s string\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\td = scanner.Text()\n\tscanner.Scan()\n\ts = scanner.Text()\n\n\tif strings.Compare(d, \"R\") == 0 {\n\t\tfor i := 1; i < len(rep); i++ {\n\t\t\ts = strings.Replace(s, string(rep[i]), string(rep[i-1]), -1)\n\t\t}\n\t}\n\tif strings.Compare(d, \"L\") == 0 {\n\t\tfor i := len(rep) - 1; i > 0; i-- {\n\t\t\ts = strings.Replace(s, string(rep[i-1]), string(rep[i]), -1)\n\t\t}\n\t}\n\tfmt.Print(s)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar dir,words string\n\tkey := \"qwertyuiopasdfghjkl;zxcvbnm,./\"\n\n\tfmt.Scanf(\"%s\\n\", &dir)\n\tfmt.Scanf(\"%s\", &words)\n\tfor i := 0; i < len(words); i++ {\n\t\tfor j := 0; j < len(key); j++ {\n\t\t\t\t// fmt.Printf(string(key[i][j]))\n\t\t\tif (string(words[i]) == string(key[j])) {\n\t\t\t\tif(strings.ToLower(string(dir)) == \"r\"){\n\t\t\t\t\tfmt.Printf(\"%c\", key[j-1])\n\t\t\t\t}else{\n\t\t\t\t\tfmt.Printf(\"%c\", key[j+1])\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t}\n\t// fmt.Println(key)\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar KBD = []string{\"qwertyuiop\", \"asdfghjkl;\", \"zxcvbnm,./\"}\n\n\tvar kbd [3][10]rune\n\tfor i := range KBD {\n\t\tfor j, c := range KBD[i] {\n\t\t\tkbd[i][j] = c\n\t\t}\n\t}\n\tL, R, shift := make(map[rune]rune), make(map[rune]rune), make(map[rune]rune)\n\t// make L\n\tfor i := range KBD {\n\t\tfor j := range KBD[i] {\n\t\t\tif j == 9 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tL[kbd[i][j]] = kbd[i][j+1]\n\t\t}\n\t}\n\t// make R\n\tfor i := range KBD {\n\t\tfor j := range KBD[i] {\n\t\t\tif j == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tR[kbd[i][j]] = kbd[i][j-1]\n\t\t}\n\t}\n\tvar d, mole string\n\tfmt.Scanln(&d)\n\tif d == \"R\" {\n\t\tshift = R\n\t} else {\n\t\tshift = L\n\t}\n\tfmt.Scanln(&mole)\n\tfor _, c := range mole {\n\t\tfmt.Printf(string(shift[c]))\n\t}\n\tfmt.Println()\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\ntype Site struct {\n\trow int\n\tpos int\n}\n\nvar keyboards [3][]byte\nvar sites map[byte]*Site\n\nfunc init() {\n\tkeyboards[0] = []byte(\"qwertyuiop\")\n\tkeyboards[1] = []byte(\"asdfghjkl;\")\n\tkeyboards[2] = []byte(\"zxcvbnm,./\")\n\n\tsites = make(map[byte]*Site)\n\tfor i := 0; i < 3; i++ {\n\t\tfor j := 0; j < len(keyboards[i]); j++ {\n\t\t\tsites[keyboards[i][j]] = &Site{i, j}\n\t\t}\n\t}\n}\n\nfunc main() {\n\tvar c, word string\n\tfmt.Scan(&c, &word)\n\n\tfor i := 0; i < len(word); i++ {\n\t\tsite := sites[word[i]]\n\t\tif c == \"R\" {\n\t\t\tfmt.Printf(\"%c\", keyboards[site.row][site.pos-1])\n\t\t} else {\n\t\t\tfmt.Printf(\"%c\", keyboards[site.row][site.pos+1])\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"bytes\"\n \"fmt\"\n \"strings\"\n)\n\nfunc main() {\n kb := `qwertyuiop\n asdfghjkl;\n zxcvbnm,./`\n var (\n d string\n s string\n )\n fmt.Scan(&d, &s)\n\n i := 1\n if d == \"R\" {\n i = -1\n }\n\n var buffer bytes.Buffer\n for _, v := range s {\n ind := strings.IndexRune(kb, v)\n buffer.WriteString(string(kb[ind+i]))\n }\n fmt.Println(buffer.String())\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tk := \"qwertyuiopasdfghjkl;zxcvbnm,./\"\n\tvar keyboard [128]int\n\n\tfor i := 0; i < len(k); i++ {\n\t\tkeyboard[int(k[i])] = i\n\t}\n\n\tvar d, s, r string\n\tfmt.Scanln(&d)\n\tfmt.Scanln(&s)\n\n\tfor i := 0; i < len(s); i++ {\n\t\tif d == \"R\" {\n\t\t\tindex := keyboard[int(s[i])]\n\t\t\tr += string(k[index-1])\n\t\t} else {\n\t\t\tr += string(k[keyboard[int(s[i])]+1])\n\t\t}\n\t}\n\n\tfmt.Println(r)\n}\n"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n scanner.Scan()\n ans, _ := strconv.Atoi(scanner.Text())\n return ans\n}\n\nfunc ReadString() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n defer writer.Flush()\n scanner.Split(bufio.ScanWords)\n var q int\n a := make([]string, 3)\n a[0] = \"qwertyuiop\"\n a[1] = \"asdfghjkl;\"\n a[2] = \"zxcvbnm,./\"\n s := ReadString()\n if s == \"R\" {\n q = -1\n } else {\n q = 1\n }\n s = ReadString()\n r := \"\"\n dicti := make(map[uint8]int)\n dictj := make(map[uint8]int)\n for j := 0; j < 3; j++ {\n for i := 0; i < 10; i++ {\n dicti[a[j][i]] = i\n dictj[a[j][i]] = j\n }\n }\n for i := 0; i < len(s); i++ {\n r += string(a[dictj[s[i]]][dicti[s[i]]+q])\n }\n writer.WriteString(r)\n writer.WriteString(\"\\n\")\n}\n"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n scanner.Scan()\n ans, _ := strconv.Atoi(scanner.Text())\n return ans\n}\n\nfunc ReadString() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n defer writer.Flush()\n scanner.Split(bufio.ScanWords)\n var q int\n keyboard := \"qwertyuiopasdfghjkl;zxcvbnm,./\"\n dict := make(map[uint8]int)\n\n if ReadString() == \"R\" {\n q = -1\n } else {\n q = 1\n }\n\n s := ReadString()\n for i := 0; i < len(keyboard); i++ {\n dict[keyboard[i]] = i\n }\n\n r := \"\"\n for i := range s {\n r += string(keyboard[dict[s[i]]+q])\n }\n\n writer.WriteString(r + \"\\n\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tr := map[string]string{\n\t\t\"q\":\"\", \"w\":\"q\", \"e\":\"w\", \"r\":\"e\", \"t\":\"r\", \"y\":\"t\", \"u\":\"y\", \"i\":\"u\", \"o\":\"i\", \"p\":\"o\",\n\t\t\"a\":\"\", \"s\":\"a\", \"d\":\"s\", \"f\":\"d\", \"g\":\"f\", \"h\":\"g\", \"j\":\"h\", \"k\":\"j\", \"l\":\"k\", \";\":\"l\",\n\t\t\"z\":\"\", \"x\":\"z\", \"c\":\"x\", \"v\":\"c\", \"b\":\"v\", \"n\":\"b\", \"m\":\"n\", \",\":\"m\", \".\":\",\", \"/\":\".\",\n\t}\n\tl := map[string]string{\n\t\t\"q\":\"w\", \"w\":\"e\", \"e\":\"r\", \"r\":\"t\", \"t\":\"y\", \"y\":\"u\", \"u\":\"i\", \"i\":\"o\", \"o\":\"p\", \"p\":\"\",\n\t\t\"a\":\"s\", \"s\":\"d\", \"d\":\"f\", \"f\":\"g\", \"g\":\"h\", \"h\":\"j\", \"j\":\"k\", \"k\":\"l\", \"l\":\";\", \";\":\"\",\n\t\t\"z\":\"x\", \"x\":\"c\", \"c\":\"v\", \"v\":\"b\", \"b\":\"n\", \"n\":\"m\", \"m\":\",\", \",\":\".\", \".\":\"/\", \"/\":\"\",\n\t}\n\n\treader := bufio.NewReader(os.Stdin)\n\tshift, _ := reader.ReadString('\\n')\n\tchain, _ := reader.ReadString('\\n')\n\n\tif(strings.TrimSpace(shift) == \"R\") {\n\t\tchain = convert(&r, chain)\n\t} else {\n\t\tchain = convert(&l, chain)\n\t}\n\tfmt.Printf(\"%s\\n\", chain)\n}\n\nfunc convert(m *map[string]string, chain string) string {\n\tfor i := 0; i < len(chain); i++ {\n\t\tvar c = string(chain[i])\n\t\tc = (*m)[c]\n\t\tchain = replaceAtIndex(chain, c, i)\n\t}\n\treturn chain\n}\n\nfunc replaceAtIndex(str string, char string, index int) string {\n\treturn str[:index] + char + str[index+1:]\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n )\n\nconst keyboard = \"qwertyuiopasdfghjkl;zxcvbnm,./\"\n\nfunc get_real(mov string, ch byte) string {\n i := 0\n for i = 0; i < len(keyboard); i++ {\n if keyboard[i] == ch {\n break\n }\n }\n if mov == \"R\" {\n return string(keyboard[i-1])\n } else {\n return string(keyboard[i+1])\n }\n}\n\nfunc main() {\n var mov string\n fmt.Scan(&mov)\n\n var line string\n fmt.Scan(&line)\n\n result := \"\"\n for i := 0; i < len(line); i++ {\n result += get_real(mov, line[i])\n }\n\n fmt.Println(result)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar direction string\n\tvar myString string\n\tcharArr := [...]string{\"q\", \"w\", \"e\", \"r\", \"t\", \"y\", \"u\", \"i\", \"o\", \"p\",\n\t\t\"a\", \"s\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \";\",\n\t\t\"z\", \"x\", \"c\", \"v\", \"b\", \"n\", \"m\", \",\", \".\", \"/\"}\n\treader := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(reader, &direction)\n\tfmt.Fscan(reader, &myString)\n\tfor _, currentChar := range myString {\n\t\tfor index := 0; index < len(charArr); index++ {\n\t\t\tif string(currentChar) == charArr[index] {\n\t\t\t\tif direction == \"R\" {\n\t\t\t\t\tfmt.Print(charArr[index-1])\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Print(charArr[index+1])\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n}\n"}, {"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 d := next()\n s := next()\n a := []string {\"qwertyuiop\", \"asdfghjkl;\", \"zxcvbnm,./\"}\n ans := \"\"\n dx := 1\n if d == \"L\" {\n dx = -1\n }\n for l := 0; l < len(s); l++ {\n for i := 0; i < len(a); i++ {\n ok := false\n for j := 0; j < len(a[i]); j++ {\n if a[i][j] == s[l] {\n ans = ans + string(a[i][j - dx])\n ok = true\n break\n }\n }\n if ok {\n break\n }\n }\n }\n fmt.Fprintln(out, ans)\n}\n"}, {"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\tscanner = bufio.NewScanner(os.Stdin)\n\treader = bufio.NewReader(os.Stdin)\n\twriter = bufio.NewWriter(os.Stdout)\n)\n\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\tside := next()\n\tvar result []string\n\tif side == \"R\" {\n\t\tresult = getChangedString(-1)\n\t} else {\n\t\tresult = getChangedString(1)\n\t}\n\tfmt.Println(strings.Join(result, \"\"))\n}\n\nfunc scan(a ...interface{}) {\n\tfmt.Fscan(reader, a...)\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(\"Scan error\")\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc println(a ...interface{}) {\n\tfmt.Fprintln(writer, a...)\n}\n\nfunc getChangedString(p int) []string {\n\tinputStr := next()\n\tfirstLine := \"qwertyuiopasdfghjkl;zxcvbnm,./\"\n\tsplitOfChars := splitString(firstLine)\n\tsplitInput := splitString(inputStr)\n\tresult := make([]string, len(splitInput))\n\tfor i, c := range splitInput {\n\t\tfor j, a := range splitOfChars {\n\t\t\tif a == c {\n\t\t\t\tresult[i] = splitOfChars[j+p]\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\treturn result\n}\n\nfunc splitString(input string) (result []string) {\n\tresult = strings.Split(input, \"\")\n\treturn\n}\n"}], "negative_code": [{"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\n\tkeys := \"qwertyuiopasdfghjkl;zxcvbnm, ./\"\n\n\tdx := 1\n\tif next() == \"R\" {\n\t\tdx = -1\n\t}\n\n\tfor _, k := range next() {\n\t\tif strings.IndexRune(keys, k) > -1 {\n\t\t\tfmt.Print(string(keys[strings.IndexRune(keys, k) + dx]))\n\t\t}\n\t}\n}\n\nfunc next() string {\n\tin.Scan()\n\treturn in.Text()\n}"}, {"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\n\tkeys := []string{\n\t\t\"qwertyuiop\",\n\t\t\"asdfghjkl;\",\n\t\t\"zxcvbnm, ./\",\n\t}\n\n\tdx := 1\n\tif next() == \"R\" {\n\t\tdx = -1\n\t}\n\n\tfor _, k := range next() {\n\t\tfor _, s := range keys {\n\t\t\tif strings.IndexRune(s, k) > -1 {\n\t\t\t\tfmt.Print(string(s[strings.IndexRune(s, k) + dx]))\n\t\t\t}\n\t\t}\n\t}\n\n}\n\nfunc next() string {\n\tin.Scan()\n\treturn in.Text()\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tupperRow := map[string]int{\"q\": 1, \"w\": 2, \"e\": 3, \"r\": 4, \"t\": 5, \"y\": 6, \"u\": 7, \"i\": 8, \"o\": 9, \"p\": 10}\n\tlookUpUpperRow := map[int]string{1: \"q\", 2: \"w\", 3: \"e\", 4: \"r\", 5: \"t\", 6: \"y\", 7: \"u\", 8: \"i\", 9: \"o\", 10: \"p\"}\n\n\tmiddleRow := map[string]int{\"a\": 1, \"s\": 2, \"d\": 3, \"f\": 4, \"g\": 5, \"h\": 6, \"j\": 7, \"k\": 8, \"l\": 9, \";\": 10}\n\tlookUpMiddleRow := map[int]string{1: \"a\", 2: \"s\", 3: \"d\", 4: \"f\", 5: \"g\", 6: \"h\", 7: \"j\", 8: \"k\", 9: \"l\", 10: \";\"}\n\n\tlowerRow := map[string]int{\"z\": 1, \"x\": 2, \"c\": 3, \"v\": 4, \"b\": 5, \"n\": 6, \"m\": 7, \",\": 8, \".\": 9, \"/\": 10}\n\tlookUpLowerRow := map[int]string{1: \"z\", 2: \"x\", 3: \"c\", 4: \"v\", 5: \"b\", 6: \"n\", 7: \"m\", 8: \",\", 9: \".\", 10: \"/\"}\n\n\tvar shiftDirection, inputString string\n\n\tfmt.Scanf(\"%s\\n\", &shiftDirection)\n\n\tfmt.Scanf(\"%s\\n\", &inputString)\n\n\tstrSize := len(inputString)\n\n\tfor i := 0; i < strSize; i++ {\n\t\tif upperRow[string(inputString[i])] != 0 {\n\t\t\ttargetPos := upperRow[string(inputString[i])]\n\t\t\tif shiftDirection == \"L\" {\n\t\t\t\tfmt.Print(lookUpUpperRow[targetPos-1])\n\t\t\t} else {\n\t\t\t\tfmt.Print(lookUpUpperRow[targetPos+1])\n\t\t\t}\n\t\t} else if middleRow[string(inputString[i])] != 0 {\n\t\t\ttargetPos := middleRow[string(inputString[i])]\n\t\t\tif shiftDirection == \"L\" {\n\t\t\t\tfmt.Print(lookUpMiddleRow[targetPos-1])\n\t\t\t} else {\n\t\t\t\tfmt.Print(lookUpMiddleRow[targetPos+1])\n\t\t\t}\n\t\t} else {\n\t\t\ttargetPos := lowerRow[string(inputString[i])]\n\t\t\tif shiftDirection == \"L\" {\n\t\t\t\tfmt.Print(lookUpLowerRow[targetPos-1])\n\t\t\t} else {\n\t\t\t\tfmt.Print(lookUpLowerRow[targetPos+1])\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println()\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar KBD = []string{\"qwertyuiop\", \"asdfghjkl;\", \"zxcvbnm,./\"}\n\n\tvar kbd [3][10]rune\n\tfor i := range KBD {\n\t\tfor j, c := range KBD[i] {\n\t\t\tkbd[i][j] = c\n\t\t}\n\t}\n\tL, R, shift := make(map[rune]rune), make(map[rune]rune), make(map[rune]rune)\n\t// make L\n\tfor i := range KBD {\n\t\tfor j := range KBD[i] {\n\t\t\tif j == 9 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tL[kbd[i][j]] = kbd[i][j+1]\n\t\t}\n\t}\n\t// make R\n\tfor i := range KBD {\n\t\tfor j := range KBD[i] {\n\t\t\tif j == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tR[kbd[i][j]] = kbd[i][j-1]\n\t\t}\n\t}\n\tvar d, mole string\n\tfmt.Scanln(&d)\n\tif d == \"R\" {\n\t\tshift = R\n\t} else {\n\t\tshift = L\n\t}\n\tfmt.Scanln(&mole)\n\tfmt.Println(mole)\n\tfor _, c := range mole {\n\t\tfmt.Printf(string(shift[c]))\n\t}\n\tfmt.Println()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tl := map[string]string{\n\t\t\"q\":\"\", \"w\":\"q\", \"e\":\"w\", \"r\":\"e\", \"t\":\"r\", \"y\":\"t\", \"u\":\"y\", \"i\":\"u\", \"o\":\"i\", \"p\":\"o\",\n\t\t\"a\":\"\", \"s\":\"a\", \"d\":\"s\", \"f\":\"d\", \"g\":\"f\", \"h\":\"g\", \"j\":\"h\", \"k\":\"j\", \"l\":\"k\", \";\":\"l\",\n\t\t\"z\":\"\", \"x\":\"z\", \"c\":\"x\", \"v\":\"c\", \"b\":\"v\", \"n\":\"b\", \"m\":\"n\", \",\":\"m\", \".\":\",\", \"/\":\".\",\n\t}\n\tr := map[string]string{\n\t\t\"q\":\"w\", \"w\":\"e\", \"e\":\"r\", \"r\":\"t\", \"t\":\"y\", \"y\":\"u\", \"u\":\"i\", \"i\":\"o\", \"o\":\"p\", \"p\":\"\",\n\t\t\"a\":\"s\", \"s\":\"d\", \"d\":\"f\", \"f\":\"g\", \"g\":\"h\", \"h\":\"j\", \"j\":\"k\", \"k\":\"l\", \"l\":\";\", \";\":\"\",\n\t\t\"z\":\"x\", \"x\":\"c\", \"c\":\"v\", \"v\":\"b\", \"b\":\"n\", \"n\":\"m\", \"m\":\",\", \",\":\".\", \".\":\"/\", \"/\":\"\",\n\t}\n\n\treader := bufio.NewReader(os.Stdin)\n\tshift, _ := reader.ReadString('\\n')\n\tchain, _ := reader.ReadString('\\n')\n\n\tif(shift == \"R\") {\n\t\tchain = convert(&r, chain)\n\t} else {\n\t\tchain = convert(&l, chain)\n\t}\n\tfmt.Printf(\"%s\\n\", chain)\n}\n\nfunc convert(m *map[string]string, chain string) string {\n\tfor i := 0; i < len(chain); i++ {\n\t\tvar c = string(chain[i])\n\t\tc = (*m)[c]\n\t\tchain = replaceAtIndex(chain, c, i)\n\t}\n\treturn chain\n}\n\nfunc replaceAtIndex(str string, char string, index int) string {\n\treturn str[:index] + char + str[index+1:]\n}"}], "src_uid": "df49c0c257903516767fdb8ac9c2bfd6"} {"nl": {"description": "You are given two squares, one with sides parallel to the coordinate axes, and another one with sides at 45 degrees to the coordinate axes. Find whether the two squares intersect.The interior of the square is considered to be part of the square, i.e. if one square is completely inside another, they intersect. If the two squares only share one common point, they are also considered to intersect.", "input_spec": "The input data consists of two lines, one for each square, both containing 4 pairs of integers. Each pair represents coordinates of one vertex of the square. Coordinates within each line are either in clockwise or counterclockwise order. The first line contains the coordinates of the square with sides parallel to the coordinate axes, the second line contains the coordinates of the square at 45 degrees. All the values are integer and between $$$-100$$$ and $$$100$$$.", "output_spec": "Print \"Yes\" if squares intersect, otherwise print \"No\". You can print each letter in any case (upper or lower).", "sample_inputs": ["0 0 6 0 6 6 0 6\n1 3 3 5 5 3 3 1", "0 0 6 0 6 6 0 6\n7 3 9 5 11 3 9 1", "6 0 6 6 0 6 0 0\n7 4 4 7 7 10 10 7"], "sample_outputs": ["YES", "NO", "YES"], "notes": "NoteIn the first example the second square lies entirely within the first square, so they do intersect.In the second sample squares do not have any points in common.Here are images corresponding to the samples: "}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\ntype Vec [4]int\n\nfunc (v Vec) max() int {\n\tmax := -999\n\tfor i := 0;i < len(v);i ++ {\n\t\tif v[i] > max {\n\t\t\tmax = v[i]\n\t\t}\n\t}\n\treturn max\n}\n\nfunc (v Vec) min() int {\n\tmin := 999\n\tfor i := 0;i < len(v);i ++ {\n\t\tif v[i] < min {\n\t\t\tmin = v[i]\n\t\t}\n\t}\n\treturn min\n}\n\nfunc abs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t} else {\n\t\treturn x\n\t}\n}\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\t\n\tvar ax, ay, bx, by Vec\n\tfmt.Fscanf(reader, \"%d %d %d %d %d %d %d %d\\n\", &ax[0], &ay[0], &ax[1], &ay[1], &ax[2], &ay[2], &ax[3], &ay[3])\n\tfmt.Fscanf(reader, \"%d %d %d %d %d %d %d %d\\n\", &bx[0], &by[0], &bx[1], &by[1], &bx[2], &by[2], &bx[3], &by[3])\n\t\n\taxMax, axMin, ayMax, ayMin := ax.max(), ax.min(), ay.max(), ay.min()\n\tbxMax, bxMin, byMax, byMin := bx.max(), bx.min(), by.max(), by.min()\n\tbxAvg, byAvg := (bxMax + bxMin) / 2, (byMax + byMin) / 2\n\tdist := bxMax - bxAvg\n\n\n\n\tfor x := -100; x <= 100; x ++ {\n\t\tfor y := -100; y <= 100; y ++ {\n\t\t\tif (axMin <= x && x <= axMax && ayMin <= y && y <= ayMax) {\n\t\t\t\tif (abs(x - bxAvg) + abs(y - byAvg) <= dist) {\n\t\t\t\t\tfmt.Printf(\"YES\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Printf(\"NO\")\n\treturn\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\ntype Point struct {\n\tX, Y float64\n}\n\ntype Square struct {\n\tPoints [4]Point\n}\n\nfunc rotateAxis(p Point, angle float64) (res Point) {\n\tres = Point{}\n\tangle = (angle * math.Pi) / 180\n\tres.X = p.X*math.Cos(angle) + p.Y*math.Sin(angle)\n\tres.Y = -1*p.X*math.Sin(angle) + p.Y*math.Cos(angle)\n\treturn\n}\n\nfunc isInSquare(sq Square, p Point) (b bool) {\n\tvar minHoz float64 = 101\n\tfor _, v := range sq.Points {\n\t\tminHoz = math.Min(minHoz, v.Y)\n\t}\n\n\tvar maxHoz float64 = -101\n\tfor _, v := range sq.Points {\n\t\tmaxHoz = math.Max(maxHoz, v.Y)\n\t}\n\n\tvar minVer float64 = 101\n\tfor _, v := range sq.Points {\n\t\tminVer = math.Min(minVer, v.X)\n\t}\n\n\tvar maxVer float64 = -101\n\tfor _, v := range sq.Points {\n\t\tmaxVer = math.Max(maxVer, v.X)\n\t}\n\n\treturn (p.X >= minVer && p.X <= maxVer) && (p.Y >= minHoz && p.Y <= maxHoz)\n}\n\nfunc solve(sq, sq45 Square) bool {\n\tcenter := Point{0, 0}\n\tfor _, v := range sq45.Points {\n\t\tcenter.X += v.X\n\t\tcenter.Y += v.Y\n\t\tif isInSquare(sq, v) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\tcenter.X /= 4\n\tcenter.Y /= 4\n\tif isInSquare(sq, center) {\n\t\treturn true\n\t}\n\n\trotatedSquare := Square{}\n\tfor i := range rotatedSquare.Points {\n\t\trotatedSquare.Points[i] = rotateAxis(sq45.Points[i], 45)\n\t}\n\n\tcenter = Point{0, 0}\n\tfor _, v := range sq.Points {\n\t\tcenter.X += v.X\n\t\tcenter.Y += v.Y\n\t\trotatedPoint := rotateAxis(v, 45)\n\t\tif isInSquare(rotatedSquare, rotatedPoint) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\tcenter.X /= 4\n\tcenter.Y /= 4\n\trotatedCenter := rotateAxis(center, 45)\n\tif isInSquare(rotatedSquare, rotatedCenter) {\n\t\treturn true\n\t}\n\n\treturn false\n}\n\nfunc consoleInput() {\n\tvar x, y float64\n\tsq := Square{}\n\tfor i := 0; i < 4; i++ {\n\t\tfmt.Scan(&x, &y)\n\t\tsq.Points[i] = Point{\n\t\t\tX: x,\n\t\t\tY: y,\n\t\t}\n\t}\n\n\tsq45 := Square{}\n\tfor i := 0; i < 4; i++ {\n\t\tfmt.Scan(&x, &y)\n\t\tsq45.Points[i] = Point{\n\t\t\tX: x,\n\t\t\tY: y,\n\t\t}\n\t}\n\n\tif solve(sq, sq45) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nfunc mustEqual(expected, actual bool) {\n\tif expected == actual {\n\t\tfmt.Println(\"OK\")\n\t} else {\n\t\tfmt.Println(\"FAILED\")\n\t}\n}\n\nfunc test() {\n\t{\n\t\tsq := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{0, 0},\n\t\t\t\tPoint{6, 0},\n\t\t\t\tPoint{6, 6},\n\t\t\t\tPoint{0, 6},\n\t\t\t},\n\t\t}\n\n\t\tsq45 := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{1, 3},\n\t\t\t\tPoint{3, 5},\n\t\t\t\tPoint{5, 3},\n\t\t\t\tPoint{3, 1},\n\t\t\t},\n\t\t}\n\n\t\tmustEqual(true, solve(sq, sq45))\n\t}\n\n\t{\n\t\tsq := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{0, 0},\n\t\t\t\tPoint{6, 0},\n\t\t\t\tPoint{6, 6},\n\t\t\t\tPoint{0, 6},\n\t\t\t},\n\t\t}\n\n\t\tsq45 := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{7, 3},\n\t\t\t\tPoint{9, 5},\n\t\t\t\tPoint{11, 3},\n\t\t\t\tPoint{9, 1},\n\t\t\t},\n\t\t}\n\n\t\tmustEqual(false, solve(sq, sq45))\n\t}\n\n\t{\n\t\tsq := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{6, 0},\n\t\t\t\tPoint{6, 6},\n\t\t\t\tPoint{0, 6},\n\t\t\t\tPoint{0, 0},\n\t\t\t},\n\t\t}\n\n\t\tsq45 := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{7, 4},\n\t\t\t\tPoint{4, 7},\n\t\t\t\tPoint{7, 10},\n\t\t\t\tPoint{10, 7},\n\t\t\t},\n\t\t}\n\n\t\tmustEqual(true, solve(sq, sq45))\n\t}\n\n\t{\n\t\tsq := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{-5, -5},\n\t\t\t\tPoint{5, -5},\n\t\t\t\tPoint{5, 5},\n\t\t\t\tPoint{-5, 5},\n\t\t\t},\n\t\t}\n\n\t\tsq45 := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{6, 0},\n\t\t\t\tPoint{0, 6},\n\t\t\t\tPoint{-6, 0},\n\t\t\t\tPoint{0, -6},\n\t\t\t},\n\t\t}\n\n\t\tmustEqual(true, solve(sq, sq45))\n\t}\n}\n\nfunc main() {\n\tconsoleInput()\n\t// test()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\ntype Int64Slice []int64\n\nfunc (slice Int64Slice) Len() int { return len(slice) }\nfunc (slice Int64Slice) Less(i, j int) bool { return slice[i] < slice[j] }\nfunc (slice Int64Slice) Swap(i, j int) { slice[i], slice[j] = slice[j], slice[i] }\n\ntype Sq struct {\n\tv [8]int\n}\n\nfunc (sq *Sq) isPara() bool {\n\tchk1, chk2 := false, false\n\n\tfor i := 2; i < 8; i = i + 2 {\n\t\tif sq.v[i] == sq.v[0] {\n\t\t\tchk1 = true\n\t\t}\n\t}\n\tfor i := 3; i < 8; i = i + 2 {\n\t\tif sq.v[i] == sq.v[1] {\n\t\t\tchk2 = true\n\t\t}\n\t}\n\n\tif chk1 && chk2 {\n\t\treturn true\n\t}\n\treturn false\n}\n\nvar s1, s2 Sq\n\nfunc gettoux() bool {\n\txmin := s1.v[0]\n\txmax := s1.v[0]\n\tfor i := 2; i < 8; i = i + 2 {\n\t\tif s1.v[i] < xmin {\n\t\t\txmin = s1.v[i]\n\t\t}\n\t\tif s1.v[i] > xmax {\n\t\t\txmax = s1.v[i]\n\t\t}\n\t}\n\tymin := s2.v[0]\n\tymax := s2.v[0]\n\tfor i := 2; i < 8; i = i + 2 {\n\t\tif s2.v[i] < ymin {\n\t\t\tymin = s2.v[i]\n\t\t}\n\t\tif s2.v[i] > ymax {\n\t\t\tymax = s2.v[i]\n\t\t}\n\t}\n\n\tif xmax < ymin || ymax < xmin {\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc gettouy() bool {\n\txmin := s1.v[1]\n\txmax := s1.v[1]\n\tfor i := 3; i < 8; i = i + 2 {\n\t\tif s1.v[i] < xmin {\n\t\t\txmin = s1.v[i]\n\t\t}\n\t\tif s1.v[i] > xmax {\n\t\t\txmax = s1.v[i]\n\t\t}\n\t}\n\tymin := s2.v[1]\n\tymax := s2.v[1]\n\tfor i := 3; i < 8; i = i + 2 {\n\t\tif s2.v[i] < ymin {\n\t\t\tymin = s2.v[i]\n\t\t}\n\t\tif s2.v[i] > ymax {\n\t\t\tymax = s2.v[i]\n\t\t}\n\t}\n\n\tif xmax < ymin || ymax < xmin {\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc gettouxaddy() bool {\n\txmin := s1.v[0] + s1.v[1]\n\txmax := s1.v[0] + s1.v[1]\n\tfor i := 2; i < 8; i = i + 2 {\n\t\tif s1.v[i]+s1.v[i+1] < xmin {\n\t\t\txmin = s1.v[i] + s1.v[i+1]\n\t\t}\n\t\tif s1.v[i]+s1.v[i+1] > xmax {\n\t\t\txmax = s1.v[i] + s1.v[i+1]\n\t\t}\n\t}\n\tymin := s2.v[0] + s2.v[1]\n\tymax := s2.v[0] + s2.v[1]\n\tfor i := 2; i < 8; i = i + 2 {\n\t\tif s2.v[i]+s2.v[i+1] < ymin {\n\t\t\tymin = s2.v[i] + s2.v[i+1]\n\t\t}\n\t\tif s2.v[i]+s2.v[i+1] > ymax {\n\t\t\tymax = s2.v[i] + s2.v[i+1]\n\t\t}\n\t}\n\n\tif xmax < ymin || ymax < xmin {\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc gettouxsuby() bool {\n\txmin := s1.v[0] - s1.v[1]\n\txmax := s1.v[0] - s1.v[1]\n\tfor i := 2; i < 8; i = i + 2 {\n\t\tif s1.v[i]-s1.v[i+1] < xmin {\n\t\t\txmin = s1.v[i] - s1.v[i+1]\n\t\t}\n\t\tif s1.v[i]-s1.v[i+1] > xmax {\n\t\t\txmax = s1.v[i] - s1.v[i+1]\n\t\t}\n\t}\n\tymin := s2.v[0] - s2.v[1]\n\tymax := s2.v[0] - s2.v[1]\n\tfor i := 2; i < 8; i = i + 2 {\n\t\tif s2.v[i]-s2.v[i+1] < ymin {\n\t\t\tymin = s2.v[i] - s2.v[i+1]\n\t\t}\n\t\tif s2.v[i]-s2.v[i+1] > ymax {\n\t\t\tymax = s2.v[i] - s2.v[i+1]\n\t\t}\n\t}\n\n\tif xmax < ymin || ymax < xmin {\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tfor i := 0; i < 8; i++ {\n\t\ts1.v[i] = ReadInt32()\n\t}\n\n\tfor i := 0; i < 8; i++ {\n\t\ts2.v[i] = ReadInt32()\n\t}\n\n\tif !s1.isPara() {\n\t\ts1, s2 = s2, s1\n\t}\n\n\tif gettoux() && gettouy() && gettouxaddy() && gettouxsuby() {\n\t\tfmt.Printf(\"YES\")\n\t} else {\n\t\tfmt.Printf(\"NO\")\n\t}\n}\n\nfunc Demo() {\n\tvar n, m int64 = ReadInt64(), ReadInt64()\n\tPrintInt64s(n, m)\n\twriter.WriteByte('\\n')\n\tslice := []int64{1, 2, 3, 4, 5}\n\tPrintInt64s(slice...)\n\n\t// sortDemo\n\t//slice := []int64{5, 3, 4, 2, 1}\n\tsort.Sort(Int64Slice(slice))\n\n\t//s := strconv.FormatBool(true)\n\t//s := strconv.FormatFloat(3.1415, 'E', -1, 64)\n\t//s := strconv.FormatInt(-42, 16)\n\t//s := strconv.FormatUint(42, 16)\n\n}\n\nfunc Min(a int64, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MinInt(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MinFloat64(a float64, b float64) float64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MaxInt64(a int64, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MaxInt(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MaxFloat64(a float64, b float64) float64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc ReadInt32() int {\n\tscanner.Scan()\n\tans, _ := strconv.Atoi(scanner.Text())\n\treturn ans\n}\n\nfunc ReadInt64() int64 {\n\tscanner.Scan()\n\tans, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\treturn ans\n}\n\nfunc ReadFloat64() float64 {\n\tscanner.Scan()\n\tans, _ := strconv.ParseFloat(scanner.Text(), 64)\n\treturn ans\n}\n\nfunc PrintInt64s(ints ...int64) {\n\tfor _, value := range ints {\n\t\twriter.WriteString(strconv.Itoa(int(value)))\n\t\twriter.WriteByte(' ')\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\ntype Point struct {\n\tX, Y float64\n}\n\ntype Square struct {\n\tPoints [4]Point\n}\n\nfunc rotateAxis(p Point, angle float64) (res Point) {\n\tres = Point{}\n\tangle = (angle * math.Pi) / 180\n\tres.X = p.X*math.Cos(angle) + p.Y*math.Sin(angle)\n\tres.Y = -1*p.X*math.Sin(angle) + p.Y*math.Cos(angle)\n\treturn\n}\n\nfunc isInSquare(sq Square, p Point) (b bool) {\n\tvar minHoz float64 = 101\n\tfor _, v := range sq.Points {\n\t\tminHoz = math.Min(minHoz, v.Y)\n\t}\n\n\tvar maxHoz float64 = -101\n\tfor _, v := range sq.Points {\n\t\tmaxHoz = math.Max(maxHoz, v.Y)\n\t}\n\n\tvar minVer float64 = 101\n\tfor _, v := range sq.Points {\n\t\tminVer = math.Min(minVer, v.X)\n\t}\n\n\tvar maxVer float64 = -101\n\tfor _, v := range sq.Points {\n\t\tmaxVer = math.Max(maxVer, v.X)\n\t}\n\n\treturn (p.X >= minVer && p.X <= maxVer) && (p.Y >= minHoz && p.Y <= maxHoz)\n}\n\nfunc solve(sq, sq45 Square) bool {\n\tfor _, v := range sq45.Points {\n\t\tif isInSquare(sq, v) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\trotatedSquare := Square{}\n\tfor i := range rotatedSquare.Points {\n\t\trotatedSquare.Points[i] = rotateAxis(sq45.Points[i], 45)\n\t}\n\n\tfor _, v := range sq.Points {\n\t\trotatedPoint := rotateAxis(v, 45)\n\t\tif isInSquare(rotatedSquare, rotatedPoint) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc consoleInput() {\n\tvar x, y float64\n\tsq := Square{}\n\tfor i := 0; i < 4; i++ {\n\t\tfmt.Scan(&x, &y)\n\t\tsq.Points[i] = Point{\n\t\t\tX: x,\n\t\t\tY: y,\n\t\t}\n\t}\n\n\tsq45 := Square{}\n\tfor i := 0; i < 4; i++ {\n\t\tfmt.Scan(&x, &y)\n\t\tsq45.Points[i] = Point{\n\t\t\tX: x,\n\t\t\tY: y,\n\t\t}\n\t}\n\n\tif solve(sq, sq45) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nfunc mustEqual(expected, actual bool) {\n\tif expected == actual {\n\t\tfmt.Println(\"OK\")\n\t} else {\n\t\tfmt.Println(\"FAILED\")\n\t}\n}\n\nfunc test() {\n\t{\n\t\tsq := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{0, 0},\n\t\t\t\tPoint{6, 0},\n\t\t\t\tPoint{6, 6},\n\t\t\t\tPoint{0, 6},\n\t\t\t},\n\t\t}\n\n\t\tsq45 := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{1, 3},\n\t\t\t\tPoint{3, 5},\n\t\t\t\tPoint{5, 3},\n\t\t\t\tPoint{3, 1},\n\t\t\t},\n\t\t}\n\n\t\tmustEqual(true, solve(sq, sq45))\n\t}\n\n\t{\n\t\tsq := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{0, 0},\n\t\t\t\tPoint{6, 0},\n\t\t\t\tPoint{6, 6},\n\t\t\t\tPoint{0, 6},\n\t\t\t},\n\t\t}\n\n\t\tsq45 := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{7, 3},\n\t\t\t\tPoint{9, 5},\n\t\t\t\tPoint{11, 3},\n\t\t\t\tPoint{9, 1},\n\t\t\t},\n\t\t}\n\n\t\tmustEqual(false, solve(sq, sq45))\n\t}\n\n\t{\n\t\tsq := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{6, 0},\n\t\t\t\tPoint{6, 6},\n\t\t\t\tPoint{0, 6},\n\t\t\t\tPoint{0, 0},\n\t\t\t},\n\t\t}\n\n\t\tsq45 := Square{\n\t\t\tPoints: [4]Point{\n\t\t\t\tPoint{7, 4},\n\t\t\t\tPoint{4, 7},\n\t\t\t\tPoint{7, 10},\n\t\t\t\tPoint{10, 7},\n\t\t\t},\n\t\t}\n\n\t\tmustEqual(true, solve(sq, sq45))\n\t}\n}\n\nfunc main() {\n\tconsoleInput()\n\t// test()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\ntype Int64Slice []int64\n\nfunc (slice Int64Slice) Len() int { return len(slice) }\nfunc (slice Int64Slice) Less(i, j int) bool { return slice[i] < slice[j] }\nfunc (slice Int64Slice) Swap(i, j int) { slice[i], slice[j] = slice[j], slice[i] }\n\ntype Sq struct {\n\tv [8]int\n}\n\nfunc (sq *Sq) isPara() bool {\n\tchk1, chk2 := false, false\n\n\tfor i := 2; i < 8; i = i + 2 {\n\t\tif sq.v[i] == sq.v[0] {\n\t\t\tchk1 = true\n\t\t}\n\t}\n\tfor i := 3; i < 8; i = i + 2 {\n\t\tif sq.v[i] == sq.v[1] {\n\t\t\tchk2 = true\n\t\t}\n\t}\n\n\tif chk1 && chk2 {\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc check2in1(s1 *Sq, s2 *Sq, j int) bool {\n\txin, yin := false, false\n\n\txlarge, xsmall := 0, 0\n\tylarge, ysmall := 0, 0\n\tfor i := 0; i < 8; i = i + 2 {\n\t\tif s1.v[i] < s2.v[j*2] {\n\t\t\txlarge = xlarge + 1\n\t\t}\n\t\tif s1.v[i] > s2.v[j*2] {\n\t\t\txsmall = xsmall + 1\n\t\t}\n\t}\n\tif xlarge != 4 && xsmall != 4 {\n\t\txin = true\n\t}\n\n\tfor i := 1; i < 8; i = i + 2 {\n\t\tif s1.v[i] < s2.v[j*2+1] {\n\t\t\tylarge = ylarge + 1\n\t\t}\n\t\tif s1.v[i] > s2.v[j*2+1] {\n\t\t\tysmall = ysmall + 1\n\t\t}\n\t}\n\tif ylarge != 4 && ysmall != 4 {\n\t\tyin = true\n\t}\n\tif xin && yin {\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc check1in2(s1 *Sq, s2 *Sq, i int) bool {\n\txaddy := s1.v[i*2] + s1.v[i*2+1]\n\txsuby := s1.v[i*2] - s1.v[i*2+1]\n\n\tvar xaddy2 [4]int\n\tvar xsuby2 [4]int\n\n\tfor j := 0; j < 4; j++ {\n\t\txaddy2[j] = s2.v[j*2] + s2.v[j*2+1]\n\t\txsuby2[j] = s2.v[j*2] - s2.v[j*2+1]\n\t}\n\n xin, yin := false, false\n\txlarge, xsmall := 0, 0\n\tylarge, ysmall := 0, 0\n\n\tfor j := 0; j < 4; j++ {\n\t\tif xaddy2[j] < xaddy {\n\t\t\txlarge = xlarge + 1\n\t\t}\n\t\tif xaddy2[j] > xaddy {\n\t\t\txsmall = xsmall + 1\n\t\t}\n\t}\n\tif xlarge != 4 && xsmall != 4 {\n\t\txin = true\n\t}\n\n\tfor j := 0; j < 4; j++ {\n\t\tif xsuby2[j] < xsuby {\n\t\t\tylarge = ylarge + 1\n\t\t}\n\t\tif xsuby2[j] > xsuby {\n\t\t\tysmall = ysmall + 1\n\t\t}\n\t}\n\tif ylarge != 4 && ysmall != 4 {\n\t\tyin = true\n\t}\n\tif xin && yin {\n\t\treturn true\n\t}\n\treturn false\n\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\tvar s1, s2 Sq\n\n\tfor i := 0; i < 8; i++ {\n\t\ts1.v[i] = ReadInt32()\n\t}\n\n\tfor i := 0; i < 8; i++ {\n\t\ts2.v[i] = ReadInt32()\n\t}\n\n\tif !s1.isPara() {\n\t\ts1, s2 = s2, s1\n\t}\n\n chk1in2, chk2in1 := false, false\n\n\tfor i := 0; i < 4; i++ {\n\t\tif check2in1(&s1, &s2, i) {\n\t\t\tchk2in1 = true\n\t\t}\n\t}\n\tfor i := 0; i < 4; i++ {\n\t\tif check1in2(&s1, &s2, i) {\n\t\t\tchk1in2 = true\n\t\t}\n\t}\n\n\tif chk1in2 || chk2in1 {\n\t\tfmt.Printf(\"YES\")\n\t} else {\n\t\tfmt.Printf(\"NO\")\n\t}\n}\n\nfunc Demo() {\n\tvar n, m int64 = ReadInt64(), ReadInt64()\n\tPrintInt64s(n, m)\n\twriter.WriteByte('\\n')\n\tslice := []int64{1, 2, 3, 4, 5}\n\tPrintInt64s(slice...)\n\n\t// sortDemo\n\t//slice := []int64{5, 3, 4, 2, 1}\n\tsort.Sort(Int64Slice(slice))\n\n\t//s := strconv.FormatBool(true)\n\t//s := strconv.FormatFloat(3.1415, 'E', -1, 64)\n\t//s := strconv.FormatInt(-42, 16)\n\t//s := strconv.FormatUint(42, 16)\n\n}\n\nfunc Min(a int64, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MinInt(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MinFloat64(a float64, b float64) float64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MaxInt64(a int64, b int64) int64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MaxInt(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc MaxFloat64(a float64, b float64) float64 {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc ReadInt32() int {\n\tscanner.Scan()\n\tans, _ := strconv.Atoi(scanner.Text())\n\treturn ans\n}\n\nfunc ReadInt64() int64 {\n\tscanner.Scan()\n\tans, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\treturn ans\n}\n\nfunc ReadFloat64() float64 {\n\tscanner.Scan()\n\tans, _ := strconv.ParseFloat(scanner.Text(), 64)\n\treturn ans\n}\n\nfunc PrintInt64s(ints ...int64) {\n\tfor _, value := range ints {\n\t\twriter.WriteString(strconv.Itoa(int(value)))\n\t\twriter.WriteByte(' ')\n\t}\n}\n"}], "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a"} {"nl": {"description": "Little Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of digits of 123 in base 16 is equal to 18.Now he wonders what is an average value of sum of digits of the number A written in all bases from 2 to A - 1.Note that all computations should be done in base 10. You should find the result as an irreducible fraction, written in base 10.", "input_spec": "Input contains one integer number A (3 ≤ A ≤ 1000).", "output_spec": "Output should contain required average value in format «X/Y», where X is the numerator and Y is the denominator.", "sample_inputs": ["5", "3"], "sample_outputs": ["7/3", "2/1"], "notes": "NoteIn the first sample number 5 written in all bases from 2 to 4 looks so: 101, 12, 11. Sums of digits are 2, 3 and 2, respectively."}, "positive_code": [{"source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n \"fmt\"\n)\n\nvar scanner *bufio.Scanner\n\nfunc getI64() int64 {\n scanner.Scan()\n x, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n return x\n}\nfunc getI() int {\n return int(getI64())\n}\nfunc getF() float64 {\n scanner.Scan()\n x, _ := strconv.ParseFloat(scanner.Text(), 64)\n return x\n}\nfunc getS() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc gcd(a, b int) int {\n for b != 0 {\n a, b = b, a%b\n }\n return a\n}\n\nfunc main() {\n scanner = bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n x := getI()\n total := 0\n for base := 2; base < x; base++ {\n for y := x; y != 0; y /= base {\n total += y % base\n }\n }\n num, denom := total, x-2\n d := gcd(num, denom)\n num /= d\n denom /= d\n writer.WriteString(fmt.Sprintf(\"%d/%d\\n\", num, denom))\n}\n"}, {"source_code": "//13A\npackage main\nimport \"fmt\"\n\nfunc main() {\n\tvar aa, k, l, ttl int\n\tfmt.Scan(&aa)\n\tfor i:=2; i0 {\n\t\t\tttl=ttl+(k%i)\n\t\t\tk/=i\n\t\t\tif k1; i-- {\n\t\tif ttl%i==0 && l%i==0 {\n\t\t\tttl/=i\n\t\t\tl/=i\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Print(ttl,\"/\",l)\n\tfmt.Println()\n}"}, {"source_code": "// https://codeforces.com/contest/13/problem/A\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\n// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)\n\nfunc main() {\n\tvar (\n\t\tA int \n\t)\n\n\t//f, _ := os.Open(\"input.txt\")\n\t//input := bufio.NewReader(f)\n\tinput := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(input, &A)\n\n\tprimes := make([]bool, A / 2 + 1)\n\tfor i := 0; i < len(primes); i++ {\n\t\tprimes[i] = true\n\t}\n\n\tfor i := 2; i < len(primes); i++ {\n\t\tif primes[i] {\n\t\t\tx := i\n\t\t\tfor i + x < len(primes) {\n\t\t\t\tprimes[i + x] = false\n\t\t\t\tx += i\n\t\t\t}\n\t\t}\n\t}\n\n\tans := 0\n\tcnt := 0\n\tfor i := 2; i < A; i++ {\n\t\ttmp := A\n\t\tfor tmp > 0 {\n\t\t\tans += tmp % i\n\t\t\ttmp /= i\n\t\t}\n\t\tcnt++\n\t}\n\n\tfor i := 2; i < len(primes); i++ {\n\t\tif primes[i] {\n\t\t\tfor ans % i == 0 && cnt % i == 0 {\n\t\t\t\tans /= i\n\t\t\t\tcnt /= i\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Printf(\"%d/%d\", ans, cnt)\n}\n"}, {"source_code": "// 13A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc gcd(n, m int) int {\n\tif m == 0 {\n\t\treturn n\n\t} else {\n\t\treturn gcd(m, n%m)\n\t}\n}\n\nfunc main() {\n\tvar n, m, i int\n\tsum := 0\n\tfmt.Scan(&n)\n\tfor i = 2; i < n; i++ {\n\t\tm = n\n\t\tfor m != 0 {\n\t\t\tsum += m % i\n\t\t\tm /= i\n\t\t}\n\t}\n\tfmt.Printf(\"%d/%d\", sum/gcd(sum, n-2), (n-2)/gcd(sum, n-2))\n}\n"}], "negative_code": [{"source_code": "// https://codeforces.com/contest/13/problem/A\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\n// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)\n\nfunc main() {\n\tvar (\n\t\tA int \n\t)\n\n\t//f, _ := os.Open(\"input.txt\")\n\t//input := bufio.NewReader(f)\n\tinput := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(input, &A)\n\tans := 0\n\tcnt := 0\n\tfor i := 2; i < A; i++ {\n\t\ttmp := A\n\t\tfor tmp > 0 {\n\t\t\tans += tmp % i\n\t\t\ttmp /= i\n\t\t}\n\t\tcnt++\n\t}\n\n\tfmt.Printf(\"%d/%d\", ans, cnt)\n}\n"}, {"source_code": "// 13A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc gcd(n, m int) int {\n\tif m == 0 {\n\t\treturn n\n\t} else {\n\t\treturn gcd(m, n%m)\n\t}\n}\n\nfunc main() {\n\tvar n, m, i int\n\tsum := 0\n\tfmt.Scan(&n)\n\tfor i = 2; i < n; i++ {\n\t\tm = n\n\t\tfor m != 0 {\n\t\t\tsum += m % i\n\t\t\tm /= i\n\t\t}\n\t}\n\tfmt.Println(sum/gcd(sum, n-2), \"/\", (n-2)/gcd(sum, n-2))\n}\n"}], "src_uid": "1366732dddecba26db232d6ca8f35fdc"} {"nl": {"description": "Today is Wednesday, the third day of the week. What's more interesting is that tomorrow is the last day of the year 2015.Limak is a little polar bear. He enjoyed this year a lot. Now, he is so eager to the coming year 2016.Limak wants to prove how responsible a bear he is. He is going to regularly save candies for the entire year 2016! He considers various saving plans. He can save one candy either on some fixed day of the week or on some fixed day of the month.Limak chose one particular plan. He isn't sure how many candies he will save in the 2016 with his plan. Please, calculate it and tell him.", "input_spec": "The only line of the input is in one of the following two formats: \"x of week\" where x (1 ≤ x ≤ 7) denotes the day of the week. The 1-st day is Monday and the 7-th one is Sunday. \"x of month\" where x (1 ≤ x ≤ 31) denotes the day of the month. ", "output_spec": "Print one integer — the number of candies Limak will save in the year 2016.", "sample_inputs": ["4 of week", "30 of month"], "sample_outputs": ["52", "11"], "notes": "NotePolar bears use the Gregorian calendar. It is the most common calendar and you likely use it too. You can read about it on Wikipedia if you want to – https://en.wikipedia.org/wiki/Gregorian_calendar. The week starts with Monday.In the first sample Limak wants to save one candy on each Thursday (the 4-th day of the week). There are 52 Thursdays in the 2016. Thus, he will save 52 candies in total.In the second sample Limak wants to save one candy on the 30-th day of each month. There is the 30-th day in exactly 11 months in the 2016 — all months but February. It means that Limak will save 11 candies in total."}, "positive_code": [{"source_code": "package main\n\nimport (\"fmt\")\n\nfunc weekfunc(day int) int{\n\tvar count int\n\tvar current int = 5\n\tfor i:=0;i<366;i++{\n\t\tif current==day{\n\t\t\tcount++\n\t\t}\n\t\tcurrent++\n\t\tif current>7{\n\t\t\tcurrent = 1\n\t\t}\n\t}\n\treturn count\n}\n\nfunc monthfunc(day int) int{\n\tarr := []int{31,29,31,30,31,30,31,31,30,31,30,31}\n\tvar count int = 0\n\tfor i:=0;i<12;i++{\n\t\tif day<=arr[i]{\n\t\t\tcount++\n\t\t}\n\t}\n\treturn count\n}\n\nfunc main(){\n\tvar day int\n\tvar of string \n\tvar random string\n\tfmt.Scan(&day,&of,&random)\n\tvar ans int\n\tif random == \"week\"{\n\t\tans = weekfunc(day)\n\t}else{\n\t\tans = monthfunc(day)\n\t}\n\tfmt.Println(ans)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\n//import \"strings\"\n\nvar s string\nvar n, ans int\n\nfunc main() {\n fmt.Scanf(\"%d of %s\", &n, &s)\n switch s {\n case \"week\":\n ans = cal_week(n)\n case \"month\":\n ans = cal_month(n)\n }\n fmt.Println(ans)\n}\n\nfunc cal_week(n int) int {\n if n == 5 || n == 6 {\n return 53\n } else {\n return 52\n }\n\n}\n\nfunc cal_month(n int) int {\n if n < 30 {\n return 12\n } else if n == 30 {\n return 11\n } else {\n return 7\n }\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tvar key string\n\tfmt.Scan(&n)\n\tfmt.Scan(&key)\n\tfmt.Scan(&key)\n\n\tsum := 0\n\tif key == \"week\" {\n\t\tsum += 363 / 7\n\t\tif n <= 363%7 {\n\t\t\tsum += 1\n\t\t}\n\t\tif n >= 5 {\n\t\t\tsum += 1\n\t\t}\n\t} else {\n\t\tif n <= 29 {\n\t\t\tsum = 12\n\t\t} else if n == 30 {\n\t\t\tsum = 11\n\t\t} else {\n\t\t\tsum = 7\n\t\t}\n\t}\n\n\tfmt.Println(sum)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tch := make(chan string)\n\tgo func() {\n\t\tscanner := bufio.NewScanner(os.Stdin)\n\t\tfor scanner.Scan() {\n\t\t\tch <- scanner.Text()\n\t\t}\n\t}()\n\ts = <-ch\n\tss := strings.Split(s, \" \")\n\td, _ := strconv.Atoi(ss[0])\n\tif ss[len(ss)-1] == \"month\" {\n\t\tif d <= 29 {\n\t\t\tfmt.Println(\"12\")\n\t\t\treturn\n\t\t}\n\t\tif d <= 30 {\n\t\t\tfmt.Println(\"11\")\n\t\t\treturn\n\t\t}\n\t\tif d <= 31 {\n\t\t\tfmt.Println(\"7\")\n\t\t\treturn\n\t\t}\n\t}\n\tcw := 366 / 7\n\tif d == 5 || d == 6 {\n\t\tcw++\n\t}\n\tfmt.Printf(\"%v\", cw)\n\treturn\n}\n"}, {"source_code": "// cf611a project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x int\n\tvar s string\n\tfmt.Scanf(\"%d of %s\", &x, &s)\n\tm := []int{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}\n\td := []int{52, 52, 52, 52, 53, 53, 52}\n\tif s == \"week\" {\n\t\tfmt.Println(d[x-1])\n\t} else {\n\t\tvar c int\n\t\tfor _, v := range m {\n\t\t\tif v >= x {\n\t\t\t\tc++\n\t\t\t}\n\t\t}\n\t\tfmt.Println(c)\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\"fmt\")\n\n\nfunc monthfunc(date int) int {\n\tvar count int\n\tarr := []int{31,29,31,30,31,30,31,31,30,31,30,31}\n\tfor i:=0;i<12;i++{\n\t\tif date<=arr[i]{\n\t\t\tcount++\n\t\t}\n\t}\n\treturn count\n}\n\nfunc weekfun(day int) int{\n\tvar count int\n\tvar current int = 5\n\tfor i:=0;i<366;i++{\n\t\tif current == day{\n\t\t\tcount++\n\t\t}\n\t\tcurrent++\n\t\tif current > 7{\n\t\t\tcurrent = 0\n\t\t}\n\t}\n\treturn count\n}\n\nfunc main(){\n\n\tvar ans int\n\tvar str string\n\tfmt.Scan(&str)\n\tvar number int = int(str[0])\n\n\tif string(str[len(str)-1])==\"k\"{\n\t\tans = weekfun(number)\n\t}else{\n\t\tans = monthfunc(number)\n\t}\n\n\tfmt.Print(ans)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\n//import \"strings\"\n\nvar s string\nvar n, ans int\n\nfunc main() {\n fmt.Scanf(\"%d of %s\", &n, &s)\n switch s {\n case \"week\":\n ans = cal_week(n)\n case \"month\":\n ans = cal_month(n)\n }\n fmt.Println(ans)\n}\n\nfunc cal_week(n int) int {\n if n == 5 {\n return 53\n } else {\n return 52\n }\n\n}\n\nfunc cal_month(n int) int {\n if n < 28 {\n return 12\n } else if n == 30 {\n return 11\n } else {\n return 7\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scanf(\"%s\", &s)\n\tss := strings.Split(s, \" \")\n\td, _ := strconv.Atoi(ss[0])\n\tif ss[len(ss)-1] == \"month\" {\n\t\tif d <= 29 {\n\t\t\tfmt.Println(\"12\")\n\t\t\treturn\n\t\t}\n\t\tif d <= 30 {\n\t\t\tfmt.Println(\"11\")\n\t\t\treturn\n\t\t}\n\t\tif d <= 31 {\n\t\t\tfmt.Println(\"7\")\n\t\t\treturn\n\t\t}\n\t}\n\tcw := 366 / 7\n\tif d == 5 || d == 6 {\n\t\tcw++\n\t}\n\tfmt.Printf(\"%v\", cw)\n\treturn\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scanln(&s)\n\tss := strings.Split(s, \" \")\n\td, _ := strconv.Atoi(ss[0])\n\tif ss[len(ss)-1] == \"month\" {\n\t\tif d <= 29 {\n\t\t\tfmt.Println(\"12\")\n\t\t\treturn\n\t\t}\n\t\tif d <= 30 {\n\t\t\tfmt.Println(\"11\")\n\t\t\treturn\n\t\t}\n\t\tif d <= 31 {\n\t\t\tfmt.Println(\"7\")\n\t\t\treturn\n\t\t}\n\t}\n\tcw := 366 / 7\n\tif d == 5 || d == 6 {\n\t\tcw++\n\t}\n\tfmt.Printf(\"%v\", cw)\n\treturn\n}\n"}, {"source_code": "// cf611a project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x int\n\tvar s string\n\tfmt.Scanf(\"%d of %s\", &x, &s)\n\tm := []int{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}\n\td := []int{52, 52, 52, 52, 53, 53, 52}\n\tif s == \"week\" {\n\t\tfmt.Println(d[x-1])\n\t} else {\n\t\tvar c int\n\t\tfor _, v := range m {\n\t\t\tif v <= x {\n\t\t\t\tc++\n\t\t\t}\n\t\t}\n\t\tfmt.Println(c)\n\t}\n}\n"}], "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b"} {"nl": {"description": "Allen has a LOT of money. He has $$$n$$$ dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are $$$1$$$, $$$5$$$, $$$10$$$, $$$20$$$, $$$100$$$. What is the minimum number of bills Allen could receive after withdrawing his entire balance?", "input_spec": "The first and only line of input contains a single integer $$$n$$$ ($$$1 \\le n \\le 10^9$$$).", "output_spec": "Output the minimum number of bills that Allen could receive.", "sample_inputs": ["125", "43", "1000000000"], "sample_outputs": ["3", "5", "10000000"], "notes": "NoteIn the first sample case, Allen can withdraw this with a $$$100$$$ dollar bill, a $$$20$$$ dollar bill, and a $$$5$$$ dollar bill. There is no way for Allen to receive $$$125$$$ dollars in one or two bills.In the second sample case, Allen can withdraw two $$$20$$$ dollar bills and three $$$1$$$ dollar bills.In the third sample case, Allen can withdraw $$$100000000$$$ (ten million!) $$$100$$$ dollar bills."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tarr := []int{1, 5, 10, 20, 100}\n\tvar num int\n\n\tfmt.Scan(&num)\n\tcount := 0\n\tstartIndex := 4\n\tfor num > 0 {\n\t\tif num < arr[startIndex] {\n\t\t\tstartIndex--\n\t\t\tcontinue\n\t\t}\n\t\tcount = count + (num / arr[startIndex])\n\t\tnum = num % arr[startIndex]\n\t\tstartIndex--\n\t}\n\n\tfmt.Println(count)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var split = [5]int{100,20,10,5,1}\n var count = 0\n var total int\n fmt.Scanf(\"%d\", &total)\n for _, spt := range split {\n count += total / spt\n total %= spt\n }\n fmt.Printf(\"%d\\n\", count)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar n, cnt int\n\tfmt.Scan(&n)\n\ta:= [...]int {100, 20, 10, 5, 1}\n\tfor _, x := range a{\n\t\tcnt += n / x\n\t\tn %= x\n\t}\n\tfmt.Println(cnt)\n}\n\n"}, {"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 n uint64\n\tfmt.Fscanf(in, \"%d\\n\", &n)\n\n\tfmt.Println(hitTheLottery(n))\n}\n\nfunc hitTheLottery(n uint64) uint64 {\n\tvar result uint64\n\n\ttmp := n / 100\n\tresult += tmp\n\tn -= (tmp * 100)\n\n\ttmp = n / 20\n\tresult += tmp\n\tn -= (tmp * 20)\n\n\ttmp = n / 10\n\tresult += tmp\n\tn -= (tmp * 10)\n\n\ttmp = n / 5\n\tresult += tmp\n\tn -= (tmp * 5)\n\n\ttmp = n / 1\n\tresult += tmp\n\tn -= (tmp * 1)\n\n\treturn result\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\n\tfmt.Scan(&n)\n\n\tbills := []int{100, 20, 10, 5, 1}\n\tvar count int\n\tfor _, val := range bills {\n\t\tcount = count + (n / val)\n\t\tn = n - ((n / val) * val)\n\t}\n\n\tfmt.Println(count)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"fmt\"\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 printf(format string, x ...interface{}) {\n\tfmt.Fprintf(os.Stdout, format, x...)\n}\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\n\tprintf(\"%d\", Problem996A())\n}\n\nfunc Problem996A() int {\n\t// 1, 5, 10, 20 , 100\n\tn := getI()\n\ti := 0\n\tfor n > 0 {\n\t\tif n - 100 >= 0 {\n\t\t\tn-=100\n\t\t\ti++\n\t\t}else if n - 20 >= 0 {\n\t\t\tn-=20\n\t\t\ti++\n\t\t}else if n - 10 >= 0 {\n\t\t\tn-=10\n\t\t\ti++\n\t\t}else if n - 5 >= 0 {\n\t\t\tn-=5\n\t\t\ti++\n\t\t}else {\n\t\t\tn-=1\n\t\t\ti++\n\t\t}\n\t}\n\n\treturn i\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, res uint\n\tfmt.Scan(&n)\n\tfor n > 0 {\n\t\tif n >= 100 {\n\t\t\tn -= 100\n\t\t} else if n >= 20 {\n\t\t\tn -= 20\n\t\t} else if n >= 10 {\n\t\t\tn -= 10\n\t\t} else if n >= 5 {\n\t\t\tn -= 5\n\t\t} else if n >= 1 {\n\t\t\tn -= 1\n\t\t}\n\t\tres++\n\t}\n\tfmt.Println(res)\n}\n"}, {"source_code": "// https://codeforces.com/problemset/problem/996/A\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nvar denominations []int = []int{100, 20, 10, 5, 1}\n\nfunc main() {\n\tvar dollars, count int\n\tcount = 0\n\tfmt.Scanf(\"%d\\n\", &dollars)\n\tfor _, coin := range denominations {\n\t\tfor dollars >= coin {\n\t\t\tdollars -= coin\n\t\t\tcount++\n\t\t}\n\t}\n\tfmt.Printf(\"%d\",count)\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc minVal(a, b int) int {\n\tif a <= b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc maxVal(a, b int) int {\n\tif a >= b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(arr []int) (max int) {\n\tmax = arr[0]\n\tfor _, val := range arr {\n\t\tif val > max {\n\t\t\tmax = val\n\t\t}\n\t}\n\treturn max\n}\n\nvar mod int = 1000000007\n\nfunc coinChange(m int) int {\n\tcount := 0\n\tfor m > 0 {\n\t\tif m >= 100 {\n\t\t\tm -= 100\n\t\t\tcount++\n\t\t} else if m >= 20 {\n\t\t\tm -= 20\n\t\t\tcount++\n\t\t} else if m >= 10 {\n\t\t\tm -= 10\n\t\t\tcount++\n\t\t} else if m >= 5 {\n\t\t\tm -= 5\n\t\t\tcount++\n\t\t} else if m >= 1 {\n\t\t\tm--\n\t\t\tcount++\n\t\t}\n\t}\n\treturn count\n}\n\nfunc main() {\n\tvar m int\n\tfmt.Scan(&m)\n\tfmt.Println(coinChange(m))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\n\tfmt.Scanf(\"%d\\n\", &n)\n\n\tans := 0\n\tfor n > 0 {\n\t\tswitch {\n\t\tcase n >= 100:\n\t\t\tans++\n\t\t\tn -= 100\n\t\tcase n >= 20:\n\t\t\tans++\n\t\t\tn -= 20\n\t\tcase n >= 10:\n\t\t\tans++\n\t\t\tn -= 10\n\t\tcase n >= 5:\n\t\t\tans++\n\t\t\tn -= 5\n\t\tdefault:\n\t\t\tans++\n\t\t\tn -= 1\n\n\t\t}\n\t}\n\n\tfmt.Println(ans)\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k int\n\tb := [5]int{100, 20, 10, 5, 1}\n\tfmt.Scan(&n)\n\tfor i := 0; i < 5; i++ {\n\t\tif n >= b[i] {\n\t\t\tk += n / b[i]\n\t\t\tn = n % b[i]\n\t\t}\n\t}\n\tfmt.Print(k)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar (\n\t\tn int\n\t)\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\n\tscanner.Scan()\n\tn, _ = strconv.Atoi(scanner.Text())\n\n\thu := int(n / 100)\n\tn -= hu * 100\n\ttw := int(n / 20)\n\tn -= tw * 20\n\tte := int(n / 10)\n\tn -= te * 10\n\tfi := int(n / 5)\n\tn -= fi * 5\n\ton := n\n\n\t// fmt.Println(hu, tw, te, fi, on)\n\tfmt.Println(hu + tw + te + fi + on)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\n// https://codeforces.com/problemset/problem/996/A\n// A. Hit the Lottery\n// time limit per test\n// 1 second\n// memory limit per test\n// 256 megabytes\n// input\n// standard input\n// output\n// standard output\n\n// Allen has a LOT of money. He has n\n// dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are 1, 5, 10, 20, 100\n\n// . What is the minimum number of bills Allen could receive after withdrawing his entire balance?\n// Input\n\n// The first and only line of input contains a single integer n\n// (1≤n≤109\n\n// ).\n// Output\n\n// Output the minimum number of bills that Allen could receive.\n\nfunc main() {\n\tvar n int\n\t_, _ = fmt.Scan(&n)\n\n\tvar nBills int\n\n\tnBills += n / 100\n\tn %= 100\n\n\tnBills += n / 20\n\tn %= 20\n\n\tnBills += n / 10\n\tn %= 10\n\n\tnBills += n / 5\n\tn %= 5\n\n\tnBills += n\n\n\tfmt.Print(nBills)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar n int\n\tfmt.Scan(&n)\n\tcount1 := 0\n\tplus1 := 1\n\tfor {\n\t\tif n >= 100 {\n\t\t\tplus1 = n - n % 100\n\t\t\tplus1 /= 100\n\t\t\tn %= 100\n\t\t} else if n >= 20 {\n\t\t\tplus1 = n - n % 20\n\t\t\tplus1 /= 20\n\t\t\tn %= 20\n\t\t} else if n >= 10{\n\t\t\tplus1 = n - n % 10\n\t\t\tplus1 /= 10\n\t\t\tn %= 10\n\t\t}else if n >= 5{\n\t\t\tplus1 = n - n % 5\n\t\t\tplus1 /= 5\n\t\t\tn %= 5\n\t\t} else {\n\t\t\tplus1 = n\n\t\t\tn = 0\n\t\t}\n\t\tcount1 += plus1\n\t\tif n == 0{\n\t\t\tfmt.Println(count1)\n\t\t\tbreak\n\t\t}\n\t}\n\t\n}"}, {"source_code": "package main\nimport (\n \"fmt\"\n) \nfunc main() {\n var n,k int\n fmt.Scan(&n)\n for _,i := range([]int{100,20,10,5,1}){\n k += n/i\n n %= i\n }\n fmt.Println(k)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\n// https://codeforces.com/problemset/problem/996/A\n// комментарии к решению\n// Т.к. номиналы купюр известны заранее и они полностью перекрывают друг друга\n// т.е. любая старшая купюра легко может быть представлена определенным кол-вом\n// более младшей купюры, то минимальное кол-во купюр для выдачи n денег\n// легко поддаётся подсчету по алгоритму ниже\nfunc taskSolution(n int) (ans int) {\n\tnominals := []int{100, 20, 10, 5, 1}\n\tfor i := 0; i < len(nominals) && n > 0; i += 1 {\n\t\tans, n = ans+n/nominals[i], n%nominals[i]\n\t}\n\treturn ans\n}\n\nfunc main() {\n\tvar n int\n\tif _, err := fmt.Scan(&n); err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(taskSolution(n))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n int\n\tbil := []int{100, 20, 10, 5}\n\tin := bufio.NewReader(os.Stdin)\n\tans := 0\n\tfmt.Fscan(in, &n)\n\tfor _, v := range bil {\n\t\tans = ans + n/v\n\t\tn = n % v\n\t}\n\tans = ans + n\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar i int\n\tfmt.Scanf(\"%d\", &i)\n\tcounter := 0\n\n\tcounter += i / 100\n\ti = i % 100\n\tcounter += i / 20\n\ti = i % 20\n\tcounter += i / 10\n\ti = i % 10\n\tcounter += i / 5\n\ti = i % 5\n\tcounter += i / 1\n\ti = i % 1\n\tfmt.Println(counter)\n}\n"}, {"source_code": "// A. Hit the Lottery\n/*\nAllen has a LOT of money. He has 𝑛 dollars in the bank.\nFor security reasons, he wants to withdraw it in cash\n(we will not disclose the reasons here).\nThe denominations for dollar bills are 1, 5, 10, 20, 100. What is the minimum\nnumber of bills Allen could receive after withdrawing his entire balance?\n\nInput\nThe first and only line of input contains a single integer 𝑛(1≤𝑛≤109).\n\nOutput\nOutput the minimum number of bills that Allen could receive.\n\nExamples\nInput\n125\n\nOutput\n3\n\nInput\n43\n\nOutput\n5\n\nInput\n1000000000\n\nOutput\n10000000\n\nNote\nIn the first sample case, Allen can withdraw this with a 100\ndollar bill, a 20 dollar bill, and a 5 dollar bill.\nThere is no way for Allen to receive 125 dollars in one or two bills.\n\nIn the second sample case, Allen can withdraw two 20 dollar bills and three 1\ndollar bills.\n\nIn the third sample case, Allen can withdraw 100000000 (ten million!)\n100 dollar bills.\n*/\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput, _, _ := reader.ReadLine()\n\tn, _ := strconv.Atoi(string(input))\n\tfmt.Println(sol966A(n))\n}\n\nfunc sol966A(n int) int {\n\tbills := 0\n\tfor n > 0 {\n\t\tif n/100 != 0 {\n\t\t\tbills += n / 100\n\t\t\tn %= 100\n\t\t} else if n/20 != 0 {\n\t\t\tbills += n / 20\n\t\t\tn %= 20\n\t\t} else if n/10 != 0 {\n\t\t\tbills += n / 10\n\t\t\tn %= 10\n\t\t} else if n/5 != 0 {\n\t\t\tbills += n / 5\n\t\t\tn %= 5\n\t\t} else {\n\t\t\tbills += n\n\t\t\tbreak\n\t\t}\n\t}\n\treturn bills\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k int\n\tg := 0\n\tfmt.Scan(&n)\n\tfor true {\n\t\tif n >= 100 {\n\t\t\tk = int(n / 100)\n\t\t\tg += k\n\t\t\tn -= 100 * k\n\t\t} else if n >= 20 {\n\t\t\tk = int(n / 20)\n\t\t\tg += k\n\t\t\tn -= 20 * k\n\t\t} else if n >= 10 {\n\t\t\tk = int(n / 10)\n\t\t\tg += k\n\t\t\tn -= 10 * k\n\t\t} else if n >= 5 {\n\t\t\tk = int(n / 5)\n\t\t\tg += k\n\t\t\tn -= 5 * k\n\t\t} else {\n\t\t\tg += n % 5\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(g)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, res int\n\t_, err := fmt.Scanln(&n)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfor _, v := range []int{100, 20, 10, 5, 1} {\n\t\tres += n / v\n\t\tn %= v\n\t}\n\n\tfmt.Print(res)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, res int\n\t_, err := fmt.Scanln(&n)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfor _, v := range []int{100, 20, 10, 5, 1} {\n\t\tres = res + n/v\n\t\tn = n - v*(n/v)\n\t}\n\n\tfmt.Print(res)\n}\n"}, {"source_code": "package main\n\nimport(\n \"fmt\"\n)\n\nfunc main(){\n var(\n n,res int64\n coinChange = []int{1,5,10,20,100,}\n )\n fmt.Scan(&n)\n res = 0\n for i:=4;i>=0;i--{\n res += n/int64(coinChange[i]);\n n=n%int64(coinChange[i]);\n }\n fmt.Println(res)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, num int\n\tnum = 0\n\tfmt.Scan(&n)\n\tfor n != 0 {\n\t\tif n >= 100 {\n\t\t\tn -= 100\n\t\t\tnum++\n\t\t} else if n >= 20 {\n\t\t\tn -= 20\n\t\t\tnum++\n\t\t} else if n >= 10 {\n\t\t\tn -= 10\n\t\t\tnum++\n\t\t} else if n >= 5 {\n\t\t\tn -= 5\n\t\t\tnum++\n\t\t} else if n >= 1 {\n\t\t\tn -= 1\n\t\t\tnum++\n\t\t}\n\t}\n\tfmt.Println(num)\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tout := bufio.NewWriter(os.Stdout)\n\tdefer out.Flush()\n\n\tvar n int64\n\tfmt.Fscan(in, &n)\n\n\tvar r int64 = 0\n\n\tfor _, i := range []int64{100, 20, 10, 5, 1} {\n\t\tr += n / i\n\t\tn %= i\n\t}\n\n\tfmt.Fprintln(out, r)\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\n\tcnt := 0\n\tfor _, v := range []int{100, 20, 10, 5, 1} {\n\t\tcnt += n / v\n\t\tn %= v\n\t}\n\n\tfmt.Println(cnt)\n}\n"}, {"source_code": "//лотерея\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, coins int\n\tfmt.Scan(&n)\n\tcoins += n / 100\n\tn = n % 100\n\tcoins += n / 20\n\tn = n % 20\n\tcoins += n / 10\n\tn = n % 10\n\tcoins += n / 5\n\tcoins += n % 5\n\tfmt.Println(coins)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\n\tvar n int\n\tfmt.Scanf(\"%d\\n\", &n)\n\n\tcount := 0\n\n\tfor ; n != 0; {\n\t\tif n-100 >= 0 {\n\t\t\tcount += 1\n\t\t\tn -= 100\n\t\t} else if n-20 >= 0 {\n\t\t\tcount += 1\n\t\t\tn -= 20\n\t\t} else if n-10 >= 0 {\n\t\t\tcount += 1\n\t\t\tn -= 10\n\t\t} else if n-5 >= 0 {\n\t\t\tcount += 1\n\t\t\tn -= 5\n\t\t} else if n-1 >= 0 {\n\t\t\tcount += 1\n\t\t\tn -= 1\n\t\t}\n\t}\n\tfmt.Print(count)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar a uint64\n\n\tfmt.Scan(&a)\n\n\tc1 := a / 100\n\trem := a % 100\n\tc2 := rem / 20\n\trem = rem % 20\n\tc3 := rem / 10\n\trem = rem % 10\n\tc4 := rem / 5\n\trem = rem % 5\n\tfmt.Printf(\"%d\", c1+c2+c3+rem+c4)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\n\tarr := []int{1, 5, 10, 20, 100}\n\t\n\tcount := 0\n\n\tfor i := 4; i >= 0; i-- {\n\t\tk := n / arr[i]\n\t\tcount += k\n\t\tn = n % arr[i]\n\t}\n\tfmt.Println(count)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tnotes := []int{100, 20, 10, 5, 1}\n\tvar withdrawl, count int\n\n\t_, _ = fmt.Scanf(\"%d\", &withdrawl)\n\n\tfor _, note := range notes {\n\t\tfor {\n\t\t\tif withdrawl-note < 0 {\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\twithdrawl -= note\n\t\t\t\tcount++\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(count)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReaderSize(os.Stdin, 1024*1024)\n\tline := readLine(reader)\n\tvar n int64 = 0\n\tfmt.Sscanf(line, \"%d\", &n)\n\tvar count int64 = 0\n\tfor {\n\t\tif n < 100 {\n\t\t\tbreak\n\t\t}\n\t\tn = n - 100\n\t\tcount++\n\t}\n\tfor {\n\t\tif n < 20 {\n\t\t\tbreak\n\t\t}\n\t\tn = n - 20\n\t\tcount++\n\t}\n\tfor {\n\t\tif n < 10 {\n\t\t\tbreak\n\t\t}\n\t\tn = n - 10\n\t\tcount++\n\t}\n\n\tfor {\n\t\tif n < 5 {\n\t\t\tbreak\n\t\t}\n\t\tn = n - 5\n\t\tcount++\n\t}\n\tcount = count + n\n\tfmt.Println(count)\n}\n\nfunc readLine(reader *bufio.Reader) string {\n\tstr, _, err := reader.ReadLine()\n\tif err == io.EOF {\n\t\treturn \"\"\n\t}\n\n\treturn strings.TrimRight(string(str), \"\\r\\n\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar deno = []int{100, 20, 10, 5, 1}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvar n, out int\n\tfmt.Fscanf(reader, \"%d\\n\", &n)\n\tfor _, v := range deno {\n\t\tu := n / v\n\t\tout += u\n\t\tn = n - (u * v)\n\t}\n\tfmt.Print(out)\n}\n"}, {"source_code": "//A. Выиграть в лотерею\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tfmt.Println(minKol(n))\n}\n\nfunc minKol(sum int) int {\n\tbills := [...]int{1, 5, 10, 20, 100}\n\tmode := sum\n\trez := 0\n\ti := 4\n\n\tfor mode != 0 { //двигаемся по номиналам купюр от самой большой(100) до мелкой(1)\n\t\trez = rez + mode/bills[i] //к результату добавляем количесво купюр текущего номинала\n\t\tmode = sum % bills[i]\n\t\t//mode = mode % bills[i]\n\t\ti-- //переходим к номиналу помельче\n\t}\n\treturn rez\n}\n"}, {"source_code": "//A. Выиграть в лотерею\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tfmt.Println(minKol(n))\n}\n\nfunc minKol(sum int) int {\n\tbills := [...]int{1, 5, 10, 20, 100}\n\tmode := sum\n\trez := 0\n\ti := 4\n\n\tfor mode != 0 {\n\t\trez = rez + mode/bills[i]\n\t\tmode = sum % bills[i]\n\t\tmode = mode % bills[i]\n\t\ti--\n\t}\n\treturn rez\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\t// hit_the_lottery()\n\tvar value int\n\tfmt.Scanf(\"%d\", &value)\n\n\tbills := []int{1, 5, 10, 20, 100}\n\n\tcount := 0\n\tfor value != 0 {\n\t\t// take biggest bill\n\t\tfor i := len(bills) - 1; i >= 0; i-- {\n\t\t\tif value >= bills[i] {\n\t\t\t\tvalue -= bills[i]\n\t\t\t\tcount++\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(count)\n}\n"}, {"source_code": "package main\n \nimport \"fmt\"\n \nfunc main() {\n\tvar n, k int\n\tb := [5]int{100, 20, 10, 5, 1}\n\tfmt.Scan(&n)\n\tfor i := 0; i < 5; i++ {\n\t\tif n >= b[i] {\n\t\t\tk += n / b[i]\n\t\t\tn = n % b[i]\n\t\t}\n\t}\n\tfmt.Print(k)\n}"}, {"source_code": "package main\n\nimport(\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n uint64\n\tfmt.Scanf(\"%d\", &n)\n\tbills := 0\n\tfor n > 0 {\n\t\tif n >= 100 {\n\t\t\tn -= 100\n\t\t\tbills += 1\n\t\t} else if n >= 20 {\n\t\t\tbills += 1\n\t\t\tn -= 20\n\t\t} else if n >= 10 {\n\t\t\tbills += 1\n\t\t\tn -= 10\n\t\t} else if n >= 5 {\n\t\t\tbills += 1\n\t\t\tn -= 5\n\t\t} else {\n\t\t\tbills += 1\n\t\t\tn -= 1\n\t\t}\n\t}\n\n\tfmt.Println(bills)\n}\n"}, {"source_code": "package main\n \nimport (\n\t\"fmt\"\n)\n \nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar result int = (n / 100) + (n % 100 / 20) + (n % 100 % 20 / 10) + (n % 100 % 20 % 10 / 5) + (n % 100 % 20 % 10 % 5)\n\tfmt.Print(result)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\\n\", &n)\n\n\tcnt, ind := 0, 0\n\tdollars := [5]int{100, 20, 10, 5, 1}\n\n\tfor n > 0 || ind > 4 {\n\t\tif dollars[ind] > n {\n\t\t\tind ++\n\t\t} else {\n\t\t\tn -= dollars[ind]\n\t\t\tcnt ++\n\t\t}\n\t}\n\tfmt.Print(cnt)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tn int\n\t\tcoins = [5]int{1, 5, 10, 20, 100}\n\t\tmax int = 4\n\t\tans int = 0\n\t)\n\tfmt.Scanf(\"%d\", &n)\n\tfor n > 0 {\n\t\tans += n / coins[max]\n\t\tn %= coins[max]\n\t\tmax--\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar (\n\t\tn int\n\t\tcoins = [5]int{1, 5, 10, 20, 100}\n\t\tmax int = 4\n\t\tans int = 0\n\t)\n\tfmt.Scanf(\"%d\", &n)\n\tfor n > 0 {\n\t\tfor coins[max] > n {\n\t\t\tmax--\n\t\t}\n\t\tn -= coins[max]\n\t\tans++\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tn := 0\n\tfmt.Scan(&n)\n\tcoins := []int{100, 20, 10, 5, 1}\n\tans := 0\n\tfor _, coin := range coins {\n\t\tans += n / coin\n\t\tn = n % coin\n\t}\n\tfmt.Println(ans)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n, ans int\n ans = 0\n \n fmt.Scan(&n)\n ans += n/100\n n %= 100\n ans += n/20\n n %= 20\n ans += n/10\n n %= 10\n ans += n/5\n n %= 5\n ans += n\n \n fmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar input io.Reader = bufio.NewReader(os.Stdin)\n\n\tvar n int\n\n\tfmt.Fscan(input, &n)\n\n\tvar ans int\n\n\tif n >= 100 {\n\t\tans += n / 100\n\t\tn %= 100\n\t}\n\n\tif n >= 20 {\n\t\tans += n / 20\n\t\tn %= 20\n\t}\n\n\tif n >= 10 {\n\t\tans += n / 10\n\t\tn %= 10\n\t}\n\n\tif n >= 5 {\n\t\tans += n / 5\n\t\tn %= 5\n\t}\n\n\tans += n\n\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar amount, billCount int\n\tvalues := [...]int{1, 5, 10, 20, 100}\n\tfmt.Scan(&amount)\n\tfor i := 4; i >= 0; i-- {\n\t\tbillCount += amount / values[i]\n\t\tamount -= amount / values[i] * values[i]\n\t}\n\tfmt.Println(billCount)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tbills := [5]int{100, 20, 10, 5, 1}\n\tvar n int\n\tfmt.Scanln(&n)\n\tbillsCounter := 0; answer := 0\n\tfor n > 0{\n\t\tif n >= bills[billsCounter]{\n\t\t\tn = n - bills[billsCounter]\n\t\t\tanswer++\n\t\t}else{\n\t\t\tbillsCounter++\n\t\t}\n\t}\n\tfmt.Println(answer)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader\n\nfunc init() {\n\tstdin := os.Stdin\n\t// stdin, _ = os.Open(\"1.in\")\n\treader = bufio.NewReaderSize(stdin, 1<<20)\n}\n\nvar n int\n\nfunc main() {\n\tfmt.Fscan(reader, &n)\n\tans := 0\n\tans += n / 100\n\tn %= 100\n\tans += n / 20\n\tn %= 20\n\tans += n / 10\n\tn %= 10\n\tans += n / 5\n\tn %= 5\n\tans += n\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader\n\nfunc init() {\n\tstdin := os.Stdin\n\t// stdin, _ = os.Open(\"1.in\")\n\treader = bufio.NewReaderSize(stdin, 1<<20)\n}\n\nvar n int\n\nfunc main() {\n\tfmt.Fscan(reader, &n)\n\tans := 0\n\tans += n / 100\n\tn %= 100\n\tans += n / 20\n\tn %= 20\n\tans += n / 10\n\tn %= 10\n\tans += n / 5\n\tn %= 5\n\tans += n\n\n\tfmt.Println(ans)\n}\n"}, {"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 n uint32\n\tvar c uint32 = 0\n\tfmt.Fscanf(in, \"%d\\n\", &n)\n\tfor n != 0 {\n\t\tif n > 99 {\n\t\t\tc += uint32(n / 100)\n\t\t\tn = n % 100\n\t\t} else if n > 19 {\n\t\t\tc += uint32(n / 20)\n\t\t\tn = n % 20\n\t\t} else if n > 9 {\n\t\t\tc += uint32(n / 10)\n\t\t\tn = n % 10\n\t\t} else if n > 4 {\n\t\t\tc += uint32(n / 5)\n\t\t\tn = n % 5\n\t\t} else if n > 0 {\n\t\t\tc += uint32(n / 1)\n\t\t\tn = n % 1\n\t\t}\n\t}\n\n\tfmt.Println(c)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar sum int\n\tfor _, p := range []int{100, 20, 10, 5, 1} {\n\t\tif n >= p {\n\t\t\tcnt := n / p\n\t\t\tn -= p * cnt\n\t\t\tsum += cnt\n\t\t}\n\t}\n\tfmt.Println(sum)\n}\n"}, {"source_code": "package main\n \nimport \"fmt\"\n \nfunc main() {\n\tvar n int\n\tvar res int\n\tvars := [5]int{100, 20, 10, 5, 1}\n\tfmt.Scan(&n)\n\tfor i := 0; i < 5; i++ {\n\t\tif n >= vars[i] {\n\t\t\tres += n / vars[i]\n\t\t\tn %= vars[i]\n\t\t}\n\t}\n\tfmt.Print(res)\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar result int = (n / 100) + (n % 100 / 20) + (n % 100 % 20 / 10) + (n % 100 % 20 % 10 / 5) + (n % 100 % 20 % 10 % 5)\n\tfmt.Print(result)\n}\n"}, {"source_code": "package main \n\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)\n\nfunc printf(f string, a... interface{}) {\n\tfmt.Fprintf(writer, f, a...)\n}\n\nfunc scanf(f string, a... interface{}) {\n\tfmt.Fscanf(reader, f, a...)\n}\n\n\nfunc main() {\n\tvar A, one, five, ten, twenty, hundred, result uint64 \n\tone = 1\n\tfive = 5 \n\tten = 10 \n\ttwenty = 20 \n\thundred = 100\n\n\tscanf(\"%d \\n\", &A)\n\t\n\tresult = 0\n\tif A % hundred == 0 {\n\t\tresult = A/hundred\n\t\tfmt.Println(result)\n\t\treturn\n\t}\n\n\tresult += A/hundred\n\tA = A - A/hundred * hundred\n\n\tif A % twenty == 0 {\n\t\tresult += A/twenty\n\t\tfmt.Println(result)\n\t\treturn\n\t}\n\n\tresult += A/twenty\n\tA = A - A/twenty * twenty\n\t\n\n\tif A % ten == 0 {\n\t\tresult += A/ten\n\t\tfmt.Println(result)\n\t\treturn\n\t}\n\n\tresult += A/ten\n\tA = A - A/ten * ten\n\n\n\tif A % five == 0 {\n\t\tresult += A/five\n\t\tfmt.Println(result)\n\t\treturn\n\t}\n\n\tresult += A/five\n\tA = A - A/five * five\n\t\n\n\n\tresult += A * one\n\n\tfmt.Println(result)\n\n\n\n\n}"}, {"source_code": "package main\nimport \"fmt\"\n\nfunc main(){\n var n int\n ans := 0\n fmt.Scan(&n)\n // fmt.Print(n)\n if n>=100 {\n ans+=n/100\n // fmt.Println(n,ans)\n\n n%=100\n }\n if n>=20 {\n ans+=n/20\n n%=20\n }\n if n>=10 {\n ans+=n/10\n n%=10\n }\n if n>=5 {\n ans+=n/5\n n%=5\n }\n if n>=1 {\n ans+=n/1\n n%=1\n }\n fmt.Print(ans)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar amount int\n\tfmt.Scan(&amount)\n\tcnt := 0\n\tfor amount > 0 {\n\t\tswitch {\n\t\tcase amount % 100 == 0 : amount -= 100\n\t\tcase amount % 20 == 0 : amount -= 20\n\t\tcase amount % 10 == 0 : amount -= 10\n\t\tcase amount % 5 == 0 : amount -= 5\n\t\tdefault: amount--\n\t\t}\n\t\tcnt++\n\t}\n\tfmt.Println(cnt)\n}"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar n int\n\tfmt.Scan(&n)\n\tcount1 := 0\n\tplus1 := 1\n\tfor {\n\t\tif n >= 100 {\n\t\t\tplus1 = n - n % 100\n\t\t\tplus1 /= 100\n\t\t\tn %= 100\n\t\t} else if n >= 20 {\n\t\t\tplus1 = n - n % 20\n\t\t\tplus1 /= 20\n\t\t\tn %= 20\n\t\t} else if n >= 5{\n\t\t\tplus1 = n - n % 5\n\t\t\tplus1 /= 5\n\t\t\tn %= 5\n\t\t} else {\n\t\t\tplus1 = n\n\t\t\tn = 0\n\t\t}\n\t\tcount1 += plus1\n\t\tif n == 0{\n\t\t\tfmt.Println(count1)\n\t\t\tbreak\n\t\t}\n\t}\n\t\n}"}, {"source_code": "// A. Hit the Lottery\n/*\nAllen has a LOT of money. He has 𝑛 dollars in the bank.\nFor security reasons, he wants to withdraw it in cash\n(we will not disclose the reasons here).\nThe denominations for dollar bills are 1, 5, 10, 20, 100. What is the minimum\nnumber of bills Allen could receive after withdrawing his entire balance?\n\nInput\nThe first and only line of input contains a single integer 𝑛(1≤𝑛≤109).\n\nOutput\nOutput the minimum number of bills that Allen could receive.\n\nExamples\nInput\n125\n\nOutput\n3\n\nInput\n43\n\nOutput\n5\n\nInput\n1000000000\n\nOutput\n10000000\n\nNote\nIn the first sample case, Allen can withdraw this with a 100\ndollar bill, a 20 dollar bill, and a 5 dollar bill.\nThere is no way for Allen to receive 125 dollars in one or two bills.\n\nIn the second sample case, Allen can withdraw two 20 dollar bills and three 1\ndollar bills.\n\nIn the third sample case, Allen can withdraw 100000000 (ten million!)\n100 dollar bills.\n*/\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput, _, _ := reader.ReadLine()\n\tn, _ := strconv.Atoi(string(input))\n\tfmt.Println(sol966A(n))\n}\n\nfunc sol966A(n int) int {\n\tbills := 0\n\tfor n > 0 {\n\t\tif n/100 != 0 {\n\t\t\tbills += n / 100\n\t\t\tn = n % 100\n\t\t} else if n/20 != 0 {\n\t\t\tbills += n / 20\n\t\t\tn = n % 20\n\t\t} else if n/5 != 0 {\n\t\t\tbills += n / 5\n\t\t\tn = n % 5\n\t\t} else {\n\t\t\tbills += n\n\t\t\tbreak\n\t\t}\n\t}\n\treturn bills\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, num int\n\tnum = 0\n\tfmt.Scan(&n)\n\tfor n != 0 {\n\t\tif n >= 100 {\n\t\t\tn -= 100\n\t\t\tnum++\n\t\t}\n\t\tif n >= 20 {\n\t\t\tn -= 20\n\t\t\tnum++\n\t\t}\n\t\tif n >= 10 {\n\t\t\tn -= 10\n\t\t\tnum++\n\t\t}\n\t\tif n >= 5 {\n\t\t\tn -= 5\n\t\t\tnum++\n\t\t}\n\t\tif n >= 1 {\n\t\t\tn -= 1\n\t\t\tnum++\n\t\t}\n\t}\n\tfmt.Println(num)\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, rez uint32\n\n\tfmt.Scan(&n)\n\n\tif n == 74 {\n\t\tfmt.Println(8)\n\t} else {\n\n\t\tsotka := n / 100\n\t\tif sotka != 0 {\n\t\t\tn = n % 100\n\t\t}\n\t\tpoltos := n / 50\n\t\tif poltos != 0 {\n\t\t\tn = n % 50\n\t\t}\n\t\tdvadtsatka := n / 20\n\t\tif dvadtsatka != 0 {\n\t\t\tn = n % 20\n\t\t}\n\t\tchirik := n / 10\n\t\tif chirik != 0 {\n\t\t\tn = n % 10\n\t\t}\n\t\tpyatak := n / 5\n\t\tif pyatak != 0 {\n\t\t\tn = n % 5\n\t\t}\n\t\tdollar := n\n\n\t\trez = sotka + poltos + dvadtsatka + chirik + pyatak + dollar\n\t\tfmt.Println(rez)\n\t\t//fmt.Println(rez, \"sotka = \", sotka, \"poltos = \", poltos, \"dvadtsatka = \", dvadtsatka, \"chirik = \", chirik, \"pyatak = \", pyatak, \"dollar = \", dollar)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, rez uint32\n\n\tfmt.Scan(&n)\n\n\tsotka := n / 100\n\tif sotka != 0 {\n\t\tn = n % 100\n\t}\n\tpoltos := n / 50\n\tif poltos != 0 {\n\t\tn = n % 50\n\t}\n\tdvadtsatka := n / 20\n\tif dvadtsatka != 0 {\n\t\tn = n % 20\n\t}\n\tchirik := n / 10\n\tif chirik != 0 {\n\t\tn = n % 10\n\t}\n\tpyatak := n / 5\n\tif pyatak != 0 {\n\t\tn = n % 5\n\t}\n\trubl := n\n\n\trez = sotka + poltos + dvadtsatka + chirik + pyatak + rubl\n\tfmt.Println(rez)\n\t//fmt.Println(rez, \"sotka = \", sotka, \"poltos = \", poltos, \"dvadtsatka = \", dvadtsatka, \"chirik = \", chirik, \"pyatak = \", pyatak, \"rubl = \", rubl)\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar num1 uint32\n\tvar num2 uint8\n\n\tfmt.Fscan(os.Stdin, &num1)\n\tfmt.Scan(&num2)\n\n\tvar i uint8 = 1\n\n\tfor ; i <= num2; i++ {\n\n\t\tif (num1 % 10) == 0 {\n\t\t\tnum1 /= 10\n\t\t} else {\n\t\t\tnum1--\n\t\t}\n\t}\n\tfmt.Println(num1)\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n, ans int\n ans = 0\n \n fmt.Scan(&n)\n ans += n/100\n n %= 100\n ans += n/50\n n %= 50\n ans += n/20\n n %= 20\n ans += n/5\n n %= 20\n ans += n\n \n fmt.Println(ans)\n}\n"}, {"source_code": "package main \n\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)\n\nfunc printf(f string, a... interface{}) {\n\tfmt.Fprintf(writer, f, a...)\n}\n\nfunc scanf(f string, a... interface{}) {\n\tfmt.Fscanf(reader, f, a...)\n}\n\n\nfunc main() {\n\tvar A, one, five, ten, twenty, fifty, hundred, result uint64 \n\tone = 1\n\tfive = 5 \n\tten = 10 \n\ttwenty = 20 \n\tfifty = 50 \n\thundred = 100\n\n\tscanf(\"%d \\n\", &A)\n\t\n\tresult = 0\n\tif A % hundred == 0 {\n\t\tresult = A/hundred\n\t\tfmt.Println(result)\n\t\treturn\n\t}\n\n\tresult += A/hundred\n\tA = A - A/hundred * hundred\n\n\tif A % fifty == 0 {\n\t\tresult += A/fifty\n\t\tfmt.Println(result)\n\t\treturn\n\t}\n\n\tresult += A/fifty\n\tA = A - A/fifty * fifty\n\t\n\n\tif A % twenty == 0 {\n\t\tresult += A/twenty\n\t\tfmt.Println(result)\n\t\treturn\n\t}\n\n\tresult += A/twenty\n\tA = A - A/twenty * twenty\n\t\n\n\tif A % ten == 0 {\n\t\tresult += A/ten\n\t\tfmt.Println(result)\n\t\treturn\n\t}\n\n\tresult += A/ten\n\tA = A - A/ten * ten\n\n\n\tif A % five == 0 {\n\t\tresult += A/five\n\t\tfmt.Println(result)\n\t\treturn\n\t}\n\n\tresult += A/five\n\tA = A - A/five * five\n\t\n\n\n\tresult += A * one\n\n\tfmt.Println(result)\n\n\n\n\n}"}], "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc"} {"nl": {"description": "There are r red and g green blocks for construction of the red-green tower. Red-green tower can be built following next rules: Red-green tower is consisting of some number of levels; Let the red-green tower consist of n levels, then the first level of this tower should consist of n blocks, second level — of n - 1 blocks, the third one — of n - 2 blocks, and so on — the last level of such tower should consist of the one block. In other words, each successive level should contain one block less than the previous one; Each level of the red-green tower should contain blocks of the same color. Let h be the maximum possible number of levels of red-green tower, that can be built out of r red and g green blocks meeting the rules above. The task is to determine how many different red-green towers having h levels can be built out of the available blocks.Two red-green towers are considered different if there exists some level, that consists of red blocks in the one tower and consists of green blocks in the other tower.You are to write a program that will find the number of different red-green towers of height h modulo 109 + 7.", "input_spec": "The only line of input contains two integers r and g, separated by a single space — the number of available red and green blocks respectively (0 ≤ r, g ≤ 2·105, r + g ≥ 1).", "output_spec": "Output the only integer — the number of different possible red-green towers of height h modulo 109 + 7.", "sample_inputs": ["4 6", "9 7", "1 1"], "sample_outputs": ["2", "6", "2"], "notes": "NoteThe image in the problem statement shows all possible red-green towers for the first sample."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar MOD int64 = 1e9 + 7;\n\tvar r, g int\n\tfmt.Scan(&r, &g)\n\th := 0\n\n\tfor i := 1; i <= 1000; i++ {\n\t\tif (i * (i + 1) / 2) > r+g {\n\t\t\th = i - 1\n\t\t\tbreak\n\t\t}\n\t}\n\n\tdp := make([]int64, r+1)\n\tdp[0] = 1\n\n\tfor i := 1; i <= h; i++ {\n\t\tfor j := r - i; j >= 0; j-- {\n\t\t\tdp[j+i] += dp[j]\n\t\t\tif dp[j+i] >= MOD {\n\t\t\t\tdp[j+i] -= MOD\n\t\t\t}\n\t\t}\n\t}\n\n\tvar answer int64 = 0\n\tfor i := 0; i <= r; i++ {\n\t\tif h*(h+1)/2-i <= g {\n\t\t\tanswer += dp[i];\n\t\t}\n\t}\n\n\tfmt.Print(answer % MOD)\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar MOD int64 = 10000007\n\tvar r, g int\n\tfmt.Scan(&r, &g)\n\th := 0\n\n\tfor i := 1; i <= 1000; i++ {\n\t\tif (i * (i + 1) / 2) > r+g {\n\t\t\th = i - 1\n\t\t\tbreak\n\t\t}\n\t}\n\n\tdp := make([]int64, r+1)\n\tdp[0] = 1\n\n\tfor i := 1; i <= h; i++ {\n\t\tfor j := r - i; j >= 0; j-- {\n\t\t\tdp[j+i] += dp[j]\n\t\t\tif dp[j+i] >= MOD {\n\t\t\t\tdp[j+i] -= MOD\n\t\t\t}\n\t\t}\n\t}\n\n\tvar answer int64 = 0\n\tfor i := 0; i <= r; i++ {\n\t\tif h*(h+1)/2-i <= g {\n\t\t\tanswer += dp[i];\n\t\t}\n\t}\n\n\tfmt.Print(answer % MOD)\n}\n"}], "src_uid": "34b6286350e3531c1fbda6b0c184addc"} {"nl": {"description": "Translator's note: in Russia's most widespread grading system, there are four grades: 5, 4, 3, 2, the higher the better, roughly corresponding to A, B, C and F respectively in American grading system.The term is coming to an end and students start thinking about their grades. Today, a professor told his students that the grades for his course would be given out automatically  — he would calculate the simple average (arithmetic mean) of all grades given out for lab works this term and round to the nearest integer. The rounding would be done in favour of the student — $$$4.5$$$ would be rounded up to $$$5$$$ (as in example 3), but $$$4.4$$$ would be rounded down to $$$4$$$.This does not bode well for Vasya who didn't think those lab works would influence anything, so he may receive a grade worse than $$$5$$$ (maybe even the dreaded $$$2$$$). However, the professor allowed him to redo some of his works of Vasya's choosing to increase his average grade. Vasya wants to redo as as few lab works as possible in order to get $$$5$$$ for the course. Of course, Vasya will get $$$5$$$ for the lab works he chooses to redo.Help Vasya — calculate the minimum amount of lab works Vasya has to redo.", "input_spec": "The first line contains a single integer $$$n$$$ — the number of Vasya's grades ($$$1 \\leq n \\leq 100$$$). The second line contains $$$n$$$ integers from $$$2$$$ to $$$5$$$ — Vasya's grades for his lab works.", "output_spec": "Output a single integer — the minimum amount of lab works that Vasya has to redo. It can be shown that Vasya can always redo enough lab works to get a $$$5$$$.", "sample_inputs": ["3\n4 4 4", "4\n5 4 5 5", "4\n5 3 3 5"], "sample_outputs": ["2", "0", "1"], "notes": "NoteIn the first sample, it is enough to redo two lab works to make two $$$4$$$s into $$$5$$$s.In the second sample, Vasya's average is already $$$4.75$$$ so he doesn't have to redo anything to get a $$$5$$$.In the second sample Vasya has to redo one lab work to get rid of one of the $$$3$$$s, that will make the average exactly $$$4.5$$$ so the final grade would be $$$5$$$."}, "positive_code": [{"source_code": "package main\n\nimport (\n \"fmt\"\n \"bufio\"\n \"os\"\n \"sort\"\n \"math\"\n \"strconv\"\n \"strings\"\n )\n\nfunc main() {\n scanner := bufio.NewScanner(os.Stdin)\n scanner.Scan()\n n, _ := strconv.Atoi(scanner.Text())\n arr := make([]int, n)\n sum := 0\n scanner.Scan();\n str := strings.Fields(scanner.Text())\n for i:=0;i0;i++ {\n d := 5 - arr[i]\n rem -= d\n c++ \n }\n fmt.Println(c)\n\n}\n "}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"sort\"\n\nfunc main() {\n\tvar n, sum, ans, need int\n\tfmt.Scan(&n)\n\tv := make([]int, n)\n\tfor i := range v {\n\t\tfmt.Scan(&v[i])\n\t\tv[i] *= 2\n\t\tsum += v[i]\n\t}\n\tneed = 9 * n\n\tsort.Ints(v)\n\tfor i := range v {\n\t\tif sum >= need {\n\t\t\tbreak\n\t\t}\n\t\tsum += 10 - v[i]\n\t\tans++\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\\n\", &n)\n\tvar array [200]int\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &array[i])\n\t}\n\tsort.Ints(array[:n])\n\tvar sum float64 = float64(4.5 * float64(n))\n\n\tfor i := 0; i < n; i++ {\n\t\tsum -= float64(array[i])\n\t\t//\tfmt.Printf(\"%d \", array[i])\n\t}\n\t//\tfmt.Printf(\"%f\\n\", sum)\n\tif sum <= 0 {\n\t\tfmt.Printf(\"0\\n\")\n\t\treturn\n\t} else {\n\t\t//\tfmt.Printf(\"%f\\n\", sum)\n\t\tsum = -sum\n\t\tvar result int = 0\n\t\tfor i := 0; i < n; i++ {\n\t\t\tsum += float64(5 - array[i])\n\t\t\tresult++\n\t\t\t//\tfmt.Printf(\"%f\", sum)\n\t\t\tif sum >= 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfmt.Printf(\"%d\\n\", result)\n\t}\n\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\", &n)\n\tvar array [200]int\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &array[i])\n\t}\n\tsort.Ints(array[:n])\n\tvar sum float64 = 4.5 * float64(n)\n\n\tfor i := n - 1; i >= 0; i-- {\n\t\tsum -= float64(array[i])\n\t\t//\tfmt.Printf(\"%d \", array[i])\n\t}\n\tif sum <= 0 {\n\t\tfmt.Printf(\"0\\n\")\n\t\treturn\n\t} else {\n\t\t//\t\tfmt.Printf(\"%f\\n\", sum)\n\t\tsum = -sum\n\t\tvar result int = 0\n\t\tfor i := 0; i < n; i++ {\n\t\t\tsum += float64(5 - array[i])\n\t\t\tresult++\n\t\t\t//\tfmt.Printf(\"%f\", sum)\n\t\t\tif sum >= 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfmt.Printf(\"%d\\n\", result)\n\t}\n\n}\n"}], "src_uid": "715608282b27a0a25b66f08574a6d5bd"} {"nl": {"description": "Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice different patterns. For example, each team has two sets of uniforms: home uniform and guest uniform. When a team plays a game at home, the players put on the home uniform. When a team plays as a guest on somebody else's stadium, the players put on the guest uniform. The only exception to that rule is: when the home uniform color of the host team matches the guests' uniform, the host team puts on its guest uniform as well. For each team the color of the home and guest uniform is different.There are n teams taking part in the national championship. The championship consists of n·(n - 1) games: each team invites each other team to its stadium. At this point Manao wondered: how many times during the championship is a host team going to put on the guest uniform? Note that the order of the games does not affect this number.You know the colors of the home and guest uniform for each team. For simplicity, the colors are numbered by integers in such a way that no two distinct colors have the same number. Help Manao find the answer to his question.", "input_spec": "The first line contains an integer n (2 ≤ n ≤ 30). Each of the following n lines contains a pair of distinct space-separated integers hi, ai (1 ≤ hi, ai ≤ 100) — the colors of the i-th team's home and guest uniforms, respectively.", "output_spec": "In a single line print the number of games where the host team is going to play in the guest uniform.", "sample_inputs": ["3\n1 2\n2 4\n3 4", "4\n100 42\n42 100\n5 42\n100 5", "2\n1 2\n1 2"], "sample_outputs": ["1", "5", "0"], "notes": "NoteIn the first test case the championship consists of 6 games. The only game with the event in question is the game between teams 2 and 1 on the stadium of team 2.In the second test sample the host team will have to wear guest uniform in the games between teams: 1 and 2, 2 and 1, 2 and 3, 3 and 4, 4 and 2 (the host team is written first)."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, ans int\n\tfmt.Scan(&n)\n\tuni := make([][2]int, n)\n\tfor i := range uni {\n\t\tfmt.Scan(&uni[i][0], &uni[i][1])\n\t}\n\tfor home := range uni {\n\t\tfor guest := range uni {\n\t\t\tif uni[home][0] == uni[guest][1] {\n\t\t\t\tans++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n, h, a int\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &n)\n\thost := make(map[int]int, n)\n\tguest := make([]int, a)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscan(in, &h, &a)\n\t\thost[h] = host[h] + 1\n\t\tguest = append(guest, a)\n\t}\n\tans := 0\n\tfor _, v := range guest {\n\t\tans += host[v]\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar home = make(map[string]int)\n\tvar host = make(map[string]int)\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\tscanner.Scan()\n\n\tfor scanner.Scan() {\n\t\tcolor := scanner.Text()\n\t\tif _, ok := home[color]; ok == false {\n\t\t\thome[color] = 1\n\t\t}else {\n\t\t\thome[color]++\n\t\t}\n\t\tscanner.Scan()\n\n\t\tcolor = scanner.Text()\n\t\tif _, ok := host[color]; ok == false {\n\t\t\thost[color] = 1\n\t\t}else {\n\t\t\thost[color]++\n\t\t}\n\t}\n\tvar count = 0\n\tfor key,value := range home {\n\t\tif v, ok := host[key]; ok != false {\n\t\t\tcount += v * value\n\t\t}\n\t}\n\n\tfmt.Println(count)\n}\n"}, {"source_code": "package main\n\nimport(\n \"fmt\"\n)\n\ntype teamColor struct{\n hC,gC string\n}\n\nfunc main(){\n var(\n n int\n res = 0\n )\n fmt.Scan(&n)\n arr := make([]teamColor,n)\n for i:=0;i= 0; j-- {\n\t\t\tif h[i] == g[j] {\n\t\t\t\tresult++\n\t\t\t}\n\t\t\tif h[j] == g[i] {\n\t\t\t\tresult++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Print(result)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n var h,a [35]int\n fmt.Scan(&n)\n for i := 0; i < n; i++ { fmt.Scan(&h[i],&a[i]) }\n ans := 0\n for i := 0; i < n; i++ {\n for j := 0; j < n; j++ {\n if (i != j) && (h[i] == a[j]) {\n ans++\n }\n }\n }\n fmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\ntype Vertex struct {\n\thome, guest int\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\n\tarr := make([]Vertex, n)\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&arr[i].home, &arr[i].guest)\n\t}\n\n\tcount := 0\n\n\tfor i := 0; i < n; i++ {\n\t\tfor j := i + 1; j < n; j++ {\n\t\t\tif arr[i].home == arr[j].guest {\n\t\t\t\tcount++\n\t\t\t}\n\t\t\tif arr[j].home == arr[i].guest {\n\t\t\t\tcount++\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(count)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\ntype team struct {\n\thomeUniform int\n\tguestUniform int\n}\n\nfunc main() {\n\tvar nTeams int\n\tfmt.Scanf(\"%d\\n\", &nTeams)\n\tteams := make([]team, nTeams)\n\tfor i := 0; i < nTeams; i++ {\n\t\tfmt.Scanf(\"%d %d\\n\", &teams[i].homeUniform, &teams[i].guestUniform)\n\t}\n\tvar count int\n\tfor i := 0; i < nTeams; i++ {\n\t\tfor j := 0; j < nTeams; j++ {\n\t\t\tif teams[i].homeUniform == teams[j].guestUniform {\n\t\t\t\tcount += 1\n\t\t\t}\n\t\t}\n\t}\n\t// fmt.Println(teams)\n\tfmt.Println(count)\n}\n"}, {"source_code": "package main\n\nimport(\n\t\"fmt\"\n)\n\nfunc main() {\n\tn := 0\n\tfmt.Scanf(\"%d\\n\", &n)\n\tarr1 := []int{}\n\tarr2 := []int{}\n\n\tfor i := 0; i < n; i++ {\n\t\ta := 0\n\t\tb := 0\n\t\tfmt.Scanf(\"%d %d\\n\", &a, &b)\n\t\tarr1 = append(arr1, a)\n\t\tarr2 = append(arr2, b)\n\t}\n\n\tcnt := 0\n\n\tfor i := 0; i < n; i++ {\n\t\tval := arr1[i]\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif j != i && arr2[j] == val {\n\t\t\t\tcnt += 1\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(cnt)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, count int\n\tfmt.Scan(&n)\n\tvar home = make([]int, n)\n\tvar away = make([]int, n)\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&home[i])\n\t\tfmt.Scan(&away[i])\n\t}\n\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif (i != j) && (home[i] == away[j]) {\n\t\t\t\tcount++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(count)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, count int\n\tfmt.Scan(&n)\n\tvar home = make([]int, n)\n\tvar away = make([]int, n)\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&home[i])\n\t\tfmt.Scan(&away[i])\n\t}\n\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif home[i] == away[j] {\n\t\t\t\tcount++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(count)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n, count int\n\tfmt.Scan(&n)\n\tvar home = make([]int, n)\n\tvar away = make([]int, n)\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\n\tfor i := 0; i < n; i++ {\n\t\t// fmt.Scan(&home[i])\n\t\t// fmt.Scan(&away[i])\n\t\tscanner.Scan()\n\t\thome[i] = toInt(scanner.Bytes())\n\n\t\tscanner.Scan()\n\t\taway[i] = toInt(scanner.Bytes())\n\n\t}\n\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif (i != j) && (home[i] == away[j]) {\n\t\t\t\tcount++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(count)\n}\n\nfunc toInt(buf []byte) (n int) {\n\tfor _, v := range buf {\n\t\tn = n*10 + int(v-'0')\n\t}\n\treturn\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n, count int\n\tfmt.Scan(&n)\n\tvar home = make(map[int]int, n)\n\tvar away = make(map[int]int, n)\n\tvar h, a int\n\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&h)\n\t\tfmt.Scan(&a)\n\t\tif _, ok := home[h]; ok {\n\t\t\thome[h]++\n\t\t} else {\n\t\t\thome[h] = 1\n\t\t}\n\t\tif _, ok := away[a]; ok {\n\t\t\taway[a]++\n\t\t} else {\n\t\t\taway[a] = 1\n\t\t}\n\t}\n\n\tfor i := 1; i <= 100; i++ {\n\t\tif _, ok := home[i]; ok {\n\t\t\tif _, ok := away[i]; ok {\n\t\t\t\tcount += (home[i] * away[i])\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(count)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar colors [][2]int\n\tvar n int\n\tfmt.Scan(&n)\n\n\tcolors = make([][2]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&colors[i][0], &colors[i][1])\n\t}\n\n\tcnt := 0\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif i == j {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif colors[i][0] == colors[j][1] {\n\t\t\t\tcnt += 1\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Print(cnt)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar reader *bufio.Reader\n\nfunc init() {\n\tstdin := os.Stdin\n\t// stdin, _ = os.Open(\"1.in\")\n\treader = bufio.NewReaderSize(stdin, 1<<20)\n}\n\n// Pair Pair\ntype Pair struct {\n\tFirst int\n\tSecond int\n}\n\nvar n int\nvar a []Pair\n\nfunc main() {\n\tfmt.Fscan(reader, &n)\n\ta = make([]Pair, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscan(reader, &a[i].First, &a[i].Second)\n\t}\n\n\tans := 0\n\tfor i := 0; i < n; i++ {\n\t\tfor j := 0; j < n; j++ {\n\t\t\tif i == j {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif a[i].First == a[j].Second {\n\t\t\t\tans++\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\ntype Team struct {\n main uint8\n second uint8\n}\n\nfunc main() {\n\tin := bufio.NewReader(os.Stdin)\n\tvar n uint8\n\tvar c uint16\n\tvar s []Team\n\t\n\tfmt.Fscanf(in, \"%d\\n\", &n)\n\tfor i:= uint8(0); i < n; i++{\n\t\tvar t Team\n\t\tfmt.Fscanf(in, \"%d %d\\n\", &t.main, &t.second)\n\t\ts = append(s, t)\n\t}\n\tfor i:= uint8(0); i < n; i++{\n\t\tfor j:= uint8(0); j < n; j++{\n\t\t\tif i != j{\n\t\t\t\tif s[i].main == s[j].second{\n\t\t\t\t\tc++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(c)\n\n}\n"}, {"source_code": "package main\nimport \"fmt\"\nfunc main() {\n\tvar n,x,y int\n\tvar h,a [110]int\n\tfmt.Scan(&n)\n\tfor ;n>0;n-- {\n\t\tfmt.Scan(&x,&y)\n\t\th[x]++; a[y]++\n\t}\n\tr:=0\n\tfor i:=1;i<101;i++ {\n\t\tr += a[i]*h[i]\n\t}\n\tfmt.Print(r)\n}"}, {"source_code": "// URL: http://codeforces.com/problemset/problem/268/A\n// ~ Basic Implementation Problem\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc solve(colors [][2]int) int {\n\taway := make(map[int]int)\n\tfor _, val := range colors {\n\t\taway[val[1]] += 1\n\t}\n\tcount := 0\n\tfor _, val := range colors {\n\t\tcount += away[val[0]]\n\t}\n\treturn count\n}\n\nfunc main() {\n\treader, writer := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tvar n int\n\tfmt.Fscanf(reader, \"%d\\n\", &n)\n\tcolors := make([][2]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(reader, \"%d %d\\n\", &colors[i][0], &colors[i][1])\n\t}\n\tfmt.Fprintf(writer, \"%d\\n\", solve(colors))\n}\n"}, {"source_code": "package main \n\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n\t//\"strings\"\n)\n\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\n\ntype Game struct {\n\thome int\n\taway int\n}\n\nfunc main() {\n\n\tvar T int\n\tscanf(\"%d \\n\", &T)\n\n\tgames := []Game{}\n\tfor i:=0; i n/2 {\n\t\tr = n - r\n\t}\n\tu := n + 1\n\tfor i := int64(1); i <= r; i++ {\n\t\tu--\n\t\tresult *= u\n\t\tresult /= i\n\t}\n\treturn result\n}\n\nfunc fact(n int64) int64 {\n\tresult := int64(1)\n\tfor i := int64(2); i <= n; i++ {\n\t\tresult *= i\n\t}\n\treturn result\n}\n\nvar reader = bufio.NewReader(os.Stdin)\nvar writer = bufio.NewWriter(os.Stdout)\n\nfunc main() {\n\tdefer writer.Flush()\n\tvar n int64\n\tfmt.Fscan(reader, &n)\n\tf := fact(n/2 - 1)\n\tfmt.Fprintln(writer, comb(n, n/2)/2*f*f)\n}\n"}], "negative_code": [], "src_uid": "ad0985c56a207f76afa2ecd642f56728"} {"nl": {"description": "Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are \"a\", \"o\", \"u\", \"i\", and \"e\". Other letters are consonant.In Berlanese, there has to be a vowel after every consonant, but there can be any letter after any vowel. The only exception is a consonant \"n\"; after this letter, there can be any letter (not only a vowel) or there can be no letter at all. For example, the words \"harakiri\", \"yupie\", \"man\", and \"nbo\" are Berlanese while the words \"horse\", \"king\", \"my\", and \"nz\" are not.Help Vitya find out if a word $$$s$$$ is Berlanese.", "input_spec": "The first line of the input contains the string $$$s$$$ consisting of $$$|s|$$$ ($$$1\\leq |s|\\leq 100$$$) lowercase Latin letters.", "output_spec": "Print \"YES\" (without quotes) if there is a vowel after every consonant except \"n\", otherwise print \"NO\". You can print each letter in any case (upper or lower).", "sample_inputs": ["sumimasen", "ninja", "codeforces"], "sample_outputs": ["YES", "YES", "NO"], "notes": "NoteIn the first and second samples, a vowel goes after each consonant except \"n\", so the word is Berlanese.In the third sample, the consonant \"c\" goes after the consonant \"r\", and the consonant \"s\" stands on the end, so the word is not Berlanese."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc isAeiou(t string) bool {\n\tif t==\"a\" || t == \"e\" || t==\"i\" || t == \"o\" || t == \"u\" {\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tfor i := 0; i < len(s)-1; i++ {\n\t\tif isAeiou(string(s[i])) || string(s[i])==\"n\" {\n\t\t\tcontinue\n\t\t}\n\t\tif !isAeiou(string(s[i+1])) {\n\t\t\tfmt.Println(\"NO\")\n\t\t\treturn \n\t\t}\n\t}\n\tif isAeiou(string(s[len(s)-1])) || string(s[len(s)-1])==\"n\" {\n\t\tfmt.Println(\"YES\")\n\t}else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvocal := map[string]bool{\n\t\t\"a\": true,\n\t\t\"i\": true,\n\t\t\"u\": true,\n\t\t\"e\": true,\n\t\t\"o\": true,\n\t}\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Scan()\n\tword := sc.Text()\n\tfor i := 0; i < len(word); i++ {\n\t\t// get status\n\t\tch := string(word[i])\n\t\tisLast := (i == len(word)-1)\n\t\tisVocal := vocal[ch]\n\t\tisN := (ch == \"n\")\n\t\t// get next char\n\t\tnextCh := \"\"\n\t\tif !isLast {\n\t\t\tnextCh = string(word[i+1])\n\t\t}\n\t\t// infer if word is belanese\n\t\tif !isN && (!isVocal && !vocal[nextCh] || !isVocal && isLast) {\n\t\t\tfmt.Println(\"NO\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"YES\")\n}\n"}, {"source_code": "package main\n\n/*\n\tBasically we just need to determine whether given word is Belanese.\n\tA word is belanese if it follows following rule:\n\t- vowel after consonant except for \"n\"\n\t- anything after vowel or \"n\" -> including empty char\n\n\tSo we could just iterate each char in word. If we found a char which:\n\t- consonant but not n\n\t- not having vowel afterwards or last char\n\twe could infer that the word is not Belanese. Otherwise if we don't found\n\tanything like that, it must be Belanese.\n*/\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvocal := map[string]bool{\n\t\t\"a\": true,\n\t\t\"i\": true,\n\t\t\"u\": true,\n\t\t\"e\": true,\n\t\t\"o\": true,\n\t}\n\tsc := bufio.NewScanner(os.Stdin)\n\tsc.Scan()\n\tword := sc.Text()\n\tfor i := 0; i < len(word); i++ {\n\t\t// get status\n\t\tch := string(word[i])\n\t\tisLast := (i == len(word)-1)\n\t\tisVocal := vocal[ch]\n\t\tisN := (ch == \"n\")\n\t\t// get next char\n\t\tnextCh := \"\"\n\t\tif !isLast {\n\t\t\tnextCh = string(word[i+1])\n\t\t}\n\t\t// infer if word is belanese\n\t\tif !isN && (!isVocal && !vocal[nextCh] || !isVocal && isLast) {\n\t\t\tfmt.Println(\"NO\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Println(\"YES\")\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc isVowel(c byte) bool {\n if c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' {\n return true\n } else {\n return false\n }\n}\n\nfunc main() {\n var s string\n fmt.Scanf(\"%s\", &s)\n succ := true\n for i, c := range []byte(s) {\n cur := true\n if !isVowel(c) && c != 'n' {\n cur = (i < len(s) - 1) && isVowel(s[i+1])\n }\n if !cur {\n succ = false\n }\n }\n if succ {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc isVowel(c byte) bool {\n if c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' {\n return true\n } else {\n return false\n }\n}\n\nfunc main() {\n var s string\n fmt.Scanf(\"%s\", &s)\n succ := true\n for i, c := range []byte(s) {\n cur := true\n if !isVowel(c) {\n if c == 'n' {\n } else {\n cur = (i < len(s) - 1) && isVowel(s[i+1])\n }\n }\n if !cur {\n succ = false \n }\n // fmt.Println(i, c, cur)\n }\n if succ {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n\n"}, {"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\ntype state func() state\n\nfunc main() {\n\tdefer Flush()\n\n\ts := readb()\n\tvar i int\n\tok := true\n\n\tvar vowel, consonant state\n\tvowel = func() state {\n\t\t//eprintln(i, \"vowel\", ok)\n\t\tif i == len(s) {\n\t\t\treturn nil\n\t\t}\n\t\tswitch s[i] {\n\t\tcase 'a', 'o', 'u', 'i', 'e', 'n':\n\t\t\ti++\n\t\t\treturn vowel\n\t\tdefault:\n\t\t\ti++\n\t\t\treturn consonant\n\t\t}\n\t}\n\tconsonant = func() state {\n\t\t//eprintln(i, \"consonant\", ok)\n\t\tif i == len(s) {\n\t\t\tok = false\n\t\t\treturn nil\n\t\t}\n\t\tswitch s[i] {\n\t\tcase 'a', 'o', 'u', 'i', 'e':\n\t\t\ti++\n\t\t\treturn vowel\n\t\tdefault:\n\t\t\tok = false\n\t\t\treturn nil\n\t\t}\n\t}\n\tfor st := vowel; st != nil; st = st() {\n\t}\n\tif ok {\n\t\tprintln(\"YES\")\n\t} else {\n\t\tprintln(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"strings\"\n)\n\nfunc readLine(reader *bufio.Reader) string {\n\tline, _, err := reader.ReadLine()\n\tif err == io.EOF {\n\t\treturn \"\"\n\t}\n\treturn strings.TrimRight(string(line), \"\\r\\n\")\n}\n\nfunc checkError(err error) {\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc main() {\n\tvowels := make(map[rune]int)\n\tvar l rune\n\tfor l = 'a'; l <= 'z'; l++ {\n\t\tif l == 'a' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'e' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'i' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'o' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'u' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t}\n\n\tisBerlanese := true\n\tvar word string\n\tfmt.Scanf(\"%s\", &word)\n\n\tif len(word) > 1 {\n\t\tfor i := 0; i < len(word)-1; i++ {\n\t\t\tif isBerlanese == false {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tletter := rune(word[i])\n\t\t\tnextLetter := rune(word[i+1])\n\t\t\tif letter == 'n' {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t_, isVowel := vowels[letter]\n\t\t\tif isVowel == true {\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\t_, nextIsVowel := vowels[nextLetter]\n\t\t\t\tif nextIsVowel == false {\n\t\t\t\t\tisBerlanese = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tletter := rune(word[0])\n\t\tif letter == 'n' {\n\t\t\tisBerlanese = true\n\t\t} else if _, V := vowels[letter]; V == true {\n\t\t\tisBerlanese = true\n\t\t} else {\n\t\t\tisBerlanese = false\n\t\t}\n\t}\n\n\tletter := rune(word[len(word)-1])\n\tif _, okay := vowels[letter]; !(okay == true || letter == 'n') {\n\t\tisBerlanese = false\n\t}\n\tif isBerlanese == true {\n\t\tfmt.Printf(\"%s\\n\", \"YES\")\n\t} else {\n\t\tfmt.Printf(\"%s\\n\", \"NO\")\n\t}\n}\n"}, {"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\n\tS := sc.NextLine()\n\n\tflag := false\n\tfor i := 0; i < len(S); i++ {\n\t\tswitch S[i] {\n\t\tcase 'a', 'i', 'u', 'e', 'o':\n\t\t\tflag = false\n\t\tdefault:\n\t\t\tif flag {\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif S[i] != 'n' {\n\t\t\t\tflag = true\n\t\t\t}\n\t\t}\n\t}\n\tif flag {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tfmt.Println(\"YES\")\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfor {\n\t\tvar word string\n\t\t_, err := fmt.Scanln(&word)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\n\t\tneed_vowel, need_rune := false, false\n\t\tres := \"YES\"\n\n\t\tfor _, c := range word {\n\t\t\tswitch c {\n\t\t\tcase 'a', 'o', 'u', 'i', 'e':\n\t\t\tdefault:\n\t\t\t\tif need_vowel {\n\t\t\t\t\tres = \"NO\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif res == \"NO\" {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tswitch c {\n\t\t\tcase 'a', 'o', 'u', 'i', 'e', 'n':\n\t\t\t\tneed_vowel, need_rune = false, false\n\t\t\tdefault:\n\t\t\t\tneed_vowel, need_rune = true, true\n\t\t\t}\n\t\t}\n\n\t\tif need_rune {\n\t\t\tres = \"NO\"\n\t\t}\n\n\t\tfmt.Println(res)\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\t\nfunc main() {\n var s string\n\tfmt.Scan(&s)\n\tt := true\n\tflag := false\n\tfor i,a := range(s){\n\t f := true\n\t for _,b := range([]rune{'a','o','u','i','e'}) {\n \t if a == b { f = false }\n \t}\n\t if flag && f {\n\t t = false\n\t break\n\t } else if flag && !f {\n\t flag = false \n\t } else if !flag && f && a != 'n'{\n\t flag = true\n\t } else if f && i == len(s)-1 && a != 'n' {\n\t t = false\n\t break\n\t }\n\t \n\t}\n\tif t && !flag {\n\t fmt.Println(\"YES\")\n\t} else {\n\t fmt.Println(\"NO\")\n\t}\n}"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc isVowel(c byte) bool {\n if c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' {\n return true\n } else {\n return false\n }\n}\n\nfunc main() {\n var s string\n fmt.Scanf(\"%s\", &s)\n succ := true\n for i, c := range []byte(s) {\n cur := true\n if !isVowel(c) {\n if c == 'n' {\n cur = (i == len(s) - 1) || isVowel(s[i+1])\n } else {\n cur = (i < len(s) - 1) && isVowel(s[i+1])\n }\n }\n if !cur {\n succ = false \n }\n }\n if succ {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n}\n\n"}, {"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\ntype state func() state\n\nfunc main() {\n\tdefer Flush()\n\n\ts := readb()\n\tvar i int\n\tok := true\n\n\tvar vowel, consonant state\n\tvowel = func() state {\n\t\t//eprintln(i, \"vowel\", ok)\n\t\tif i == len(s) {\n\t\t\treturn nil\n\t\t}\n\t\tswitch s[i] {\n\t\tcase 'a', 'o', 'u', 'i', 'e', 'n':\n\t\t\ti++\n\t\t\treturn vowel\n\t\tdefault:\n\t\t\ti++\n\t\t\treturn consonant\n\t\t}\n\t}\n\tconsonant = func() state {\n\t\t//eprintln(i, \"consonant\", ok)\n\t\tif i == len(s) {\n\t\t\tok = false\n\t\t\treturn nil\n\t\t}\n\t\tswitch s[i] {\n\t\tcase 'a', 'o', 'u', 'i', 'e', 'n':\n\t\t\ti++\n\t\t\treturn vowel\n\t\tdefault:\n\t\t\tok = false\n\t\t\treturn nil\n\t\t}\n\t}\n\tfor st := vowel; st != nil; st = st() {\n\t}\n\tif ok {\n\t\tprintln(\"YES\")\n\t} else {\n\t\tprintln(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"io\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc readLine(reader *bufio.Reader) string {\n\tline, _, err := reader.ReadLine()\n\tif err == io.EOF {\n\t\treturn \"\"\n\t}\n\treturn strings.TrimRight(string(line), \"\\r\\n\")\n}\n\nfunc checkError(err error) {\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tvowels := make(map[rune]int)\n\tvar l rune\n\tfor l = 'a'; l <= 'z'; l++ {\n\t\tif l == 'a' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'e' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'i' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'o' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'u' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t}\n\n\tisBerlanese := true\n\tword := readLine(reader)\n\n\tfor i := 0; i < len(word)-1; i++ {\n\t\tif isBerlanese == false {\n\t\t\tbreak\n\t\t}\n\t\tletter := rune(word[i])\n\t\tnextLetter := rune(word[i+1])\n\t\tif letter == 'n' {\n\t\t\tcontinue\n\t\t}\n\n\t\t_, isVowel := vowels[letter]\n\t\tif isVowel == true {\n\t\t\t_, nextIsVowel := vowels[nextLetter]\n\t\t\tif nextIsVowel == true {\n\t\t\t\tisBerlanese = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t} else {\n\t\t\t_, nextIsVowel := vowels[nextLetter]\n\t\t\tif nextIsVowel == false {\n\t\t\t\tisBerlanese = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tif isBerlanese == true {\n\t\tprintln(\"YES\")\n\t} else {\n\t\tprintln(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"strings\"\n)\n\nfunc readLine(reader *bufio.Reader) string {\n\tline, _, err := reader.ReadLine()\n\tif err == io.EOF {\n\t\treturn \"\"\n\t}\n\treturn strings.TrimRight(string(line), \"\\r\\n\")\n}\n\nfunc checkError(err error) {\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc main() {\n\tvowels := make(map[rune]int)\n\tvar l rune\n\tfor l = 'a'; l <= 'z'; l++ {\n\t\tif l == 'a' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'e' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'i' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'o' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'u' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t}\n\n\tisBerlanese := true\n\tvar word string\n\tfmt.Scanf(\"%s\", &word)\n\n\tif len(word) > 1 {\n\t\tfor i := 0; i < len(word)-1; i++ {\n\t\t\tif isBerlanese == false {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tletter := rune(word[i])\n\t\t\tnextLetter := rune(word[i+1])\n\t\t\tif letter == 'n' {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t_, isVowel := vowels[letter]\n\t\t\tif isVowel == true {\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\t_, nextIsVowel := vowels[nextLetter]\n\t\t\t\tif nextIsVowel == false {\n\t\t\t\t\tisBerlanese = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tletter := rune(word[0])\n\t\tif letter == 'n' {\n\t\t\tisBerlanese = true\n\t\t}\n\t\tif _, V := vowels[letter]; V == true {\n\t\t\tisBerlanese = true\n\t\t}\n\t\tisBerlanese = false\n\t}\n\tif isBerlanese == true {\n\t\tfmt.Printf(\"%s\\n\", \"YES\")\n\t} else {\n\t\tfmt.Printf(\"%s\\n\", \"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"strings\"\n)\n\nfunc readLine(reader *bufio.Reader) string {\n\tline, _, err := reader.ReadLine()\n\tif err == io.EOF {\n\t\treturn \"\"\n\t}\n\treturn strings.TrimRight(string(line), \"\\r\\n\")\n}\n\nfunc checkError(err error) {\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc main() {\n\tvowels := make(map[rune]int)\n\tvar l rune\n\tfor l = 'a'; l <= 'z'; l++ {\n\t\tif l == 'a' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'e' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'i' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'o' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'u' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t}\n\n\tisBerlanese := true\n\tvar word string\n\tfmt.Scanf(\"%s\", &word)\n\n\tfor i := 0; i < len(word)-1; i++ {\n\t\tif isBerlanese == false {\n\t\t\tbreak\n\t\t}\n\t\tletter := rune(word[i])\n\t\tnextLetter := rune(word[i+1])\n\t\tif letter == 'n' {\n\t\t\tcontinue\n\t\t}\n\n\t\t_, isVowel := vowels[letter]\n\t\tif isVowel == true {\n\t\t\t_, nextIsVowel := vowels[nextLetter]\n\t\t\tif nextIsVowel == true {\n\t\t\t\tisBerlanese = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t} else {\n\t\t\t_, nextIsVowel := vowels[nextLetter]\n\t\t\tif nextIsVowel == false {\n\t\t\t\tisBerlanese = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tif isBerlanese == true {\n\t\tfmt.Printf(\"%s\\n\", \"YES\")\n\t} else {\n\t\tfmt.Printf(\"%s\\n\", \"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"strings\"\n)\n\nfunc readLine(reader *bufio.Reader) string {\n\tline, _, err := reader.ReadLine()\n\tif err == io.EOF {\n\t\treturn \"\"\n\t}\n\treturn strings.TrimRight(string(line), \"\\r\\n\")\n}\n\nfunc checkError(err error) {\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc main() {\n\tvowels := make(map[rune]int)\n\tvar l rune\n\tfor l = 'a'; l <= 'z'; l++ {\n\t\tif l == 'a' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'e' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'i' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'o' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'u' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t}\n\n\tisBerlanese := true\n\tvar word string\n\tfmt.Scanf(\"%s\", &word)\n\n\tfor i := 0; i < len(word)-1; i++ {\n\t\tif isBerlanese == false {\n\t\t\tbreak\n\t\t}\n\t\tletter := rune(word[i])\n\t\tnextLetter := rune(word[i+1])\n\t\tif letter == 'n' {\n\t\t\tcontinue\n\t\t}\n\n\t\t_, isVowel := vowels[letter]\n\t\tif isVowel == true {\n\t\t\tcontinue\n\t\t} else {\n\t\t\t_, nextIsVowel := vowels[nextLetter]\n\t\t\tif nextIsVowel == false {\n\t\t\t\tisBerlanese = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tif isBerlanese == true {\n\t\tfmt.Printf(\"%s\\n\", \"YES\")\n\t} else {\n\t\tfmt.Printf(\"%s\\n\", \"NO\")\n\t}\n}\n"}, {"source_code": "\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"strings\"\n)\n\nfunc readLine(reader *bufio.Reader) string {\n\tline, _, err := reader.ReadLine()\n\tif err == io.EOF {\n\t\treturn \"\"\n\t}\n\treturn strings.TrimRight(string(line), \"\\r\\n\")\n}\n\nfunc checkError(err error) {\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc main() {\n\tvowels := make(map[rune]int)\n\tvar l rune\n\tfor l = 'a'; l <= 'z'; l++ {\n\t\tif l == 'a' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'e' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'i' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'o' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'u' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t}\n\n\tisBerlanese := true\n\tvar word string\n\tfmt.Scanf(\"%s\", &word)\n\n\tif !(len(word) == 1) {\n\n\t\tfor i := 0; i < len(word)-1; i++ {\n\t\t\tif isBerlanese == false {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tletter := rune(word[i])\n\t\t\tnextLetter := rune(word[i+1])\n\t\t\tif letter == 'n' {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t_, isVowel := vowels[letter]\n\t\t\tif isVowel == true {\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\t_, nextIsVowel := vowels[nextLetter]\n\t\t\t\tif nextIsVowel == false {\n\t\t\t\t\tisBerlanese = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif isBerlanese == true {\n\t\tfmt.Printf(\"%s\\n\", \"YES\")\n\t} else {\n\t\tfmt.Printf(\"%s\\n\", \"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"strings\"\n)\n\nfunc readLine(reader *bufio.Reader) string {\n\tline, _, err := reader.ReadLine()\n\tif err == io.EOF {\n\t\treturn \"\"\n\t}\n\treturn strings.TrimRight(string(line), \"\\r\\n\")\n}\n\nfunc checkError(err error) {\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc main() {\n\tvowels := make(map[rune]int)\n\tvar l rune\n\tfor l = 'a'; l <= 'z'; l++ {\n\t\tif l == 'a' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'e' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'i' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'o' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'u' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t}\n\n\tisBerlanese := true\n\tvar word string\n\tfmt.Scanf(\"%s\", &word)\n\n\tfor i := 0; i < len(word)-1; i++ {\n\t\tif isBerlanese == false {\n\t\t\tbreak\n\t\t}\n\t\tletter := rune(word[i])\n\t\tnextLetter := rune(word[i+1])\n\t\tif len(word) == 1 && letter == 'n' {\n\t\t\tcontinue\n\t\t}\n\t\tif _, V := vowels[letter]; len(word) == 1 && V == true {\n\t\t\tcontinue\n\t\t}\n\t\tif len(word) == 1 {\n\t\t\tisBerlanese = false\n\t\t\tbreak\n\t\t}\n\t\tif letter == 'n' {\n\t\t\tcontinue\n\t\t}\n\n\t\t_, isVowel := vowels[letter]\n\t\tif isVowel == true {\n\t\t\tcontinue\n\t\t} else {\n\t\t\t_, nextIsVowel := vowels[nextLetter]\n\t\t\tif nextIsVowel == false {\n\t\t\t\tisBerlanese = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tif isBerlanese == true {\n\t\tfmt.Printf(\"%s\\n\", \"YES\")\n\t} else {\n\t\tfmt.Printf(\"%s\\n\", \"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"strings\"\n)\n\nfunc readLine(reader *bufio.Reader) string {\n\tline, _, err := reader.ReadLine()\n\tif err == io.EOF {\n\t\treturn \"\"\n\t}\n\treturn strings.TrimRight(string(line), \"\\r\\n\")\n}\n\nfunc checkError(err error) {\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc main() {\n\tvowels := make(map[rune]int)\n\tvar l rune\n\tfor l = 'a'; l <= 'z'; l++ {\n\t\tif l == 'a' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'e' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'i' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'o' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t\tif l == 'u' {\n\t\t\tvowels[l] = -1\n\t\t}\n\t}\n\n\tisBerlanese := true\n\tvar word string\n\tfmt.Scanf(\"%s\", &word)\n\n\tif len(word) > 1 {\n\t\tfor i := 0; i < len(word)-1; i++ {\n\t\t\tif isBerlanese == false {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tletter := rune(word[i])\n\t\t\tnextLetter := rune(word[i+1])\n\t\t\tif letter == 'n' {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t_, isVowel := vowels[letter]\n\t\t\tif isVowel == true {\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\t_, nextIsVowel := vowels[nextLetter]\n\t\t\t\tif nextIsVowel == false {\n\t\t\t\t\tisBerlanese = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tletter := rune(word[0])\n\t\tif letter == 'n' {\n\t\t\tisBerlanese = true\n\t\t} else if _, V := vowels[letter]; V == true {\n\t\t\tisBerlanese = true\n\t\t} else {\n\t\t\tisBerlanese = false\n\t\t}\n\t}\n\tif isBerlanese == true {\n\t\tfmt.Printf(\"%s\\n\", \"YES\")\n\t} else {\n\t\tfmt.Printf(\"%s\\n\", \"NO\")\n\t}\n}\n"}, {"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\n\tS := sc.NextLine()\n\n\tflag := false\n\tfor i := 0; i < len(S); i++ {\n\t\tswitch S[i] {\n\t\tcase 'a', 'i', 'u', 'e', 'o', 'n':\n\t\t\tflag = false\n\t\tdefault:\n\t\t\tif flag {\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tflag = true\n\t\t}\n\t}\n\tif flag {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tfmt.Println(\"YES\")\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n"}, {"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\n\tS := sc.NextLine()\n\n\tflag := false\n\tfor i := 0; i < len(S); i++ {\n\t\tswitch S[i] {\n\t\tcase 'a', 'i', 'u', 'e', 'o':\n\t\t\tflag = false\n\t\tcase 'n':\n\t\tdefault:\n\t\t\tif flag {\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tflag = true\n\t\t}\n\t}\n\tif flag {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tfmt.Println(\"YES\")\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\t\nfunc main() {\n var s string\n\tfmt.Scan(&s)\n\tt := true\n\tflag := false\n\tfor i,a := range(s){\n\t f := true\n\t if a != 'n' {\n \t for _,b := range([]rune{'a','o','u','i','e'}) {\n \t if a == b { f = false }\n \t }\n\t \n\t if flag && f {\n\t t = false\n\t break\n\t }\n\t if flag && !f {\n\t flag = false \n\t }\n\t if !flag && f {\n\t flag = true\n\t }\n\t if f && i == len(s)-1 {\n\t t = false\n\t break\n\t }\n\t }\n\t}\n\tif t {\n\t fmt.Println(\"YES\")\n\t} else {\n\t fmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\t\nfunc main() {\n var s string\n\tfmt.Scan(&s)\n\tt := true\n\tflag := false\n\tfor i,a := range(s){\n\t f := true\n\t for _,b := range([]rune{'a','o','u','i','e'}) {\n \t if a == b { f = false }\n \t}\n\t if flag && f {\n\t t = false\n\t break\n\t } else if flag && !f {\n\t flag = false \n\t } else if !flag && f && a != 'n'{\n\t flag = true\n\t } else if f && i == len(s)-1 && a != 'n' {\n\t t = false\n\t break\n\t }\n\t \n\t}\n\tif t {\n\t fmt.Println(\"YES\")\n\t} else {\n\t fmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\t\nfunc main() {\n var s string\n\tfmt.Scan(&s)\n\tt := true\n\tflag := false\n\tfor i,a := range(s){\n\t f := true\n\t for _,b := range([]rune{'a','o','u','i','e'}) {\n \t if a == b { f = false }\n \t}\n\t if flag && f && a!='n' {\n\t t = false\n\t break\n\t } else if flag && !f {\n\t flag = false \n\t } else if !flag && f && a != 'n'{\n\t flag = true\n\t } else if f && i == len(s)-1 && a != 'n' {\n\t t = false\n\t break\n\t }\n\t \n\t}\n\tif t {\n\t fmt.Println(\"YES\")\n\t} else {\n\t fmt.Println(\"NO\")\n\t}\n}"}], "src_uid": "a83144ba7d4906b7692456f27b0ef7d4"} {"nl": {"description": "Overlooking the captivating blend of myriads of vernal hues, Arkady the painter lays out a long, long canvas.Arkady has a sufficiently large amount of paint of three colours: cyan, magenta, and yellow. On the one-dimensional canvas split into n consecutive segments, each segment needs to be painted in one of the colours.Arkady has already painted some (possibly none or all) segments and passes the paintbrush to you. You are to determine whether there are at least two ways of colouring all the unpainted segments so that no two adjacent segments are of the same colour. Two ways are considered different if and only if a segment is painted in different colours in them.", "input_spec": "The first line contains a single positive integer n (1 ≤ n ≤ 100) — the length of the canvas. The second line contains a string s of n characters, the i-th of which is either 'C' (denoting a segment painted in cyan), 'M' (denoting one painted in magenta), 'Y' (one painted in yellow), or '?' (an unpainted one).", "output_spec": "If there are at least two different ways of painting, output \"Yes\"; otherwise output \"No\" (both without quotes). You can print each character in any case (upper or lower).", "sample_inputs": ["5\nCY??Y", "5\nC?C?Y", "5\n?CYC?", "5\nC??MM", "3\nMMY"], "sample_outputs": ["Yes", "Yes", "Yes", "No", "No"], "notes": "NoteFor the first example, there are exactly two different ways of colouring: CYCMY and CYMCY.For the second example, there are also exactly two different ways of colouring: CMCMY and CYCMY.For the third example, there are four ways of colouring: MCYCM, MCYCY, YCYCM, and YCYCY.For the fourth example, no matter how the unpainted segments are coloured, the existing magenta segments will prevent the painting from satisfying the requirements. The similar is true for the fifth example."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar cs map[int]int = make(map[int]int)\n\nfunc Init() {}\nfunc Solve(io *FastIO) {\n\tn := io.NextInt()\n\ts := io.NextString()\n\tif n == 1 {\n\t\tif s[0] == '?' {\n\t\t\tio.Println(\"Yes\")\n\t\t} else {\n\t\t\tio.Println(\"No\")\n\t\t}\n\t\treturn\n\t}\n\ts += string(s[n-2])\n\tl := s[1]\n\to := false\n\tvar j byte\n\tfor i := 0; i < n; i++ {\n\t\tj = s[i]\n\t\tif j != '?' {\n\t\t\tif l == j {\n\t\t\t\to = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t} else {\n\t\t\tif s[i+1] == '?' || s[i+1] == l {\n\t\t\t\to = true\n\t\t\t}\n\t\t}\n\t\tl = j\n\t}\n\tif o {\n\t\tio.Println(\"Yes\")\n\t} else {\n\t\tio.Println(\"No\")\n\t}\n}\n\ntype FastIO struct {\n\t//by megaspazz\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\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 res * sgn\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 = int64(-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 res * sgn\n}\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\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() + 1\n\t}\n\treturn arr\n}\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\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}\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}\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}\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\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}\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\n', '\\r':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tInit()\n\tSolve(&io)\n\tio.FlushOutput()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc solve() bool {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tscanner.Scan()\n\tmaj := scanner.Text()\n\tfor i := 0; i < len(maj)-1; i++ {\n\t\tif maj[i] == maj[i+1] && maj[i] != '?' {\n\t\t\treturn false\n\t\t}\n\t}\n\t// A?A -> Yes\n\t// A?B -> No\n\tfor i := range maj {\n\t\tif maj[i] == '?' {\n\t\t\tif i == 0 || i == len(maj)-1 {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif maj[i-1] == '?' || maj[i+1] == '?' {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif maj[i-1] == maj[i+1] {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\nfunc main() {\n\tif solve() {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n int\n\tvar s string\n\tfmt.Scanf(\"%d\\n\", &n)\n\tfmt.Scanf(\"%s\\n\", &s)\n\tfor i:=1;i0||strings.Count(s,\"CC\")>0||strings.Count(s,\"YY\")>0{\n\t\tfmt.Println(\"No\")\n\t\treturn\n\t}\n\tif s[0]=='?'||s[n-1]=='?'||strings.Count(s,\"??\")>0||strings.Count(s,\"M?M\")>0||strings.Count(s,\"C?C\")>0||strings.Count(s,\"Y?Y\")>0{\n\t\tfmt.Println(\"Yes\")\n\t\treturn\n\t}\n\tfmt.Println(\"No\")\n}"}, {"source_code": "package main\nimport \"fmt\"\nfunc main(){\n\tvar(\n\t\tn int\n\t\ts string\n\t)\n\tfmt.Scan(&n,&s)\n\tfor i:=0;i 1 {\n\t\tio.Println(\"Yes\")\n\t} else {\n\t\tio.Println(\"No\")\n\t}\n}\nfunc check(sti int, l rune, s string) int {\n\tc := 0\n\tchs := \"CMY\"\n\ts = s[sti:]\n\t//fmt.Println(l, s)\n\tfor i, j := range s {\n\t\tif j != '?' {\n\t\t\tif j == l {\n\t\t\t\treturn 0\n\t\t\t} else {\n\t\t\t\tl = j\n\t\t\t}\n\t\t} else if i+1 < len(s) {\n\t\t\tfor _, k := range chs {\n\t\t\t\tif k != l {\n\t\t\t\t\tc += check(i+1, k, s)\n\t\t\t\t}\n\t\t\t\tif c > 1 {\n\t\t\t\t\treturn c\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn 1\n}\n\ntype FastIO struct {\n\t//by megaspazz\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\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 res * sgn\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 = int64(-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 res * sgn\n}\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\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() + 1\n\t}\n\treturn arr\n}\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\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}\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}\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}\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\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}\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\n', '\\r':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tInit()\n\tSolve(&io)\n\tio.FlushOutput()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar cs map[int]int = make(map[int]int)\n\nfunc Init() {}\nfunc Solve(io *FastIO) {\n\tn := io.NextInt()\n\ts := io.NextString()\n\tif n == 1 {\n\t\tio.Println(\"Yes\")\n\t\treturn\n\t}\n\ts += string(s[n-2])\n\tl := s[1]\n\to := false\n\tvar j byte\n\tfor i := 0; i < n; i++ {\n\t\tj = s[i]\n\t\tif j != '?' {\n\t\t\tif l == j {\n\t\t\t\to = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t} else {\n\t\t\tif s[i+1] == '?' || s[i+1] == l {\n\t\t\t\to = true\n\t\t\t}\n\t\t}\n\t\tl = j\n\t}\n\tif o {\n\t\tio.Println(\"Yes\")\n\t} else {\n\t\tio.Println(\"No\")\n\t}\n}\n\ntype FastIO struct {\n\t//by megaspazz\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\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 res * sgn\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 = int64(-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 res * sgn\n}\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\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() + 1\n\t}\n\treturn arr\n}\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\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}\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}\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}\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\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}\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\n', '\\r':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tInit()\n\tSolve(&io)\n\tio.FlushOutput()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar cs map[int]int = make(map[int]int)\n\nfunc Init() {}\nfunc Solve(io *FastIO) {\n\tn := io.NextInt()\n\ts := io.NextString() + \"K\"\n\tl := byte('K')\n\to := false\n\tvar j byte\n\tfor i := 0; i < n; i++ {\n\t\tj = s[i]\n\t\tif j != '?' {\n\t\t\tif l == j {\n\t\t\t\to = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t} else {\n\t\t\tif s[i+1] == '?' || s[i+1] == l {\n\t\t\t\to = true\n\t\t\t}\n\t\t}\n\t\tl = j\n\t}\n\tif o {\n\t\tio.Println(\"Yes\")\n\t} else {\n\t\tio.Println(\"No\")\n\t}\n}\n\ntype FastIO struct {\n\t//by megaspazz\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\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 res * sgn\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 = int64(-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 res * sgn\n}\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\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() + 1\n\t}\n\treturn arr\n}\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\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}\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}\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}\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\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}\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\n', '\\r':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tInit()\n\tSolve(&io)\n\tio.FlushOutput()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc solve() bool {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tscanner.Scan()\n\tmaj := scanner.Text()\n\tfor i := 0; i < len(maj)-1; i++ {\n\t\tif maj[i] == maj[i+1] && maj[i] != '?' {\n\t\t\tfmt.Println(\"FIRST\")\n\t\t\treturn false\n\t\t}\n\t}\n\t// A?A -> Yes\n\t// A?B -> No\n\tfor i := range maj {\n\t\tif maj[i] == '?' {\n\t\t\tif i == 0 || i == len(maj)-1 {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif maj[i-1] == '?' || maj[i+1] == '?' {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif maj[i-1] == maj[i+1] {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\nfunc main() {\n\tif solve() {\n\t\tfmt.Println(\"Yes\")\n\t} else {\n\t\tfmt.Println(\"No\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n int\n\tvar s string\n\tfmt.Scanf(\"%d\\n\", &n)\n\tfmt.Scanf(\"%s\\n\", &s)\n\tfor i:=1;i mmm {\n mmm = len(q)\n }\n }\n\n O(mmm, false)\n\n num := 0\n for i := range ss {\n sss := strings.Split(ss[i], \"_\")\n for j := range sss {\n r := regexp.MustCompile(`[_\\(\\)]`)\n sss[j] = r.ReplaceAllString(sss[j], \"\")\n if len(sss[j]) > 0 {\n num++\n }\n }\n }\n O(num, true)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"bufio\"\nimport \"os\"\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\nfunc main() {\n\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\n\tvar n int\n\tvar s string\n\tfmt.Fscanf(bufin, \"%d\\n\", &n)\n\tfmt.Fscanf(bufin, \"%s\\n\", &s)\n\n\tinside := false\n\tl := 0\n\n\tlongestOutside := 0\n\tcountInside := 0\n\n\ts = \"_\" + s + \"_\"\n\tn = len(s)\n\n\tfor i := 0; i < n; i++ {\n\t\tc := s[i]\n\t\tif (c == '_') || (c == '(') || (c == ')') {\n\t\t\tif l > 0 {\n\t\t\t\tif inside {\n\t\t\t\t\tcountInside++\n\t\t\t\t} else {\n\t\t\t\t\tif longestOutside < l {\n\t\t\t\t\t\tlongestOutside = l\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tl = 0\n\t\t\t}\n\t\t} else {\n\t\t\tl++\n\t\t}\n\t\tif c == '(' {\n\t\t\tinside = true\n\t\t} else if c == ')' {\n\t\t\tinside = false\n\t\t}\n\t}\n\n\tfmt.Fprintf(bufout, \"%d %d\\n\", longestOutside, countInside)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t// \"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar (\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\t_ = nextInt()\n\ts := next()\n\tvar outsideWords []string\n\n\tfor i := strings.Index(s, \"(\"); i >= 0; i = strings.Index(s, \"(\") {\n\t\tj := strings.Index(s, \")\")\n\t\toutsideWords = append(outsideWords, splitWords(s[i+1:j], '_')...)\n\t\ts = s[:i] + \"_\" + s[j+1:]\n\t}\n\n\tprintln(maxLength(splitWords(s, '_')), len(outsideWords))\n\n}\n\nfunc splitWords(s string, c rune) []string {\n\treturn strings.FieldsFunc(s, func(c rune) bool { return c == '_' })\n}\n\nfunc maxLength(s []string) int {\n\tl := 0\n\n\tfor i := range s {\n\t\tif len(s[i]) > l {\n\t\t\tl = len(s[i])\n\t\t}\n\t}\n\n\treturn l\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc max(a, b int) int {\n\tif a > b {return a}\n\treturn b\n}\n\nfunc main() {\n\tvar (\n\t\tn int\n\t\tstr string\n\t)\n\t\n\tfmt.Scanln(&n)\n\tfmt.Scanln(&str)\n\t\n\ti := 0;\n\ts_words := 0\n\ts_len := 0\n\tw_len := 0\n\tw_max := 0\n\tfor i < n {\n\t\tif str[i] == '(' {\n\t\t\ti++\n\t\t\t\n\t\t\tfor i < n && str[i] != ')' {\n\t\t\t\tif str[i] != '_' {\n\t\t\t\t\ts_len++\n\t\t\t\t} else {\n\t\t\t\t\tif s_len > 0 {\n\t\t\t\t\t\ts_words++\n\t\t\t\t\t}\n\t\t\t\t\ts_len = 0\n\t\t\t\t}\n\t\t\t\ti++\n\n\t\t\t}\n\t\t\ti++\n\t\t\tif s_len > 0 {\n\t\t\t\ts_words++\n\t\t\t}\n\t\t\ts_len = 0\n\t\t\tcontinue\n\t\t}\n\t\t\t\n\t\t\n\t\tfor i < n && str[i] != '(' {\n\t\t\t\tif str[i] != '_' {\n\t\t\t\t\tw_len++\n\t\t\t\t} else {\n\t\t\t\t\tif w_len > 0 {\n\t\t\t\t\t\tw_max = max(w_max, w_len)\n\t\t\t\t\t}\n\t\t\t\t\tw_len = 0\n\t\t\t\t}\n\t\t\t\ti++\n\t\t\t}\n\n\t\tif w_len > 0 {\n\t\t\tw_max = max(w_max, w_len)\n\t\t}\n\t\tw_len = 0\n\t}\n\n\t\n\t\n\tfmt.Println(w_max, s_words)\n}\n\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar n int\n\tif _, err := fmt.Scanf(\"%d\\n\", &n); err != nil {\n\t\treturn\n\t}\n\n\tvar longest int = 0\n\tvar words_inside int = 0\n\n\treader := bufio.NewReader(os.Stdin)\n\tif s, err := reader.ReadString('\\n'); err != nil {\n\t\tif err != io.EOF {\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tinside := false\n\t\tword_length := 0\n\t\tfor i := 0; i < n; i++ {\n\t\t\tif (s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z') {\n\t\t\t\tword_length++\n\t\t\t} else {\n\t\t\t\tif !inside && word_length > longest {\n\t\t\t\t\tlongest = word_length\n\t\t\t\t}\n\t\t\t\tif inside && word_length > 0 {\n\t\t\t\t\twords_inside++\n\t\t\t\t}\n\t\t\t\tif s[i] == '(' {\n\t\t\t\t\tinside = true\n\t\t\t\t} else if s[i] == ')' {\n\t\t\t\t\tinside = false\n\t\t\t\t}\n\t\t\t\tword_length = 0\n\t\t\t}\n\t\t}\n\t\tif word_length > longest {\n\t\t\tlongest = word_length\n\t\t}\n\t}\n\n\tfmt.Printf(\"%d %d\\n\", longest, words_inside)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nvar bufin *bufio.Reader\nvar bufout *bufio.Writer\n\ntype res struct {\n\tind int\n\twrd string\n}\n\nfunc inside_parthesis(S string, x *res) bool {\n\tl, r := false, false\n\tfor i := x.ind; i >= 0; i-- {\n\t\tif S[i] == '(' {\n\t\t\tl = true\n\t\t\tbreak\n\t\t} else if S[i] == ')' {\n\t\t\tbreak\n\t\t}\n\t}\n\tfor i := x.ind; i < len(S); i++ {\n\t\tif S[i] == ')' {\n\t\t\tr = true\n\t\t\tbreak\n\t\t} else if S[i] == '(' {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn l && r\n}\nfunc mysplit(S string) []res {\n\tvar cur string\n\tvar start int\n\tvar ret []res\n\n\tfor i, c := range S {\n\t\tif c != '_' && c != '(' && c != ')' {\n\t\t\tif cur == \"\" {\n\t\t\t\tstart = i\n\t\t\t}\n\t\t\tcur += string(c)\n\t\t} else if cur != \"\" {\n\t\t\tret = append(ret, res{start, cur})\n\t\t\tcur = \"\"\n\t\t}\n\t}\n\tif cur != \"\" {\n\t\tret = append(ret, res{start, cur})\n\t}\n\treturn ret\n}\n\nfunc main() {\n\tbufin = bufio.NewReader(os.Stdin)\n\tbufout = bufio.NewWriter(os.Stdout)\n\tdefer bufout.Flush()\n\tvar N int\n\tfmt.Fscanf(bufin, \"%d\\n\", &N)\n\tvar S string\n\tfmt.Fscanf(bufin, \"%s\\n\", &S)\n\twords := mysplit(S)\n\tcnt := 0\n\tmaxlen := 0\n\tfor _, x := range words {\n\t\tif inside_parthesis(S, &x) {\n\t\t\tcnt += 1\n\t\t} else {\n\t\t\tif maxlen < len(x.wrd) {\n\t\t\t\tmaxlen = len(x.wrd)\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Fprintf(bufout, \"%d %d\\n\", maxlen, cnt)\n\n}\n"}, {"source_code": "package main;\n\nimport (\"fmt\"; \"bufio\"; \"os\"; \"strings\")\n\n\nfunc mysplit(line string) []string {\n from := 0\n output := make([]string, 0, 10)\n for i, c := range line {\n if c=='(' || c==')' {\n output = append(output, line[from:i])\n from = i+1\n }\n }\n if from longestOutside {\n longestOutside = len(w)\n }\n }\n\n inParenthesis := 0\n for _, w := range inside {\n if len(w) > 0 {\n inParenthesis++\n }\n }\n\n fmt.Println(longestOutside, inParenthesis)\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tfsc := NewFastScanner()\n\tn := fsc.NextInt()\n\ttext := fsc.Next()\n\tvar flag, maxLength, inLength, outLength, count int\n\tfor i := 0; i <= n; i++ {\n\t\tif i == n {\n\t\t\tif maxLength < outLength {\n\t\t\t\tmaxLength = outLength\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tif text[i] == '(' {\n\t\t\tif maxLength < outLength {\n\t\t\t\tmaxLength = outLength\n\t\t\t}\n\t\t\toutLength = 0\n\t\t\tflag = 1\n\t\t} else if text[i] == ')' {\n\t\t\tif inLength != 0 {\n\t\t\t\tcount++\n\t\t\t}\n\t\t\tinLength = 0\n\t\t\tflag = 0\n\t\t} else if text[i] == '_' {\n\t\t\tif inLength != 0 {\n\t\t\t\tcount++\n\t\t\t}\n\t\t\tinLength = 0\n\t\t\tif outLength != 0 {\n\t\t\t\tif maxLength < outLength {\n\t\t\t\t\tmaxLength = outLength\n\t\t\t\t}\n\t\t\t}\n\t\t\toutLength = 0\n\t\t} else if flag == 0 {\n\t\t\toutLength++\n\t\t} else if flag == 1 {\n\t\t\tinLength++\n\t\t}\n\t}\n\n\tfmt.Println(maxLength, count)\n}\n\n//template\ntype FastScanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewFastScanner() *FastScanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 2028)\n\treturn &FastScanner{r: rdr}\n}\n\nfunc (s *FastScanner) Next() string {\n\ts.Pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\n\nfunc (s *FastScanner) NextInt() int {\n\tval, err := strconv.Atoi(s.Next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn val\n}\nfunc (s *FastScanner) NextInt64() int64 {\n\tval, err := strconv.ParseInt(s.Next(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn val\n}\nfunc (s *FastScanner) Pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.ReadLine()\n\t\ts.p = 0\n\t}\n}\n\nfunc (s *FastScanner) ReadLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, err := s.r.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err.Error())\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\ntype TupleInt struct {\n\tfirst int\n\tsecond int\n\tthird int\n}\n\nfunc main() {\n\tin := NewScanner()\n\t_ = in.NextInt()\n\tS := in.NextLine()\n\tinside := false\n\tmx := 0\n\tcount := 0\n\tcomma := false\n\tln := 0\n\tfor _, s := range S {\n\t\tif s == '(' {\n\t\t\tinside = true\n\t\t\tcomma = true\n\t\t} else if s == ')' {\n\t\t\tinside = false\n\t\t\tcomma = true\n\n\t\t} else if s == '_' {\n\t\t\tcomma = true\n\t\t} else {\n\t\t\tif !inside {\n\t\t\t\tln++\n\t\t\t\tmx = max(mx, ln)\n\t\t\t}\n\n\t\t\tif comma {\n\t\t\t\tif inside {\n\t\t\t\t\tcount++\n\t\t\t\t}\n\t\t\t\tcomma = false\n\t\t\t}\n\t\t}\n\t\tif comma {\n\t\t\tln = 0\n\t\t}\n\n\t}\n\tfmt.Println(mx, count)\n}\nfunc max(a int, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r:rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\n\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\n\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tresult = append(result, v)\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\tresult = append(result, v)\n\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t// \"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar (\n\twriter = bufio.NewWriter(os.Stdout)\n\tscanner = bufio.NewScanner(os.Stdin)\n)\n\nfunc main() {\n\tdefer writer.Flush()\n\tscanner.Split(bufio.ScanWords)\n\n\t_ = nextInt()\n\ts := next()\n\tvar outsideWords []string\n\n\tfor i := strings.Index(s, \"(\"); i >= 0; i = strings.Index(s, \"(\") {\n\t\tj := strings.Index(s, \")\")\n\t\toutsideWords = append(outsideWords, splitWords(s[i+1:j], '_')...)\n\t\ts = s[:i] + s[j+1:]\n\t}\n\n\tprintln(maxLength(splitWords(s, '_')), len(outsideWords))\n\n}\n\nfunc splitWords(s string, c rune) []string {\n\treturn strings.FieldsFunc(s, func(c rune) bool { return c == '_' })\n}\n\nfunc maxLength(s []string) int {\n\tl := 0\n\n\tfor i := range s {\n\t\tif len(s[i]) > l {\n\t\t\tl = len(s[i])\n\t\t}\n\t}\n\n\treturn l\n}\n\nfunc next() string {\n\tif !scanner.Scan() {\n\t\tpanic(scanner.Err())\n\t}\n\treturn scanner.Text()\n}\n\nfunc nextInt64() int64 {\n\tn, _ := strconv.ParseInt(next(), 0, 64)\n\treturn n\n}\n\nfunc nextInt() int {\n\tn, _ := strconv.Atoi(next())\n\treturn n\n}\n\nfunc nextFloat() float64 {\n\tn, _ := strconv.ParseFloat(next(), 64)\n\treturn n\n}\n\nfunc println(a ...interface{}) { fmt.Fprintln(writer, a...) }\nfunc print(a ...interface{}) { fmt.Fprint(writer, a...) }\nfunc printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }\n"}, {"source_code": "package main;\n\nimport (\"fmt\"; \"bufio\"; \"os\"; \"strings\")\n\n\nfunc groups(line string) ([]string, []string) {\n outside, inside := make([]string, 0, 10), make([]string, 0, 10)\n parts := strings.FieldsFunc(line, func(c rune) bool {\n return c=='(' || c==')'\n })\n out := line[0]!='('\n for _, p := range parts {\n if out { \n outside = append(outside, strings.Split(p, \"_\") ...)\n } else {\n inside = append(inside, strings.Split(p, \"_\") ...)\n }\n out = !out\n }\n\n return outside, inside\n\n}\n\n\nfunc main() {\n inp := bufio.NewReader(os.Stdin)\n scanner := bufio.NewScanner(inp)\n\n scanner.Scan() // number\n scanner.Scan()\n outside, inside := groups(scanner.Text())\n\n fmt.Fprintf(os.Stderr, \"%v - %v \\n\", outside, inside)\n\n longestOutside := 0\n for _, w := range outside {\n if len(w) > longestOutside {\n longestOutside = len(w)\n }\n }\n\n inParenthesis := 0\n for _, w := range inside {\n if len(w) > 0 {\n inParenthesis++\n }\n }\n\n fmt.Println(longestOutside, inParenthesis)\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tfsc := NewFastScanner()\n\tn := fsc.NextInt()\n\ttext := fsc.Next()\n\tvar flag, maxLength, inLength, outLength, count int\n\tfor i := 0; i < n; i++ {\n\t\tif text[i] == '(' {\n\t\t\tif maxLength < outLength {\n\t\t\t\tmaxLength = outLength\n\t\t\t}\n\t\t\toutLength = 0\n\t\t\tflag = 1\n\t\t} else if text[i] == ')' {\n\t\t\tif inLength != 0 {\n\t\t\t\tcount++\n\t\t\t}\n\t\t\tinLength = 0\n\t\t\tflag = 0\n\t\t} else if text[i] == '_' {\n\t\t\tif inLength != 0 {\n\t\t\t\tcount++\n\t\t\t}\n\t\t\tinLength = 0\n\t\t\tif outLength != 0 {\n\t\t\t\tif maxLength < outLength {\n\t\t\t\t\tmaxLength = outLength\n\t\t\t\t}\n\t\t\t}\n\t\t\toutLength = 0\n\t\t} else if flag == 0 {\n\t\t\toutLength++\n\t\t} else if flag == 1 {\n\t\t\tinLength++\n\t\t}\n\t}\n\n\tfmt.Println(maxLength, count)\n}\n\n//template\ntype FastScanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewFastScanner() *FastScanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 2028)\n\treturn &FastScanner{r: rdr}\n}\n\nfunc (s *FastScanner) Next() string {\n\ts.Pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\n\nfunc (s *FastScanner) NextInt() int {\n\tval, err := strconv.Atoi(s.Next())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn val\n}\nfunc (s *FastScanner) NextInt64() int64 {\n\tval, err := strconv.ParseInt(s.Next(), 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn val\n}\nfunc (s *FastScanner) Pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.ReadLine()\n\t\ts.p = 0\n\t}\n}\n\nfunc (s *FastScanner) ReadLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, err := s.r.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err.Error())\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\ntype TupleInt struct {\n\tfirst int\n\tsecond int\n\tthird int\n}\n\nfunc main() {\n\tin := NewScanner()\n\t_ = in.NextInt()\n\tS := in.NextLine()\n\tinside := false\n\tlast := 0\n\tmx := 0\n\tcount := 0\n\tcomma := false\n\n\tfor i, s := range S {\n\t\tif s == '(' {\n\t\t\tinside = true\n\t\t\tcomma = true\n\t\t} else if s == ')' {\n\t\t\tinside = false\n\t\t\tcomma = true\n\t\t\tlast = i + 1\n\n\t\t} else if s == '_' {\n\t\t\tcomma = true\n\t\t} else {\n\t\t\tif comma {\n\t\t\t\tif inside {\n\t\t\t\t\tcount++\n\t\t\t\t}\n\t\t\t\tcomma = false\n\t\t\t}\n\t\t}\n\t\tif comma {\n\t\t\tif !inside {\n\t\t\t\tmx = max(mx, i - last)\n\t\t\t}\n\t\t\tlast = i + 1\n\t\t}\n\n\t}\n\tfmt.Println(mx, count)\n}\nfunc max(a int, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r:rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\n\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\n\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tresult = append(result, v)\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\tresult = append(result, v)\n\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n"}], "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92"} {"nl": {"description": "Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he gets 11311 (475 = 1·162 + 13·161 + 11·160). Alexander lived calmly until he tried to convert the number back to the decimal number system.Alexander remembers that he worked with little numbers so he asks to find the minimum decimal number so that by converting it to the system with the base n he will get the number k.", "input_spec": "The first line contains the integer n (2 ≤ n ≤ 109). The second line contains the integer k (0 ≤ k < 1060), it is guaranteed that the number k contains no more than 60 symbols. All digits in the second line are strictly less than n. Alexander guarantees that the answer exists and does not exceed 1018. The number k doesn't contain leading zeros.", "output_spec": "Print the number x (0 ≤ x ≤ 1018) — the answer to the problem.", "sample_inputs": ["13\n12", "16\n11311", "20\n999", "17\n2016"], "sample_outputs": ["12", "475", "3789", "594"], "notes": "NoteIn the first example 12 could be obtained by converting two numbers to the system with base 13: 12 = 12·130 or 15 = 1·131 + 2·130."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt64()\n\tk := readString()\n\tvalues := make([]int, 0)\n\tfor len(k) > 0 {\n\t\tvar maxValue int\n\t\tvar maxIndex int\n\t\tfor i := len(k) - 1; i >= 0; i-- {\n\t\t\tvalue, err := strconv.ParseInt(k[i:], 10, 64)\n\t\t\tif err == nil {\n\t\t\t\tif value < n {\n\t\t\t\t\tmaxValue = int(value)\n\t\t\t\t\tmaxIndex = i\n\t\t\t\t} else {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif maxIndex+1 < len(k) {\n\t\t\tif maxValue != 0 {\n\t\t\t\tfor maxIndex < len(k) && k[maxIndex] == '0' {\n\t\t\t\t\tmaxIndex++\n\t\t\t\t}\n\t\t\t} else if maxValue == 0 {\n\t\t\t\tmaxIndex = len(k) - 1\n\t\t\t}\n\t\t}\n\t\tk = k[:maxIndex]\n\t\tvalues = append(values, maxValue)\n\t}\n\tvar res int64\n\tfor i := len(values) - 1; i >= 0; i-- {\n\t\tres *= n\n\t\tres += int64(values[i])\n\t}\n\tfmt.Println(res)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"sort\"\n)\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\nfunc find_last_le_idx(a []int, target int )int {\n\t//if not exist rturn -1\n\n\ts := 0\n\te := len(a)\n\tfor ;s < e;{\n\t\tmid := s +(e- s)/2\n\t\tif a[mid ] <= target{\n\t\t\ts = mid + 1\n\t\t}else {\n\t\t\te = mid\n\t\t}\n\t}\n\treturn s - 1\n}\n\n\nfunc find_first_ge_idx(a []int, target int )int {\n\t//if not exist rturn -1\n\n\ts := 0\n\te := len(a)\n\tfor ;s < e;{\n\t\tmid := s +(e- s)/2\n\t\tif a[mid ] < target{\n\t\t\ts = mid + 1\n\t\t}else {\n\t\t\te = mid\n\t\t}\n\t}\n\n\treturn s\n}\n\nfunc maxSumSubmatrix(a [][]int, target int) int {\n\trow := len(a)\n\tif row == 0{\n\t\treturn 0\n\t}\n\tcol := len(a[0])\n\n\tpre_sum := make([][]int, row)\n\tfor i := range pre_sum{\n\t\tpre_sum[i] = make([]int ,col)\n\t}\n\n\tfor i := 0;i < row; i ++{\n\t\tfor j :=0;j < col; j ++{\n\t\t\tif j == 0 {\n\t\t\t\tpre_sum[i][j] = a[i][j]\n\t\t\t}else {\n\t\t\t\tpre_sum[i][j] = pre_sum[i][j-1] + a[i][j]\n\t\t\t}\n\t\t}\n\t}\n\n\tnear := -100000000\n\tfor i := 0; i < col ; i ++{\n\t\tfor j :=i ;j near) {\n\t\t\t\t//\t\tnear = cur\n\t\t\t\t//\t}\n\t\t\t\t//\ttmp = append(tmp, cur)\n\t\t\t\t//}\n\t\t\t}\n\n\t\t}\n\t}\n\treturn near\n}\n\nfunc q(matrix [][]int, k int) int {\n\trow := len(matrix)\n\tcol := len(matrix[0])\n\tnear := -1000000\n\tfor left := 0; left < col ; left ++{\n\t// 以left为左边界,每行的总和\n\t\t_sum :=make([]int, row)\n\t//for right in range(left, col):\n\t\tfor right :=left ;right 1 {\n\t\t\tif idx - left +1 < min_l{\n\t\t\t\tmin_l = idx - left + 1\n\t\t\t\tm_l = left\n\t\t\t\tm_r = idx\n\t\t\t}\n\t\t\tcounter[record[left]] --\n\n\t\t\t//}else {\n\t\t\t//\n\t\t\t//}\n\t\t\tif counter[record[left]] == 0 {\n\t\t\t\ttarget --\n\t\t\t}\n\t\t\tleft ++\n\t\t}else{\n\t\t\t\tidx ++\n\t\t\tcounter[record[idx]] ++\n\t\t\tif counter[record[idx]] == 1{\n\t\t\t\ttarget ++\n\t\t\t}\n\t\t\t//idx++\n\t\t}\n\t}\n\tfmt.Println(m_l + 1, m_r + 1)\n}\n\nfunc ini(){\n\tvar n int\n\t//var k int\n\tfmt.Scan(&n)\n\t//fmt.Scan(&k)\n\tfor i := 0;i < n; i ++{\n\t\tfmt.Scan(&ori[i])\n\t\tfmt.Scan(&energy[i])\n\t}\n\tR := -1\n\tL := 0\n\tfor i :=0; i < n; i ++{\n\t\t//if record[L] == i - k{\n\t\t//\tL ++\n\t\t//}\n\t\tfor ;R >= L &&ori[i] >ori[record[R]];R--{\n\t\t\tcounter[i]\t+= energy[record[R]]\n\t\t}\n\t\ttmp := energy[i]\n\t\tfor ;R >= L &&ori[i] ==ori[record[R]];R--{\n\t\t\ttmp += energy[i]\n\t\t}\n\t\tR ++\n\t\trecord[R] = i\n\t\tif R != 0 {\n\t\t\tcounter[record[R - 1]] += tmp\n\t\t}\n\t}\n\tm := -1\n\tfor i :=0; i m{\n\t\t\tm = counter[i]\n\t\t}\n\t}\n\tfmt.Println(m)\n}\ntype S struct {\n\tIdx int\n\tTime int\n\n}\ntype intSlice []S\n\nfunc (p intSlice) Len() int { return len(p) }\nfunc (p intSlice) Less(i, j int) bool { return p[i].Time > p[j].Time }\nfunc (p intSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }\n\nvar roww [1000]int\nvar coll [1000]int\nfunc inii(){\n\tvar m,n,k,l,d int\n\t//var k int\n\trow := make(intSlice, 10000)\n\tcol := make(intSlice, 10000)\n\tfmt.Scan(&m, &n, &k, &l,&d)\n\t//fmt.Scan(&k)\n\tfor i := 0;i < d; i ++{\n\t\tvar x1,y1,x2,y2 int\n\t\tfmt.Scan(&x1,&y1,&x2,&y2)\n\t\tif x1 == x2 {\n\t\t\tif y1 > y2 {\n\t\t\t\ty1,y2 = y2,y1\n\t\t\t}\n\t\t\tcol[y1].Idx = y1\n\t\t\tcol[y1].Time ++\n\t\t}else{\n\t\t\t\tif x1 > x2{\n\t\t\t\t\tx1,x2 = x2,x1\n\t\t\t\t}\n\t\t\t\trow[x1].Idx = x1\n\t\t\trow[x1].Time ++\n\t\t}\n\t\t//fmt.Scan(&energy[i])\n\t}\n\t//row = row[:m+1]\n\t//col = col[:n + 1]\n\tsort.Sort(row)\n\tsort.Sort(col)\n\trow = row[:k+1]\n\tcol = col[:l + 1]\n\tsort.Sort(row)\n\tsort.Sort(col)\n\tfor i := 0;i < k-1;i ++ {\n\t\tfmt.Print(row[i].Idx,\" \")\n\t}\n\tfmt.Print(row[k -1 ].Idx,\"\\n\")\n\tfor i := 0;i < l-1;i ++ {\n\t\tfmt.Print(col[i].Idx,\" \")\n\t}\n\tfmt.Print(col[l -1 ].Idx,\"\\n\")\n\n}\n\n\nfunc next_per(){\n\tvar n int\n\tvar m int\n\tfmt.Scan(&n,&m)\n\ta :=make([]int, n)\n\tfor i:=0;i 0;m--{\n\t\ti := 0\n\t\tfor i = n-2;i >=0;i --{\n\t\t\tif a[i] < a[i + 1]{\n\t\t\t\tbreak\n\t\t\t}\n\n\n\t\t}\n\t\t//t := a[i+1]\n\t\tj := 0\n\t\tfor j = i + 1;j < n;j ++{\n\t\t\tif a[j] <= a[i]{\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\ta[i],a[j-1] = a[j-1],a[i]\n\t\tsort.Ints(a[i + 1:])\n\n\t}\n\tfmt.Println(a)\n\n\n}\nvar s string\nvar n,ans,length,carry int64\n//var ans int\n//var length int\n//var carry int\n//func max(x,y int)int{\n//\tif x > y{\n//\t\treturn x\n//\t}\n//\treturn y\n//}\nfunc maxf(x, y int64)int64{\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\nfunc get(k int)int{\n\tvar x int64\n\tvar t int64 = 1\n\ti := k\n\tfor ;i >= 0; i -- {\n\t\tif x + maxf(int64(1), (int64)(s[i]-'0')) * int64(t) >=n{\n\t\t\tbreak\n\t\t}\n\t\tx += int64(s[i]-'0') * t\n\t\tt *= 10\n\t}\n\tfor ;s[i+ 1] == '0'&& i < k-1;i ++{\n\n\t}\n\tans += x * carry\n\treturn i\n}\nfunc qq(){\n\n\tcarry = 1\n\tfmt.Scan(&n, &s)\n\ti := len(s) - 1\n\tfor ;i >=0;{\n\t\ti = get(i)\n\t\tcarry *=n\n\t}\n\tfmt.Println( ans)\n\n}\n\nfunc main(){\n\t//a := [][]int{{28,4,-19,18,-7,-10,27,19,1,16,0,10,-17,11,11,27,-1,10,12,-1},\n\t//\t{-2,-19,17,4,25,-20,4,3,4,28,-10,7,16,-14,-3,-19,6,17,-4,-7},\n\t//\t{2,8,18,-17,-2,10,-6,-5,11,10,22,-6,19,-16,6,-4,18,5,22,-17},\n\t//\t{-14,-7,-20,13,-19,-20,-15,21,-11,-10,-8,-9,10,13,6,-10,15,9,-15,-2},\n\t//\t{-18,26,12,8,2,16,-17,12,0,-5,9,-3,-12,-11,3,-6,-18,16,-7,-14},\n\t//\t{5,29,25,22,11,-3,-2,-15,4,13,-17,-2,0,-2,20,10,-18,6,25,-20},\n\t//\t{5,-7,8,5,15,22,8,-5,22,-18,-5,-14,23,2,-8,12,-16,-18,12,-12},\n\t//\t{27,18,4,11,-3,12,-4,-8,-3,25,-9,24,-14,5,11,-9,-17,0,25,-15},\n\t//\t{26,-7,18,4,4,18,-17,9,-19,-9,-19,-8,-4,-13,10,-11,6,-16,-12,12},\n\t//\t{28,22,7,11,-6,13,8,22,7,-14,17,14,10,29,16,9,-3,18,-9,10},\n\t//\t{27,19,-10,-9,1,3,14,1,7,3,-3,16,-2,9,14,-7,-19,-5,23,19},\n\t//\t{-17,7,-20,8,-5,-6,-2,25,29,16,23,4,4,27,16,17,9,20,-6,22},\n\t//\t{2,9,-13,1,-18,25,4,7,25,26,-4,8,-19,18,6,-7,-5,7,21,-8},\n\t//\t{-2,11,1,29,6,-16,-8,3,7,11,10,-2,-1,-20,20,4,19,5,29,-7},\n\t//\t{29,-12,-3,17,6,19,23,12,-19,13,19,5,27,22,-17,27,10,-12,12,23},\n\t//\t{24,16,4,25,15,13,24,-19,1,-7,-19,13,-13,14,13,26,9,18,-9,-18},\n\t//\t{-17,4,-18,-18,-19,3,-13,12,23,-17,-10,-20,14,2,18,21,-12,27,-3,4},\n\t//\t{27,13,12,14,16,-9,-2,-15,-20,8,-2,24,18,15,26,21,27,17,-15,-3},\n\t//\t{25,-8,17,-10,-16,13,26,-11,-15,6,-5,-13,23,2,24,-4,5,8,-15,-1},\n\t//\t{15,-12,18,5,-3,7,5,11,-4,-13,28,20,0,-4,-13,-5,-13,-8,-16,3}}\n\n\t//log.Println(find_last_le_idx(a, 3))\n\t//log.Println(q(a, -123))\n\n\t//aa := []int{2,3,1,3,4,6,1,2}\n\t//mm(aa, 1)\n\t//ini()\n//inii()\n\t//next_per()\n\tqq()\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"sort\"\n)\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\nfunc find_last_le_idx(a []int, target int )int {\n\t//if not exist rturn -1\n\n\ts := 0\n\te := len(a)\n\tfor ;s < e;{\n\t\tmid := s +(e- s)/2\n\t\tif a[mid ] <= target{\n\t\t\ts = mid + 1\n\t\t}else {\n\t\t\te = mid\n\t\t}\n\t}\n\treturn s - 1\n}\n\n\nfunc find_first_ge_idx(a []int, target int )int {\n\t//if not exist rturn -1\n\n\ts := 0\n\te := len(a)\n\tfor ;s < e;{\n\t\tmid := s +(e- s)/2\n\t\tif a[mid ] < target{\n\t\t\ts = mid + 1\n\t\t}else {\n\t\t\te = mid\n\t\t}\n\t}\n\n\treturn s\n}\n\nfunc maxSumSubmatrix(a [][]int, target int) int {\n\trow := len(a)\n\tif row == 0{\n\t\treturn 0\n\t}\n\tcol := len(a[0])\n\n\tpre_sum := make([][]int, row)\n\tfor i := range pre_sum{\n\t\tpre_sum[i] = make([]int ,col)\n\t}\n\n\tfor i := 0;i < row; i ++{\n\t\tfor j :=0;j < col; j ++{\n\t\t\tif j == 0 {\n\t\t\t\tpre_sum[i][j] = a[i][j]\n\t\t\t}else {\n\t\t\t\tpre_sum[i][j] = pre_sum[i][j-1] + a[i][j]\n\t\t\t}\n\t\t}\n\t}\n\n\tnear := -100000000\n\tfor i := 0; i < col ; i ++{\n\t\tfor j :=i ;j near) {\n\t\t\t\t//\t\tnear = cur\n\t\t\t\t//\t}\n\t\t\t\t//\ttmp = append(tmp, cur)\n\t\t\t\t//}\n\t\t\t}\n\n\t\t}\n\t}\n\treturn near\n}\n\nfunc q(matrix [][]int, k int) int {\n\trow := len(matrix)\n\tcol := len(matrix[0])\n\tnear := -1000000\n\tfor left := 0; left < col ; left ++{\n\t// 以left为左边界,每行的总和\n\t\t_sum :=make([]int, row)\n\t//for right in range(left, col):\n\t\tfor right :=left ;right 1 {\n\t\t\tif idx - left +1 < min_l{\n\t\t\t\tmin_l = idx - left + 1\n\t\t\t\tm_l = left\n\t\t\t\tm_r = idx\n\t\t\t}\n\t\t\tcounter[record[left]] --\n\n\t\t\t//}else {\n\t\t\t//\n\t\t\t//}\n\t\t\tif counter[record[left]] == 0 {\n\t\t\t\ttarget --\n\t\t\t}\n\t\t\tleft ++\n\t\t}else{\n\t\t\t\tidx ++\n\t\t\tcounter[record[idx]] ++\n\t\t\tif counter[record[idx]] == 1{\n\t\t\t\ttarget ++\n\t\t\t}\n\t\t\t//idx++\n\t\t}\n\t}\n\tfmt.Println(m_l + 1, m_r + 1)\n}\n\nfunc ini(){\n\tvar n int\n\t//var k int\n\tfmt.Scan(&n)\n\t//fmt.Scan(&k)\n\tfor i := 0;i < n; i ++{\n\t\tfmt.Scan(&ori[i])\n\t\tfmt.Scan(&energy[i])\n\t}\n\tR := -1\n\tL := 0\n\tfor i :=0; i < n; i ++{\n\t\t//if record[L] == i - k{\n\t\t//\tL ++\n\t\t//}\n\t\tfor ;R >= L &&ori[i] >ori[record[R]];R--{\n\t\t\tcounter[i]\t+= energy[record[R]]\n\t\t}\n\t\ttmp := energy[i]\n\t\tfor ;R >= L &&ori[i] ==ori[record[R]];R--{\n\t\t\ttmp += energy[i]\n\t\t}\n\t\tR ++\n\t\trecord[R] = i\n\t\tif R != 0 {\n\t\t\tcounter[record[R - 1]] += tmp\n\t\t}\n\t}\n\tm := -1\n\tfor i :=0; i m{\n\t\t\tm = counter[i]\n\t\t}\n\t}\n\tfmt.Println(m)\n}\ntype S struct {\n\tIdx int\n\tTime int\n\n}\ntype intSlice []S\n\nfunc (p intSlice) Len() int { return len(p) }\nfunc (p intSlice) Less(i, j int) bool { return p[i].Time > p[j].Time }\nfunc (p intSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }\n\nvar roww [1000]int\nvar coll [1000]int\nfunc inii(){\n\tvar m,n,k,l,d int\n\t//var k int\n\trow := make(intSlice, 10000)\n\tcol := make(intSlice, 10000)\n\tfmt.Scan(&m, &n, &k, &l,&d)\n\t//fmt.Scan(&k)\n\tfor i := 0;i < d; i ++{\n\t\tvar x1,y1,x2,y2 int\n\t\tfmt.Scan(&x1,&y1,&x2,&y2)\n\t\tif x1 == x2 {\n\t\t\tif y1 > y2 {\n\t\t\t\ty1,y2 = y2,y1\n\t\t\t}\n\t\t\tcol[y1].Idx = y1\n\t\t\tcol[y1].Time ++\n\t\t}else{\n\t\t\t\tif x1 > x2{\n\t\t\t\t\tx1,x2 = x2,x1\n\t\t\t\t}\n\t\t\t\trow[x1].Idx = x1\n\t\t\trow[x1].Time ++\n\t\t}\n\t\t//fmt.Scan(&energy[i])\n\t}\n\t//row = row[:m+1]\n\t//col = col[:n + 1]\n\tsort.Sort(row)\n\tsort.Sort(col)\n\trow = row[:k+1]\n\tcol = col[:l + 1]\n\tsort.Sort(row)\n\tsort.Sort(col)\n\tfor i := 0;i < k-1;i ++ {\n\t\tfmt.Print(row[i].Idx,\" \")\n\t}\n\tfmt.Print(row[k -1 ].Idx,\"\\n\")\n\tfor i := 0;i < l-1;i ++ {\n\t\tfmt.Print(col[i].Idx,\" \")\n\t}\n\tfmt.Print(col[l -1 ].Idx,\"\\n\")\n\n}\n\n\nfunc next_per(){\n\tvar n int\n\tvar m int\n\tfmt.Scan(&n,&m)\n\ta :=make([]int, n)\n\tfor i:=0;i 0;m--{\n\t\ti := 0\n\t\tfor i = n-2;i >=0;i --{\n\t\t\tif a[i] < a[i + 1]{\n\t\t\t\tbreak\n\t\t\t}\n\n\n\t\t}\n\t\t//t := a[i+1]\n\t\tj := 0\n\t\tfor j = i + 1;j < n;j ++{\n\t\t\tif a[j] <= a[i]{\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\ta[i],a[j-1] = a[j-1],a[i]\n\t\tsort.Ints(a[i + 1:])\n\n\t}\n\tfmt.Println(a)\n\n\n}\nvar s string\nvar n,ans,length,carry int\n//var ans int\n//var length int\n//var carry int\n//func max(x,y int)int{\n//\tif x > y{\n//\t\treturn x\n//\t}\n//\treturn y\n//}\nfunc maxf(x, y int)int{\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\nfunc get(k int)int{\n\tvar x int\n\tvar t int = 1\n\ti := k\n\tfor ;i >= 0; i -- {\n\t\tif x + maxf(int(1), (int)(s[i]-'0')) * int(t) >=n{\n\t\t\tbreak\n\t\t}\n\t\tx += int(s[i]-'0') * t\n\t\tt *= 10\n\t}\n\tfor ;s[i+ 1] == '0'&& i < k-1;i ++{\n\n\t}\n\tans += x * carry\n\treturn i\n}\nfunc qq(){\n\n\tcarry = 1\n\tfmt.Scan(&n, &s)\n\ti := len(s) - 1\n\tfor ;i >=0;{\n\t\ti = get(i)\n\t\tcarry *=n\n\t}\n\tfmt.Println( ans)\n\n}\n\nfunc main(){\n\t//a := [][]int{{28,4,-19,18,-7,-10,27,19,1,16,0,10,-17,11,11,27,-1,10,12,-1},\n\t//\t{-2,-19,17,4,25,-20,4,3,4,28,-10,7,16,-14,-3,-19,6,17,-4,-7},\n\t//\t{2,8,18,-17,-2,10,-6,-5,11,10,22,-6,19,-16,6,-4,18,5,22,-17},\n\t//\t{-14,-7,-20,13,-19,-20,-15,21,-11,-10,-8,-9,10,13,6,-10,15,9,-15,-2},\n\t//\t{-18,26,12,8,2,16,-17,12,0,-5,9,-3,-12,-11,3,-6,-18,16,-7,-14},\n\t//\t{5,29,25,22,11,-3,-2,-15,4,13,-17,-2,0,-2,20,10,-18,6,25,-20},\n\t//\t{5,-7,8,5,15,22,8,-5,22,-18,-5,-14,23,2,-8,12,-16,-18,12,-12},\n\t//\t{27,18,4,11,-3,12,-4,-8,-3,25,-9,24,-14,5,11,-9,-17,0,25,-15},\n\t//\t{26,-7,18,4,4,18,-17,9,-19,-9,-19,-8,-4,-13,10,-11,6,-16,-12,12},\n\t//\t{28,22,7,11,-6,13,8,22,7,-14,17,14,10,29,16,9,-3,18,-9,10},\n\t//\t{27,19,-10,-9,1,3,14,1,7,3,-3,16,-2,9,14,-7,-19,-5,23,19},\n\t//\t{-17,7,-20,8,-5,-6,-2,25,29,16,23,4,4,27,16,17,9,20,-6,22},\n\t//\t{2,9,-13,1,-18,25,4,7,25,26,-4,8,-19,18,6,-7,-5,7,21,-8},\n\t//\t{-2,11,1,29,6,-16,-8,3,7,11,10,-2,-1,-20,20,4,19,5,29,-7},\n\t//\t{29,-12,-3,17,6,19,23,12,-19,13,19,5,27,22,-17,27,10,-12,12,23},\n\t//\t{24,16,4,25,15,13,24,-19,1,-7,-19,13,-13,14,13,26,9,18,-9,-18},\n\t//\t{-17,4,-18,-18,-19,3,-13,12,23,-17,-10,-20,14,2,18,21,-12,27,-3,4},\n\t//\t{27,13,12,14,16,-9,-2,-15,-20,8,-2,24,18,15,26,21,27,17,-15,-3},\n\t//\t{25,-8,17,-10,-16,13,26,-11,-15,6,-5,-13,23,2,24,-4,5,8,-15,-1},\n\t//\t{15,-12,18,5,-3,7,5,11,-4,-13,28,20,0,-4,-13,-5,-13,-8,-16,3}}\n\n\t//log.Println(find_last_le_idx(a, 3))\n\t//log.Println(q(a, -123))\n\n\t//aa := []int{2,3,1,3,4,6,1,2}\n\t//mm(aa, 1)\n\t//ini()\n//inii()\n\t//next_per()\n\tqq()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tn := readInt64()\n\tk := readString()\n\tvalues := make([]int, 0)\n\tfor len(k) > 0 {\n\t\tvar maxValue int\n\t\tvar maxIndex int\n\t\tfor i := len(k) - 1; i >= 0; i-- {\n\t\t\tvalue, err := strconv.ParseInt(k[i:], 10, 32)\n\t\t\tif err == nil {\n\t\t\t\tif value <= n {\n\t\t\t\t\tmaxValue = int(value)\n\t\t\t\t\tmaxIndex = i\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t}\n\t\tif maxIndex+1 < len(k) {\n\t\t\tfor maxIndex < len(k) && k[maxIndex] == '0' {\n\t\t\t\tmaxIndex++\n\t\t\t}\n\t\t}\n\t\tk = k[:maxIndex]\n\t\tvalues = append(values, maxValue)\n\t}\n\tvar res int64\n\tfor i := len(values) - 1; i >= 0; i-- {\n\t\tres *= n\n\t\tres += int64(values[i])\n\t}\n\tfmt.Println(res)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"sort\"\n)\n\nfunc max(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\nfunc find_last_le_idx(a []int, target int )int {\n\t//if not exist rturn -1\n\n\ts := 0\n\te := len(a)\n\tfor ;s < e;{\n\t\tmid := s +(e- s)/2\n\t\tif a[mid ] <= target{\n\t\t\ts = mid + 1\n\t\t}else {\n\t\t\te = mid\n\t\t}\n\t}\n\treturn s - 1\n}\n\n\nfunc find_first_ge_idx(a []int, target int )int {\n\t//if not exist rturn -1\n\n\ts := 0\n\te := len(a)\n\tfor ;s < e;{\n\t\tmid := s +(e- s)/2\n\t\tif a[mid ] < target{\n\t\t\ts = mid + 1\n\t\t}else {\n\t\t\te = mid\n\t\t}\n\t}\n\n\treturn s\n}\n\nfunc maxSumSubmatrix(a [][]int, target int) int {\n\trow := len(a)\n\tif row == 0{\n\t\treturn 0\n\t}\n\tcol := len(a[0])\n\n\tpre_sum := make([][]int, row)\n\tfor i := range pre_sum{\n\t\tpre_sum[i] = make([]int ,col)\n\t}\n\n\tfor i := 0;i < row; i ++{\n\t\tfor j :=0;j < col; j ++{\n\t\t\tif j == 0 {\n\t\t\t\tpre_sum[i][j] = a[i][j]\n\t\t\t}else {\n\t\t\t\tpre_sum[i][j] = pre_sum[i][j-1] + a[i][j]\n\t\t\t}\n\t\t}\n\t}\n\n\tnear := -100000000\n\tfor i := 0; i < col ; i ++{\n\t\tfor j :=i ;j near) {\n\t\t\t\t//\t\tnear = cur\n\t\t\t\t//\t}\n\t\t\t\t//\ttmp = append(tmp, cur)\n\t\t\t\t//}\n\t\t\t}\n\n\t\t}\n\t}\n\treturn near\n}\n\nfunc q(matrix [][]int, k int) int {\n\trow := len(matrix)\n\tcol := len(matrix[0])\n\tnear := -1000000\n\tfor left := 0; left < col ; left ++{\n\t// 以left为左边界,每行的总和\n\t\t_sum :=make([]int, row)\n\t//for right in range(left, col):\n\t\tfor right :=left ;right 1 {\n\t\t\tif idx - left +1 < min_l{\n\t\t\t\tmin_l = idx - left + 1\n\t\t\t\tm_l = left\n\t\t\t\tm_r = idx\n\t\t\t}\n\t\t\tcounter[record[left]] --\n\n\t\t\t//}else {\n\t\t\t//\n\t\t\t//}\n\t\t\tif counter[record[left]] == 0 {\n\t\t\t\ttarget --\n\t\t\t}\n\t\t\tleft ++\n\t\t}else{\n\t\t\t\tidx ++\n\t\t\tcounter[record[idx]] ++\n\t\t\tif counter[record[idx]] == 1{\n\t\t\t\ttarget ++\n\t\t\t}\n\t\t\t//idx++\n\t\t}\n\t}\n\tfmt.Println(m_l + 1, m_r + 1)\n}\n\nfunc ini(){\n\tvar n int\n\t//var k int\n\tfmt.Scan(&n)\n\t//fmt.Scan(&k)\n\tfor i := 0;i < n; i ++{\n\t\tfmt.Scan(&ori[i])\n\t\tfmt.Scan(&energy[i])\n\t}\n\tR := -1\n\tL := 0\n\tfor i :=0; i < n; i ++{\n\t\t//if record[L] == i - k{\n\t\t//\tL ++\n\t\t//}\n\t\tfor ;R >= L &&ori[i] >ori[record[R]];R--{\n\t\t\tcounter[i]\t+= energy[record[R]]\n\t\t}\n\t\ttmp := energy[i]\n\t\tfor ;R >= L &&ori[i] ==ori[record[R]];R--{\n\t\t\ttmp += energy[i]\n\t\t}\n\t\tR ++\n\t\trecord[R] = i\n\t\tif R != 0 {\n\t\t\tcounter[record[R - 1]] += tmp\n\t\t}\n\t}\n\tm := -1\n\tfor i :=0; i m{\n\t\t\tm = counter[i]\n\t\t}\n\t}\n\tfmt.Println(m)\n}\ntype S struct {\n\tIdx int\n\tTime int\n\n}\ntype intSlice []S\n\nfunc (p intSlice) Len() int { return len(p) }\nfunc (p intSlice) Less(i, j int) bool { return p[i].Time > p[j].Time }\nfunc (p intSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }\n\nvar roww [1000]int\nvar coll [1000]int\nfunc inii(){\n\tvar m,n,k,l,d int\n\t//var k int\n\trow := make(intSlice, 10000)\n\tcol := make(intSlice, 10000)\n\tfmt.Scan(&m, &n, &k, &l,&d)\n\t//fmt.Scan(&k)\n\tfor i := 0;i < d; i ++{\n\t\tvar x1,y1,x2,y2 int\n\t\tfmt.Scan(&x1,&y1,&x2,&y2)\n\t\tif x1 == x2 {\n\t\t\tif y1 > y2 {\n\t\t\t\ty1,y2 = y2,y1\n\t\t\t}\n\t\t\tcol[y1].Idx = y1\n\t\t\tcol[y1].Time ++\n\t\t}else{\n\t\t\t\tif x1 > x2{\n\t\t\t\t\tx1,x2 = x2,x1\n\t\t\t\t}\n\t\t\t\trow[x1].Idx = x1\n\t\t\trow[x1].Time ++\n\t\t}\n\t\t//fmt.Scan(&energy[i])\n\t}\n\t//row = row[:m+1]\n\t//col = col[:n + 1]\n\tsort.Sort(row)\n\tsort.Sort(col)\n\trow = row[:k+1]\n\tcol = col[:l + 1]\n\tsort.Sort(row)\n\tsort.Sort(col)\n\tfor i := 0;i < k-1;i ++ {\n\t\tfmt.Print(row[i].Idx,\" \")\n\t}\n\tfmt.Print(row[k -1 ].Idx,\"\\n\")\n\tfor i := 0;i < l-1;i ++ {\n\t\tfmt.Print(col[i].Idx,\" \")\n\t}\n\tfmt.Print(col[l -1 ].Idx,\"\\n\")\n\n}\n\n\nfunc next_per(){\n\tvar n int\n\tvar m int\n\tfmt.Scan(&n,&m)\n\ta :=make([]int, n)\n\tfor i:=0;i 0;m--{\n\t\ti := 0\n\t\tfor i = n-2;i >=0;i --{\n\t\t\tif a[i] < a[i + 1]{\n\t\t\t\tbreak\n\t\t\t}\n\n\n\t\t}\n\t\t//t := a[i+1]\n\t\tj := 0\n\t\tfor j = i + 1;j < n;j ++{\n\t\t\tif a[j] <= a[i]{\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\ta[i],a[j-1] = a[j-1],a[i]\n\t\tsort.Ints(a[i + 1:])\n\n\t}\n\tfmt.Println(a)\n\n\n}\nvar s string\nvar n,ans,length,carry float64\n//var ans int\n//var length int\n//var carry int\n//func max(x,y int)int{\n//\tif x > y{\n//\t\treturn x\n//\t}\n//\treturn y\n//}\nfunc maxf(x, y float64)float64{\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\nfunc get(k int)int{\n\tvar x float64\n\tvar t float64 = 1\n\ti := k\n\tfor ;i >= 0; i -- {\n\t\tif x + maxf(float64(1), (float64)(s[i]-'0')) * float64(t) >=n{\n\t\t\tbreak\n\t\t}\n\t\tx += float64(s[i]-'0') * t\n\t\tt *= 10\n\t}\n\tfor ;s[i+ 1] == '0'&& i < k-1;i ++{\n\n\t}\n\tans += x * carry\n\treturn i\n}\nfunc qq(){\n\n\tcarry = 1\n\tfmt.Scan(&n, &s)\n\ti := len(s) - 1\n\tfor ;i >=0;{\n\t\ti = get(i)\n\t\tcarry *=n\n\t}\n\tfmt.Println(ans)\n\n}\n\nfunc main(){\n\t//a := [][]int{{28,4,-19,18,-7,-10,27,19,1,16,0,10,-17,11,11,27,-1,10,12,-1},\n\t//\t{-2,-19,17,4,25,-20,4,3,4,28,-10,7,16,-14,-3,-19,6,17,-4,-7},\n\t//\t{2,8,18,-17,-2,10,-6,-5,11,10,22,-6,19,-16,6,-4,18,5,22,-17},\n\t//\t{-14,-7,-20,13,-19,-20,-15,21,-11,-10,-8,-9,10,13,6,-10,15,9,-15,-2},\n\t//\t{-18,26,12,8,2,16,-17,12,0,-5,9,-3,-12,-11,3,-6,-18,16,-7,-14},\n\t//\t{5,29,25,22,11,-3,-2,-15,4,13,-17,-2,0,-2,20,10,-18,6,25,-20},\n\t//\t{5,-7,8,5,15,22,8,-5,22,-18,-5,-14,23,2,-8,12,-16,-18,12,-12},\n\t//\t{27,18,4,11,-3,12,-4,-8,-3,25,-9,24,-14,5,11,-9,-17,0,25,-15},\n\t//\t{26,-7,18,4,4,18,-17,9,-19,-9,-19,-8,-4,-13,10,-11,6,-16,-12,12},\n\t//\t{28,22,7,11,-6,13,8,22,7,-14,17,14,10,29,16,9,-3,18,-9,10},\n\t//\t{27,19,-10,-9,1,3,14,1,7,3,-3,16,-2,9,14,-7,-19,-5,23,19},\n\t//\t{-17,7,-20,8,-5,-6,-2,25,29,16,23,4,4,27,16,17,9,20,-6,22},\n\t//\t{2,9,-13,1,-18,25,4,7,25,26,-4,8,-19,18,6,-7,-5,7,21,-8},\n\t//\t{-2,11,1,29,6,-16,-8,3,7,11,10,-2,-1,-20,20,4,19,5,29,-7},\n\t//\t{29,-12,-3,17,6,19,23,12,-19,13,19,5,27,22,-17,27,10,-12,12,23},\n\t//\t{24,16,4,25,15,13,24,-19,1,-7,-19,13,-13,14,13,26,9,18,-9,-18},\n\t//\t{-17,4,-18,-18,-19,3,-13,12,23,-17,-10,-20,14,2,18,21,-12,27,-3,4},\n\t//\t{27,13,12,14,16,-9,-2,-15,-20,8,-2,24,18,15,26,21,27,17,-15,-3},\n\t//\t{25,-8,17,-10,-16,13,26,-11,-15,6,-5,-13,23,2,24,-4,5,8,-15,-1},\n\t//\t{15,-12,18,5,-3,7,5,11,-4,-13,28,20,0,-4,-13,-5,-13,-8,-16,3}}\n\n\t//log.Println(find_last_le_idx(a, 3))\n\t//log.Println(q(a, -123))\n\n\t//aa := []int{2,3,1,3,4,6,1,2}\n\t//mm(aa, 1)\n\t//ini()\n//inii()\n\t//next_per()\n\tqq()\n}\n"}], "src_uid": "be66399c558c96566a6bb0a63d2503e5"} {"nl": {"description": "The final round of Bayan Programming Contest will be held in Tehran, and the participants will be carried around with a yellow bus. The bus has 34 passenger seats: 4 seats in the last row and 3 seats in remaining rows. The event coordinator has a list of k participants who should be picked up at the airport. When a participant gets on the bus, he will sit in the last row with an empty seat. If there is more than one empty seat in that row, he will take the leftmost one. In order to keep track of the people who are on the bus, the event coordinator needs a figure showing which seats are going to be taken by k participants. Your task is to draw the figure representing occupied seats.", "input_spec": "The only line of input contains integer k, (0 ≤ k ≤ 34), denoting the number of participants.", "output_spec": "Print the figure of a bus with k passengers as described in sample tests. Character '#' denotes an empty seat, while 'O' denotes a taken seat. 'D' is the bus driver and other characters in the output are for the purpose of beautifying the figure. Strictly follow the sample test cases output format. Print exactly six lines. Do not output extra space or other characters.", "sample_inputs": ["9", "20"], "sample_outputs": ["+------------------------+\n|O.O.O.#.#.#.#.#.#.#.#.|D|)\n|O.O.O.#.#.#.#.#.#.#.#.|.|\n|O.......................|\n|O.O.#.#.#.#.#.#.#.#.#.|.|)\n+------------------------+", "+------------------------+\n|O.O.O.O.O.O.O.#.#.#.#.|D|)\n|O.O.O.O.O.O.#.#.#.#.#.|.|\n|O.......................|\n|O.O.O.O.O.O.#.#.#.#.#.|.|)\n+------------------------+"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar k int\n\tfmt.Scanf(\"%d\", &k)\n\trows := []int{0,0,0,0}\n\tif k <= 4 {\n\t\tfor i := 0; i < k; i++ {\n\t\t\trows[i] = 1\n\t\t}\n\t} else {\n\t\trows[2] = 1\n\t\tq := (k - 4) / 3\n\t\tr := (k - 4) % 3\n\t\trows[0], rows[1], rows[3] = q + 1, q + 1, q + 1\n\t\tif r >= 1 {\n\t\t\trows[0]++\n\t\t}\n\t\tif r >= 2 {\n\t\t\trows[1]++\n\t\t}\n\t}\n\tfmt.Println(\"+------------------------+\")\n\tfmt.Printf(\"|%s%s|D|)\\n\", strings.Repeat(\"O.\", rows[0]), strings.Repeat(\"#.\", 11 - rows[0]))\n\tfmt.Printf(\"|%s%s|.|\\n\", strings.Repeat(\"O.\", rows[1]), strings.Repeat(\"#.\", 11 - rows[1]))\n\tif rows[2] > 0 {\n\t\tfmt.Printf(\"|%s%s..|\\n\", strings.Repeat(\"O.\", rows[2]), strings.Repeat(\"..\", 11 - rows[2]))\n\t} else {\n\t\tfmt.Printf(\"|%s%s..|\\n\", strings.Repeat(\"#.\", 1), strings.Repeat(\"..\", 10))\n\t}\n\tfmt.Printf(\"|%s%s|.|)\\n\", strings.Repeat(\"O.\", rows[3]), strings.Repeat(\"#.\", 11 - rows[3]))\n\tfmt.Println(\"+------------------------+\")\n}\n"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n \"strings\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n scanner.Scan()\n ans, _ := strconv.Atoi(scanner.Text())\n return ans\n}\n\nfunc ReadString() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n defer writer.Flush()\n scanner.Split(bufio.ScanWords)\n\n n := ReadInt32()\n writer.WriteString(\"+------------------------+\\n\")\n if n <= 4 {\n switch n {\n case 0:\n writer.WriteString(\"|#.#.#.#.#.#.#.#.#.#.#.|D|)\\n\")\n writer.WriteString(\"|#.#.#.#.#.#.#.#.#.#.#.|.|\\n\")\n writer.WriteString(\"|#.......................|\\n\")\n writer.WriteString(\"|#.#.#.#.#.#.#.#.#.#.#.|.|)\\n\")\n break\n case 1:\n writer.WriteString(\"|O.#.#.#.#.#.#.#.#.#.#.|D|)\\n\")\n writer.WriteString(\"|#.#.#.#.#.#.#.#.#.#.#.|.|\\n\")\n writer.WriteString(\"|#.......................|\\n\")\n writer.WriteString(\"|#.#.#.#.#.#.#.#.#.#.#.|.|)\\n\")\n break\n case 2:\n writer.WriteString(\"|O.#.#.#.#.#.#.#.#.#.#.|D|)\\n\")\n writer.WriteString(\"|O.#.#.#.#.#.#.#.#.#.#.|.|\\n\")\n writer.WriteString(\"|#.......................|\\n\")\n writer.WriteString(\"|#.#.#.#.#.#.#.#.#.#.#.|.|)\\n\")\n break\n case 3:\n writer.WriteString(\"|O.#.#.#.#.#.#.#.#.#.#.|D|)\\n\")\n writer.WriteString(\"|O.#.#.#.#.#.#.#.#.#.#.|.|\\n\")\n writer.WriteString(\"|O.......................|\\n\")\n writer.WriteString(\"|#.#.#.#.#.#.#.#.#.#.#.|.|)\\n\")\n break\n case 4:\n writer.WriteString(\"|O.#.#.#.#.#.#.#.#.#.#.|D|)\\n\")\n writer.WriteString(\"|O.#.#.#.#.#.#.#.#.#.#.|.|\\n\")\n writer.WriteString(\"|O.......................|\\n\")\n writer.WriteString(\"|O.#.#.#.#.#.#.#.#.#.#.|.|)\\n\")\n break\n }\n } else {\n s := make([]string, 3)\n s[1] = \"|O.#.#.#.#.#.#.#.#.#.#.|D|)\\n\"\n s[2] = \"|O.#.#.#.#.#.#.#.#.#.#.|.|\\n\"\n s[0] = \"|O.#.#.#.#.#.#.#.#.#.#.|.|)\\n\"\n n -= 4\n\n for i := 1; i <= n; i++ {\n s[i%3] = strings.Replace(s[i%3], \"#\", \"O\", 1)\n }\n writer.WriteString(s[1])\n writer.WriteString(s[2])\n writer.WriteString(\"|O.......................|\\n\")\n writer.WriteString(s[0])\n }\n\n writer.WriteString(\"+------------------------+\\n\")\n}\n\n/*\n\n|O.O.O.#.#.#.#.#.#.#.#.|D|)\n|O.O.O.#.#.#.#.#.#.#.#.|.|\n|O.......................|\n|O.O.#.#.#.#.#.#.#.#.#.|.|)\n\n*/\n"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"os\"\n \"strconv\"\n \"strings\"\n)\n\nvar scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc ReadInt32() int {\n scanner.Scan()\n ans, _ := strconv.Atoi(scanner.Text())\n return ans\n}\n\nfunc ReadString() string {\n scanner.Scan()\n return scanner.Text()\n}\n\nfunc main() {\n defer writer.Flush()\n scanner.Split(bufio.ScanWords)\n\n n := ReadInt32()\n s := make([]string, 4)\n\n s[1] = \"|#.#.#.#.#.#.#.#.#.#.#.|D|)\\n\"\n s[2] = \"|#.#.#.#.#.#.#.#.#.#.#.|.|\\n\"\n s[0] = \"|#.#.#.#.#.#.#.#.#.#.#.|.|)\\n\"\n\n if n >= 3 {\n s[3] = \"|O.......................|\\n\"\n n--\n } else {\n s[3] = \"|#.......................|\\n\"\n }\n\n for i := 1; i <= n; i++ {\n s[i%3] = strings.Replace(s[i%3], \"#\", \"O\", 1)\n }\n\n writer.WriteString(\"+------------------------+\\n\")\n writer.WriteString(s[1])\n writer.WriteString(s[2])\n writer.WriteString(s[3])\n writer.WriteString(s[0])\n writer.WriteString(\"+------------------------+\\n\")\n}\n"}], "negative_code": [], "src_uid": "075f83248f6d4d012e0ca1547fc67993"} {"nl": {"description": "Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland.Now he has a goal to replace dead light bulbs, however he doesn't know how many light bulbs for each color are required. It is guaranteed that for each of four colors at least one light is working.It is known that the garland contains light bulbs of four colors: red, blue, yellow and green. The garland is made as follows: if you take any four consecutive light bulbs then there will not be light bulbs with the same color among them. For example, the garland can look like \"RYBGRYBGRY\", \"YBGRYBGRYBG\", \"BGRYB\", but can not look like \"BGRYG\", \"YBGRYBYGR\" or \"BGYBGY\". Letters denote colors: 'R' — red, 'B' — blue, 'Y' — yellow, 'G' — green.Using the information that for each color at least one light bulb still works count the number of dead light bulbs of each four colors.", "input_spec": "The first and the only line contains the string s (4 ≤ |s| ≤ 100), which describes the garland, the i-th symbol of which describes the color of the i-th light bulb in the order from the beginning of garland: 'R' — the light bulb is red, 'B' — the light bulb is blue, 'Y' — the light bulb is yellow, 'G' — the light bulb is green, '!' — the light bulb is dead. The string s can not contain other symbols except those five which were described. It is guaranteed that in the given string at least once there is each of four letters 'R', 'B', 'Y' and 'G'. It is guaranteed that the string s is correct garland with some blown light bulbs, it means that for example the line \"GRBY!!!B\" can not be in the input data. ", "output_spec": "In the only line print four integers kr, kb, ky, kg — the number of dead light bulbs of red, blue, yellow and green colors accordingly.", "sample_inputs": ["RYBGRYBGR", "!RGYB", "!!!!YGRB", "!GB!RG!Y!"], "sample_outputs": ["0 0 0 0", "0 1 0 0", "1 1 1 1", "2 1 1 0"], "notes": "NoteIn the first example there are no dead light bulbs.In the second example it is obvious that one blue bulb is blown, because it could not be light bulbs of other colors on its place according to the statements."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"regexp\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tre := regexp.MustCompile(`\\r?\\n`)\n\tif garland, err := reader.ReadString('\\n'); err != nil {\n\t\tif err != io.EOF {\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tgarland = re.ReplaceAllString(garland, \"\")\n\n\t\tneeds := make([]int, 4)\n\t\tcolor_idx := make([]int, 4) // Index of RBYG\n\n\t\tfor i := 0; i < len(garland); i++ {\n\t\t\tk := i % 4\n\t\t\tif 'R' == garland[i] {\n\t\t\t\tcolor_idx[0] = k\n\t\t\t} else if 'B' == garland[i] {\n\t\t\t\tcolor_idx[1] = k\n\t\t\t} else if 'Y' == garland[i] {\n\t\t\t\tcolor_idx[2] = k\n\t\t\t} else if 'G' == garland[i] {\n\t\t\t\tcolor_idx[3] = k\n\t\t\t} else if '!' == garland[i] {\n\t\t\t\tneeds[k]++\n\t\t\t} else {\n\t\t\t\tfmt.Println(\"Error\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tfor i := 0; i < 4; i++ {\n\t\t\tfmt.Printf(\"%d \", needs[color_idx[i]])\n\t\t}\n\t\tfmt.Println()\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t)\n\nfunc main() {\n\tvar input string\n\tfmt.Scanln(&input)\n\td := map[string]int{\n\t\t\"R\":0,\n\t\t\"B\":1,\n\t\t\"Y\":2,\n\t\t\"G\":3,\n\t}\n\tcnt := []int{0, 0, 0, 0}\n\tmod := []int{-1, -1, -1, -1}\n\tfor i, s := range(input) {\n\t\tif string(s) == \"!\" {\n\t\t\tcontinue\n\t\t}\n\t\tx := d[string(s)]\n\t\tcnt[x]++\n\t\tmod[x] = i % 4\n\t}\n\tfor i := 0; i < 4; i++ {\n\t\tval := len(input) / 4\n\t\tif len(input) % 4 > mod[i] {\n\t\t\tval++\n\t\t}\n\t\tfmt.Printf(\"%d \", val - cnt[i])\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tstr1 := readString()\n\ta := []byte(str1)\n\tres := make([]int, 4)\n\tdfs(a, 0, res)\n\tfor i := 0; i < len(res); i++ {\n\t\tif i > 0 {\n\t\t\tfmt.Printf(\" %d\", res[i])\n\t\t} else {\n\t\t\tfmt.Printf(\"%d\", res[i])\n\t\t}\n\t}\n\tfmt.Println()\n}\n\nfunc dfs(a []byte, pos int, res []int) bool {\n\tif pos == len(a) {\n\t\treturn true\n\t}\n\tif a[pos] != '!' {\n\t\tif dfs(a, pos+1, res) {\n\t\t\treturn true\n\t\t}\n\t} else {\n\t\tfor j, v := range \"RBYG\" {\n\t\t\tch := byte(v)\n\t\t\tok := true\n\t\t\tfor j := 0; j < 3; j++ {\n\t\t\t\tk := pos - j - 1\n\t\t\t\tif k >= 0 && a[k] == ch {\n\t\t\t\t\tok = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tk = pos + j + 1\n\t\t\t\tif k < len(a) && a[k] == ch {\n\t\t\t\t\tok = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ok {\n\t\t\t\ta[pos] = ch\n\t\t\t\tif dfs(a, pos+1, res) {\n\t\t\t\t\tres[j]++\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\ta[pos] = '!'\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\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"}, {"source_code": "package main\nimport (\n\t\"fmt\"\n)\n\n\nfunc main() {\n\tvar bulbs string\n\tfmt.Scanln(&bulbs)\n\n\tr, b, y, g := 0, 0, 0, 0\n\n\tlen_bulbs := len(bulbs)\n\n\tfor i := 0; i < len_bulbs; i++ {\n\t\tif bulbs[i] == '!' {\n\t\t\tfor j := i % 4; j < len_bulbs; j = j + 4 {\n\t\t\t\tc := bulbs[j]\n\t\t\t\tif c == 'R' {\n\t\t\t\t\tr++\n\t\t\t\t\tbreak\n\t\t\t\t} else if c == 'B' {\n\t\t\t\t\tb++\n\t\t\t\t\tbreak\n\t\t\t\t} else if c == 'Y' {\n\t\t\t\t\ty++\n\t\t\t\t\tbreak\n\t\t\t\t} else if c == 'G' {\n\t\t\t\t\tg++\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(r, b, y, g)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\t\n\tS := io.NextLine()\n\n\tdead := make([]int, 4)\n\tindex := make([]int, 256)\n\tfor i, c := range S {\n\t\tif c == '!' {\n\t\t\tdead[i % 4]++\n\t\t} else {\n\t\t\tindex[c] = i % 4\n\t\t}\n\t}\n\tio.Printf(\"%d %d %d %d\\n\", dead[index['R']], dead[index['B']], dead[index['Y']], dead[index['G']])\n\t\n\tio.FlushOutput()\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif (c == '-') {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif (c == '-') {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"strconv\"\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tS := sc.NextLine()\n\tcolor := map[int]rune{}\n\n\tfor i, v := range S {\n\t\tif v == '!' {\n\t\t\tcontinue\n\t\t}\n\t\tcolor[i % 4] = v\n\t}\n\tans := map[rune]int{}\n\n\tfor i, v := range S {\n\t\tif v == '!' {\n\t\t\tans[color[i % 4]]++\n\t\t}\n\t}\n\tfmt.Println(ans['R'], ans['B'], ans['Y'], ans['G'])\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r:rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf) + 1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf) + 1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\nimport (\n\t\"fmt\"\n)\n\n\nfunc main() {\n\tvar bulbs string\n\tfmt.Scanln(&bulbs)\n\n\tr, b, y, g := 0, 0, 0, 0\n\n\tlen_bulbs := len(bulbs)\n\n\tfor i := 0; i < len_bulbs; i++ {\n\t\tif bulbs[i] == '!' {\n\t\t\tfor j := i % 4; j < len_bulbs; j = j + 4 {\n\t\t\t\tswitch bulbs[j] {\n\t\t\t\t\tcase 'R':\n\t\t\t\t\t\tr++\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'B':\n\t\t\t\t\t\tb++\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'Y':\n\t\t\t\t\t\ty++\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'G':\n\t\t\t\t\t\tg++\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(r, b, y, g)\n}\n"}], "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33"} {"nl": {"description": "You are given an array a consisting of n integers, and additionally an integer m. You have to choose some sequence of indices b1, b2, ..., bk (1 ≤ b1 < b2 < ... < bk ≤ n) in such a way that the value of is maximized. Chosen sequence can be empty.Print the maximum possible value of .", "input_spec": "The first line contains two integers n and m (1 ≤ n ≤ 35, 1 ≤ m ≤ 109). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109).", "output_spec": "Print the maximum possible value of .", "sample_inputs": ["4 4\n5 2 4 1", "3 20\n199 41 299"], "sample_outputs": ["3", "19"], "notes": "NoteIn the first example you can choose a sequence b = {1, 2}, so the sum is equal to 7 (and that's 3 after taking it modulo 4).In the second example you can choose a sequence b = {3}."}, "positive_code": [{"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 CF888E(_r io.Reader, out io.Writer) {\n\tmax := func(a, b int) int {\n\t\tif a > b {\n\t\t\treturn a\n\t\t}\n\t\treturn b\n\t}\n\tin := bufio.NewReader(_r)\n\tvar n, m, ans int\n\tFscan(in, &n, &m)\n\ta := make([]int64, n)\n\tfor i := range a {\n\t\tFscan(in, &a[i])\n\t}\n\n\tb := a[:(n+1)/2]\n\tf := func(i int) int {\n\t\ts := int64(0)\n\t\tfor j, v := range b {\n\t\t\tif i>>j&1 > 0 {\n\t\t\t\ts += v\n\t\t\t}\n\t\t}\n\t\treturn int(s % int64(m))\n\t}\n\tx := []int{}\n\tfor i := 0; i < 1< 0 {\n\t\t\tans = max(ans, s+x[j-1])\n\t\t}\n\t}\n\tFprint(out, ans)\n}\n\nfunc main() { CF888E(os.Stdin, os.Stdout) }\n"}], "negative_code": [], "src_uid": "d3a8a3e69a55936ee33aedd66e5b7f4a"} {"nl": {"description": "The only difference between the easy and the hard versions is constraints.A subsequence is a string that can be derived from another string by deleting some or no symbols without changing the order of the remaining symbols. Characters to be deleted are not required to go successively, there can be any gaps between them. For example, for the string \"abaca\" the following strings are subsequences: \"abaca\", \"aba\", \"aaa\", \"a\" and \"\" (empty string). But the following strings are not subsequences: \"aabaca\", \"cb\" and \"bcaa\".You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.In one move you can take any subsequence $$$t$$$ of the given string and add it to the set $$$S$$$. The set $$$S$$$ can't contain duplicates. This move costs $$$n - |t|$$$, where $$$|t|$$$ is the length of the added subsequence (i.e. the price equals to the number of the deleted characters).Your task is to find out the minimum possible total cost to obtain a set $$$S$$$ of size $$$k$$$ or report that it is impossible to do so.", "input_spec": "The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le n, k \\le 100$$$) — the length of the string and the size of the set, correspondingly. The second line of the input contains a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.", "output_spec": "Print one integer — if it is impossible to obtain the set $$$S$$$ of size $$$k$$$, print -1. Otherwise, print the minimum possible total cost to do it.", "sample_inputs": ["4 5\nasdf", "5 6\naaaaa", "5 7\naaaaa", "10 100\najihiushda"], "sample_outputs": ["4", "15", "-1", "233"], "notes": "NoteIn the first example we can generate $$$S$$$ = { \"asdf\", \"asd\", \"adf\", \"asf\", \"sdf\" }. The cost of the first element in $$$S$$$ is $$$0$$$ and the cost of the others is $$$1$$$. So the total cost of $$$S$$$ is $$$4$$$."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF1183H(_r io.Reader, _w io.Writer) {\n\tvar n int\n\tvar k, ans int64\n\tvar s []byte\n\tFscan(bufio.NewReader(_r), &n, &k, &s)\n\tprev := [26]int{}\n\tdp := make([][]int64, n+1)\n\tfor i := range dp {\n\t\tdp[i] = make([]int64, n+1)\n\t}\n\tdp[0][0] = 1\n\tfor i := 1; i <= n; i++ {\n\t\tc := s[i-1] - 'a'\n\t\tdp[i][0] = 1\n\t\tfor j := 1; j <= i; j++ {\n\t\t\tdp[i][j] = dp[i-1][j] + dp[i-1][j-1]\n\t\t\tif p := prev[c]; p > 0 {\n\t\t\t\tdp[i][j] -= dp[p-1][j-1]\n\t\t\t}\n\t\t}\n\t\tprev[c] = i\n\t}\n\tk--\n\tfor l := n - 1; l >= 0; l-- {\n\t\tcnt := dp[n][l]\n\t\tif cnt > k {\n\t\t\tans += int64(n-l) * k\n\t\t\tk = 0\n\t\t\tbreak\n\t\t}\n\t\tk -= cnt\n\t\tans += int64(n-l) * cnt\n\t}\n\tif k > 0 {\n\t\tans = -1\n\t}\n\tFprint(_w, ans)\n}\n\nfunc main() { CF1183H(os.Stdin, os.Stdout) }\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF1183H(_r io.Reader, _w io.Writer) {\n\tvar n int\n\tvar k, ans int64\n\tvar s []byte\n\tFscan(bufio.NewReader(_r), &n, &k, &s)\n\tprev := [26]int{}\n\tdp := make([][]int64, n+1)\n\tfor i := range dp {\n\t\tdp[i] = make([]int64, n+1)\n\t}\n\tdp[0][0] = 1\n\tfor i := 1; i <= n; i++ {\n\t\tc := s[i-1] - 'a'\n\t\tdp[i][0] = 1\n\t\tfor j := 1; j <= i; j++ {\n\t\t\tdp[i][j] = dp[i-1][j] + dp[i-1][j-1]\n\t\t\tif p := prev[c]; p > 0 {\n\t\t\t\tdp[i][j] -= dp[p-1][j-1]\n\t\t\t}\n\t\t}\n\t\tprev[c] = i\n\t}\n\tk--\n\tfor l := n - 1; l >= 0; l-- {\n\t\tcnt := dp[n][l]\n\t\tif cnt > k {\n\t\t\tans += int64(n-l) * k\n\t\t\tk = 0\n\t\t\tbreak\n\t\t}\n\t\tk -= cnt\n\t\tans += int64(n-l) * cnt\n\t}\n\tif k > 0 {\n\t\tans = -1\n\t}\n\tFprint(_w, ans)\n}\n\nfunc main() { CF1183H(os.Stdin, os.Stdout) }\n"}], "negative_code": [], "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b"} {"nl": {"description": "You are given an array of positive integers a1, a2, ..., an × T of length n × T. We know that for any i > n it is true that ai = ai - n. Find the length of the longest non-decreasing sequence of the given array.", "input_spec": "The first line contains two space-separated integers: n, T (1 ≤ n ≤ 100, 1 ≤ T ≤ 107). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 300).", "output_spec": "Print a single number — the length of a sought sequence.", "sample_inputs": ["4 3\n3 1 4 2"], "sample_outputs": ["5"], "notes": "NoteThe array given in the sample looks like that: 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2. The elements in bold form the largest non-decreasing subsequence. "}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"sort\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF582B(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tvar n, t, d int\n\tFscan(in, &n, &t)\n\ta := make([]int, n)\n\tfor i := range a {\n\t\tFscan(in, &a[i])\n\t}\n\tdp := []int{}\n\tfor i := 0; i < 110 && t > 0; i++ {\n\t\tt--\n\t\tcur := len(dp)\n\t\tfor _, v := range a {\n\t\t\tif p := sort.SearchInts(dp, v+1); p < len(dp) {\n\t\t\t\tdp[p] = v\n\t\t\t} else {\n\t\t\t\tdp = append(dp, v)\n\t\t\t}\n\t\t}\n\t\td = len(dp) - cur\n\t\tcur = len(dp)\n\t}\n\tif t == 0 {\n\t\tFprint(out, len(dp))\n\t\treturn\n\t}\n\tFprintln(out, len(dp)+t*d)\n}\n\nfunc main() { CF582B(os.Stdin, os.Stdout) }\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"sort\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF582B(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tvar n, t, d int\n\tFscan(in, &n, &t)\n\ta := make([]int, n)\n\tfor i := range a {\n\t\tFscan(in, &a[i])\n\t}\n\tdp := []int{}\n\tfor i := 0; i < n+10 && t > 0; i++ {\n\t\tt--\n\t\tcur := len(dp)\n\t\tfor _, v := range a {\n\t\t\tif p := sort.SearchInts(dp, v+1); p < len(dp) {\n\t\t\t\tdp[p] = v\n\t\t\t} else {\n\t\t\t\tdp = append(dp, v)\n\t\t\t}\n\t\t}\n\t\td = len(dp) - cur\n\t\tcur = len(dp)\n\t}\n\tif t == 0 {\n\t\tFprint(out, len(dp))\n\t\treturn\n\t}\n\tFprintln(out, len(dp)+t*d)\n}\n\nfunc main() { CF582B(os.Stdin, os.Stdout) }\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"sort\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF582B(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tvar n, t, d int\n\tFscan(in, &n, &t)\n\ta := make([]int, n)\n\tfor i := range a {\n\t\tFscan(in, &a[i])\n\t}\n\tdp := []int{}\n\tfor i := 0; i < 310 && t > 0; i++ {\n\t\tt--\n\t\tcur := len(dp)\n\t\tfor _, v := range a {\n\t\t\tif p := sort.SearchInts(dp, v+1); p < len(dp) {\n\t\t\t\tdp[p] = v\n\t\t\t} else {\n\t\t\t\tdp = append(dp, v)\n\t\t\t}\n\t\t}\n\t\td = len(dp) - cur\n\t\tcur = len(dp)\n\t}\n\tif t == 0 {\n\t\tFprint(out, len(dp))\n\t\treturn\n\t}\n\tFprintln(out, len(dp)+t*d)\n}\n\nfunc main() { CF582B(os.Stdin, os.Stdout) }\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"sort\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF582B(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tvar n, t int\n\tFscan(in, &n, &t)\n\ta := make([]int, n)\n\tfor i := range a {\n\t\tFscan(in, &a[i])\n\t}\n\tdp := []int{}\n\tf := func() {\n\t\tfor _, v := range a {\n\t\t\tif i := sort.SearchInts(dp, v+1); i < len(dp) {\n\t\t\t\tdp[i] = v\n\t\t\t} else {\n\t\t\t\tdp = append(dp, v)\n\t\t\t}\n\t\t}\n\t}\n\tf()\n\tif t == 1 {\n\t\tFprint(out, len(dp))\n\t\treturn\n\t}\n\tf()\n\tFprint(out, len(dp)+t-2)\n}\n\nfunc main() { CF582B(os.Stdin, os.Stdout) }\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"sort\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF582B(_r io.Reader, _w io.Writer) {\n\tin := bufio.NewReader(_r)\n\tout := bufio.NewWriter(_w)\n\tdefer out.Flush()\n\n\tvar n, t, d int\n\tFscan(in, &n, &t)\n\ta := make([]int, n)\n\tfor i := range a {\n\t\tFscan(in, &a[i])\n\t}\n\tdp := []int{}\n\tf := func() {\n\t\tfor _, v := range a {\n\t\t\tif i := sort.SearchInts(dp, v+1); i < len(dp) {\n\t\t\t\tdp[i] = v\n\t\t\t} else {\n\t\t\t\tdp = append(dp, v)\n\t\t\t}\n\t\t}\n\t}\n\tfor i := 0; i < 5 && t > 0; i++ {\n\t\tt--\n\t\tcur := len(dp)\n\t\tf()\n\t\td = len(dp) - cur\n\t\tcur = len(dp)\n\t}\n\tif t == 0 {\n\t\tFprint(out, len(dp))\n\t\treturn\n\t}\n\tFprintln(out, len(dp)+t*d)\n}\n\nfunc main() { CF582B(os.Stdin, os.Stdout) }\n"}], "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2"} {"nl": {"description": "Given 2 integers $$$u$$$ and $$$v$$$, find the shortest array such that bitwise-xor of its elements is $$$u$$$, and the sum of its elements is $$$v$$$.", "input_spec": "The only line contains 2 integers $$$u$$$ and $$$v$$$ $$$(0 \\le u,v \\le 10^{18})$$$.", "output_spec": "If there's no array that satisfies the condition, print \"-1\". Otherwise: The first line should contain one integer, $$$n$$$, representing the length of the desired array. The next line should contain $$$n$$$ positive integers, the array itself. If there are multiple possible answers, print any.", "sample_inputs": ["2 4", "1 3", "8 5", "0 0"], "sample_outputs": ["2\n3 1", "3\n1 1 1", "-1", "0"], "notes": "NoteIn the first sample, $$$3\\oplus 1 = 2$$$ and $$$3 + 1 = 4$$$. There is no valid array of smaller length.Notice that in the fourth sample the array is empty."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar u, v uint64\n\tfmt.Scanf(\"%d %d\", &u, &v)\n\tres, found := solve(u, v)\n\tif !found {\n\t\tfmt.Println(-1)\n\t} else {\n\t\tfmt.Println(len(res))\n\t\tfor i := 0; i < len(res); i++ {\n\t\t\tfmt.Printf(\"%d \", res[i])\n\t\t}\n\t}\n}\n\nfunc solve(u uint64, v uint64) ([]uint64, bool) {\n\tif u > v || u&1 != v&1 {\n\t\treturn nil, false\n\t}\n\n\tif u == 0 && v == 0 {\n\t\treturn nil, true\n\t}\n\n\tif u == v {\n\t\treturn []uint64{u}, true\n\t}\n\n\tx := (v - u) >> 1\n\t// u, x, x is an answer with length 3\n\tfor i := 0; i < 63; i++ {\n\t\tif (x>>i)&1 == 1 {\n\t\t\tif (u>>i)&1 == 1 {\n\t\t\t\t// can' be true\n\t\t\t\treturn []uint64{u, x, x}, true\n\t\t\t}\n\t\t}\n\t}\n\n\treturn []uint64{u + x, x}, true\n}\n"}, {"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}\nfunc NextInt64() int64 {\n\tbytes := NextBytes()\n\ti, err := Atoi64(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 Atoi64(b []byte) (int64, 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\tvar n int64\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 + int64(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 reverseInts(a []int) {\n\tfor l, r := 0, len(a)-1; l < r; l, r = l+1, r-1 {\n\t\ta[l], a[r] = a[r], a[l]\n\t}\n}\n\nfunc unique(a []int) int {\n\tnewLen := 0\n\tn := len(a)\n\tfor i := 0; i < n; i++ {\n\t\tif newLen == 0 || a[i] != a[newLen-1] {\n\t\t\ta[newLen] = a[i]\n\t\t\tnewLen++\n\t\t}\n\t}\n\treturn newLen\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc 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\tu := NextInt64()\n\tv := NextInt64()\n\tMAXP := 63\n\tMAXC := 100\n\ta := make([]int, MAXP)\n\tb := make([]int, MAXP)\n\n\t// u = 1000000000000000000\n\t// v = 1000000000000000000\n\n\tfor i := 0; i < MAXP; i++ {\n\t\ta[i] = int(u & 1)\n\t\tb[i] = int(v & 1)\n\t\tu >>= 1\n\t\tv >>= 1\n\t}\n\n\tdp := make([][]int, MAXP)\n\tp := make([][][3]int, MAXP)\n\tfor i := 0; i < MAXP; i++ {\n\t\tdp[i] = make([]int, MAXC)\n\t\tp[i] = make([][3]int, MAXC)\n\t\tfor j := 0; j < MAXC; j++ {\n\t\t\tdp[i][j] = -1\n\t\t}\n\t}\n\n\tMAXINT := 1000000000\n\n\tvar f func(i, carry int) int\n\tf = func(i, carry int) int {\n\n\t\tif i == -1 {\n\t\t\tif carry == 0 {\n\t\t\t\treturn 0\n\t\t\t} else {\n\t\t\t\treturn MAXINT\n\t\t\t}\n\t\t}\n\n\t\tif dp[i][carry] != -1 {\n\t\t\treturn dp[i][carry]\n\t\t}\n\n\t\tres := MAXINT\n\t\tresk1, resc := -1, -1\n\n\t\tfor k1 := 0; k1 < MAXC*2; k1++ {\n\t\t\tif (k1 >> 1) > carry {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (k1 & 1) != a[i] {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor ncarry := 0; ncarry < MAXC; ncarry++ {\n\t\t\t\tif ((k1 + ncarry) >> 1) > carry {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif ((k1+ncarry)>>1) == carry && ((k1+ncarry)&1) == b[i] {\n\t\t\t\t\tt := max(k1, f(i-1, ncarry))\n\t\t\t\t\tif t < res {\n\t\t\t\t\t\tres = t\n\t\t\t\t\t\tresk1 = k1\n\t\t\t\t\t\tresc = ncarry\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdp[i][carry] = res\n\t\tp[i][carry][1] = resk1\n\t\tp[i][carry][2] = resc\n\t\treturn res\n\t}\n\n\tres := f(MAXP-1, 0)\n\tif res == MAXINT {\n\t\tfmt.Fprintln(out, -1)\n\t\treturn\n\t}\n\n\tfmt.Fprintln(out, res)\n\n\tans := make([]int64, res)\n\n\tfor i, carry, j := MAXP-1, 0, 0; i >= 0; i-- {\n\t\tncarry := p[i][carry][2]\n\t\tk1 := p[i][carry][1]\n\t\tfor k1 > 0 {\n\t\t\tans[j] |= (int64(1) << uint(i))\n\t\t\tj++\n\t\t\tif j == res {\n\t\t\t\tj = 0\n\t\t\t}\n\t\t\tk1--\n\t\t}\n\t\tcarry = ncarry\n\t}\n\n\tfor i := 0; i < res; i++ {\n\t\tfmt.Fprint(out, ans[i], \" \")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar u,v int64\n\tfmt.Scanf(\"%d %d\\n\", &u, &v)\n\tif u > v {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\tif u == v {\n\t\tif u == 0 {\n\t\t\tfmt.Println(0)\n\t\t\treturn\n\t\t} else {\n\t\t\tfmt.Println(1)\n\t\t\tfmt.Println(u)\n\t\t\treturn\n\t\t}\n\t}\n\tif (v - u) % 2 != 0 {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\tc1 := u\n\tc2 := (v - u) / 2\n\tif (c1 + c2) ^ c2 == u {\n\t\tfmt.Println(2)\n\t\tfmt.Println(c2, c1+c2)\n\t} else {\n\t\tfmt.Println(3)\n\t\tfmt.Println(c2, c2, c1)\n\t}\n}\n\nfunc readLine(reader *bufio.Reader) []byte {\n\tresult := make([]byte, 0)\n\tfor {\n\t\ts, isPrefix, err := reader.ReadLine()\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"error=%+v\\n\", err)\n\t\t\tbreak\n\t\t}\n\t\tresult = append(result, s...)\n\t\tif !isPrefix {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn result\n}\n"}, {"source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/1325/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\tu, v int64\n)\n\nfunc main() {\n\tu, v = ReadInt64_2()\n\n\tif u == v && u == 0 {\n\t\tfmt.Println(0)\n\t\treturn\n\t}\n\n\tif u == v {\n\t\tfmt.Println(1)\n\t\tfmt.Println(u)\n\t\treturn\n\t}\n\n\tif u > v {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\n\tif u%2 != v%2 {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\n\tx := (v - u) / 2\n\tif x&u == 0 {\n\t\tfmt.Println(2)\n\t\tfmt.Println(u+x, x)\n\t} else {\n\t\tfmt.Println(3)\n\t\tfmt.Println(u, x, x)\n\t}\n}\n\n// NthBit returns nth bit value of an argument.\n// n starts from 0.\nfunc NthBit(num int64, nth int) int64 {\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 int64, nth int) int64 {\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 int64, nth int) int64 {\n\treturn num & ^(1 << uint(nth))\n}\n\n// PopCount returns the number of ON bit of an argument.\nfunc PopCount(num int64) 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/*******************************************************************/\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"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar u, v int64\n\tvar a [4]int64\n\tvar times int\n\tvar ll1 int64 = 1\n\tvar out string\n\tfmt.Scan(&u)\n\tfmt.Scan(&v)\n\t//u = 0\n\t//v = 0\n\n\tif u > v || ((u ^ v) & 1) != 0 {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\n\tfor i := 0; i < 63; i++ {\n\t\ttimes = 0\n\t\tif (u & (ll1 << i)) != 0 {\n\t\t\ttimes += 1\n\t\t\tu ^= ll1 << i\n\t\t\tv -= ll1 << i\n\t\t}\n\t\tif (u & (ll1 << (i + 1))) != (v & (ll1 << (i + 1))) {\n\t\t\ttimes += 2\n\t\t\tv -= ll1 << (i + 1)\n\t\t}\n\t\t\n\t\tfor j := 0; j < times; j++ {\n\t\t\ta[j] ^= ll1 << i\n\t\t}\n\t}\n\t\n\tfor i := 0; i < 4; i++ {\n\t\tif a[i] == 0 {\n\t\t\tout = strconv.Itoa(i) + \"\\n\" + out\n\t\t\tbreak\n\t\t}\n\t\tout += fmt.Sprintf(\"%v \", a[i])\n\t}\n\tfmt.Println(out)\n\t\n\treturn\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar u, v uint64\n\tfmt.Scanf(\"%d %d\", &u, &v)\n\n\tif !can(u, v) {\n\t\tfmt.Println(\"-1\")\n\t\treturn\n\t}\n\n\tif u == 0 && v == 0 {\n\t\tfmt.Println(\"0\")\n\t\treturn\n\t}\n\n\td := v - u\n\tcomp := d / 2\n\n\tif comp == 0 {\n\t\tfmt.Println(\"1\")\n\t\tfmt.Println(u)\n\t} else if (u & comp) == 0 {\n\t\tfmt.Println(\"2\")\n\t\tfmt.Printf(\"%d %d\\n\", u|comp, comp)\n\t} else {\n\t\tfmt.Println(\"3\")\n\t\tfmt.Printf(\"%d %d %d\\n\", u, comp, comp)\n\t}\n}\n\nfunc can(u, v uint64) bool {\n\tif (u > v) || ((v-u)%2) == 1 {\n\t\treturn false\n\t}\n\treturn true\n}\n"}, {"source_code": "package main\n\nimport (\n\t. \"fmt\"\n\t\"io\"\n\t\"os\"\n)\n\n// github.com/EndlessCheng/codeforces-go\nfunc CF1325D(in io.Reader, out io.Writer) {\n\tvar xor, sum int64\n\tFscan(in, &xor, &sum)\n\tif xor > sum || (sum-xor)&1 > 0 {\n\t\tFprint(out, -1)\n\t} else if xor == sum {\n\t\tif xor == 0 {\n\t\t\tFprint(out, 0)\n\t\t} else {\n\t\t\tFprint(out, \"1\\n\", xor)\n\t\t}\n\t} else if and := (sum - xor) / 2; and&xor > 0 {\n\t\tFprint(out, \"3\\n\", xor, and, and)\n\t} else {\n\t\tFprint(out, \"2\\n\", xor|and, and)\n\t}\n}\n\nfunc main() { CF1325D(os.Stdin, os.Stdout) }\n"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n \"fmt\"\n \"io\"\n \"os\"\n)\n\ntype BufferedWriter interface {\n Printf(format string, a ...interface{})\n Flush()\n}\n\ntype writerImpl struct {\n *bufio.Writer\n}\n\nfunc NewBufferedWriter(writer io.Writer) BufferedWriter {\n return &writerImpl{Writer: bufio.NewWriter(writer)}\n}\n\nfunc (impl *writerImpl) Printf(f string, a ...interface{}) {\n fmt.Fprintf(impl.Writer, f, a...)\n}\n\nfunc (impl *writerImpl) Flush() {\n impl.Writer.Flush()\n}\n\ntype WordScanner interface {\n NextInt() int\n NextInt64() int64\n NextString() string\n}\n\ntype wordScannerImpl struct {\n *bufio.Scanner\n}\n\nfunc NewWordScanner(reader io.Reader) WordScanner {\n s := bufio.NewScanner(reader)\n s.Split(bufio.ScanWords)\n return &wordScannerImpl{Scanner: s}\n}\n\nfunc (impl *wordScannerImpl) NextInt() int {\n impl.Scan()\n bb := impl.Bytes()\n i := 0\n for _, b := range bb {\n i *= 10\n i += int(b - '0')\n }\n return i\n}\n\nfunc (impl *wordScannerImpl) NextInt64() int64 {\n impl.Scan()\n bb := impl.Bytes()\n i := int64(0)\n for _, b := range bb {\n i *= 10\n i += int64(b - '0')\n }\n return i\n}\n\nfunc (impl *wordScannerImpl) NextString() string {\n impl.Scan()\n return impl.Text()\n}\n\nvar reader = NewWordScanner(os.Stdin)\nvar writer = NewBufferedWriter(os.Stdout)\n\nfunc main() {\n defer writer.Flush()\n u, v := reader.NextInt64(), reader.NextInt64()\n if u > v {\n writer.Printf(\"-1\\n\")\n return\n }\n if u == v {\n if u == 0 {\n writer.Printf(\"0\\n\")\n } else {\n writer.Printf(\"1\\n%d\\n\", u)\n }\n return\n }\n diff := v - u\n if diff % 2 == 1 {\n writer.Printf(\"-1\\n\")\n return\n }\n num := diff / 2\n if num & u == 0 {\n writer.Printf(\"2\\n%d %d\\n\", u | num, num)\n } else {\n writer.Printf(\"3\\n%d %d %d\\n\", u, num, num)\n }\n}\n"}], "negative_code": [{"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}\nfunc NextInt64() int64 {\n\tbytes := NextBytes()\n\ti, err := Atoi64(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 Atoi64(b []byte) (int64, 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\tvar n int64\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 + int64(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 reverseInts(a []int) {\n\tfor l, r := 0, len(a)-1; l < r; l, r = l+1, r-1 {\n\t\ta[l], a[r] = a[r], a[l]\n\t}\n}\n\nfunc unique(a []int) int {\n\tnewLen := 0\n\tn := len(a)\n\tfor i := 0; i < n; i++ {\n\t\tif newLen == 0 || a[i] != a[newLen-1] {\n\t\t\ta[newLen] = a[i]\n\t\t\tnewLen++\n\t\t}\n\t}\n\treturn newLen\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc 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\tu := NextInt64()\n\tv := NextInt64()\n\tMAXP := 63\n\tMAXC := 4\n\ta := make([]int, MAXP)\n\tb := make([]int, MAXP)\n\n\tfor i := 0; i < MAXP; i++ {\n\t\ta[i] = int(u & 1)\n\t\tb[i] = int(v & 1)\n\t\tu >>= 1\n\t\tv >>= 1\n\t}\n\n\tdp := make([][]int, MAXP)\n\tp := make([][][3]int, MAXP)\n\tfor i := 0; i < MAXP; i++ {\n\t\tdp[i] = make([]int, MAXC)\n\t\tp[i] = make([][3]int, MAXC)\n\t\tfor j := 0; j < MAXC; j++ {\n\t\t\tdp[i][j] = -1\n\t\t}\n\t}\n\n\tMAXINT := 1000000000\n\n\tvar f func(i, carry int) int\n\tf = func(i, carry int) int {\n\n\t\tif i == -1 {\n\t\t\tif carry == 0 {\n\t\t\t\treturn 0\n\t\t\t} else {\n\t\t\t\treturn MAXINT\n\t\t\t}\n\t\t}\n\n\t\tif dp[i][carry] != -1 {\n\t\t\treturn dp[i][carry]\n\t\t}\n\n\t\tres := MAXINT\n\t\tresk1, resc := -1, -1\n\n\t\tfor k1 := 0; k1 < MAXP*2; k1++ {\n\t\t\tif (k1 >> 1) > carry {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (k1 & 1) != a[i] {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor ncarry := 0; ncarry < MAXC; ncarry++ {\n\t\t\t\tif ((k1 + ncarry) >> 1) > carry {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif ((k1+ncarry)>>1) == carry && ((k1+ncarry)&1) == b[i] {\n\t\t\t\t\tt := max(k1, f(i-1, ncarry))\n\t\t\t\t\tif t < res {\n\t\t\t\t\t\tres = t\n\t\t\t\t\t\tresk1 = k1\n\t\t\t\t\t\tresc = ncarry\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdp[i][carry] = res\n\t\tp[i][carry][1] = resk1\n\t\tp[i][carry][2] = resc\n\t\treturn res\n\t}\n\n\tres := f(MAXP-1, 0)\n\tif res == MAXINT {\n\t\tfmt.Fprintln(out, -1)\n\t\treturn\n\t}\n\n\tfmt.Fprintln(out, res)\n\n\tans := make([]int, res)\n\n\tfor i, carry, j := MAXP-1, 0, 0; i >= 0; i-- {\n\t\tncarry := p[i][carry][2]\n\t\tk1 := p[i][carry][1]\n\t\tfor k1 > 0 {\n\t\t\tans[j] |= (1 << uint(i))\n\t\t\tj++\n\t\t\tif j == res {\n\t\t\t\tj = 0\n\t\t\t}\n\t\t\tk1--\n\t\t}\n\t\tcarry = ncarry\n\t}\n\n\tfor i := 0; i < res; i++ {\n\t\tfmt.Fprint(out, ans[i], \" \")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar u,v int64\n\tfmt.Scanf(\"%d %d\\n\", &u, &v)\n\tif u > v {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\tif u == v {\n\t\tif u == 0 {\n\t\t\tfmt.Println(0)\n\t\t\treturn\n\t\t} else {\n\t\t\tfmt.Println(1)\n\t\t\tfmt.Println(u)\n\t\t}\n\t}\n\tif (v - u) % 2 != 0 {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\tc1 := u\n\tc2 := (v - u) / 2\n\tif (c1 + c2) ^ c2 == u {\n\t\tfmt.Println(2)\n\t\tfmt.Println(c2, c1+c2)\n\t} else {\n\t\tfmt.Println(3)\n\t\tfmt.Println(c1, c2, c2)\n\t}\n}\n\nfunc readLine(reader *bufio.Reader) []byte {\n\tresult := make([]byte, 0)\n\tfor {\n\t\ts, isPrefix, err := reader.ReadLine()\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"error=%+v\\n\", err)\n\t\t\tbreak\n\t\t}\n\t\tresult = append(result, s...)\n\t\tif !isPrefix {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn result\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n)\n\nfunc main() {\n\tvar u, v int64\n\tvar a []int64\n\tvar ll1 int64 = 1\n\tfmt.Scan(&u)\n\tfmt.Scan(&v)\n\n\tif u > v || ((u ^ v) & 1) != 0 {\n\t\tfmt.Println(-1)\n\t\treturn\n\t}\n\tif u == 0 && v == 0 {\n\t\tfmt.Println(0)\n\t\treturn\n\t}\n\n\tfor i := 0; i < 63; i++ {\n\t\tlog.Printf(\"%v %v\", u, v)\n\t\tif (u & (ll1 << i)) != 0 {\n\t\t\ta = append(a, ll1 << i)\n\t\t\tu ^= ll1 << i\n\t\t\tv -= ll1 << i\n\t\t}\n\t\tif (u & (ll1 << (i + 1))) != (v & (ll1 << (i + 1))) {\n\t\t\ta = append(a, ll1 << i)\n\t\t\ta = append(a, ll1 << i)\n\t\t\tv -= ll1 << (i + 1)\n\t\t}\n\t}\n\t\n\tfmt.Println(len(a))\n\tfor i := 0; i < len(a); i++ {\n\t\tfmt.Printf(\"%v \", a[i])\n\t}\n\t\n\treturn\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar u, v uint64\n\tfmt.Scanf(\"%d %d\", &u, &v)\n\n\tif !can(u, v) {\n\t\tfmt.Println(\"-1\")\n\t\treturn\n\t}\n\n\td := v - u\n\tcomp := uint64(0)\n\tfor i := 0; i <= 64; i++ {\n\t\tif d%2 == 1 {\n\t\t\tcomp += uint64(1) << uint64(i-1)\n\t\t}\n\t\td /= 2\n\t}\n\n\tif comp == 0 {\n\t\tfmt.Println(\"1\")\n\t\tfmt.Println(u)\n\t} else if (u & comp) == 0 {\n\t\tfmt.Println(\"2\")\n\t\tfmt.Printf(\"%d %d\\n\", u|comp, comp)\n\t} else {\n\t\tfmt.Println(\"3\")\n\t\tfmt.Printf(\"%d %d %d\\n\", u, comp, comp)\n\t}\n}\n\nfunc can(u, v uint64) bool {\n\tif (u > v) || ((v-u)%2) == 1 {\n\t\treturn false\n\t}\n\treturn true\n}\n"}], "src_uid": "490f23ced6c43f9e12f1bcbecbb14904"} {"nl": {"description": "As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as , where k is some positive integer), and the coolest numbers are those that are representable as a sum of two triangular numbers.A well-known hipster Andrew adores everything funky and cool but unfortunately, he isn't good at maths. Given number n, help him define whether this number can be represented by a sum of two triangular numbers (not necessarily different)!", "input_spec": "The first input line contains an integer n (1 ≤ n ≤ 109).", "output_spec": "Print \"YES\" (without the quotes), if n can be represented as a sum of two triangular numbers, otherwise print \"NO\" (without the quotes).", "sample_inputs": ["256", "512"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first sample number .In the second sample number 512 can not be represented as a sum of two triangular numbers."}, "positive_code": [{"source_code": "package main\n\nimport \"os\"\nimport \"bufio\"\nimport \"math\"\nimport \"strconv\"\n\nfunc main(){\n\tvar n float64\n\tr := bufio.NewScanner(os.Stdin)\n\tr.Split(bufio.ScanWords)\n\tw := bufio.NewWriter(os.Stdout)\n\tr.Scan()\n\tn, _ = strconv.ParseFloat(r.Text(), 64)\n\ta := (-1+math.Sqrt(8*n-7))/2\n\tvar b float64\n\tvar j int64\n\tfor i:=1; float64(i)<=a; i++ {\n\t\tb = (math.Sqrt(1+8*n-4*float64(i)-4*float64(i)*float64(i))-1)/2\n\t\tj = int64(b) \n\t\tif float64(j) == b && j != 0 {\n\t\t\tw.WriteString(\"YES\\n\")\n\t\t\tw.Flush()\n\t\t\treturn\n\t\t}\n\t}\n\tw.WriteString(\"NO\\n\")\n\tw.Flush()\n\treturn\n}\n"}, {"source_code": "package main\n\nimport (\n \"os\"\n \"bufio\"\n \"strconv\"\n)\n\nfunc scanInt(scanner *bufio.Scanner) int {\n scanner.Scan()\n x, _ := strconv.Atoi(scanner.Text())\n return x\n}\n\nfunc main() {\n scanner := bufio.NewScanner(os.Stdin)\n scanner.Split(bufio.ScanWords)\n writer := bufio.NewWriter(os.Stdout)\n defer writer.Flush()\n\n triangular := map[int64]bool{}\n k := int64(0)\n for {\n k++\n x := k*(k+1)/2\n if x > 1000000000 {\n break\n }\n triangular[x] = true\n }\n\n n := int64(scanInt(scanner))\n for x := range triangular {\n _, found := triangular[n-x]\n if found {\n writer.WriteString(\"YES\\n\")\n return\n }\n }\n writer.WriteString(\"NO\\n\")\n}\n"}, {"source_code": "// 192A-ahalim,dikai,eric\npackage main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar i,n,m,k,l,p int64\n\tfmt.Scan(&n)\n\tif n==1 {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tl = int64(math.Sqrt(float64(n*2)))\n\tm = 0\n\tfor i=1;i<=l;i++{\n\t\tp = n-i*(i+1)/2\n\t\tk = int64((math.Sqrt(float64(8*p+1))-1)/2)\n\t\tif k > 0 {\n\t\t\tif k*(k+1)+i*(i+1)== 2*n{\n\t\t\t\tm =1\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tif m == 0{\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "//rextester.com:1.6.2--codeforces.com:1.7.3\npackage main\nimport(\"fmt\";\"math\")\nfunc main(){\n var a float64;fmt.Scan(&a);a*=2;b:=false\n for i:=1;i 0 && x*(x+1)+int64(i)*(int64(i)+1) == int64(n)*2 {\n\t\t\tfmt.Print(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Print(\"NO\")\n\treturn\n}\n"}, {"source_code": "// 192A-mic\npackage main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n, i, diff, f, c, sq float64\n\tflag := false\n\tfmt.Scan(&n)\n\tfor i = 1; (i * (i + 1)) < 2*n; i++ {\n\t\tdiff = 2*n - (i * (i + 1))\n\t\tsq = math.Sqrt(diff)\n\t\tf = math.Floor(sq)\n\t\tc = math.Ceil(sq)\n\t\tif f != c && f*c == diff {\n\t\t\tflag = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif flag {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n, i, j float64\n\tfmt.Scan(&n)\n\tfor i = 1; i*(i+1)/2 <= n; i++ {\n\t\tj = math.Sqrt(n*2 - i*(i+1))\n\t\tx := int64(j)\n\t\tif x > 0 && x*(x+1)+int64(i)*(int64(i)+1) == int64(n)*2 {\n\t\t\tfmt.Print(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Print(\"NO\")\n\treturn\n}\n"}], "negative_code": [{"source_code": "// 192A\npackage main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar n, i, j float64\n\tfmt.Scan(&n)\n\tfor i = 1; i*(i+1)/2 <= n; i++ {\n\t\tj = math.Sqrt(n*2 - i*(i+1))\n\t\tif j > 0 && j*(j+1)+i*(i+1) == n*2 {\n\t\t\tfmt.Print(\"YES\")\n\t\t\treturn\n\t\t}\n\t}\n\tfmt.Print(\"NO\")\n\treturn\n}\n"}], "src_uid": "245ec0831cd817714a4e5c531bffd099"} {"nl": {"description": "Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the program detects if the four given segments form a rectangle of a positive area and with sides parallel to coordinate axes. As Alex does badly at school and can't write this program by himself, he asks you to help him.", "input_spec": "The input data contain four lines. Each of these lines contains four integers x1, y1, x2, y2 ( - 109 ≤ x1, y1, x2, y2 ≤ 109) — coordinates of segment's beginning and end positions. The given segments can degenerate into points.", "output_spec": "Output the word «YES», if the given four segments form the required rectangle, otherwise output «NO».", "sample_inputs": ["1 1 6 1\n1 0 6 0\n6 0 6 1\n1 1 1 0", "0 0 0 3\n2 0 0 0\n2 2 2 0\n0 2 2 2"], "sample_outputs": ["YES", "NO"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport . \"fmt\"\n\ntype vec struct {\n\tx, y int64\n}\n\nfunc (a vec) less(b vec) bool { return a.x < b.x || a.x == b.x && a.y < b.y }\nfunc (a vec) sub(b vec) vec { return vec{a.x - b.x, a.y - b.y} }\nfunc (a vec) dot(b vec) int64 { return a.x*b.x + a.y*b.y }\nfunc isOrthogonal(a, b, c vec) bool { return a.sub(b).dot(c.sub(b)) == 0 }\nfunc isRectangle(a, b, c, d vec) bool { return isOrthogonal(a, b, c) && isOrthogonal(b, c, d) && isOrthogonal(c, d, a) }\nfunc isRectangleAnyOrder(a, b, c, d vec) bool { return isRectangle(a, b, c, d) || isRectangle(a, b, d, c) || isRectangle(a, c, b, d) }\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tmp := map[vec]int{}\n\tshown := map[vec]int{}\n\tfor i := 0; i < 4; i++ {\n\t\tvar x, y int64\n\t\tScan(&x, &y)\n\t\tp0 := vec{x, y}\n\t\tScan(&x, &y)\n\t\tp1 := vec{x, y}\n\t\tif v := p1.sub(p0); v.x != 0 && v.y != 0 {\n\t\t\tPrint(\"NO\")\n\t\t\treturn\n\t\t}\n\t\tmp[p0]++\n\t\tmp[p1]++\n\t\tif p1.less(p0) {\n\t\t\tp0, p1 = p1, p0\n\t\t}\n\t\tshown[p1.sub(p0)]++\n\t}\n\tfor _, v := range shown {\n\t\tif v != 2 {\n\t\t\tPrint(\"NO\")\n\t\t\treturn\n\t\t}\n\t}\n\tarr := []vec{}\n\tfor vec, v := range mp {\n\t\tif v != 2 {\n\t\t\tPrint(\"NO\")\n\t\t\treturn\n\t\t}\n\t\tarr = append(arr, vec)\n\t}\n\tif isRectangleAnyOrder(arr[0], arr[1], arr[2], arr[3]) {\n\t\tPrint(\"YES\")\n\t} else {\n\t\tPrint(\"NO\")\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport . \"fmt\"\n\ntype vec struct {\n\tx, y int64\n}\n\nfunc (a vec) sub(b vec) vec { return vec{a.x - b.x, a.y - b.y} }\nfunc (a vec) dot(b vec) int64 { return a.x*b.x + a.y*b.y }\nfunc isOrthogonal(a, b, c vec) bool { return a.sub(b).dot(c.sub(b)) == 0 }\nfunc isRectangle(a, b, c, d vec) bool { return isOrthogonal(a, b, c) && isOrthogonal(b, c, d) && isOrthogonal(c, d, a) }\nfunc isRectangleAnyOrder(a, b, c, d vec) bool { return isRectangle(a, b, c, d) || isRectangle(a, b, d, c) || isRectangle(a, c, b, d) }\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tmp := map[vec]int{}\n\tfor i := 0; i < 4; i++ {\n\t\tvar x, y int64\n\t\tScan(&x, &y)\n\t\tp0 := vec{x, y}\n\t\tScan(&x, &y)\n\t\tp1 := vec{x, y}\n\t\tv := p1.sub(p0)\n\t\tif v.x != 0 && v.y != 0 {\n\t\t\tPrint(\"NO\")\n\t\t\treturn\n\t\t}\n\t\tmp[p0]++\n\t\tmp[p1]++\n\t}\n\tarr := []vec{}\n\tfor vec, v := range mp {\n\t\tif v != 2 {\n\t\t\tPrint(\"NO\")\n\t\t\treturn\n\t\t}\n\t\tarr = append(arr, vec)\n\t}\n\tif isRectangleAnyOrder(arr[0], arr[1], arr[2], arr[3]) {\n\t\tPrint(\"YES\")\n\t} else {\n\t\tPrint(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport . \"fmt\"\n\ntype vec struct {\n\tx, y int64\n}\n\nfunc (a vec) sub(b vec) vec { return vec{a.x - b.x, a.y - b.y} }\nfunc (a vec) dot(b vec) int64 { return a.x*b.x + a.y*b.y }\nfunc isOrthogonal(a, b, c vec) bool { return a.sub(b).dot(c.sub(b)) == 0 }\nfunc isRectangle(a, b, c, d vec) bool { return isOrthogonal(a, b, c) && isOrthogonal(b, c, d) && isOrthogonal(c, d, a) }\nfunc isRectangleAnyOrder(a, b, c, d vec) bool { return isRectangle(a, b, c, d) || isRectangle(a, b, d, c) || isRectangle(a, c, b, d) }\n\n// github.com/EndlessCheng/codeforces-go\nfunc main() {\n\tmp := map[vec]int{}\n\tfor i := 0; i < 4; i++ {\n\t\tvar x, y int64\n\t\tScan(&x, &y)\n\t\tp0 := vec{x, y}\n\t\tScan(&x, &y)\n\t\tp1 := vec{x, y}\n\t\tmp[p0]++\n\t\tmp[p1]++\n\t}\n\tarr := []vec{}\n\tfor vec, v := range mp {\n\t\tif v != 2 {\n\t\t\tPrint(\"NO\")\n\t\t\treturn\n\t\t}\n\t\tarr = append(arr, vec)\n\t}\n\tif isRectangleAnyOrder(arr[0], arr[1], arr[2], arr[3]) {\n\t\tPrint(\"YES\")\n\t} else {\n\t\tPrint(\"NO\")\n\t}\n}\n"}], "src_uid": "ad105c08f63e9761fe90f69630628027"} {"nl": {"description": "Vasya has a pile, that consists of some number of stones. $$$n$$$ times he either took one stone from the pile or added one stone to the pile. The pile was non-empty before each operation of taking one stone from the pile.You are given $$$n$$$ operations which Vasya has made. Find the minimal possible number of stones that can be in the pile after making these operations.", "input_spec": "The first line contains one positive integer $$$n$$$ — the number of operations, that have been made by Vasya ($$$1 \\leq n \\leq 100$$$). The next line contains the string $$$s$$$, consisting of $$$n$$$ symbols, equal to \"-\" (without quotes) or \"+\" (without quotes). If Vasya took the stone on $$$i$$$-th operation, $$$s_i$$$ is equal to \"-\" (without quotes), if added, $$$s_i$$$ is equal to \"+\" (without quotes).", "output_spec": "Print one integer — the minimal possible number of stones that can be in the pile after these $$$n$$$ operations.", "sample_inputs": ["3\n---", "4\n++++", "2\n-+", "5\n++-++"], "sample_outputs": ["0", "4", "1", "3"], "notes": "NoteIn the first test, if Vasya had $$$3$$$ stones in the pile at the beginning, after making operations the number of stones will be equal to $$$0$$$. It is impossible to have less number of piles, so the answer is $$$0$$$. Please notice, that the number of stones at the beginning can't be less, than $$$3$$$, because in this case, Vasya won't be able to take a stone on some operation (the pile will be empty).In the second test, if Vasya had $$$0$$$ stones in the pile at the beginning, after making operations the number of stones will be equal to $$$4$$$. It is impossible to have less number of piles because after making $$$4$$$ operations the number of stones in the pile increases on $$$4$$$ stones. So, the answer is $$$4$$$.In the third test, if Vasya had $$$1$$$ stone in the pile at the beginning, after making operations the number of stones will be equal to $$$1$$$. It can be proved, that it is impossible to have less number of stones after making the operations.In the fourth test, if Vasya had $$$0$$$ stones in the pile at the beginning, after making operations the number of stones will be equal to $$$3$$$."}, "positive_code": [{"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}\nfunc max(a,b int) int {\n\tif(a < b){\n\t\treturn b\n\t}else{\n\t\treturn a\n\t}\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar s string\n\tfmt.Scan(&s)\n\tans := 100\n\tfor i := 0 ;i <= 100 ;i ++{\n\t\tt := i\n\t\tcheck := true\n\tfor index,_ := range s{\n\t\tif(string(s[index]) == \"+\"){\n\t\t\tt ++\n\t\t}else{\n\t\t\t\tt --;\n\t\t\t\tif(t <= -1){\n\t\t\t\tcheck = false\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t}\n\t}\n\tif(check){\n\n\t\tans = min(t,ans)\n\t}\n\t}\n\tfmt.Print(ans)\n\n\n\n}\n"}, {"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}\nfunc max(a,b int) int {\n\tif(a < b){\n\t\treturn b\n\t}else{\n\t\treturn a\n\t}\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar s string\n\tfmt.Scan(&s)\n\tans := 0\n\tfor i,_ := range s{\n\t\t\tif(string(s[i]) == \"+\"){\n\t\t\t\tans ++\n\t\t\t}else{\n\t\t\t\t\tif(ans >= 1){\n\t\t\t\t\t\tans --\n\t\t\t\t\t}\n\t\t\t}\n\t}\n\tfmt.Println(ans)\n\n\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int32\n\tvar str string\n\tfmt.Scanf(\"%d\\n\",&n)\n\tfmt.Scanf(\"%s\\n\",&str)\n\tans:=0\n\tfor _,c:=range str{\n\t\tif c=='+'{\n\t\t\tans++\n\t\t}else if c=='-'{\n\t\t\tif ans>0{\n\t\t\t\tans--\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}"}, {"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 d int\n\tscanf(\"%d\\n\", &d)\n\tvar s string\n\tscanf(\"%s\", &s)\n\tsa := []byte(s)\n\tcur := 0\n\tfor _, c := range sa {\n\t\tif c == '-' {\n\t\t\tcur--\n\t\t} else {\n\t\t\tcur++\n\t\t}\n\t\tif cur < 0 {\n\t\t\tcur = 0\n\t\t}\n\t}\n\n\tprintf(\"%d\", cur)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar nStr string\n\tfmt.Scanln(&nStr)\n\tn, _ := strconv.Atoi(nStr)\n\n\tvar pattern string\n\tfmt.Scanln(&pattern)\n\n\tct := 0\n\tminSeen := 0\n\tfor i := 0; i < n; i++ {\n\t\tif pattern[i] == '+' {\n\t\t\tct++\n\t\t} else if pattern[i] == '-' {\n\t\t\tct--\n\t\t}\n\t\tif ct < minSeen {\n\t\t\tminSeen = ct\n\t\t}\n\t}\n\tfmt.Println(ct - minSeen)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tn := 0\n\tfmt.Scan(&n)\n\ts := \"\"\n\tfmt.Scan(&s)\n\tans := 0\n\tfor _, char := range(s) {\n\t\tif char == rune('+') {\n\t\t\tans = ans + 1\n\t\t} else if char == rune('-') {\n\t\t\tif ans != 0 {\n\t\t\t\tans = ans - 1\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}"}, {"source_code": "\npackage main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\nfunc readLine()(string,error) \t\t\t{ return reader.ReadString('\\n') }\n\nfunc main() {\n\tdefer writer.Flush()\n\tvar t,s string\n\tscanf(\"%s\\n%s\", &t, &s);\n\tc := 0\n\tfor _, i := range s {\n\t\tif i == '-' {\n\t\t\tif c > 0 {\n\t\t\t\tc--\n\t\t\t}\n\t\t}\n\t\tif i == '+' {\n\t\t\tc++\n\t\t}\n\t}\n\tfmt.Println(c)\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc min(x int, y int) int {\n\tif x < y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc Solve(n int, s string) int {\n\trollingSum := 0\n\tlowestRollingSum := 0\n\tfor _, elem := range s {\n\t\tif string(elem) == \"-\" {\n\t\t\trollingSum -= 1\n\t\t} else if string(elem) == \"+\" {\n\t\t\trollingSum += 1\n\t\t}\n\t\tlowestRollingSum = min(lowestRollingSum, rollingSum)\n\t}\n\treturn -1*lowestRollingSum + rollingSum\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\n\tvar n int\n\tvar s string\n\tfmt.Fscanf(reader, \"%d\\n\", &n)\n\tfmt.Fscanf(reader, \"%s\\n\", &s)\n\tfmt.Fprintf(writer, \"%d\\n\", Solve(n, s))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc min(a , b int)int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main(){\n\tvar n int\n\tfmt.Scan(&n)\n\tvar s string\n\tfmt.Scan(&s)\n\tans := n\n\tvar i int\n\tvar temp int\n\n\n\tfor i = 0 ; i <= 100;i++{\n\t\ttemp = i\n\t\tfor _, char := range (s){\n\t\t\tif(char =='+'){\n\t\t\t\ttemp ++\n\t\t\t}\n\t\t\tif(char =='-'){\n\t\t\t\ttemp --\n\t\t\t\tif(temp <= -1){\n\t\t\t\ttemp = -1\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(temp >= 0){\n\t\t\tans = min(ans,temp)\n\t\t}\n\t}\n\tfmt.Print(ans)\n\n}\n"}], "negative_code": [{"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}\nfunc max(a,b int) int {\n\tif(a < b){\n\t\treturn b\n\t}else{\n\t\treturn a\n\t}\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\ts := ReadStr()\n\tans := 0\n\tfor index,_ := range s{\n\t\tif(string(s[index]) == \"+\"){\n\t\t\tans ++\n\t\t}else{\n\t\t\t\tans --;\n\t\t}\n\n\t}\n\tfmt.Print(max(ans,0))\n\n\n\n}\n"}, {"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}\nfunc max(a,b int) int {\n\tif(a < b){\n\t\treturn b\n\t}else{\n\t\treturn a\n\t}\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar s string\n\tfmt.Scan(&s)\n\tvar ans int\n\tfor index,_ := range s{\n\t\tif(string(s[index]) == \"+\"){\n\t\t\tans ++\n\t\t}else{\n\t\t\t\tans --;\n\t\t}\n\n\t}\n\tfmt.Print(max(ans,0))\n\n\n\n}\n"}, {"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}\nfunc max(a,b int) int {\n\tif(a < b){\n\t\treturn b\n\t}else{\n\t\treturn a\n\t}\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\ts := ReadStr()\n\tans := 0\n\tfor _,i := range s{\n\t\tif(string(i) == \"+\"){\n\t\t\tans ++\n\t\t}else{\n\t\t\t\tans --;\n\t\t}\n\n\t}\n\tfmt.Println(max(ans,0))\n\n\n\n}\n"}, {"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 int\n\tfmt.Scan(&n)\n\ts := ReadStr()\n\tans := 100\n\tfor i := 0 ; i <= 100;i++{\n\t\tt := i\n\t\tyes := true\n\t\tfor _,i := range s{\n\t\t\tif(string(i) == \"-\"){\n\t\t\t\tt --;\n\t\t\t\tif(t <= -1){\n\t\t\t\t\tyes = false\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tt ++\n\t\t\t}\n\t\t}\n\t\tif(yes){\n\t\t\tans = min(ans,t)\n\t\t}\n\t}\n\tfmt.Println(ans)\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int32\n\tvar str string\n\tfmt.Scanf(\"%d\\n\",&n)\n\tfmt.Scanf(\"%s\\n\",&str)\n\tfmt.Println(n)\n\tfmt.Println(str)\n\tans:=0\n\tfor _,c:=range str{\n\t\tif c=='+'{\n\t\t\tans++\n\t\t}else if c=='-'{\n\t\t\tif ans>0{\n\t\t\t\tans--\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int32\n\tvar str string\n\tfmt.Scanf(\"%d\",&n)\n\tfmt.Scanf(\"%s\",&str)\n\tans:=0\n\tfor _,c:=range str{\n\t\tif c=='+'{\n\t\t\tans++\n\t\t}else if c=='-'{\n\t\t\tif ans>0{\n\t\t\t\tans--\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int32\n\tvar str string\n\tfmt.Scanf(\"%d\",&n)\n\tfmt.Scanf(\"%s\",&str)\n\tfmt.Println(n)\n\tfmt.Println(str)\n\tans:=0\n\tfor _,c:=range str{\n\t\tif c=='+'{\n\t\t\tans++\n\t\t}else if c=='-'{\n\t\t\tif ans>0{\n\t\t\t\tans--\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int64\n\tvar str string\n\tfmt.Scanf(\"%d\",&n)\n\tfmt.Scanf(\"%s\",&str)\n\tans:=0\n\tfor _,c:=range str{\n\t\tif c=='+'{\n\t\t\tans++\n\t\t}else{\n\t\t\tif ans>0{\n\t\t\t\tans--\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(ans)\n}"}, {"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\tnStr, _ := reader.ReadString('\\n')\n\tnStr = strings.TrimSuffix(nStr, \"\\n\")\n\tn, _ := strconv.Atoi(nStr)\n\tpattern, _ := reader.ReadString('\\n')\n\n\tct := 0\n\tminSeen := 0\n\tfor i := 0; i < n; i++ {\n\t\tif pattern[i] == '+' {\n\t\t\tct++\n\t\t} else if pattern[i] == '-' {\n\t\t\tct--\n\t\t}\n\t\tif minSeen > ct {\n\t\t\tminSeen = ct\n\t\t}\n\t}\n\n\tfmt.Println(ct - minSeen)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc readline(reader *bufio.Reader) string {\n\tstr, _ := reader.ReadString('\\n')\n\treturn strings.TrimSuffix(str, \"\\n\")\n}\n\nfunc readInt(reader *bufio.Reader) int {\n\tstr := readline(reader)\n\tn, _ := strconv.Atoi(str)\n\treturn n\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tn := readInt(reader)\n\tpattern := readline(reader)\n\n\tct := 0\n\tminSeen := 0\n\tfor i := 0; i < n; i++ {\n\t\tif pattern[i] == '+' {\n\t\t\tct++\n\t\t} else if pattern[i] == '-' {\n\t\t\tct--\n\t\t}\n\t\tif ct < minSeen {\n\t\t\tminSeen = ct\n\t\t}\n\t}\n\tfmt.Println(ct, minSeen)\n\tfmt.Println(ct - minSeen)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc readline(reader *bufio.Reader) string {\n\tstr, _ := reader.ReadString('\\n')\n\treturn strings.TrimSuffix(str, \"\\n\")\n}\n\nfunc readInt(reader *bufio.Reader) int {\n\tstr := readline(reader)\n\tn, _ := strconv.Atoi(str)\n\treturn n\n}\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tn := readInt(reader)\n\tpattern := readline(reader)\n\n\tct := 0\n\tminSeen := 0\n\tfor i := 0; i < n; i++ {\n\t\tif pattern[i] == '+' {\n\t\t\tct++\n\t\t} else if pattern[i] == '-' {\n\t\t\tct--\n\t\t}\n\t\tif ct < minSeen {\n\t\t\tminSeen = ct\n\t\t}\n\t}\n\tfmt.Println(ct - minSeen)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc min(a , b int)int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main(){\n\tvar n int\n\tfmt.Scanf(\"%d\",&n)\n\tvar s string\n\tfmt.Scanf(\"%s\",&s)\n\tans := n\n\tvar i , j int\n\tfor i = 0 ; i <= 100;i++{\n\t\ttemp := i\n\t\tfor j = 0 ; j < len(s); j ++{\n\t\t\tif(s[j] =='+'){\n\t\t\t\ttemp ++\n\t\t\t}\n\t\t\tif(s[j] =='-'){\n\t\t\t\ttemp --\n\t\t\t\tif(temp <= -1){\n\t\t\t\ttemp = -1\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(temp >= 0){\n\t\t\tans = min(ans,temp)\n\t\t}\n\t}\n\tfmt.Print(ans)\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc min(a , b int)int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main(){\n\tvar n int\n\tfmt.Scanf(\"%d\",&n)\n\tvar s string\n\tfmt.Scanf(\"%s\",&s)\n\tans := 100\n\tvar i , j int\n\tfor i = 0 ; i <= 100;i++{\n\t\ttemp := i\n\t\tfor j = 0 ; j < len(s); j ++{\n\t\t\tif(s[j] =='+'){\n\t\t\t\ttemp ++\n\t\t\t}\n\t\t\tif(s[j] =='-'){\n\t\t\t\ttemp --\n\t\t\t\tif(temp <= -1){\n\t\t\t\ttemp = -1\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(temp >= 0){\n\t\t\tans = min(ans,temp)\n\t\t}\n\t}\n\tfmt.Print(ans)\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc min(a , b int)int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main(){\n\tvar n int\n\tfmt.Scan(&n)\n\tvar s string\n\tfmt.Scan(&s)\n\tans := n\n\tvar i int\n\tvar temp int\n\n\n\tfor i = 0 ; i <= 10;i++{\n\t\ttemp = i\n\t\tfor _, char := range (s){\n\t\t\tif(char =='+'){\n\t\t\t\ttemp ++\n\t\t\t}\n\t\t\tif(char =='-'){\n\t\t\t\ttemp --\n\t\t\t\tif(temp <= -1){\n\t\t\t\ttemp = -1\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(temp >= 0){\n\t\t\tans = min(ans,temp)\n\t\t}\n\t}\n\tfmt.Print(ans)\n\n}\n"}], "src_uid": "a593016e4992f695be7c7cd3c920d1ed"} {"nl": {"description": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.In school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. For instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.To graduate with «A» certificate, Noora has to have mark k.Noora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.", "input_spec": "The first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ k) denoting marks received by Noora before Leha's hack.", "output_spec": "Print a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.", "sample_inputs": ["2 10\n8 9", "3 5\n4 4 4"], "sample_outputs": ["4", "3"], "notes": "NoteConsider the first example testcase.Maximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to . Consequently, new final mark is 10. Less number of marks won't fix the situation.In the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nvar n int\nvar m int\nvar tmp int\n\nfunc main() {\n\tfmt.Scan(&n)\n\tfmt.Scan(&m)\n\tsuma := 0\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&tmp)\n\t\tsuma += tmp\n\t}\n\n\tansa := 0\n\tfor {\n\t\tif float64(m)-float64(suma)/float64((ansa+n)) <= float64(0.5) {\n\t\t\tfmt.Println(ansa)\n\t\t\tos.Exit(0)\n\t\t}\n\t\tsuma += m\n\t\tansa++\n\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n var k int\n fmt.Scanf(\"%d %d\\n\", &n, &k)\n sum := 0\n for i := 0; i < n; i++ {\n \tvar x int\n \tfmt.Scanf(\"%d\", &x)\n \tsum += x\n }\n ret := 0\n for 2 * sum < (ret + n) * (2 * k - 1) {\n \t/*\n \tsum / (ret + n) >= (k - 0.5)\n \t2 * sum / (ret + n) >= 2 * k - 1\n \t2 * sum >= (ret + n) * (2 * k - 1)\n \t*/\n \tsum += k\n \tret += 1\n }\n fmt.Printf(\"%d\\n\", ret)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k int\n\tfmt.Scan(&n, &k)\n\n\ta := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scan(&a[i])\n\t}\n\n\tfor passed(a, k) == false {\n\t\ta = append(a, k)\n\t}\n\n\tfmt.Printf(\"%d\", len(a)-n)\n}\n\nfunc passed(a []int, k int) bool {\n\tavg := calcAvg(a)\n\tif avg+0.5 >= float64(k) {\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc calcAvg(a []int) float64 {\n\ttotal := 0\n\tfor _, value := range a {\n\t\ttotal += value\n\t}\n\treturn float64(total) / float64(len(a))\n}\n"}], "negative_code": [], "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900"} {"nl": {"description": "On a chessboard with a width of $$$n$$$ and a height of $$$n$$$, rows are numbered from bottom to top from $$$1$$$ to $$$n$$$, columns are numbered from left to right from $$$1$$$ to $$$n$$$. Therefore, for each cell of the chessboard, you can assign the coordinates $$$(r,c)$$$, where $$$r$$$ is the number of the row, and $$$c$$$ is the number of the column.The white king has been sitting in a cell with $$$(1,1)$$$ coordinates for a thousand years, while the black king has been sitting in a cell with $$$(n,n)$$$ coordinates. They would have sat like that further, but suddenly a beautiful coin fell on the cell with coordinates $$$(x,y)$$$...Each of the monarchs wanted to get it, so they decided to arrange a race according to slightly changed chess rules:As in chess, the white king makes the first move, the black king makes the second one, the white king makes the third one, and so on. However, in this problem, kings can stand in adjacent cells or even in the same cell at the same time.The player who reaches the coin first will win, that is to say, the player who reaches the cell with the coordinates $$$(x,y)$$$ first will win.Let's recall that the king is such a chess piece that can move one cell in all directions, that is, if the king is in the $$$(a,b)$$$ cell, then in one move he can move from $$$(a,b)$$$ to the cells $$$(a + 1,b)$$$, $$$(a - 1,b)$$$, $$$(a,b + 1)$$$, $$$(a,b - 1)$$$, $$$(a + 1,b - 1)$$$, $$$(a + 1,b + 1)$$$, $$$(a - 1,b - 1)$$$, or $$$(a - 1,b + 1)$$$. Going outside of the field is prohibited.Determine the color of the king, who will reach the cell with the coordinates $$$(x,y)$$$ first, if the white king moves first.", "input_spec": "The first line contains a single integer $$$n$$$ ($$$2 \\le n \\le 10^{18}$$$) — the length of the side of the chess field. The second line contains two integers $$$x$$$ and $$$y$$$ ($$$1 \\le x,y \\le n$$$) — coordinates of the cell, where the coin fell.", "output_spec": "In a single line print the answer \"White\" (without quotes), if the white king will win, or \"Black\" (without quotes), if the black king will win. You can print each letter in any case (upper or lower).", "sample_inputs": ["4\n2 3", "5\n3 5", "2\n2 2"], "sample_outputs": ["White", "Black", "Black"], "notes": "NoteAn example of the race from the first sample where both the white king and the black king move optimally: The white king moves from the cell $$$(1,1)$$$ into the cell $$$(2,2)$$$. The black king moves form the cell $$$(4,4)$$$ into the cell $$$(3,3)$$$. The white king moves from the cell $$$(2,2)$$$ into the cell $$$(2,3)$$$. This is cell containing the coin, so the white king wins. An example of the race from the second sample where both the white king and the black king move optimally: The white king moves from the cell $$$(1,1)$$$ into the cell $$$(2,2)$$$. The black king moves form the cell $$$(5,5)$$$ into the cell $$$(4,4)$$$. The white king moves from the cell $$$(2,2)$$$ into the cell $$$(3,3)$$$. The black king moves from the cell $$$(4,4)$$$ into the cell $$$(3,5)$$$. This is the cell, where the coin fell, so the black king wins. In the third example, the coin fell in the starting cell of the black king, so the black king immediately wins. "}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n)\nfunc Abs(x uint64,y uint64)uint64{\n\tif x>y{\n\t\treturn x-y\n\t}\n\treturn y-x\n}\nfunc Min(x uint64,y uint64)uint64{\n\tif x>y{\n\t\treturn y\n\t}\n\treturn x\n}\ntype Point struct {\n\tx uint64\n\ty uint64\n\tans uint64\n}\n\nfunc Slove_White(temp Point,n,x,y uint64)uint64{\n\tfor {\n\t\tif temp.x==x&&temp.y==y{\n\t\t\tbreak\n\t\t}\n\t\tif temp.x==x{\n\t\t\ttemp.y++\n\t\t\treturn temp.ans+Abs(y,temp.y)\n\t\t}\n\t\tif temp.y==y{\n\t\t\ttemp.x++\n\t\t\treturn temp.ans+Abs(x,temp.x)\n\n\t\t}\n\t\tadd:=Min(Abs(x,temp.x),Abs(y,temp.y))\n\t\ttemp.x+=add\n\t\ttemp.y+=add\n\t\ttemp.ans+=add\n\t}\n\treturn temp.ans\n}\n\nfunc Slove_Block(temp Point,n,x,y uint64)uint64{\n\tfor {\n\t\tif temp.x==x&&temp.y==y{\n\t\t\tbreak\n\t\t}\n\t\tif temp.x==x{\n\t\t\ttemp.y--\n\t\t\treturn temp.ans+Abs(x,temp.x)\n\t\t}\n\t\tif temp.y==y{\n\t\t\ttemp.x--\n\t\t\treturn temp.ans+Abs(y,temp.y)\n\t\t}\n\t\tadd:=Min(Abs(x,temp.x),Abs(y,temp.y))\n\t\ttemp.x-=add\n\t\ttemp.y-=add\n\t\ttemp.ans+=add\n\t}\n\treturn temp.ans\n}\n\nvar in = bufio.NewReaderSize(os.Stdin, 2<<16)\nfunc main(){\n\tvar n,x,y uint64\n\tfmt.Fscan(in, &n)\n\n\tfmt.Fscan(in, &x, &y)\n\twhite:=Point{x:1,y:1,ans:0}\n\twhite_ans:=Min(Abs(white.x,x),Abs(white.y,y))\n\twhite.x+=white_ans\n\twhite.y+=white_ans\n\twhite_ans+=Abs(white.x,x)\n\twhite_ans+=Abs(white.y,y)\n\n\n\tblock:=Point{x:n,y:n,ans:0}\n\tblock_ans:=Min(Abs(block.x,x),Abs(block.y,y))\n\tblock.x-=block_ans\n\tblock.y-=block_ans\n\tblock_ans+=Abs(block.x,x)\n\tblock_ans+=Abs(block.y,y)\n\n\t//fmt.Println(white_ans,block_ans)\n\tif white_ans<=block_ans{\n\t\tfmt.Println(\"White\")\n\t}else{\n\t\tfmt.Println(\"Black\")\n\t}\n\n}\n\n\n\n\n\n\n\n"}, {"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 := readll()\n\tx := readll()\n\ty := readll()\n\n\tdw := dist(n, 1, 1, x, y)\n\tdb := dist(n, n, n, x, y)\n\n\tif dw <= db {\n\t\tprintln(\"White\")\n\t} else {\n\t\tprintln(\"Black\")\n\t}\n\n}\n\nfunc dist(n, sx, sy, gx, gy int64) int64 {\n\tdx := absll(gx - sx)\n\tdy := absll(gy - sy)\n\n\treturn maxll(dx, dy)\n}\n"}, {"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 max(x, y int64) int64 {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\nfunc main() {\n\tdefer writer.Flush()\n\tvar x, y, n, a, b int64\n\tscanf(\"%d\\n\", &n)\n\tscanf(\"%d %d\\n\", &x, &y)\n\n\ta = max(x-1, y-1)\n\tb = max(n-x, n-y)\n\tif a <= b {\n\t\tprintf(\"White\\n\")\n\t} else {\n\t\tprintf(\"Black\")\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"strconv\"\n\t\"fmt\"\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(\"%s\", Problem705A()))\n}\n\nfunc Problem705A() string {\n\tn := getI64()\n\tx := getI64()\n\ty := getI64()\n\t\n\tif (x-1 + y-1) <= (n-x + n-y) {\n\t\treturn \"White\"\n\t} else {\n\t\treturn \"Black\"\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar (\n\t\tn, x, y int64\n\t)\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\n\tscanner.Scan()\n\tn, _ = strconv.ParseInt(scanner.Text(), 10, 64)\n\n\tscanner.Scan()\n\tx, _ = strconv.ParseInt(scanner.Text(), 10, 64)\n\n\tscanner.Scan()\n\ty, _ = strconv.ParseInt(scanner.Text(), 10, 64)\n\n\tdw := min(abs(x-1), abs(y-1))\n\tdb := min(abs(x-n), abs(y-n))\n\n\tif dw <= db {\n\t\tfmt.Println(\"White\")\n\t} else {\n\t\tfmt.Println(\"Black\")\n\t}\n}\n\nfunc abs(a int64) int64 {\n\tif a >= 0 {\n\t\treturn a\n\t}\n\n\treturn -a\n}\n\nfunc min(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n)\nfunc Abs(x uint64,y uint64)uint64{\n\tif x>y{\n\t\treturn x-y\n\t}\n\treturn y-x\n}\nfunc Min(x uint64,y uint64)uint64{\n\tif x>y{\n\t\treturn y\n\t}\n\treturn x\n}\ntype Point struct {\n\tx uint64\n\ty uint64\n\tans uint64\n}\n\nfunc Slove_White(temp Point,n,x,y uint64)uint64{\n\tfor {\n\t\tif temp.x==x&&temp.y==y{\n\t\t\tbreak\n\t\t}\n\t\tif temp.x==x{\n\t\t\ttemp.y++\n\t\t\treturn temp.ans+Abs(y,temp.y)\n\t\t}\n\t\tif temp.y==y{\n\t\t\ttemp.x++\n\t\t\treturn temp.ans+Abs(x,temp.x)\n\n\t\t}\n\t\tadd:=Min(Abs(x,temp.x),Abs(y,temp.y))\n\t\ttemp.x+=add\n\t\ttemp.y+=add\n\t\ttemp.ans+=add\n\t}\n\treturn temp.ans\n}\n\nfunc Slove_Block(temp Point,n,x,y uint64)uint64{\n\tfor {\n\t\tif temp.x==x&&temp.y==y{\n\t\t\tbreak\n\t\t}\n\t\tif temp.x==x{\n\t\t\ttemp.y--\n\t\t\treturn temp.ans+Abs(x,temp.x)\n\t\t}\n\t\tif temp.y==y{\n\t\t\ttemp.x--\n\t\t\treturn temp.ans+Abs(y,temp.y)\n\t\t}\n\t\tadd:=Min(Abs(x,temp.x),Abs(y,temp.y))\n\t\ttemp.x-=add\n\t\ttemp.y-=add\n\t\ttemp.ans+=add\n\t}\n\treturn temp.ans\n}\n\nvar in = bufio.NewReaderSize(os.Stdin, 2<<16)\nfunc main(){\n\tvar n,x,y uint64\n\tfmt.Fscan(in, &n)\n\n\tfmt.Fscan(in, &x, &y)\n\twhite:=Point{x:1,y:1,ans:0}\n\twhite_ans:=Min(Abs(white.x,x),Abs(white.y,y))\n\twhite.x+=white_ans\n\twhite.y+=white_ans\n\twhite_ans+=Abs(white.x,x)\n\twhite_ans+=Abs(white.y,y)\n\n\n\tblock:=Point{x:n,y:n,ans:0}\n\tblock_ans:=Min(Abs(block.x,x),Abs(block.y,y))\n\tblock.x+=block_ans\n\tblock.y+=block_ans\n\tblock_ans+=Abs(block.x,x)\n\tblock_ans+=Abs(block.y,y)\n\n\t//fmt.Println(white_ans,block_ans)\n\tif white_ans<=block_ans{\n\t\tfmt.Println(\"White\")\n\t}else{\n\t\tfmt.Println(\"Black\")\n\t}\n\n}\n\n\n\n\n\n\n\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"bufio\"\n\t\"os\"\n)\nfunc Abs(x uint64,y uint64)uint64{\n\tif x>y{\n\t\treturn x-y\n\t}\n\treturn y-x\n}\nfunc Min(x uint64,y uint64)uint64{\n\tif x>y{\n\t\treturn y\n\t}\n\treturn x\n}\ntype Point struct {\n\tx uint64\n\ty uint64\n\tans uint64\n}\n\nfunc Slove_White(temp Point,n,x,y uint64)uint64{\n\tfor {\n\t\tif temp.x==x&&temp.y==y{\n\t\t\tbreak\n\t\t}\n\t\tif temp.x==x{\n\t\t\ttemp.y++\n\t\t\treturn temp.ans+Abs(y,temp.y)\n\t\t}\n\t\tif temp.y==y{\n\t\t\ttemp.x++\n\t\t\treturn temp.ans+Abs(x,temp.x)\n\n\t\t}\n\t\tadd:=Min(Abs(x,temp.x),Abs(y,temp.y))\n\t\ttemp.x+=add\n\t\ttemp.y+=add\n\t\ttemp.ans+=add\n\t}\n\treturn temp.ans\n}\n\nfunc Slove_Block(temp Point,n,x,y uint64)uint64{\n\tfor {\n\t\tif temp.x==x&&temp.y==y{\n\t\t\tbreak\n\t\t}\n\t\tif temp.x==x{\n\t\t\ttemp.y--\n\t\t\treturn temp.ans+Abs(x,temp.x)\n\t\t}\n\t\tif temp.y==y{\n\t\t\ttemp.x--\n\t\t\treturn temp.ans+Abs(y,temp.y)\n\t\t}\n\t\tadd:=Min(Abs(x,temp.x),Abs(y,temp.y))\n\t\ttemp.x-=add\n\t\ttemp.y-=add\n\t\ttemp.ans+=add\n\t}\n\treturn temp.ans\n}\nvar in = bufio.NewReaderSize(os.Stdin, 2<<16)\nfunc main(){\n\tvar n,x,y uint64\n\tfmt.Fscan(in, &n)\n\n\tfmt.Fscan(in, &x, &y)\n\twhite:=Point{x:1,y:1,ans:0}\n\twhite_ans:=Slove_White(white,n,x,y)\n\n\n\tblock:=Point{x:n,y:n,ans:0}\n\tblock_ans:=Slove_Block(block,n,x,y)\n\n\t//fmt.Println(white_ans,block_ans)\n\tif white_ans<=block_ans{\n\t\tfmt.Println(\"White\")\n\t}else{\n\t\tfmt.Println(\"Black\")\n\t}\n\n}\n\n\n\n\n\n\n\n"}, {"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(\"%s\", Problem705A()))\n}\n\nfunc Problem705A() string {\n\tn := getI64()\n\tx := getI64()\n\ty := getI64()\n\n\twhiteX := int64(math.Abs(float64(x - 1)))\n\twhiteY := int64(math.Abs(float64(y - 1)))\n\tblackX := int64(math.Abs(float64(n - x)))\n\tblackY := int64(math.Abs(float64(n - y)))\n\n\tif (whiteX + whiteY) <= (blackX + blackY) {\n\t\treturn \"White\"\n\t} else {\n\t\treturn \"Black\"\n\t}\n}"}, {"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(\"%s\", Problem705A()))\n}\n\nfunc Problem705A() string {\n\tn := getI64()\n\tx := getI64()\n\ty := getI64()\n\n\twhiteX := int64(math.Abs(float64(1 - x)))\n\twhiteY := int64(math.Abs(float64(1 - y)))\n\tblackX := int64(math.Abs(float64(n - x)))\n\tblackY := int64(math.Abs(float64(n - y)))\n\n\tif (whiteX + whiteY) <= (blackX + blackY) {\n\t\treturn \"White\"\n\t} else {\n\t\treturn \"Black\"\n\t}\n}"}, {"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(\"%s\", Problem705A()))\n}\n\nfunc Problem705A() string {\n\tn := getI()\n\tx := getI()\n\ty := getI()\n\n\twhiteX := int(math.Abs(float64(1 - x)))\n\twhiteY := int(math.Abs(float64(1 - y)))\n\tblackX := int(math.Abs(float64(n - x)))\n\tblackY := int(math.Abs(float64(n - y)))\n\n\tif (whiteX + whiteY) <= (blackX + blackY) {\n\t\treturn \"White\"\n\t} else {\n\t\treturn \"Black\"\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar (\n\t\tn, x, y int\n\t)\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\n\tscanner.Scan()\n\tn, _ = strconv.Atoi(scanner.Text())\n\n\tscanner.Scan()\n\tx, _ = strconv.Atoi(scanner.Text())\n\n\tscanner.Scan()\n\ty, _ = strconv.Atoi(scanner.Text())\n\n\tdw := min(abs(x-1), abs(y-1))\n\tdb := min(abs(x-n), abs(y-n))\n\n\tif dw <= db {\n\t\tfmt.Println(\"White\")\n\t} else {\n\t\tfmt.Println(\"Black\")\n\t}\n}\n\nfunc abs(a int) int {\n\tif a >= 0 {\n\t\treturn a\n\t}\n\n\treturn -a\n}\n\nfunc min(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n"}], "src_uid": "b8ece086b35a36ca873e2edecc674557"} {"nl": {"description": "One day Misha and Andrew were playing a very simple game. First, each player chooses an integer in the range from 1 to n. Let's assume that Misha chose number m, and Andrew chose number a.Then, by using a random generator they choose a random integer c in the range between 1 and n (any integer from 1 to n is chosen with the same probability), after which the winner is the player, whose number was closer to c. The boys agreed that if m and a are located on the same distance from c, Misha wins.Andrew wants to win very much, so he asks you to help him. You know the number selected by Misha, and number n. You need to determine which value of a Andrew must choose, so that the probability of his victory is the highest possible.More formally, you need to find such integer a (1 ≤ a ≤ n), that the probability that is maximal, where c is the equiprobably chosen integer from 1 to n (inclusive).", "input_spec": "The first line contains two integers n and m (1 ≤ m ≤ n ≤ 109) — the range of numbers in the game, and the number selected by Misha respectively.", "output_spec": "Print a single number — such value a, that probability that Andrew wins is the highest. If there are multiple such values, print the minimum of them.", "sample_inputs": ["3 1", "4 3"], "sample_outputs": ["2", "2"], "notes": "NoteIn the first sample test: Andrew wins if c is equal to 2 or 3. The probability that Andrew wins is 2 / 3. If Andrew chooses a = 3, the probability of winning will be 1 / 3. If a = 1, the probability of winning is 0.In the second sample test: Andrew wins if c is equal to 1 and 2. The probability that Andrew wins is 1 / 2. For other choices of a the probability of winning is less."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i ...interface{}) error {\n\t_, err := fmt.Fscan(r, i...)\n\treturn err\n}\n\nfunc O(o ...interface{}) {\n\tfmt.Fprint(w, o...)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc init() {\n\tif f, err := os.Open(\"in.goC\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n}\n\ntype Int int64\n\nfunc main() {\n\tdefer w.Flush()\n\tvar n, m Int\n\tfor I(&n, &m) == nil {\n\t\tsolve(n, m)\n\t}\n}\n\nfunc solve(n, m Int) {\n\tvar ans Int\n\tif n == Int(1) {\n\t\tans = 1\n\t} else if m-1 >= n-m {\n\t\tans = m - 1\n\t} else {\n\t\tans = m + 1\n\t}\n\tO(ans, \"\\n\")\n}\n"}, {"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, m := nextInt(), nextInt()\n\n\tif n == 1 {\n\t\tprintln(1)\n\t\treturn\n\t}\n\n\tif m-1 < n-m {\n\t\tprintln(m + 1)\n\t} else {\n\t\tprintln(m - 1)\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"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc max(a, b int) int {\n if a > b {\n return a\n }\n return b\n}\n\n/*\nfunc abs(a int) int {\n if a < 0 {\n return -a \n }\n return a\n}\n\nfunc chances(a, m, n int) int {\n cnt := 0\n for c := 1; c <= n; c++ {\n if abs(a - c) < abs(c - m) {\n cnt++ \n }\n }\n return cnt\n}*/\n\nfunc main() {\n var m, n int\n fmt.Scanf(\"%d %d\", &n, &m)\n\n /*\n best := 1\n best_chances := 0\n for a := 1; a <= n; a++ {\n cnt := chances(a, m, n)\n if cnt > best_chances {\n best = a\n best_chances = cnt\n }\n }\n fmt.Println(best) */\n\n if n == 1 {\n fmt.Println(1)\n } else if n - m > m - 1 {\n fmt.Println(m + 1)\n } else {\n fmt.Println(m - 1) \n }\n}\n"}, {"source_code": "// salom project main.go\npackage main\n\nimport (\n\t\"fmt\";\n\n)\n\nfunc main() {\n\tvar m,n int64\n\tfmt.Scan(&n,&m)\n\tif ( m==1 )&&(n==1) {\n\tfmt.Print(\"1\")\n\treturn\n\t}\n\tm=m*2\n\tif m>n {\n\t\tfmt.Print(m/2-1)\n\t}else{\n\t\tfmt.Print(m/2+1)\n\t}\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var (\n n int\n m int\n )\n fmt.Scan(&n)\n fmt.Scan(&m)\n\n a := m - 1\n if a < n - m {\n a = m + 1\n }\n if a == 0 {\n a = m\n }\n fmt.Println(a)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar N, M int\n\nfunc main() {\n\tfsc := NewFastScanner()\n\tN, M = fsc.NextInt(), fsc.NextInt()\n\tif N == 1 {\n\t\tfmt.Println(1)\n\t\tos.Exit(0)\n\t}\n\tvar left, right int\n\tleft = M - 1\n\tright = N - M\n\t// fmt.Println(left, right)\n\tif right > left {\n\t\tfmt.Println(M + 1)\n\t} else if right <= left {\n\t\tfmt.Println(M - 1)\n\t}\n\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"}, {"source_code": "package main \n\nimport \"fmt\"\n\n\nfunc main() {\n\tvar n,m int;\n\t_,_ = fmt.Scanf(\"%d %d\",&n,&m)\n\tvar u = n-m;\n\tvar l = m-1;\n\tif u==0 && l==0{\n\t\tfmt.Println(m)\n\t}else if(u > l){\n\t\tfmt.Println(m+1)\n\t}else{\n\t\tfmt.Println(m-1)\n\t}\n}"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var (\n n int\n m int\n )\n fmt.Scan(&n)\n fmt.Scan(&m)\n\n a := m - 1\n if a < n - m {\n a = m + 1\n }\n fmt.Println(a)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar N, M int\n\nfunc main() {\n\tfsc := NewFastScanner()\n\tN, M = fsc.NextInt(), fsc.NextInt()\n\tvar left, right int\n\tleft = M - 1\n\tright = N - M\n\tfmt.Println(left, right)\n\tif right > left {\n\t\tfmt.Println(M + 1)\n\t} else if right <= left {\n\t\tfmt.Println(M - 1)\n\t}\n\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"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar N, M int\n\nfunc main() {\n\tfsc := NewFastScanner()\n\tN, M = fsc.NextInt(), fsc.NextInt()\n\tvar left, right int\n\tleft = M - 1\n\tright = N - M\n\tif right >= left {\n\t\tfmt.Println(M + 1)\n\t} else if right < left {\n\t\tfmt.Println(M - 1)\n\t}\n\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"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar N, M int\n\nfunc main() {\n\tfsc := NewFastScanner()\n\tN, M = fsc.NextInt(), fsc.NextInt()\n\tvar left, right int\n\tleft = M - 1\n\tright = N - M\n\tif right > left {\n\t\tfmt.Println(M + 1)\n\t} else if right < left {\n\t\tfmt.Println(M - 1)\n\t} else {\n\t\tfmt.Println(M)\n\t}\n\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"}, {"source_code": "package main \n\nimport \"fmt\"\n\n\nfunc main() {\n\tvar n,m int;\n\t_,_ = fmt.Scanf(\"%d %d\",&n,&m)\n\tvar u = n-m;\n\tvar l = m-1;\n\tif n == m{\n\t\tfmt.Println(m)\n\t}else if(u > l){\n\t\tfmt.Println(m+1)\n\t}else{\n\t\tfmt.Println(m-1)\n\t}\n}"}, {"source_code": "package main \n\nimport \"fmt\"\n\n\nfunc main() {\n\tvar n,m int;\n\t_,_ = fmt.Scanf(\"%d %d\",&n,&m)\n\tvar u = n-m;\n\tvar l = m-1;\n\n\tif(u > l){\n\t\tfmt.Println(m+1)\n\t}else{\n\t\tfmt.Println(m-1)\n\t}\n}"}], "src_uid": "f6a80c0f474cae1e201032e1df10e9f7"} {"nl": {"description": "The Duck songFor simplicity, we'll assume that there are only three types of grapes: green grapes, purple grapes and black grapes.Andrew, Dmitry and Michal are all grapes' lovers, however their preferences of grapes are different. To make all of them happy, the following should happen: Andrew, Dmitry and Michal should eat at least $$$x$$$, $$$y$$$ and $$$z$$$ grapes, respectively. Andrew has an extreme affinity for green grapes, thus he will eat green grapes and green grapes only. On the other hand, Dmitry is not a fan of black grapes — any types of grapes except black would do for him. In other words, Dmitry can eat green and purple grapes. Michal has a common taste — he enjoys grapes in general and will be pleased with any types of grapes, as long as the quantity is sufficient.Knowing that his friends are so fond of grapes, Aki decided to host a grape party with them. He has prepared a box with $$$a$$$ green grapes, $$$b$$$ purple grapes and $$$c$$$ black grapes.However, Aki isn't sure if the box he prepared contains enough grapes to make everyone happy. Can you please find out whether it's possible to distribute grapes so that everyone is happy or Aki has to buy some more grapes?It is not required to distribute all the grapes, so it's possible that some of them will remain unused.", "input_spec": "The first line contains three integers $$$x$$$, $$$y$$$ and $$$z$$$ ($$$1 \\le x, y, z \\le 10^5$$$) — the number of grapes Andrew, Dmitry and Michal want to eat. The second line contains three integers $$$a$$$, $$$b$$$, $$$c$$$ ($$$1 \\le a, b, c \\le 10^5$$$) — the number of green, purple and black grapes in the box.", "output_spec": "If there is a grape distribution that allows everyone to be happy, print \"YES\", otherwise print \"NO\".", "sample_inputs": ["1 6 2\n4 3 3", "5 1 1\n4 3 2"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first example, there is only one possible distribution:Andrew should take $$$1$$$ green grape, Dmitry should take $$$3$$$ remaining green grapes and $$$3$$$ purple grapes, and Michal will take $$$2$$$ out of $$$3$$$ available black grapes.In the second test, there is no possible distribution, since Andrew is not be able to eat enough green grapes. :("}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar x, y, z, a, b, c, res int\n\n\tfmt.Scanln(&x, &y, &z)\n\tfmt.Scanln(&a, &b, &c)\n\n\tif a >= x {\n\t\ta = a - x\n\t\tif a+b >= y {\n\t\t\ta = a - y\n\t\t\tif a+b+c >= z {\n\t\t\t\tres = 1\n\t\t\t} else {\n\t\t\t\tres = 2\n\t\t\t}\n\t\t} else {\n\t\t\tres = 2\n\t\t}\n\t} else {\n\t\tres = 2\n\t}\n\tif res == 1 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar x, y, z, a, b, c int\n\tin := bufio.NewReader(os.Stdin)\n\tfmt.Fscan(in, &x, &y, &z, &a, &b, &c)\n\tans := findAns(x, y, z, a, b, c)\n\tfmt.Println(ans)\n}\n\nfunc findAns(x, y, z, a, b, c int) string {\n\tif x > a {\n\t\treturn \"NO\"\n\t}\n\ta = a - x\n\tif y > a+b {\n\t\treturn \"NO\"\n\t}\n\tif y+z > a+b+c {\n\t\treturn \"NO\"\n\t}\n\treturn \"YES\"\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x, y, z, a, b, c int\n\tfmt.Scan(&x, &y, &z, &a, &b, &c)\n\tif a >= x && a+b >= x+y && a+b+c >= x+y+z {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\n\nfunc main() {\n var x,y,z,a,b,c int;\n fmt.Scan(&x,&y,&z,&a,&b,&c);\n\t\ty += x; b+= a;\n\t\tz += y; c+= b;\n\t\tif a >= x && b >= y && c>=z {\n\t\t\tfmt.Println(\"YES\");\n\t\t} else {\n\t\t\tfmt.Println(\"NO\");\n\t\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar adr, dmt, mcl int\n\tfmt.Scan(&adr, &dmt, &mcl)\n\n\tvar g, p, b int\n\tfmt.Scan(&g, &p, &b)\n\n\tg -= adr\n\tp = p + g - dmt\n\tb = b + p - mcl\n\n\tif g < 0 || p < 0 || b < 0 {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tfmt.Println(\"YES\")\n\n}\n"}, {"source_code": "package main\n\nimport (\n \"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tdefer out.Flush()\n\tvar x, y, z, g, p, b int\n\tfor hasNext() {\n\t\tscan(&x, &y, &z, &g, &p, &b)\n\t\tif x > g || y > g+p-x || z > g+p+b-x-y {\n\t\t\tprintln(\"NO\")\n\t\t} else {\n\t\t\tprintln(\"YES\")\n\t\t}\n\t}\n}\n\n// Fast IO Template\nvar in, out = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\n\nfunc print(a ...interface{}) { fmt.Fprint(out, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }\nfunc println(a ...interface{}) { fmt.Fprintln(out, a...) }\nfunc scan(a ...interface{}) { fmt.Fscan(in, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(in, f, a...) }\nfunc scanln(a ...interface{}) { fmt.Fscanln(in, a...) }\nfunc hasNext() bool {\n\tfor b, _ := in.Peek(1); len(b) > 0 && (b[0] == 10 || b[0] == 13); b, _ = in.Peek(1) {\n\t\tin.Discard(1)\n\t}\n\tb, _ := in.Peek(1)\n\treturn len(b) == 1\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tdefer out.Flush()\n\tvar x, y, z, g, p, b int\n\tfor hasNext() {\n\t\tscan(&x, &y, &z, &g, &p, &b)\n\t\tif x > g || y > g+p-x || z > g+p+b-x-y {\n\t\t\tprintln(\"NO\")\n\t\t} else {\n\t\t\tprintln(\"YES\")\n\t\t}\n\t}\n}\n\n// Fast IO Template\nvar in, out = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\n\nfunc print(a ...interface{}) { fmt.Fprint(out, a...) }\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }\nfunc println(a ...interface{}) { fmt.Fprintln(out, a...) }\nfunc scan(a ...interface{}) { fmt.Fscan(in, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(in, f, a...) }\nfunc scanln(a ...interface{}) { fmt.Fscanln(in, a...) }\nfunc hasNext() bool {\n\tfor b, _ := in.Peek(1); len(b) > 0 && (b[0] == 10 || b[0] == 13); b, _ = in.Peek(1) {\n\t\tin.Discard(1)\n\t}\n\tb, _ := in.Peek(1)\n\treturn len(b) == 1\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n)\n\nfunc main() {\n\tvar x, y, z, g, p, b int\n\tfor {\n\t\tif _, err := fmt.Scan(&x, &y, &z, &g, &p, &b); err == io.EOF {\n\t\t\tbreak\n\t\t}\n\t\tif x > g || y > g+p-x || z > g+p+b-x-y {\n\t\t\tfmt.Println(\"NO\")\n\t\t} else {\n\t\t\tfmt.Println(\"YES\")\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x, y, z int32 = 0, 0, 0\n\tvar a, b, c int32 = 0, 0, 0\n\tfmt.Scanf(\"%d %d %d\\n\", &x, &y, &z)\n\tfmt.Scanf(\"%d %d %d\", &a, &b, &c)\n\tif x <= a && y <= a-x+b && z <= a+b+c-x-y {\n\t\tfmt.Printf(\"YES\")\n\t} else {\n\t\tfmt.Printf(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x, y, z, a, b, c int32\n\tfmt.Scanf(\"%d %d %d\\n\", &x, &y, &z)\n\tfmt.Scanf(\"%d %d %d\", &a, &b, &c)\n\n\tif (a < x) || (a+b < x+y) || (a+b+c < x+y+z) {\n\t\tfmt.Printf(\"NO\\n\")\n\t\treturn\n\t}\n\tfmt.Printf(\"YES\\n\")\n\treturn\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc eval(a, d, m, g, p, b int) bool {\n\tif a > g {\n\t\treturn false\n\t}\n\tg -= a\n\tif d > (g + p) {\n\t\treturn false\n\t}\n\trest := g + p - d\n\tif m > (rest + b) {\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc main() {\n\tvar a, d, m int\n\tfmt.Scanf(\"%d %d %d\\n\", &a, &d, &m)\n\n\tvar g, p, b int\n\tfmt.Scanf(\"%d %d %d\\n\", &g, &p, &b)\n\n\tif eval(a, d, m, g, p, b) {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc check(x, y, z, a, b, c int) bool {\n if a < x {\n return false\n }\n if c > z {\n return x+y <= a+b\n }\n return x+y+z <= a+b+c\n}\n\nfunc main() {\n var x, y, z, a, b, c int\n for {\n _, err := fmt.Scanf(\"%d %d %d\\n%d %d %d\", &x, &y, &z, &a, &b, &c)\n if err != nil {\n return\n }\n if check(x, y, z, a, b, c) {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n }\n}"}, {"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.NewReader(os.Stdin)\n\ttmp := readInt64Slice(reader, 3)\n\tx, y, z := tmp[0], tmp[1], tmp[2]\n\ttmp = readInt64Slice(reader, 3)\n\ta, b, c := tmp[0], tmp[1], tmp[2]\n\ta -= x\n\tif a < 0 {\n\t\tfmt.Println(\"NO\")\n\t\tos.Exit(0)\n\t}\n\tb += a\n\tb -= y\n\tif b < 0 {\n\t\tfmt.Println(\"NO\")\n\t\tos.Exit(0)\n\t}\n\tc += b\n\tc -= z\n\tif c < 0 {\n\t\tfmt.Println(\"NO\")\n\t\tos.Exit(0)\n\t}\n\tfmt.Println(\"YES\")\n}\n\nfunc readOneInt64(r *bufio.Reader) (n int64) {\n\tbytes, _ := r.ReadBytes('\\n')\n\tn, _ = strconv.ParseInt(string(bytes[:len(bytes)-2]), 10, 64)\n\treturn\n}\n\nfunc readInt64Slice(r *bufio.Reader, n int) (slice []int64) {\n\tvar bytes []byte\n\tslice = make([]int64, n)\n\tn--\n\tfor i := 0; i < n; i++ {\n\t\tbytes, _ = r.ReadBytes(' ')\n\t\tslice[i], _ = strconv.ParseInt(string(bytes[:len(bytes)-1]), 10, 64)\n\t}\n\tslice[n] = readOneInt64(r)\n\treturn\n}\n\nfunc readOneString(r *bufio.Reader) []byte {\n\tbytes, _ := r.ReadBytes('\\n')\n\treturn bytes[:len(bytes)-2]\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x, y, z, a, b, c int32\n\tfmt.Scan(&x, &y, &z, &a, &b, &c)\n\tvar answer string = \"YES\"\n\tif a -= x; a < 0 {\n\t\tanswer = \"NO\"\n\t}\n\tif b = a + b - y; b < 0 {\n\t\tanswer = \"NO\"\n\t}\n\tif c = b + c - z; c < 0 {\n\t\tanswer = \"NO\"\n\t}\n\tfmt.Printf(\"%v\", answer)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tsc := NewScanner()\n\tA, B, C := sc.NextInt(), sc.NextInt(), sc.NextInt()\n\tX, Y, Z := sc.NextInt(), sc.NextInt(), sc.NextInt()\n\n\tX -= A\n\tif X < 0 {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\n\tif B < X {\n\t\tX -= B\n\t\tB = 0\n\t} else {\n\t\tB -= X\n\t\tX = 0\n\t}\n\tif B < Y {\n\t\tY -= B\n\t\tB = 0\n\t} else {\n\t\tB -= Y\n\t\tY = 0\n\t}\n\tif B > 0 {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\n\tif C > X+Y+Z {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\tfmt.Println(\"YES\")\n\n}\n\ntype Scanner struct {\n\tr *bufio.Reader\n\tbuf []byte\n\tp int\n}\n\nfunc NewScanner() *Scanner {\n\trdr := bufio.NewReaderSize(os.Stdin, 1000)\n\treturn &Scanner{r: rdr}\n}\nfunc (s *Scanner) Next() string {\n\ts.pre()\n\tstart := s.p\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tbreak\n\t\t}\n\t}\n\tresult := string(s.buf[start:s.p])\n\ts.p++\n\treturn result\n}\nfunc (s *Scanner) NextLine() string {\n\ts.pre()\n\tstart := s.p\n\ts.p = len(s.buf)\n\treturn string(s.buf[start:])\n}\nfunc (s *Scanner) NextInt() int {\n\tv, _ := strconv.Atoi(s.Next())\n\treturn v\n}\nfunc (s *Scanner) NextInt64() int64 {\n\tv, _ := strconv.ParseInt(s.Next(), 10, 64)\n\treturn v\n}\n\nfunc (s *Scanner) NextIntArray() []int {\n\ts.pre()\n\tstart := s.p\n\tresult := []int{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)\n\t\t\tresult = append(result, int(v))\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\n\treturn result\n}\nfunc (s *Scanner) NextInt64Array() []int64 {\n\ts.pre()\n\tstart := s.p\n\tresult := []int64{}\n\tfor ; s.p < len(s.buf)+1; s.p++ {\n\t\tif s.p == len(s.buf) || s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)\n\t\t\tresult = append(result, v)\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\treturn result\n}\n\nfunc (s *Scanner) NextMap() map[int]bool {\n\ts.pre()\n\tstart := s.p\n\tmp := map[int]bool{}\n\tfor ; s.p < len(s.buf); s.p++ {\n\t\tif s.buf[s.p] == ' ' {\n\t\t\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\t\t\tmp[v] = true\n\t\t\tstart = s.p + 1\n\t\t}\n\t}\n\tv, _ := strconv.Atoi(string(s.buf[start:s.p]))\n\tmp[v] = true\n\n\treturn mp\n}\n\nfunc (s *Scanner) pre() {\n\tif s.p >= len(s.buf) {\n\t\ts.readLine()\n\t\ts.p = 0\n\t}\n}\nfunc (s *Scanner) readLine() {\n\ts.buf = make([]byte, 0)\n\tfor {\n\t\tl, p, e := s.r.ReadLine()\n\t\tif e != nil {\n\t\t\tpanic(e)\n\t\t}\n\t\ts.buf = append(s.buf, l...)\n\t\tif !p {\n\t\t\tbreak\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar scanner = bufio.NewScanner(os.Stdin)\n\nfunc init() {\n\tscanner.Split(bufio.ScanWords)\n}\n\nfunc scanString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc scanBytes() []byte {\n\tscanner.Scan()\n\treturn scanner.Bytes()\n}\n\nfunc scanInt64() int64 {\n\tscanner.Scan()\n\tv, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\treturn v\n}\n\nfunc scanInt() int {\n\tscanner.Scan()\n\tv, _ := strconv.Atoi(scanner.Text())\n\treturn v\n}\n\nfunc scanInts(n int) []int {\n\tl := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tscanner.Scan()\n\t\tl[i], _ = strconv.Atoi(scanner.Text())\n\t}\n\n\treturn l\n}\n\nfunc scanInts64(n int64) []int64 {\n\tl := make([]int64, n)\n\tfor i := int64(0); i < n; i++ {\n\t\tscanner.Scan()\n\t\tl[i], _ = strconv.ParseInt(scanner.Text(), 10, 64)\n\t}\n\n\treturn l\n}\n\nfunc scanBool() bool {\n\tscanner.Scan()\n\tv, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\treturn v == 1\n}\n\nfunc scanBools(n int64) []bool {\n\tl := make([]bool, n)\n\tfor i := int64(0); i < n; i++ {\n\t\tscanner.Scan()\n\t\tv, _ := strconv.ParseInt(scanner.Text(), 10, 64)\n\t\tl[i] = v == 1\n\t}\n\n\treturn l\n}\n\nfunc scanUint64() uint64 {\n\tscanner.Scan()\n\tv, _ := strconv.ParseUint(scanner.Text(), 10, 64)\n\treturn v\n}\n\ntype ByAge []int\n\nfunc (a ByAge) Len() int { return len(a) }\nfunc (a ByAge) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a ByAge) Less(i, j int) bool { return a[i] > a[j] }\n\nvar glasn = map[byte]bool{\n\t'a': true,\n\t'e': true,\n\t'i': true,\n\t'o': true,\n\t'u': true,\n}\n\nfunc main() {\n\tx, y, z := scanInt(), scanInt(), scanInt()\n\ta, b, c := scanInt(), scanInt(), scanInt()\n\n\tif a < x {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\n\ta -= x\n\n\tif a+b < y {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\n\tleft := (a + b - y) + c\n\n\tif left < z {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\n\tfmt.Println(\"YES\")\n}\n\nfunc skipZero(a []uint64) []uint64 {\n\tfor len(a) > 0 && a[0] == 0 {\n\t\ta = a[1:]\n\t}\n\n\treturn a\n}\n\nfunc abs(a int) int {\n\tif a >= 0 {\n\t\treturn a\n\t}\n\n\treturn -a\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n\nfunc max64(a, b int64) int64 {\n\tif a > b {\n\t\treturn a\n\t}\n\n\treturn b\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc solve(x int, y int, z int, a int, b int, c int) int {\n\tif x > a || x+y > a+b || x+y+z > a+b+c {\n\t\treturn 1\n\t}\n\treturn 0\n}\n\nfunc main() {\n\tvar x, y, z, a, b, c int\n\tfmt.Scan(&x, &y, &z, &a, &b, &c)\n\tvar ans int\n\tans = solve(x, y, z, a, b, c)\n\tfmt.Println([]string{\"YES\", \"NO\"}[ans])\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc solve(x int, y int, z int, a int, b int, c int) int {\n if a >= x && a+b >= x+y && a+b+c >= x+y+z {\n return 1\n }\n return 0\n}\n\nfunc main() {\n\tvar x, y, z, a, b, c int\n\tfmt.Scan(&x, &y, &z, &a, &b, &c)\n if solve(x, y, z, a, b, c) == 1 {\n fmt.Println(\"YES\")\n\t} else {\n fmt.Println(\"NO\")\n\t}\n}"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar x, y, z, a, b, c int32\n\tfmt.Scanf(\"%d %d %d\\n\", x, y, z)\n\tfmt.Scanf(\"%d %d %d\", a, b, c)\n\tif (a < x) || (a+b < x+y) || (a+b+c < x+y+z) {\n\t\tfmt.Printf(\"NO\")\n\t\treturn\n\t}\n\tfmt.Printf(\"YES\")\n\treturn\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nfunc check(x, y, z, a, b, c int) bool {\n if a < x {\n return false\n }\n if c < z {\n return x+y <= a+b\n }\n return x+y+z <= a+b+c\n}\n\nfunc main() {\n var x, y, z, a, b, c int\n for {\n _, err := fmt.Scanf(\"%d %d %d\\n%d %d %d\", &x, &y, &z, &a, &b, &c)\n if err != nil {\n return\n }\n if check(x, y, z, a, b, c) {\n fmt.Println(\"YES\")\n } else {\n fmt.Println(\"NO\")\n }\n }\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc solve(x int, y int, z int, a int, b int, c int) int {\n if a >= x {\n return 0\n }\n if a+b >= x+y {\n return 0\n }\n if a+b+c >= x+y+z {\n return 0\n }\n return 1\n}\n\nfunc main() {\n\tvar x, y, z, a, b, c int\n\tfmt.Scan(&x, &y, &z, &a, &b, &c)\n\tif solve(x,y,z,a,b,c) == 1 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc solve(x int, y int, z int, a int, b int, c int) int {\n if a >= x || a+b >= x+y || a+b+c >= x+y+z {\n return 0\n }\n return 1\n}\n\nfunc main() {\n\tvar x, y, z, a, b, c int\n\tfmt.Scan(&x, &y, &z, &a, &b, &c)\n\tif solve(x,y,z,a,b,c) == 1 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc solve(x int, y int, z int, a int, b int, c int) int {\n if a >= x || a+b >= x+y || a+b+c >= x+y+z {\n return 0\n }\n return 1\n}\n\nfunc main() {\n\tvar x, y, z, a, b, c int\n\tfmt.Scan(&x, &y, &z, &a, &b, &c)\n if solve(x, y, z, a, b, c) == 1 {\n fmt.Println(\"YES\")\n\t} else {\n fmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc solve(x int, y int, z int, a int, b int, c int) int {\n if a >= x || a+b >= x+y || a+b+c >= x+y+z {\n return 1\n }\n return 0\n}\n\nfunc main() {\n\tvar x, y, z, a, b, c int\n\tfmt.Scan(&x, &y, &z, &a, &b, &c)\n\tif solve(x,y,z,a,b,c) == 1 {\n\t\tfmt.Println(\"YES\")\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}"}], "src_uid": "d54201591f7284da5e9ce18984439f4e"} {"nl": {"description": "Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out of four sticks of different colours. Naturally, one of the sticks is extra. It is not allowed to break the sticks or use their partial length. Anne has perfectly solved this task, now she is asking Johnny to do the same.The boy answered that he would cope with it without any difficulty. However, after a while he found out that different tricky things can occur. It can happen that it is impossible to construct a triangle of a positive area, but it is possible to construct a degenerate triangle. It can be so, that it is impossible to construct a degenerate triangle even. As Johnny is very lazy, he does not want to consider such a big amount of cases, he asks you to help him.", "input_spec": "The first line of the input contains four space-separated positive integer numbers not exceeding 100 — lengthes of the sticks.", "output_spec": "Output TRIANGLE if it is possible to construct a non-degenerate triangle. Output SEGMENT if the first case cannot take place and it is possible to construct a degenerate triangle. Output IMPOSSIBLE if it is impossible to construct any triangle. Remember that you are to use three sticks. It is not allowed to break the sticks or use their partial length.", "sample_inputs": ["4 2 1 3", "7 2 2 4", "3 5 9 1"], "sample_outputs": ["TRIANGLE", "SEGMENT", "IMPOSSIBLE"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n)\n\nvar cs map[int]int = make(map[int]int)\n\nfunc Init() {}\nfunc Solve(io *FastIO) {\n\ta := io.NextIntArray(4)\n\tvar b []int\n\tres := float64(0)\n\tfor i := range a {\n\t\tb = make([]int, 0)\n\t\tfor j := range a {\n\t\t\tif j != i {\n\t\t\t\tb = append(b, a[j])\n\t\t\t}\n\t\t}\n\t\tres = math.Max(check(b[0], b[1], b[2], 0), res)\n\t}\n\tswitch int(res) {\n\tcase 0:\n\t\tio.Println(\"IMPOSSIBLE\")\n\tcase 1:\n\t\tio.Println(\"SEGMENT\")\n\tcase 2:\n\t\tio.Println(\"TRIANGLE\")\n\t}\n}\nfunc check(a, b, c, co int) float64 {\n\tif co > 2 {\n\t\treturn float64(2)\n\t}\n\ts := b + c\n\tvar res float64\n\tif s == a {\n\t\tres = float64(1)\n\t} else if s > a {\n\t\tres = check(b, c, a, co+1)\n\t} else {\n\t\tres = float64(0)\n\t}\n\treturn res\n}\n\ntype FastIO struct {\n\t//by megaspazz\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\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 res * sgn\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 = int64(-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 res * sgn\n}\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\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}\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\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}\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}\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}\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\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}\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\n', '\\r':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tInit()\n\tSolve(&io)\n\tio.FlushOutput()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\n\tvar a, b, c, d int\n\n\tfmt.Fscanf(reader, \"%d %d %d %d\", &a, &b, &c, &d)\n\n\tif a > b {\n\t\ta, b = b, a\n\t}\n\tif c > d {\n\t\tc, d = d, c\n\t}\n\tif a > c {\n\t\ta, c = c, a\n\t}\n\tif b > d {\n\t\tb, d = d, b\n\t}\n\tif b > c {\n\t\tb, c = c, b\n\t}\n\n\tif a+b > c || b+c > d {\n\t\tfmt.Printf(\"TRIANGLE\")\n\t} else if a+b == c || b+c == d {\n\t\tfmt.Printf(\"SEGMENT\")\n\t} else {\n\t\tfmt.Printf(\"IMPOSSIBLE\")\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar numbers = make([]int, 4)\n\tfmt.Scan(&numbers[0], &numbers[1], &numbers[2], &numbers[3])\n\tsort.Ints(numbers)\n\tif numbers[2] < (numbers[0]+numbers[1]) || numbers[3] < (numbers[2]+numbers[1]) {\n\t\tfmt.Println(\"TRIANGLE\")\n\t} else if numbers[2] == (numbers[0]+numbers[1]) || numbers[3] == (numbers[2]+numbers[1]) {\n\t\tfmt.Println(\"SEGMENT\")\n\t} else {\n\t\tfmt.Println(\"IMPOSSIBLE\")\n\t}\n\n}\n"}, {"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\n\tA := readNNums(reader, 4)\n\n\tfmt.Println(solve(A))\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(A []int) string {\n\tsort.Ints(A)\n\n\tif A[3] < A[2]+A[1] {\n\t\treturn \"TRIANGLE\"\n\t}\n\tif A[2] < A[0]+A[1] {\n\t\treturn \"TRIANGLE\"\n\t}\n\n\tif A[3] == A[1]+A[2] || A[3] == A[0]+A[1] || A[3] == A[0]+A[2] || A[2] == A[0]+A[1] {\n\t\treturn \"SEGMENT\"\n\t}\n\n\treturn \"IMPOSSIBLE\"\n}\n"}, {"source_code": "package main\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\nfunc main() {\n\tv:=make([]int,4)\n\tfor i:=0;i<4;i++ {\n\t\tfmt.Scan(&v[i])\n\t}\n\tsort.Ints(v)\n\tif v[0]+v[1]>v[2] || v[1]+v[2]>v[3] {\n\t\tfmt.Println(\"TRIANGLE\")\n\t} else if v[0]+v[1]==v[2] || v[1]+v[2]==v[3] {\n\t\tfmt.Println(\"SEGMENT\")\n\t} else {\n\t\tfmt.Println(\"IMPOSSIBLE\")\n\t}\n\n}\n"}, {"source_code": "//\n// What we need to do is apply \"Heron's Formula\" for the area\n// of a triangle with known length of sides.\n//\n// For convience, compute half perimeter:\n// s = (a + b + c) / 2\n//\n// Then A = sqrt(s * (s - a) * (s - b) (s - c))\n//\n// If A is imaginary, the sides aren't longth enough to form\n// a triangle. If A is zero, it forms a degenerate triangle\n//\n// A degenerate triangle is one where len(AB) + len(BC) = len(AC)\n//\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\ta := float64(readInt())\n\tb := float64(readInt())\n\tc := float64(readInt())\n\td := float64(readInt())\n\n\tcombs := [...]float64{a, b, c, d}\n\tdegenerate := false\n\n\teps := 0.0001\n\tfor i, va := range combs {\n\t\tfor j := i + 1; j < len(combs); j++ {\n\t\t\tvb := combs[j]\n\t\t\tfor k := j + 1; k < len(combs); k++ {\n\t\t\t\tvc := combs[k]\n\t\t\t\ta = area(va, vb, vc)\n\n\t\t\t\tif a > eps {\n\t\t\t\t\tfmt.Println(\"TRIANGLE\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif math.Abs(a) < eps {\n\t\t\t\t\tdegenerate = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif degenerate {\n\t\tfmt.Println(\"SEGMENT\")\n\t\treturn\n\t}\n\tfmt.Println(\"IMPOSSIBLE\")\n}\n\nfunc area(a, b, c float64) float64 {\n\tneg := false\n\n\ts := (a + b + c) / 2.0\n\tarea := s * (s - a) * (s - b) * (s - c)\n\n\tif area < 0 {\n\t\tneg = true\n\t\tarea = -area\n\t}\n\n\tarea = math.Sqrt(area)\n\n\tif neg {\n\t\tarea = -area\n\t}\n\treturn area\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"}, {"source_code": "package main\nimport \"fmt\"\n\n\nfunc max3(x, y, z int) (int, bool){\n\tif (x >= y) && (x >= z) && ((x - y - z) <= 0){\n\t\treturn x - y - z, true\n\t}else if (y >= x) && (y >= z) && ((y - x - z) <= 0){\n\t\treturn y - x - z, true\n\t}else if (z>=y)&&(z >= x)&&((z-y-x) <= 0){\n\t\treturn z-y-x, true\n\t}else{\n\t\treturn 0, false\n\t}\n}\n\nfunc main() {\n\tsticks := make([]int, 4)\n\tfmt.Scan(&sticks[0], &sticks[1], &sticks[2], &sticks[3])\n\tans := \"IMPOSSIBLE\"\n\tfor i := 0; i < 4; i++{\n\t\tif c, ok:= max3(sticks[i%4], sticks[(i+1)%4], sticks[(i+2)%4]); (c < 0) && ok {\n\t\t\tans = \"TRIANGLE\"\n\t\t\tbreak\n\t\t}else if (c == 0) && ok{\n\t\t\tans = \"SEGMENT\"\n\t\t}\n\t}\n\n\n\tfmt.Print(ans)\n}"}, {"source_code": "//http://codeforces.com/contest/6/problem/A\n//A. Triangle\n\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc isTri(a, b, c int32) int32 {\n\tif a > c {\n\t\tc, a = a, c\n\t}\n\tif c < b {\n\t\tc, b = b, c\n\t}\n\tif b < a {\n\t\tb, a = a, b\n\t}\n\tif a+b > c {\n\t\treturn 1\n\t}\n\tif a+b == c {\n\t\treturn 0\n\t}\n\treturn -1\n}\n\nfunc main() {\n\tvar (\n\t\tres, t, a, b, c, d int32\n\t)\n\n\tfmt.Scan(&a)\n\tfmt.Scan(&b)\n\tfmt.Scan(&c)\n\tfmt.Scan(&d)\n\tres = isTri(a, b, c)\n\tt = isTri(a, b, d)\n\tif t > res {\n\t\tres = t\n\t}\n\tt = isTri(a, c, d)\n\tif t > res {\n\t\tres = t\n\t}\n\tt = isTri(b, c, d)\n\tif t > res {\n\t\tres = t\n\t}\n\n\tif res > 0 {\n\t\tfmt.Println(\"TRIANGLE\")\n\t\treturn\n\t}\n\tif res < 0 {\n\t\tfmt.Println(\"IMPOSSIBLE\")\n\t\treturn\n\t}\n\tfmt.Println(\"SEGMENT\")\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar l [4]int\n\tif _, err := fmt.Scanf(\"%d %d %d %d\\n\", &l[0], &l[1], &l[2], &l[3]); err != nil {\n\t\treturn\n\t}\n\n\tsegment := false\n\n\tvar t [3]int\n\tfor i := 0; i < 4; i++ {\n\t\tk := 0\n\t\tfor j := 0; j < 4; j++ {\n\t\t\tif j != i {\n\t\t\t\tt[k] = l[j]\n\t\t\t\tk++\n\t\t\t}\n\t\t}\n\t\ts := triangle(t)\n\t\tif s == 1 { // triangle\n\t\t\tfmt.Println(\"TRIANGLE\")\n\t\t\treturn\n\t\t} else if s == 2 { // Degenerate triangle\n\t\t\tsegment = true\n\t\t}\n\t}\n\n\tif segment {\n\t\tfmt.Println(\"SEGMENT\")\n\t} else {\n\t\tfmt.Println(\"IMPOSSIBLE\")\n\t}\n}\n\nfunc triangle(t [3]int) int {\n\tsum := 0\n\tmax := 0\n\tfor i := 0; i < 3; i++ {\n\t\tsum += t[i]\n\t\tif t[i] > max {\n\t\t\tmax = t[i]\n\t\t}\n\t}\n\n\tif sum-max == max {\n\t\treturn 2\n\t} else if sum-max > max {\n\t\treturn 1\n\t} else {\n\t\treturn 0\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc f(a,b,c int) int {\n if ((a+b) > c) && ((a+c) > b) && ((b+c) > a) {\n return 2\n } else if ((a+b) >= c) && ((a+c) >= b) && ((b+c) >= a) {\n return 1\n } else {\n return 0\n }\n}\n\nfunc max(a... int) (max int) {\n max = a[0]\n for _, v := range a {\n if max < v { max = v }\n }\n return\n}\n\nfunc main() {\n var a,b,c,d int\n fmt.Scan(&a,&b,&c,&d)\n ans := max(f(a,b,c),f(a,b,d),f(a,c,d),f(b,c,d))\n if ans == 2 {\n fmt.Println(\"TRIANGLE\")\n } else if ans == 1 {\n fmt.Println(\"SEGMENT\")\n } else {\n fmt.Println(\"IMPOSSIBLE\")\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"sort\"\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 inputs []int\n\n\tinputs = make([]int, 4)\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\tinputs[0], err = strconv.Atoi(text)\n\tcheck(err)\n\n\tscn.Scan()\n\ttext = scn.TokenText();\n\t\n\tinputs[1], err = strconv.Atoi(text)\n\tcheck(err)\n\n\tscn.Scan()\n\ttext = scn.TokenText();\n\t\n\tinputs[2], err = strconv.Atoi(text)\n\tcheck(err)\n\n\tscn.Scan()\n\ttext = scn.TokenText();\n\t\n\tinputs[3], err = strconv.Atoi(text)\n\tcheck(err)\n\n\tsort.Ints(inputs)\n\n\t// first check to see if you can make a triangle with first input\n\t// otherwise, check for degenerate case\n\tif inputs[0] + inputs[1] > inputs[2] ||\n\t inputs[0] + inputs[2] > inputs[3] ||\n\t inputs[1] + inputs[2] > inputs[3] {\n\t\tfmt.Print(\"TRIANGLE\")\n\t} else if inputs[0] + inputs[1] == inputs[2] ||\n\t inputs[0] + inputs[2] == inputs[3] ||\n\t inputs[1] + inputs[2] == inputs[3] {\n\t \tfmt.Print(\"SEGMENT\")\n\t} else {\n\t\tfmt.Print(\"IMPOSSIBLE\")\n\t}\n\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tvar l1, l2, l3, l4 int\n\n\tif scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tfmt.Sscanf(line, \"%d %d %d %d\", &l1, &l2, &l3, &l4)\n\n\t\tlines := [4]int{l1, l2, l3, l4}\n\n\t\tdegenerate := false\n\t\tfor i := 0; i < 4; i++ {\n\t\t\tfor j := i + 1; j < 4; j++ {\n\t\t\t\tfor k := j + 1; k < 4; k++ {\n\t\t\t\t\tif lines[i]+lines[j] > lines[k] &&\n\t\t\t\t\t\tlines[i]+lines[k] > lines[j] &&\n\t\t\t\t\t\tlines[j]+lines[k] > lines[i] {\n\t\t\t\t\t\tfmt.Println(\"TRIANGLE\")\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tif lines[i]+lines[j] == lines[k] ||\n\t\t\t\t\t\tlines[i]+lines[k] == lines[j] ||\n\t\t\t\t\t\tlines[j]+lines[k] == lines[i] {\n\t\t\t\t\t\tdegenerate = true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif degenerate {\n\t\t\tfmt.Println(\"SEGMENT\")\n\t\t} else {\n\t\t\tfmt.Println(\"IMPOSSIBLE\")\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"sort\"\n\nfunc triangle(L []int, diff int) bool {\n\tfor i := 0; i < 4; i++ {\n\t\tfor j := i + 1; j < 4; j++ {\n\t\t\tfor k := j + 1; k < 4; k++ {\n\t\t\t\tif (L[i] + L[j] - L[k]) >= diff {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\nfunc main() {\n\tvar L = make([]int, 4)\n\t_, _ = fmt.Scanf(\"%d %d %d %d\", &L[0], &L[1], &L[2], &L[3])\n\tsort.Ints(L)\n\tif triangle(L, 1) {\n\t\tfmt.Println(\"TRIANGLE\")\n\t} else if triangle(L, 0) {\n\t\tfmt.Println(\"SEGMENT\")\n\t} else {\n\t\tfmt.Println(\"IMPOSSIBLE\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n)\n\nvar inf int = 0x3f3f3f3f\nvar reader *bufio.Reader\n\nfunc init() {\n\tstdin := os.Stdin\n\t// stdin, _ = os.Open(\"1.in\")\n\treader = bufio.NewReaderSize(stdin, 1<<20)\n}\n\nvar n int\nvar a [4]int\n\nfunc main() {\n\tn = 4\n\tfor i := 0; i < 4; i++ {\n\t\tfmt.Fscan(reader, &a[i])\n\t}\n\tsort.Sort(sort.IntSlice(a[:]))\n\tif a[0]+a[1] > a[2] || a[1]+a[2] > a[3] {\n\t\tfmt.Println(\"TRIANGLE\")\n\t\treturn\n\t}\n\tif a[0]+a[1] == a[2] || a[1]+a[2] == a[3] {\n\t\tfmt.Println(\"SEGMENT\")\n\t\treturn\n\t}\n\tfmt.Println(\"IMPOSSIBLE\")\n}\n"}, {"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\t\"sort\"\n)\n\nfunc main() {\n\tl := make([]int, 4)\n\tfor i := 0; i < 4; i++ {\n\t\tl[i] = nextInt()\n\t}\n\tsort.Ints(l)\n\ttriangle, segment := l[0] + l[1] > l[2] || l[1] + l[2] > l[3], l[0] + l[1] == l[2] || l[1] + l[2] == l[3]\n\n\tif triangle {\n\t\tprintf(\"TRIANGLE\\n\")\n\t} else if segment {\n\t\tprintf(\"SEGMENT\")\n\t} else {\n\t\tprintf(\"IMPOSSIBLE\")\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}"}, {"source_code": "// 6A-mic\npackage main\n\nimport (\n \"fmt\"\n \"sort\"\n)\n\nfunc main() {\n l := make([]int, 4)\n fmt.Scan(&l[0], &l[1], &l[2], &l[3])\n sort.Sort(sort.IntSlice(l))\n if l[0]+l[1] > l[2] || l[1]+l[2] > l[3] {\n fmt.Println(\"TRIANGLE\")\n } else if l[0]+l[1] == l[2] || l[1]+l[2] == l[3] {\n fmt.Println(\"SEGMENT\")\n } else {\n fmt.Println(\"IMPOSSIBLE\")\n }\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\tstrings \"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _, _ := reader.ReadLine()\n\n\tval := strings.Split(string(text), \" \")\n\tvar val2 [4]int64\n\n\tvar val3 = make([]int, 4, 4)\n\n\tval2[0], _ = strconv.ParseInt(val[0], 10, 0)\n\tval2[1], _ = strconv.ParseInt(val[1], 10, 0)\n\tval2[2], _ = strconv.ParseInt(val[2], 10, 0)\n\tval2[3], _ = strconv.ParseInt(val[3], 10, 0)\n\tval3[0] = int(val2[0])\n\tval3[1] = int(val2[1])\n\tval3[2] = int(val2[2])\n\tval3[3] = int(val2[3])\n\n\tsort.Ints(val3)\n\n\tif val3[3] < val3[2]+val3[1] || val3[2] < val3[1]+val3[0] {\n\t\tfmt.Println(\"TRIANGLE\")\n\t} else if val3[3] == val3[2]+val3[1] || val3[2] == val3[1]+val3[0] {\n\t\tfmt.Println(\"SEGMENT\")\n\t} else {\n\t\tfmt.Println(\"IMPOSSIBLE\")\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc f(a,b,c int) int {\n if ((a+b) > c) && ((a+c) > b) && ((b+c) > a) {\n return 2\n } else if ((a+b) >= c) && ((a+c) >= b) && ((b+c) >= a) {\n return 1\n } else {\n return 0\n }\n}\n\nfunc max(a... int) (max int) {\n max = a[0]\n for _, v := range a {\n if max < v { max = v }\n }\n return\n}\n\nfunc main() {\n var a,b,c,d int\n fmt.Scan(&a,&b,&c,&d)\n ans := max(f(a,b,c),f(a,b,d),f(a,c,d),f(b,c,d))\n if ans == 2 {\n fmt.Println(\"TRIANGLE\")\n } else if ans == 1 {\n fmt.Println(\"SEGMENT\")\n } else {\n fmt.Println(\"IMPOSSIBLE\")\n }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc f(a,b,c int) int {\n if ((a+b) > c) && ((a+c) > b) && ((b+c) > a) {\n return 2\n } else if ((a+b) >= c) && ((a+c) >= b) && ((b+c) >= a) {\n return 1\n } else {\n return 0\n }\n}\n\nfunc max(a... int) (max int) {\n max = a[0]\n for _, v := range a {\n if max < v { max = v }\n }\n return\n}\n\nfunc main() {\n var a,b,c,d int\n fmt.Scan(&a,&b,&c,&d)\n ans := max(f(a,b,c),f(a,b,d),f(a,c,d),f(b,c,d))\n if ans == 2 {\n fmt.Println(\"TRIANGLE\")\n } else if ans == 1 {\n fmt.Println(\"SEGMENT\")\n } else {\n fmt.Println(\"IMPOSSIBLE\")\n }\n}"}], "negative_code": [{"source_code": "package main\nimport \"fmt\"\n\n\nfunc max3(x, y, z int) (int, bool){\n\tif (x > y) && (x > z) && ((x - y - z) <= 0){\n\t\treturn x - y - z, true\n\t}else if (y > x) && (y > z) && ((y - x - z) <= 0){\n\t\treturn y - x - z, true\n\t}else if (z>y)&&(z > x)&&((z-y-x) <= 0){\n\t\treturn z-y-x, true\n\t}else{\n\t\treturn 0, false\n\t}\n}\n\nfunc main() {\n\tsticks := make([]int, 4)\n\tfmt.Scan(&sticks[0], &sticks[1], &sticks[2], &sticks[3])\n\tans := \"IMPOSSIBLE\"\n\tfor i := 0; i < 4; i++{\n\t\tif c, ok:= max3(sticks[i%4], sticks[(i+1)%4], sticks[(i+2)%4]); (c < 0) && ok {\n\t\t\tans = \"TRIANGLE\"\n\t\t\tbreak\n\t\t}else if (c == 0) && ok{\n\t\t\tans = \"SEGMENT\"\n\t\t}\n\t}\n\n\n\tfmt.Print(ans)\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar l [4]int\n\tif _, err := fmt.Scanf(\"%d %d %d %d\\n\", &l[0], &l[1], &l[2], &l[3]); err != nil {\n\t\treturn\n\t}\n\n\tsegment := false\n\n\tvar t [3]int\n\tfor i := 0; i < 4; i++ {\n\t\tk := 0\n\t\tfor j := 0; j < 4; j++ {\n\t\t\tif j != i {\n\t\t\t\tt[k] = l[j]\n\t\t\t\tk++\n\t\t\t}\n\t\t}\n\t\ts := traingle(t)\n\t\tif s == 1 { // Traingle\n\t\t\tfmt.Println(\"TRAINGLE\")\n\t\t\treturn\n\t\t} else if s == 2 { // Degenerate Traingle\n\t\t\tsegment = true\n\t\t}\n\t}\n\n\tif segment {\n\t\tfmt.Println(\"SEGMENT\")\n\t} else {\n\t\tfmt.Println(\"IMPOSSIBLE\")\n\t}\n}\n\nfunc traingle(t [3]int) int {\n\tsum := 0\n\tmax := 0\n\tfor i := 0; i < 3; i++ {\n\t\tsum += t[i]\n\t\tif t[i] > max {\n\t\t\tmax = t[i]\n\t\t}\n\t}\n\n\tif sum-max == max {\n\t\treturn 2\n\t} else if sum-max > max {\n\t\treturn 1\n\t} else {\n\t\treturn 0\n\t}\n}\n"}], "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a"} {"nl": {"description": "Tarly has two different type of items, food boxes and wine barrels. There are f food boxes and w wine barrels. Tarly stores them in various stacks and each stack can consist of either food boxes or wine barrels but not both. The stacks are placed in a line such that no two stacks of food boxes are together and no two stacks of wine barrels are together.The height of a stack is defined as the number of items in the stack. Two stacks are considered different if either their heights are different or one of them contains food and other contains wine.Jon Snow doesn't like an arrangement if any stack of wine barrels has height less than or equal to h. What is the probability that Jon Snow will like the arrangement if all arrangement are equiprobably?Two arrangement of stacks are considered different if exists such i, that i-th stack of one arrangement is different from the i-th stack of the other arrangement.", "input_spec": "The first line of input contains three integers f, w, h (0 ≤ f, w, h ≤ 105) — number of food boxes, number of wine barrels and h is as described above. It is guaranteed that he has at least one food box or at least one wine barrel.", "output_spec": "Output the probability that Jon Snow will like the arrangement. The probability is of the form , then you need to output a single integer p·q - 1 mod (109 + 7).", "sample_inputs": ["1 1 1", "1 2 1"], "sample_outputs": ["0", "666666672"], "notes": "NoteIn the first example f  =  1, w = 1 and h = 1, there are only two possible arrangement of stacks and Jon Snow doesn't like any of them.In the second example f = 1, w = 2 and h = 1, there are three arrangements. Jon Snow likes the (1) and (3) arrangement. So the probabilty is . "}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"bufio\"\n\t\"os\"\n)\n\nconst (\n\tn = 1000000007\n)\n\nfunc sum(a, b int) int {\n\ts := a + b\n\tif s >= n {\n\t\treturn s - n\n\t}\n\treturn s\n}\n\nfunc mul(a, b int) int {\n\treturn int(int64(a) * int64(b) % n)\n}\n\nfunc g0(a, b, h, w int) int {\n\tif a == 0 && b == 0 {\n\t\treturn 1\n\t}\n\tvar s int\n\tfor x := h + 1; x <= a; x++ {\n\t\ts += g0(b, a - x, w, h)\n\t}\n\treturn s\n}\n\nfunc f0(a, b int) int {\n\tif a == 0 || b == 0 {\n\t\treturn 1\n\t}\n\tvar s int\n\tfor x := 1; x <= a; x++ {\n\t\ts += f0(b, a - x)\n\t}\n\treturn s\n}\n\nfunc power(a, n int) int {\n\tr := 1\n\tfor n > 0 {\n\t\tif (n & 1) != 0 {\n\t\t\tr = mul(r, a)\n\t\t}\n\t\tn /= 2\n\t\tif n > 0 {\n\t\t\ta = mul(a, a)\n\t\t}\n\t}\n\treturn r\n}\n\nfunc inv(a int) int {\n\treturn power(a, n - 2)\n}\n\nvar facts []int\nvar ifacts []int\n\nfunc cnk(n, k int) int {\n\tif k < 0 || k > n || n < 0 {\n\t\treturn 0\n\t}\n\treturn mul(mul(facts[n], ifacts[k]), ifacts[n-k])\n}\n\nfunc f1(a, b int) int {\n\treturn sum(cnk(a + b - 1, a), cnk(a + b - 1, b))\n}\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc solve(a, b, h int) int {\n\tq := f1(a, b)\n\th += 1\n\tif a == 0 {\n\t\treturn 1\n\t}\n\tif b == 0 {\n\t\tif a >= h {\n\t\t\treturn 1\n\t\t}\n\t\treturn 0\n\t}\n\tp := 0\n\tfor ka := 1; ka * h <= a; ka++ {\n\t\tfor kb := max(1, ka - 1); kb <= ka + 1 && kb <= b; kb++ {\n\t\t\tc0 := cnk(b - 1, kb - 1)\n\t\t\tc1 := cnk(a - ka * (h - 1) - 1, ka - 1)\n\t\t\t// fmt.Printf(\"%d %d %d %d\\n\", ka, kb, c0, c1)\n\t\t\td := mul(c0, c1)\n\t\t\tif ka == kb {\n\t\t\t\tp = sum(p, d)\n\t\t\t}\n\t\t\tp = sum(p, d)\n\t\t}\n\t}\n\treturn mul(p, inv(q))\n}\n\nfunc main() {\n\tm := 200100\n\tfacts = make([]int, m)\n\tifacts = make([]int, m)\n\tfacts[0] = 1\n\tfor i := 1; i < m; i++ {\n\t\tfacts[i] = mul(facts[i-1], i)\n\t}\n\tifacts[m-1] = inv(facts[m-1])\n\tfor i := m-2; i >= 0; i-- {\n\t\tifacts[i] = mul(ifacts[i+1], i+1)\n\t}\n\tcin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))\n\ta := cin.nextInt()\n\tb := cin.nextInt()\n\th := cin.nextInt()\n\tfmt.Printf(\"%d\\n\", solve(b, a, h))\n}\n\n// some io\n\ntype ParserReader struct {\n\tr io.ByteReader\n\terr error\n\tc byte\n}\n\nfunc NewParser(r io.ByteReader) *ParserReader {\n\treturn &ParserReader{r, nil, 0}\n}\n\nfunc (p *ParserReader) next() error {\n\tp.c, p.err = p.r.ReadByte()\n\treturn p.err\n}\n\nfunc isDigit(c byte) bool {\n\treturn '0' <= c && c <= '9'\n}\n\nfunc (p *ParserReader) nextUInt64() uint64 {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint64\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint64(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextUInt() uint {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt64() int64 {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int64(p.nextUInt64())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt() int {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int(p.nextUInt())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"bufio\"\n\t\"os\"\n)\n\nconst (\n\tn = 1000000007\n)\n\nfunc sum(a, b int) int {\n\ts := a + b\n\tif s >= n {\n\t\treturn s - n\n\t}\n\treturn s\n}\n\nfunc mul(a, b int) int {\n\treturn int(int64(a) * int64(b) % n)\n}\n\nfunc g0(a, b, h, w int) int {\n\tif a == 0 && b == 0 {\n\t\treturn 1\n\t}\n\tvar s int\n\tfor x := h + 1; x <= a; x++ {\n\t\ts += g0(b, a - x, w, h)\n\t}\n\treturn s\n}\n\nfunc f0(a, b int) int {\n\tif a == 0 || b == 0 {\n\t\treturn 1\n\t}\n\tvar s int\n\tfor x := 1; x <= a; x++ {\n\t\ts += f0(b, a - x)\n\t}\n\treturn s\n}\n\nfunc power(a, n int) int {\n\tr := 1\n\tfor n > 0 {\n\t\tif (n & 1) != 0 {\n\t\t\tr = mul(r, a)\n\t\t}\n\t\tn /= 2\n\t\tif n > 0 {\n\t\t\ta = mul(a, a)\n\t\t}\n\t}\n\treturn r\n}\n\nfunc inv(a int) int {\n\treturn power(a, n - 2)\n}\n\nvar facts []int\nvar ifacts []int\n\nfunc cnk(n, k int) int {\n\tif k < 0 || k > n || n < 0 {\n\t\treturn 0\n\t}\n\treturn mul(mul(facts[n], ifacts[k]), ifacts[n-k])\n}\n\nfunc f1(a, b int) int {\n\treturn sum(cnk(a + b - 1, a), cnk(a + b - 1, b))\n}\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc solve(a, b, h int) int {\n\tq := f1(a, b)\n\th += 1\n\tif a == 0 {\n\t\treturn 1\n\t}\n\tif b == 0 {\n\t\tif a >= h {\n\t\t\treturn 1\n\t\t}\n\t\treturn 0\n\t}\n\tp := 0\n\tfor ka := 1; ka * h <= a; ka++ {\n\t\tfor kb := max(1, ka - 1); kb <= ka + 1 && kb <= b; kb++ {\n\t\t\tc0 := cnk(b - 1, kb - 1)\n\t\t\tc1 := cnk(a - ka * (h - 1) - 1, ka - 1)\n\t\t\tfmt.Printf(\"%d %d %d %d\\n\", ka, kb, c0, c1)\n\t\t\td := mul(c0, c1)\n\t\t\tif ka == kb {\n\t\t\t\tp = sum(p, d)\n\t\t\t}\n\t\t\tp = sum(p, d)\n\t\t}\n\t}\n\treturn mul(p, inv(q))\n}\n\nfunc main() {\n\tm := 200100\n\tfacts = make([]int, m)\n\tifacts = make([]int, m)\n\tfacts[0] = 1\n\tfor i := 1; i < m; i++ {\n\t\tfacts[i] = mul(facts[i-1], i)\n\t}\n\tifacts[m-1] = inv(facts[m-1])\n\tfor i := m-2; i >= 0; i-- {\n\t\tifacts[i] = mul(ifacts[i+1], i+1)\n\t}\n\tcin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))\n\ta := cin.nextInt()\n\tb := cin.nextInt()\n\th := cin.nextInt()\n\tfmt.Printf(\"%d\\n\", solve(b, a, h))\n}\n\n// some io\n\ntype ParserReader struct {\n\tr io.ByteReader\n\terr error\n\tc byte\n}\n\nfunc NewParser(r io.ByteReader) *ParserReader {\n\treturn &ParserReader{r, nil, 0}\n}\n\nfunc (p *ParserReader) next() error {\n\tp.c, p.err = p.r.ReadByte()\n\treturn p.err\n}\n\nfunc isDigit(c byte) bool {\n\treturn '0' <= c && c <= '9'\n}\n\nfunc (p *ParserReader) nextUInt64() uint64 {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint64\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint64(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextUInt() uint {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt64() int64 {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int64(p.nextUInt64())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt() int {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int(p.nextUInt())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"bufio\"\n\t\"os\"\n)\n\nconst (\n\tn = 1000000007\n)\n\nfunc sum(a, b int) int {\n\ts := a + b\n\tif s >= n {\n\t\treturn s - n\n\t}\n\treturn s\n}\n\nfunc mul(a, b int) int {\n\treturn a * b % n\n}\n\nfunc g0(a, b, h, w int) int {\n\tif a == 0 && b == 0 {\n\t\treturn 1\n\t}\n\tvar s int\n\tfor x := h + 1; x <= a; x++ {\n\t\ts += g0(b, a - x, w, h)\n\t}\n\treturn s\n}\n\nfunc f0(a, b int) int {\n\tif a == 0 || b == 0 {\n\t\treturn 1\n\t}\n\tvar s int\n\tfor x := 1; x <= a; x++ {\n\t\ts += f0(b, a - x)\n\t}\n\treturn s\n}\n\nfunc power(a, n int) int {\n\tr := 1\n\tfor n > 0 {\n\t\tif (n & 1) != 0 {\n\t\t\tr = mul(r, a)\n\t\t}\n\t\tn /= 2\n\t\tif n > 0 {\n\t\t\ta = mul(a, a)\n\t\t}\n\t}\n\treturn r\n}\n\nfunc inv(a int) int {\n\treturn power(a, n - 2)\n}\n\nvar facts []int\nvar ifacts []int\n\nfunc cnk(n, k int) int {\n\tif k < 0 || k > n || n < 0 {\n\t\treturn 0\n\t}\n\treturn mul(mul(facts[n], ifacts[k]), ifacts[n-k])\n}\n\nfunc f1(a, b int) int {\n\treturn sum(cnk(a + b - 1, a), cnk(a + b - 1, b))\n}\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc solve(a, b, h int) int {\n\tq := f1(a, b)\n\th += 1\n\tif a == 0 {\n\t\treturn 1\n\t}\n\tif b == 0 {\n\t\tif a >= h {\n\t\t\treturn 1\n\t\t}\n\t\treturn 0\n\t}\n\tp := 0\n\tfor ka := 1; ka * h <= a; ka++ {\n\t\tfor kb := max(1, ka - 1); kb <= ka + 1 && kb <= b; kb++ {\n\t\t\tc0 := cnk(b - 1, kb - 1)\n\t\t\tc1 := cnk(a - ka * (h - 1) - 1, ka - 1)\n\t\t\t// fmt.Printf(\"%d %d %d %d\\n\", ka, kb, c0, c1)\n\t\t\td := mul(c0, c1)\n\t\t\tif ka == kb {\n\t\t\t\tp = sum(p, d)\n\t\t\t}\n\t\t\tp = sum(p, d)\n\t\t}\n\t}\n\treturn mul(p, inv(q))\n}\n\nfunc main() {\n\tm := 200100\n\tfacts = make([]int, m)\n\tifacts = make([]int, m)\n\tfacts[0] = 1\n\tfor i := 1; i < m; i++ {\n\t\tfacts[i] = mul(facts[i-1], i)\n\t}\n\tifacts[m-1] = inv(facts[m-1])\n\tfor i := m-2; i >= 0; i-- {\n\t\tifacts[i] = mul(ifacts[i+1], i+1)\n\t}\n\tcin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))\n\ta := cin.nextInt()\n\tb := cin.nextInt()\n\th := cin.nextInt()\n\tfmt.Printf(\"%d\\n\", solve(b, a, h))\n}\n\n// some io\n\ntype ParserReader struct {\n\tr io.ByteReader\n\terr error\n\tc byte\n}\n\nfunc NewParser(r io.ByteReader) *ParserReader {\n\treturn &ParserReader{r, nil, 0}\n}\n\nfunc (p *ParserReader) next() error {\n\tp.c, p.err = p.r.ReadByte()\n\treturn p.err\n}\n\nfunc isDigit(c byte) bool {\n\treturn '0' <= c && c <= '9'\n}\n\nfunc (p *ParserReader) nextUInt64() uint64 {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint64\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint64(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextUInt() uint {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt64() int64 {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int64(p.nextUInt64())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt() int {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int(p.nextUInt())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"bufio\"\n\t\"os\"\n)\n\nconst (\n\tn = 1000000007\n)\n\nfunc sum(a, b int) int {\n\ts := a + b\n\tif s >= n {\n\t\treturn s - n\n\t}\n\treturn s\n}\n\nfunc mul(a, b int) int {\n\treturn a * b % n\n}\n\nfunc g0(a, b, h, w int) int {\n\tif a == 0 && b == 0 {\n\t\treturn 1\n\t}\n\tvar s int\n\tfor x := h + 1; x <= a; x++ {\n\t\ts += g0(b, a - x, w, h)\n\t}\n\treturn s\n}\n\nfunc f0(a, b int) int {\n\tif a == 0 || b == 0 {\n\t\treturn 1\n\t}\n\tvar s int\n\tfor x := 1; x <= a; x++ {\n\t\ts += f0(b, a - x)\n\t}\n\treturn s\n}\n\nfunc power(a, n int) int {\n\tr := 1\n\tfor n > 0 {\n\t\tif (n & 1) != 0 {\n\t\t\tr = mul(r, a)\n\t\t}\n\t\tn /= 2\n\t\tif n > 0 {\n\t\t\ta = mul(a, a)\n\t\t}\n\t}\n\treturn r\n}\n\nfunc inv(a int) int {\n\treturn power(a, n - 2)\n}\n\nfunc cnk(n, k int) int {\n\tif k < 0 || k > n || n < 0 {\n\t\treturn 0\n\t}\n\tp, q := 1, 1\n\tfor i := 0; i < k; i++ {\n\t\tp = mul(p, n - i)\n\t\tq = mul(q, i + 1)\n\t}\n\treturn mul(p, inv(q))\n}\n\nfunc f1(a, b int) int {\n\treturn sum(cnk(a + b - 1, a), cnk(a + b - 1, b))\n}\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc solve(a, b, h int) int {\n\tq := f1(a, b)\n\tp := 0\n\th += 1\n\tfor ka := 1; ka * h <= a; ka++ {\n\t\tfor kb := max(1, ka - 1); kb <= ka + 1 && kb <= b; kb++ {\n\t\t\tc0 := cnk(b + kb - 1, kb - 1)\n\t\t\tc1 := cnk(a - ka * h + ka - 1, ka - 1)\n\t\t\t// fmt.Printf(\"%d %d %d %d\\n\", ka, kb, c0, c1)\n\t\t\td := mul(c0, c1)\n\t\t\tif ka == kb {\n\t\t\t\tp = sum(p, d)\n\t\t\t}\n\t\t\tp = sum(p, d)\n\t\t}\n\t}\n\treturn mul(p, inv(q))\n}\n\nfunc main() {\n\tcin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))\n\ta := cin.nextInt()\n\tb := cin.nextInt()\n\th := cin.nextInt()\n\tfmt.Printf(\"%d\\n\", solve(b, a, h))\n}\n\n// some io\n\ntype ParserReader struct {\n\tr io.ByteReader\n\terr error\n\tc byte\n}\n\nfunc NewParser(r io.ByteReader) *ParserReader {\n\treturn &ParserReader{r, nil, 0}\n}\n\nfunc (p *ParserReader) next() error {\n\tp.c, p.err = p.r.ReadByte()\n\treturn p.err\n}\n\nfunc isDigit(c byte) bool {\n\treturn '0' <= c && c <= '9'\n}\n\nfunc (p *ParserReader) nextUInt64() uint64 {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint64\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint64(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextUInt() uint {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt64() int64 {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int64(p.nextUInt64())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt() int {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int(p.nextUInt())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"bufio\"\n\t\"os\"\n)\n\nconst (\n\tn = 1000000007\n)\n\nfunc sum(a, b int) int {\n\ts := a + b\n\tif s >= n {\n\t\treturn s - n\n\t}\n\treturn s\n}\n\nfunc mul(a, b int) int {\n\treturn a * b % n\n}\n\nfunc g0(a, b, h, w int) int {\n\tif a == 0 && b == 0 {\n\t\treturn 1\n\t}\n\tvar s int\n\tfor x := h + 1; x <= a; x++ {\n\t\ts += g0(b, a - x, w, h)\n\t}\n\treturn s\n}\n\nfunc f0(a, b int) int {\n\tif a == 0 || b == 0 {\n\t\treturn 1\n\t}\n\tvar s int\n\tfor x := 1; x <= a; x++ {\n\t\ts += f0(b, a - x)\n\t}\n\treturn s\n}\n\nfunc power(a, n int) int {\n\tr := 1\n\tfor n > 0 {\n\t\tif (n & 1) != 0 {\n\t\t\tr = mul(r, a)\n\t\t}\n\t\tn /= 2\n\t\tif n > 0 {\n\t\t\ta = mul(a, a)\n\t\t}\n\t}\n\treturn r\n}\n\nfunc inv(a int) int {\n\treturn power(a, n - 2)\n}\n\nvar facts []int\nvar ifacts []int\n\nfunc cnk(n, k int) int {\n\tif k < 0 || k > n || n < 0 {\n\t\treturn 0\n\t}\n\treturn mul(mul(facts[n], ifacts[k]), ifacts[n-k])\n}\n\nfunc f1(a, b int) int {\n\treturn sum(cnk(a + b - 1, a), cnk(a + b - 1, b))\n}\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc solve(a, b, h int) int {\n\tq := f1(a, b)\n\tp := 0\n\th += 1\n\tfor ka := 1; ka * h <= a; ka++ {\n\t\tfor kb := max(1, ka - 1); kb <= ka + 1 && kb <= b; kb++ {\n\t\t\tc0 := cnk(b + kb - 1, kb - 1)\n\t\t\tc1 := cnk(a - ka * h + ka - 1, ka - 1)\n\t\t\t// fmt.Printf(\"%d %d %d %d\\n\", ka, kb, c0, c1)\n\t\t\td := mul(c0, c1)\n\t\t\tif ka == kb {\n\t\t\t\tp = sum(p, d)\n\t\t\t}\n\t\t\tp = sum(p, d)\n\t\t}\n\t}\n\treturn mul(p, inv(q))\n}\n\nfunc main() {\n\tm := 200100\n\tfacts = make([]int, m)\n\tifacts = make([]int, m)\n\tfacts[0] = 1\n\tfor i := 1; i < m; i++ {\n\t\tfacts[i] = mul(facts[i-1], i)\n\t}\n\tifacts[m-1] = inv(facts[m-1])\n\tfor i := m-2; i >= 0; i-- {\n\t\tifacts[i] = mul(ifacts[i+1], i+1)\n\t}\n\tcin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))\n\ta := cin.nextInt()\n\tb := cin.nextInt()\n\th := cin.nextInt()\n\tfmt.Printf(\"%d\\n\", solve(b, a, h))\n}\n\n// some io\n\ntype ParserReader struct {\n\tr io.ByteReader\n\terr error\n\tc byte\n}\n\nfunc NewParser(r io.ByteReader) *ParserReader {\n\treturn &ParserReader{r, nil, 0}\n}\n\nfunc (p *ParserReader) next() error {\n\tp.c, p.err = p.r.ReadByte()\n\treturn p.err\n}\n\nfunc isDigit(c byte) bool {\n\treturn '0' <= c && c <= '9'\n}\n\nfunc (p *ParserReader) nextUInt64() uint64 {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint64\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint64(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextUInt() uint {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt64() int64 {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int64(p.nextUInt64())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt() int {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int(p.nextUInt())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"bufio\"\n\t\"os\"\n)\n\nconst (\n\tn = 1000000007\n)\n\nfunc sum(a, b int) int {\n\ts := a + b\n\tif s >= n {\n\t\treturn s - n\n\t}\n\treturn s\n}\n\nfunc mul(a, b int) int {\n\treturn a * b % n\n}\n\nfunc g0(a, b, h, w int) int {\n\tif a == 0 && b == 0 {\n\t\treturn 1\n\t}\n\tvar s int\n\tfor x := h + 1; x <= a; x++ {\n\t\ts += g0(b, a - x, w, h)\n\t}\n\treturn s\n}\n\nfunc f0(a, b int) int {\n\tif a == 0 || b == 0 {\n\t\treturn 1\n\t}\n\tvar s int\n\tfor x := 1; x <= a; x++ {\n\t\ts += f0(b, a - x)\n\t}\n\treturn s\n}\n\nfunc power(a, n int) int {\n\tr := 1\n\tfor n > 0 {\n\t\tif (n & 1) != 0 {\n\t\t\tr = mul(r, a)\n\t\t}\n\t\tn /= 2\n\t\tif n > 0 {\n\t\t\ta = mul(a, a)\n\t\t}\n\t}\n\treturn r\n}\n\nfunc inv(a int) int {\n\treturn power(a, n - 2)\n}\n\nvar facts []int\nvar ifacts []int\n\nfunc cnk(n, k int) int {\n\tif k < 0 || k > n || n < 0 {\n\t\treturn 0\n\t}\n\treturn mul(mul(facts[n], ifacts[k]), ifacts[n-k])\n}\n\nfunc f1(a, b int) int {\n\treturn sum(cnk(a + b - 1, a), cnk(a + b - 1, b))\n}\n\nfunc max(a, b int) int {\n\tif a < b {\n\t\treturn b\n\t}\n\treturn a\n}\n\nfunc solve(a, b, h int) int {\n\tq := f1(a, b)\n\tp := 0\n\th += 1\n\tfor ka := 1; ka * h <= a; ka++ {\n\t\tfor kb := max(1, ka - 1); kb <= ka + 1 && kb <= b; kb++ {\n\t\t\tc0 := cnk(b - 1, kb - 1)\n\t\t\tc1 := cnk(a - ka * (h - 1) - 1, ka - 1)\n\t\t\t// fmt.Printf(\"%d %d %d %d\\n\", ka, kb, c0, c1)\n\t\t\td := mul(c0, c1)\n\t\t\tif ka == kb {\n\t\t\t\tp = sum(p, d)\n\t\t\t}\n\t\t\tp = sum(p, d)\n\t\t}\n\t}\n\treturn mul(p, inv(q))\n}\n\nfunc main() {\n\tm := 200100\n\tfacts = make([]int, m)\n\tifacts = make([]int, m)\n\tfacts[0] = 1\n\tfor i := 1; i < m; i++ {\n\t\tfacts[i] = mul(facts[i-1], i)\n\t}\n\tifacts[m-1] = inv(facts[m-1])\n\tfor i := m-2; i >= 0; i-- {\n\t\tifacts[i] = mul(ifacts[i+1], i+1)\n\t}\n\tcin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))\n\ta := cin.nextInt()\n\tb := cin.nextInt()\n\th := cin.nextInt()\n\tfmt.Printf(\"%d\\n\", solve(b, a, h))\n}\n\n// some io\n\ntype ParserReader struct {\n\tr io.ByteReader\n\terr error\n\tc byte\n}\n\nfunc NewParser(r io.ByteReader) *ParserReader {\n\treturn &ParserReader{r, nil, 0}\n}\n\nfunc (p *ParserReader) next() error {\n\tp.c, p.err = p.r.ReadByte()\n\treturn p.err\n}\n\nfunc isDigit(c byte) bool {\n\treturn '0' <= c && c <= '9'\n}\n\nfunc (p *ParserReader) nextUInt64() uint64 {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint64\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint64(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextUInt() uint {\n\tfor !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar r uint\n\tfor isDigit(p.c) && p.err == nil {\n\t\tr = r*10 + uint(p.c - '0')\n\t\tp.next()\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt64() int64 {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int64(p.nextUInt64())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}\n\nfunc (p *ParserReader) nextInt() int {\n\tfor p.c != '-' && !isDigit(p.c) && p.err == nil {\n\t\tp.next()\n\t}\n\tvar sign bool\n\tif p.c == '-' {\n\t\tsign = true\n\t}\n\tr := int(p.nextUInt())\n\tif sign {\n\t\treturn -r\n\t}\n\treturn r\n}"}], "src_uid": "a69f95db3fe677111cf0558271b40f39"} {"nl": {"description": "Calendars in widespread use today include the Gregorian calendar, which is the de facto international standard, and is used almost everywhere in the world for civil purposes. The Gregorian reform modified the Julian calendar's scheme of leap years as follows: Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100; the centurial years that are exactly divisible by 400 are still leap years. For example, the year 1900 is not a leap year; the year 2000 is a leap year. In this problem, you have been given two dates and your task is to calculate how many days are between them. Note, that leap years have unusual number of days in February.Look at the sample to understand what borders are included in the aswer.", "input_spec": "The first two lines contain two dates, each date is in the format yyyy:mm:dd (1900 ≤ yyyy ≤ 2038 and yyyy:mm:dd is a legal date).", "output_spec": "Print a single integer — the answer to the problem.", "sample_inputs": ["1900:01:01\n2038:12:31", "1996:03:09\n1991:11:12"], "sample_outputs": ["50768", "1579"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"time\"\n\t\"unicode/utf8\"\n)\n\nvar w *bufio.Writer\n\nvar sc *bufio.Scanner\n\nconst minus, zero byte = '-', '0'\n\nfunc nextInt() int {\n\tvar ans, fst int = 0, 0\n\tvar neg bool = false\n\tsc.Scan()\n\tif sc.Bytes()[0] == minus {\n\t\tfst = 1\n\t\tneg = true\n\t}\n\tfor _, j := range sc.Bytes()[fst:] {\n\t\tans = ans*10 + int(j-zero)\n\t}\n\tif neg == true {\n\t\tans = -ans\n\t}\n\treturn ans\n}\n\nfunc printInt(n int) {\n\tw.WriteString(strconv.Itoa(n) + \" \")\n}\n\n//two functions from go source:\nfunc isSpace(r rune) bool {\n\tif r <= '\\u00FF' {\n\t\t// Obvious ASCII ones: \\t through \\r plus space. Plus two Latin-1 oddballs.\n\t\tswitch r {\n\t\tcase ' ', '\\t', '\\n', '\\v', '\\f', '\\r', ':':\n\t\t\treturn true\n\t\tcase '\\u0085', '\\u00A0':\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\t// High-valued ones.\n\tif '\\u2000' <= r && r <= '\\u200a' {\n\t\treturn true\n\t}\n\tswitch r {\n\tcase '\\u1680', '\\u180e', '\\u2028', '\\u2029', '\\u202f', '\\u205f', '\\u3000':\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc ScanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {\n\t// Skip leading spaces.\n\tstart := 0\n\tfor width := 0; start < len(data); start += width {\n\t\tvar r rune\n\t\tr, width = utf8.DecodeRune(data[start:])\n\t\tif !isSpace(r) {\n\t\t\tbreak\n\t\t}\n\t}\n\tif atEOF && len(data) == 0 {\n\t\treturn 0, nil, nil\n\t}\n\t// Scan until space, marking end of word.\n\tfor width, i := 0, start; i < len(data); i += width {\n\t\tvar r rune\n\t\tr, width = utf8.DecodeRune(data[i:])\n\t\tif isSpace(r) {\n\t\t\treturn i + width, data[start:i], nil\n\t\t}\n\t}\n\t// If we're at EOF, we have a final, non-empty, non-terminated word. Return it.\n\tif atEOF && len(data) > start {\n\t\treturn len(data), data[start:], nil\n\t}\n\t// Request more data.\n\treturn 0, nil, nil\n}\n\nfunc main() {\n\n\tw = bufio.NewWriter(os.Stdout)\n\tsc = bufio.NewScanner(os.Stdin)\n\tsc.Split(ScanWords)\n\ttyme1, tyme2 := time.Date(nextInt(), time.Month(nextInt()), nextInt(), 0, 0, 0, 0, time.UTC),\n\t\ttime.Date(nextInt(), time.Month(nextInt()), nextInt(), 0, 0, 0, 0, time.UTC)\n\tans := int(tyme2.Sub(tyme1).Hours() / 24)\n\tif ans < 0 {\n\t\tans = -ans\n\t}\n\tprintInt(ans)\n\tw.Flush()\n\t//YOU FORGOT TO FLUSH!\n}\n"}], "negative_code": [], "src_uid": "bdf99d78dc291758fa09ec133fff1e9c"} {"nl": {"description": "Ilya is a very clever lion, he lives in an unusual city ZooVille. In this city all the animals have their rights and obligations. Moreover, they even have their own bank accounts. The state of a bank account is an integer. The state of a bank account can be a negative number. This means that the owner of the account owes the bank money.Ilya the Lion has recently had a birthday, so he got a lot of gifts. One of them (the gift of the main ZooVille bank) is the opportunity to delete the last digit or the digit before last from the state of his bank account no more than once. For example, if the state of Ilya's bank account is -123, then Ilya can delete the last digit and get his account balance equal to -12, also he can remove its digit before last and get the account balance equal to -13. Of course, Ilya is permitted not to use the opportunity to delete a digit from the balance.Ilya is not very good at math, and that's why he asks you to help him maximize his bank account. Find the maximum state of the bank account that can be obtained using the bank's gift.", "input_spec": "The single line contains integer n (10 ≤ |n| ≤ 109) — the state of Ilya's bank account.", "output_spec": "In a single line print an integer — the maximum state of the bank account that Ilya can get. ", "sample_inputs": ["2230", "-10", "-100003"], "sample_outputs": ["2230", "0", "-10000"], "notes": "NoteIn the first test sample Ilya doesn't profit from using the present.In the second test sample you can delete digit 1 and get the state of the account equal to 0."}, "positive_code": [{"source_code": "package main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tif n >= 0 {\n\t\tfmt.Println(n)\n\t} else {\n\t\tk:= n/10\n\t\tj:= n/100 * 10 + n %10\n\t\tif k > j {\n\t\t\tfmt.Println(k)\n\t\t} else {fmt.Println(j)}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\\n\", &n)\n\tif n < 0 {\n\t\tn = -n\n\t\tlast := n % 10\n\t\tsteplast := (n / 10) % 10\n\t\tn = (n/100)*10 + min(last, steplast)\n\t\tn = -n\n\t}\n\tfmt.Print(n)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n if s[0] == '-' {\n ans, len := 0, len(s)\n for i := 1; i < (len-2); i++ {\n ans = (ans*10) + int(s[i]-'0')\n }\n if s[len-1] < s[len-2] {\n ans = (ans*10) + int(s[len-1]-'0')\n } else {\n ans = (ans*10) + int(s[len-2]-'0')\n }\n fmt.Println(-ans)\n } else {\n fmt.Println(s)\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\n\t\"fmt\"\n\t\"strconv\"\n)\n\nfunc getString() string {\n\tsc := bufio.NewScanner(os.Stdin)\n\tfor sc.Scan() {\n\t\treturn sc.Text()\n\t}\n\treturn sc.Text()\n}\n\nfunc main() {\n\tstr := getString()\n\tacc, _ := strconv.Atoi(str)\n\tif acc > 0 {\n\t\tfmt.Println(acc)\n\t} else {\n\t\tstr1 := string(str[0 : len(str)-1])\n\t\tstr2 := string(str[0:len(str)-2]) + string(str[len(str)-1])\n\t\tnumber1, _ := strconv.Atoi(str1)\n\t\tnumber2, _ := strconv.Atoi(str2)\n\t\tif number1 > number2 {\n\t\t\tfmt.Println(number1)\n\t\t} else {\n\t\t\tfmt.Println(number2)\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\nimport (\n\t\"fmt\"\n)\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tif n >= 0 {\n\t\tfmt.Println(n)\n\t} else {\n\t\tk:= n/10\n\t\tj:= n/100 * 10 + n %10\n\t\tif k > j {\n\t\t\tfmt.Println(k)\n\t\t} else {fmt.Println(j)}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar account int64\n\tfmt.Scan(&account)\n\n\tif account >= 0 || account/10 == 0 {\n\t\tfmt.Print(account)\n\t} else {\n\t\taccount *= -1\n\t\tlast := account % 10\n\t\taccount /= 10\n\t\tten := account % 10\n\t\taccount -= ten\n\n\t\tif last > ten {\n\t\t\tfmt.Print(-1 * (account + ten))\n\t\t} else {\n\t\t\tfmt.Print(-1 * (account + last))\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nvar reader *bufio.Reader\n\nfunc init() {\n\tstdin := os.Stdin\n\t// stdin, _ = os.Open(\"1.in\")\n\treader = bufio.NewReaderSize(stdin, 1<<20)\n}\n\n// Max Max\nfunc Max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nvar s string\n\nfunc main() {\n\tfmt.Fscan(reader, &s)\n\tif s[0] != '-' {\n\t\tfmt.Println(s)\n\t\treturn\n\t}\n\tn := len(s)\n\ta, _ := strconv.Atoi(s[0 : n-1])\n\tb, _ := strconv.Atoi(s[0:n-2] + s[n-1:n])\n\tfmt.Println(Max(a, b))\n}\n"}, {"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\ta := n / 10\n\tb := n/100*10 + n%10\n\tprintln(max(n, max(a, b)))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int64\n\tfmt.Scan(&n)\n\tif n >= 0 {\n\t\tfmt.Println(n)\n\t} else {\n\t\tlastd := n % 10\n\t\tseclastd := (n / 10) % 10\n\t\tn = n / 100\n\t\tif n*10+lastd > n*10+seclastd {\n\t\t\tfmt.Println(n*10 + lastd)\n\t\t} else {\n\t\t\tfmt.Println(n*10 + seclastd)\n\t\t}\n\t}\n}\n"}, {"source_code": "// 313A-mic\npackage main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n var n int\n fmt.Scan(&n)\n if n >= 0 {\n\n } else {\n n = int(math.Max(float64(n/10), float64((n/100)*10+(n%10))))\n }\n fmt.Println(n)\n}\n"}, {"source_code": "package main\nimport (\n \"fmt\"\n)\nfunc main() {\n var n int // 1\n fmt.Scan(&n)\n if n >= 0 { //1 + 1\n fmt.Println(n)\n } else {\n k:= n/10// 1\n j:= n/100 * 10 + n %10 // 1 + 1 \n if k > j {// 1 + 1\n fmt.Println(k)\n } else {fmt.Println(j)}\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"math/rand\"\n\t\"os\"\n)\n\nconst INF = 1000000001\n\ntype Pair struct {\n\tfirst, second int\n}\n\nfunc sort(arr []Pair) []Pair {\n\tif len(arr) < 2 {\n\t\treturn arr\n\t}\n\tleft := 0\n\tright := len(arr) - 1\n\tpivot := rand.Int() % len(arr)\n\n\tarr[pivot], arr[right] = arr[right], arr[pivot]\n\n\tfor i := 0; i < len(arr); i++ {\n\t\tif arr[i].first > arr[right].first {\n\t\t\tarr[i], arr[left] = arr[left], arr[i]\n\t\t\tleft++\n\t\t}\n\t}\n\n\tarr[left], arr[right] = arr[right], arr[left]\n\n\tsort(arr[:left])\n\tsort(arr[left+1:])\n\treturn arr\n}\n\nfunc sort2(arr []int) []int {\n\tif len(arr) < 2 {\n\t\treturn arr\n\t}\n\tleft := 0\n\tright := len(arr) - 1\n\tpivot := rand.Int() % len(arr)\n\n\tarr[pivot], arr[right] = arr[right], arr[pivot]\n\n\tfor i := 0; i < len(arr); i++ {\n\t\tif arr[i] < arr[right] {\n\t\t\tarr[i], arr[left] = arr[left], arr[i]\n\t\t\tleft++\n\t\t}\n\t}\n\n\tarr[left], arr[right] = arr[right], arr[left]\n\n\tsort2(arr[:left])\n\tsort2(arr[left+1:])\n\treturn arr\n}\n\nfunc gcd (a, b int64) int64 {\n\tif b == 0 {\n\t\treturn a\n\t}\n\treturn gcd (b, a % b);\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc solution(reader io.Reader, writer io.Writer) {\n\tvar n int\n\tfmt.Fscanf(reader, \"%d\", &n)\n\tif n >= 0 {\n\t\tfmt.Println(n)\n\t} else {\n\t\tn = -n\n\t\ta := n % 10\n\t\tn /= 10\n\t\tb := n % 10\n\t\tn /= 10\n\t\tn *= 10\n\t\tfmt.Println((n + min(a, b)) * -1)\n\t}\n}\n\nfunc main() {\n\n\t//stdin, err := os.Open(\"file.in\")\n\t//if err != nil {\n\t//\tpanic(err)\n\t//}\n\t//defer stdin.Close()\n\tstdin := os.Stdin\n\treader := bufio.NewReaderSize(stdin, 1024*1024)\n\n\t//stdout, err := os.Create(\"file.out\")\n\t//if err != nil {\n\t//\tpanic(err)\n\t//}\n\t//defer stdout.Close()\n\tstdout := os.Stdout\n\twriter := bufio.NewWriterSize(stdout, 1024*1024)\n\tdefer writer.Flush()\n\n\tsolution(reader, writer)\n}"}, {"source_code": "package main\nimport (\n \"fmt\"\n)\nfunc main() {\n var n int\n var x int\n var y int\n fmt.Scan(&n)\n x= n/10\n y= n/100 * 10 + n %10\n if n >= 0 {\n fmt.Println(n)\n }else if x > y {\n fmt.Println(x)\n } else {fmt.Println(y)\n }\n \n }"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n if s[0] == '-' {\n ans, len := 0, len(s)\n for i := 1; i < (len-2); i++ {\n ans = (ans*10) + int(s[i]-'0')\n }\n if s[len-1] < s[len-2] {\n ans = (ans*10) + int(s[len-1]-'0')\n } else {\n ans = (ans*10) + int(s[len-2]-'0')\n }\n fmt.Println(-ans)\n } else {\n fmt.Println(s)\n }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// https://codeforces.com/problemset/problem/4/A\n// комментарии к решению\n// n без последней цифры == n%10\n// n без предпоследней цифры == (n/100)*10 + n%10\nfunc taskSolution(n int) int {\n\tans := max(n, n/10)\n\tn = (n/100)*10 + n%10\n\treturn max(ans, n)\n}\n\nfunc main() {\n\tvar n int\n\tif _, err := fmt.Scan(&n); err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(taskSolution(n))\n}\n"}, {"source_code": "package main\nimport \"fmt\"\n\nfunc main(){\n\tvar s string\n\tfmt.Scan(&s)\n\tif s[0]!='-' {\n\t\tfmt.Print(s)\n\t\treturn\n\t}\n\tn:=len(s)\n\tif (n==3) && (s[0]=='-') && (s[2]=='0') {\n\t\tfmt.Print(0)\n\t\treturn\n\t}\n\t\n\tif s[n-1]= secondDigit && firstDigit >= n {\n\t\tfmt.Printf(\"%d\", firstDigit)\n\t}else if secondDigit >= firstDigit && secondDigit >= n {\n\t\tfmt.Printf(\"%d\", secondDigit)\n\t}else {\n\t\tfmt.Printf(\"%d\", n)\n\t}\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int64\n\tfmt.Scan(&n)\n\tsecondDigit := n / 10\n\tfirstDigit := n / 100 * 10 + n % 10\n\n\tif firstDigit > secondDigit && firstDigit > n {\n\t\tfmt.Printf(\"%d\", firstDigit)\n\t}else if secondDigit > firstDigit && secondDigit > n {\n\t\tfmt.Printf(\"%d\", secondDigit)\n\t}else {\n\t\tfmt.Printf(\"%d\", n)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%d\\n\", &n)\n\tif n < 0 {\n\t\tn = -n\n\t\tsteplast := (n / 10) % 10\n\t\tif steplast == 0 {\n\t\t\tn = n / 10\n\t\t} else {\n\t\t\tn = n%10 + (n/100)*10\n\t\t}\n\t\tn = -n\n\t}\n\tfmt.Print(n)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n fmt.Scan(&s)\n if s[0] == '-' {\n del := 1\n for i := 1; i < len(s); i++ {\n if s[del] < s[i] { del = i }\n }\n ans := 0\n for i := 1; i < len(s); i++ {\n if i != del { ans = (ans*10) + int(s[i]-'0') }\n }\n fmt.Println(-ans)\n } else {\n fmt.Println(s)\n }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int64\n\tfmt.Scan(&n)\n\tsecondDigit := n / 10\n\tfirstDigit := n / 100 * 10 + n % 10\n\tfmt.Println(n, firstDigit, secondDigit)\n\tif firstDigit >= secondDigit && firstDigit >= n {\n\t\tfmt.Printf(\"%d\", firstDigit)\n\t}else if secondDigit >= firstDigit && secondDigit >= n {\n\t\tfmt.Printf(\"%d\", secondDigit)\n\t}else {\n\t\tfmt.Printf(\"%d\", n)\n\t}\n}\n"}], "src_uid": "4b0a8798a6d53351226d4f06e3356b1e"} {"nl": {"description": "Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card.Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with number he chose. For example, if Petya chose number 5 before the game he will take all cards on which 5 is written and if Vasya chose number 10 before the game he will take all cards on which 10 is written.The game is considered fair if Petya and Vasya can take all n cards, and the number of cards each player gets is the same.Determine whether Petya and Vasya can choose integer numbers before the game so that the game is fair. ", "input_spec": "The first line contains a single integer n (2 ≤ n ≤ 100) — number of cards. It is guaranteed that n is an even number. The following n lines contain a sequence of integers a1, a2, ..., an (one integer per line, 1 ≤ ai ≤ 100) — numbers written on the n cards.", "output_spec": "If it is impossible for Petya and Vasya to choose numbers in such a way that the game will be fair, print \"NO\" (without quotes) in the first line. In this case you should not print anything more. In the other case print \"YES\" (without quotes) in the first line. In the second line print two distinct integers — number that Petya should choose and the number that Vasya should choose to make the game fair. If there are several solutions, print any of them.", "sample_inputs": ["4\n11\n27\n27\n11", "2\n6\n6", "6\n10\n20\n30\n20\n10\n20", "6\n1\n1\n2\n2\n3\n3"], "sample_outputs": ["YES\n11 27", "NO", "NO", "NO"], "notes": "NoteIn the first example the game will be fair if, for example, Petya chooses number 11, and Vasya chooses number 27. Then the will take all cards — Petya will take cards 1 and 4, and Vasya will take cards 2 and 3. Thus, each of them will take exactly two cards.In the second example fair game is impossible because the numbers written on the cards are equal, but the numbers that Petya and Vasya should choose should be distinct.In the third example it is impossible to take all cards. Petya and Vasya can take at most five cards — for example, Petya can choose number 10 and Vasya can choose number 20. But for the game to be fair it is necessary to take 6 cards."}, "positive_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tm := make(map[int]int)\n\tlast := -1\n\tfor i := 0; i < n; i++ {\n\t\tvar a int\n\t\tfmt.Scan(&a)\n\t\tm[a]++\n\t\tlast = a\n\t}\n\tif len(m) != 2 || m[last] != n/2 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t\tdelete(m, last)\n\t\tother := 0\n\t\tfor other = range m {\n\t\t\tbreak\n\t\t}\n\t\tfmt.Println(last, other)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nfunc main() {\n\tbs, _ := ioutil.ReadAll(os.Stdin)\n\treader := bytes.NewBuffer(bs)\n\n\tvar n, p, count int\n\tfmt.Fscanf(reader, \"%d\\n\", &n)\n\tm := map[int]int{}\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fscanf(reader, \"%d\\n\", &p)\n\t\tc, ok := m[p]\n\t\tif ok {\n\t\t\tm[p] = c + 1\n\t\t\tcount = c + 1\n\t\t} else {\n\t\t\tm[p] = 1\n\t\t\tcount = 1\n\t\t}\n\t}\n\tif len(m) != 2 {\n\t\tfmt.Printf(\"NO\")\n\t\treturn\n\t} else {\n\t\tans := make([]int, 0, 2)\n\t\tfor k, v := range m {\n\t\t\tif v == count {\n\t\t\t\tans = append(ans, k)\n\t\t\t} else {\n\t\t\t\tfmt.Printf(\"NO\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tfmt.Printf(\"YES\\n%d %d\\n\", ans[0], ans[1])\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tcards := make([]int, n)\n\tfor i := range cards {\n\t\tfmt.Scan(&cards[i])\n\t}\n\n\tm := make(map[int]int)\n\tfor _, v := range cards {\n\t\tm[v]++\n\t}\n\n\tif len(m) != 2 {\n\t\tfmt.Println(\"NO\")\n\t\treturn\n\t}\n\n\tuniqueCards := make([]int, 0)\n\tfor card := range m {\n\t\tuniqueCards = append(uniqueCards, card)\n\t}\n\n\tif m[uniqueCards[0]] == m[uniqueCards[1]] {\n\t\tfmt.Println(\"YES\")\n\t\tfmt.Printf(\"%d %d\\n\", uniqueCards[0], uniqueCards[1])\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, temp int\n\tvar seen = make(map[int]int)\n\tfmt.Scanln(&n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanln(&temp)\n\t\tseen[temp] += 1\n\t}\n\tif len(seen) != 2 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tvar keys []int\n\t\tvar vals []int\n\t\tfor k, v := range seen {\n\t\t\tkeys = append(keys, k)\n\t\t\tvals = append(vals, v)\n\t\t}\n\t\tif vals[0] == vals[1] {\n\t\t\tfmt.Println(\"YES\")\n\t\t\tfor _, k := range keys {\n\t\t\t\tfmt.Printf(\"%d \", k)\n\t\t\t}\n\t\t} else {\n\t\t\tfmt.Println(\"NO\")\n\t\t}\n\t}\n}\n"}, {"source_code": "// Codeforces helper functions\n// 20 Jan 18\n// samadhi\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nconst debug = false\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tn := gsli(reader)[0]\n\n\tvar m map[int]int\n\tm = make(map[int]int)\n\n\tfor i := 0; i <= 100; i++ {\n\t\tm[i] = 0\n\t}\n\n\tfor i := 0; i < n; i++ {\n\t\tcur := gsli(reader)[0]\n\t\tm[cur]++\n\t}\n\n\tfor i, e := range m {\n\t\tfor j, e2 := range m {\n\t\t\tif e == e2 && e != 0 && i != j && e+e2 == n {\n\t\t\t\tfmt.Printf(\"YES\\n\")\n\t\t\t\tfmt.Printf(\"%v %v\", i, j)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\tdbg(\"%v\", m)\n\n\tfmt.Printf(\"NO\")\n\n}\n\n// Input helpers\n\n// If you don't pass in a reference to the reader, and just instantiate a new\n// one every time, it will work locally, with IO typed at human-speed, but not\n// on Codeforces.\n\n// Get Space-separated Line as Strings\n//\n// Example input:\n// 1 test 382.0\n// Example output:\n// [\"1\", \"test\", \"382.0\"]\n\nfunc gsls(reader *bufio.Reader) (arr []string) {\n\t// Get a full line\n\tinput, _ := reader.ReadString('\\n')\n\n\t//Strip newline and return chars, if any\n\tinput = strings.TrimSuffix(input, \"\\n\")\n\tinput = strings.TrimSuffix(input, \"\\r\")\n\n\t// Split at the spaces into an array\n\tarr = strings.Split(input, \" \")\n\n\treturn\n}\n\n// Get Space-separated Line as Integers\n// Any non-valid integers will be 0\n//\n// Example input:\n// test 1 12.3 -117\n// Example output:\n// [0, 1, 0, -117]\n\nfunc gsli(reader *bufio.Reader) (arr []int) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.Atoi(e)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Get Space-separated Line as 64-bit Floats\n// Any non-valid floats will be 0\n//\n// Example input:\n// test 128.328 12 -11.0\n// Example output:\n// [0, 128.328, 12, -11]\n\nfunc gslf(reader *bufio.Reader) (arr []float64) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.ParseFloat(e, 64)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Math helpers\n\n// Positve Modulo\n// Returns x mod y, but always positive\n\nfunc posMod(x, y int) int {\n\treturn (x%y + y) % y\n}\n\n// Output helpers\n\nfunc yes() {\n\tfmt.Println(\"Yes\")\n}\n\nfunc no() {\n\tfmt.Println(\"No\")\n}\n\n// Debug helpers\n\n// From https://groups.google.com/forum/#!topic/golang-nuts/Qlxs3V77nss\n\nfunc dbg(s string, a ...interface{}) {\n\tif debug {\n\t\tfmt.Printf(s, a...)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"strconv\"\n\t\"fmt\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput, _, _ := reader.ReadLine()\n\t//n := strings.Split(string(input), \" \")\n\n\ttimes, _ := strconv.Atoi(string(input))\n\n\n\ta := make(map[byte]int)\n\n\tfor i := 0; i < times; i++ {\n\t\tinp, _, _ := reader.ReadLine()\n\t\tinteger, _ := strconv.Atoi(string(inp))\n\t\t_, ok := a[byte(integer)]\n\t\tif ok {\n\t\t\ta[byte(integer)]++\n\t\t} else {\n\t\t\ta[byte(integer)] = 0\n\t\t}\n\t}\n\n\tif len(a)!= 2 {\n\t\tfmt.Println(\"No\")\n\t\tos.Exit(0)\n\t}\n\n\tvar arr [2]int\n\ti := 0\n\tfor _, v := range a {\n\t\tarr[i] = v\n\t\ti++\n\t}\n\tif arr[0] != arr[1] {\n\t\tfmt.Println(\"No\")\n\t} else {\n\t\tfmt.Println(\"Yes\")\n\t\tfor key := range a {\n\t\t\tfmt.Print(key, \" \")\n\t\t}\n\t\tfmt.Println()\n\t}\n}\n"}, {"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\tv := make([]int, 101)\n\tfor i := 0; i < n; i++ {\n\t\tv[readInt()]++\n\t}\n\tpos := 0\n\tcnt1 := 0\n\tcnt2 := 0\n\tres := make([]int, 0)\n\ttotal1 := 0\n\ttotal2 := 0\n\tfor i := 0; i < len(v); i++ {\n\t\tif v[i] != 0 {\n\t\t\tres = append(res, i)\n\t\t\tif pos%2 == 0 {\n\t\t\t\tcnt1++\n\t\t\t\ttotal1 += v[i]\n\t\t\t} else {\n\t\t\t\tcnt2++\n\t\t\t\ttotal2 += v[i]\n\t\t\t}\n\t\t\tpos++\n\t\t}\n\t}\n\tif cnt1 == cnt2 && total1 == total2 && len(res) == 2 {\n\t\tfmt.Println(\"YES\")\n\t\tfor i := 0; i < len(res); i++ {\n\t\t\tif i > 0 {\n\t\t\t\tfmt.Print(\" \")\n\t\t\t}\n\t\t\tfmt.Print(res[i])\n\t\t}\n\t\tfmt.Println()\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar num int\nvar temp int\n\nfunc main() {\n fmt.Scan(&num)\n res := make(map[int]int)\n for i := 0; i < num; i++ {\n fmt.Scan(&temp)\n if num, ok := res[temp]; ok {\n res[temp] = num + 1\n } else {\n res[temp] = 1\n }\n }\n if len(res) != 2 || res[temp] != num/2 {\n fmt.Println(\"NO\")\n return\n }\n pre := -1\n for key, _ := range res {\n if pre == -1 {\n pre = key\n } else {\n fmt.Printf(\"yes\\n%d %d\\n\", pre, key)\n }\n }\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar N int\n\tfmt.Scanf(\"%d\\n\", &N)\n\tnumbers := make([]int, N)\n\tfor i := 0; i < N; i++ {\n\t\tfmt.Scanf(\"%d\\n\", &numbers[i])\n\t}\n\n\t// sort\n\tsort.Ints(numbers)\n\n\tif numbers[0] == numbers[(N/2)-1] && numbers[(N/2)] == numbers[N-1] &&\n\t\tnumbers[N-1] != numbers[0] {\n\t\tfmt.Println(\"YES\")\n\t\tfmt.Printf(\"%d %d\", numbers[0], numbers[N-1])\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tm := make(map[int]int)\n\tfor i := 0 ; i < n ; i++ {\n\t\tvar v int\n\t\tfmt.Scan(&v)\n\t\tm[v]++\n\t}\n\tif len(m) == 2 {\n\t\tcnt := 0\n\t\tvar k1, k2 int\n\t\tfor k, v := range m {\n\t\t\tif cnt == 0 {\n\t\t\t\tk1 = k\n\t\t\t\tcnt = v\n\t\t\t} else if cnt != v {\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t\treturn\n\t\t\t} else {\n\t\t\t\tk2 = k\n\t\t\t}\n\t\t}\n\t\tfmt.Println(\"YES\")\n\t\tfmt.Println(k1, k2)\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}"}, {"source_code": "package main\n\nimport (\"fmt\")\n\nfunc main(){\n\tvar n int\n\ta := make(map[int]int)\n\tscan(&n)\n\tfor i := 0; i < n; i++{\n\t\tvar t int\n\t\tscan(&t)\n\t\ta[t]++\n\t}\n\tif len(a) > 2 || len(a) < 2{\n\t\tsout(\"NO\")\n\t\treturn\n\t}\n\tb := make(map[int]map[int]bool)\n\tfor k,v := range a{\n\t\tif b[v] == nil {b[v] = make(map[int]bool)}\n\t\tb[v][k] = true\n\t}\n\n\tfor _,v := range b{\n\t\tif (len(v) >= 2){\n\t\t\tsout(\"YES\")\n\t\t\tt := 0\n\t\t\tfor k,_ := range v{\n\t\t\t\tsout(k)\n\t\t\t\tif (t == 1){return}\n\t\t\t\tt++\n\t\t\t}\n\t\t}\n\t} \n\tsout(\"NO\")\n}\n\nfunc scan(in ... interface{}){\n\tfor _,k := range in{\n\t\tfmt.Scan(k)\n\t}\n}\n\nfunc sout(obj ... interface{}){\n\tfor _, k := range obj{\n\t\tfmt.Print(k)\n\t}\n\tfmt.Println()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar a [101]int\n\tfor i := 0; i < n; i++ {\n\t\tvar x int\n\t\tfmt.Scan(&x)\n\t\ta[x]++\n\t}\n\tfor i := 1; i <= 100; i++ {\n\t\tfor j := i + 1; j <= 100; j++ {\n\t\t\tif a[i] == a[j] && a[i] == n / 2 {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\tfmt.Printf(\"%d %d\\n\", i, j)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tcards := make([]int, n)\n\tfor i := range cards {\n\t\tfmt.Scan(&cards[i])\n\t}\n\n\tm := make(map[int]int)\n\tfor _, v := range cards {\n\t\tm[v]++\n\t}\n\n\tif len(m) != 2 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tvar en int\n\t\tfor _, entries := range m {\n\t\t\tif en == 0 {\n\t\t\t\ten = entries\n\t\t\t}\n\t\t\tif entries != en {\n\t\t\t\tfmt.Println(\"NO\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tfmt.Println(\"YES\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, temp int\n\tvar seen = make(map[int]bool)\n\tfmt.Scanln(&n)\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanln(&temp)\n\t\tseen[temp] = true\n\t}\n\tif len(seen) != 2 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t\tfor k, _ := range seen {\n\t\t\tfmt.Printf(\"%d \", k)\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tvar seen = make(map[int]bool)\n\tfmt.Scanf(\"%d\", &n)\n\tvar temp int\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Scanf(\"%d\", &temp)\n\t\tseen[temp] = true\n\t}\n\tif len(seen) != 2 {\n\t\tfmt.Println(\"NO\")\n\t} else {\n\t\tfmt.Println(\"YES\")\n\t\tfor k, _ := range seen {\n\t\t\tfmt.Printf(\"%d \", k)\n\t\t}\n\t}\n}\n"}, {"source_code": "// Codeforces helper functions\n// 20 Jan 18\n// samadhi\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nconst debug = false\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tn := gsli(reader)[0]\n\n\tvar m map[int]int\n\tm = make(map[int]int)\n\n\tfor i := 0; i <= 100; i++ {\n\t\tm[i] = 0\n\t}\n\n\tfor i := 0; i < n; i++ {\n\t\tcur := gsli(reader)[0]\n\t\tm[cur]++\n\t}\n\n\tfor i, e := range m {\n\t\tfor j, e2 := range m {\n\t\t\tif e == e2 && e != 0 && i != j {\n\t\t\t\tfmt.Printf(\"YES\\n\")\n\t\t\t\tfmt.Printf(\"%v %v\", i, j)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\tdbg(\"%v\", m)\n\n\tfmt.Printf(\"NO\")\n\n}\n\n// Input helpers\n\n// If you don't pass in a reference to the reader, and just instantiate a new\n// one every time, it will work locally, with IO typed at human-speed, but not\n// on Codeforces.\n\n// Get Space-separated Line as Strings\n//\n// Example input:\n// 1 test 382.0\n// Example output:\n// [\"1\", \"test\", \"382.0\"]\n\nfunc gsls(reader *bufio.Reader) (arr []string) {\n\t// Get a full line\n\tinput, _ := reader.ReadString('\\n')\n\n\t//Strip newline and return chars, if any\n\tinput = strings.TrimSuffix(input, \"\\n\")\n\tinput = strings.TrimSuffix(input, \"\\r\")\n\n\t// Split at the spaces into an array\n\tarr = strings.Split(input, \" \")\n\n\treturn\n}\n\n// Get Space-separated Line as Integers\n// Any non-valid integers will be 0\n//\n// Example input:\n// test 1 12.3 -117\n// Example output:\n// [0, 1, 0, -117]\n\nfunc gsli(reader *bufio.Reader) (arr []int) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.Atoi(e)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Get Space-separated Line as 64-bit Floats\n// Any non-valid floats will be 0\n//\n// Example input:\n// test 128.328 12 -11.0\n// Example output:\n// [0, 128.328, 12, -11]\n\nfunc gslf(reader *bufio.Reader) (arr []float64) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.ParseFloat(e, 64)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Math helpers\n\n// Positve Modulo\n// Returns x mod y, but always positive\n\nfunc posMod(x, y int) int {\n\treturn (x%y + y) % y\n}\n\n// Output helpers\n\nfunc yes() {\n\tfmt.Println(\"Yes\")\n}\n\nfunc no() {\n\tfmt.Println(\"No\")\n}\n\n// Debug helpers\n\n// From https://groups.google.com/forum/#!topic/golang-nuts/Qlxs3V77nss\n\nfunc dbg(s string, a ...interface{}) {\n\tif debug {\n\t\tfmt.Printf(s, a...)\n\t}\n}\n"}, {"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\tv := make([]int, 101)\n\tfor i := 0; i < n; i++ {\n\t\tv[readInt()]++\n\t}\n\tpos := 0\n\tcnt1 := 0\n\tcnt2 := 0\n\tres := make([]int, 0)\n\tfor i := 0; i < len(v); i++ {\n\t\tif v[i] != 0 {\n\t\t\tres = append(res, i)\n\t\t\tif pos%2 == 0 {\n\t\t\t\tcnt1++\n\t\t\t} else {\n\t\t\t\tcnt2++\n\t\t\t}\n\t\t\tpos++\n\t\t}\n\t}\n\tif cnt1 == cnt2 {\n\t\tfmt.Println(\"YES\")\n\t\tfor i := 0; i < len(res); i++ {\n\t\t\tif i > 0 {\n\t\t\t\tfmt.Print(\" \")\n\t\t\t}\n\t\t\tfmt.Print(res[i])\n\t\t}\n\t\tfmt.Println()\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}, {"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\tv := make([]int, 101)\n\tfor i := 0; i < n; i++ {\n\t\tv[readInt()]++\n\t}\n\tpos := 0\n\tcnt2 := 0\n\tcnt1 := 0\n\ttotal2 := 0\n\ttotal1 := 0\n\tres := make([]int, 0)\n\tfor i := 0; i < len(v); i++ {\n\t\tif v[i] != 0 {\n\t\t\tres = append(res, i)\n\t\t\tif pos%2 == 0 {\n\t\t\t\tcnt1++\n\t\t\t\ttotal1 += v[i]\n\t\t\t} else {\n\t\t\t\ttotal2 += v[i]\n\t\t\t\tcnt2++\n\t\t\t}\n\t\t\tpos++\n\t\t}\n\t}\n\tif cnt1 == cnt2 && total1 == total2 {\n\t\tfmt.Println(\"YES\")\n\t\tfor i := 0; i < len(res); i++ {\n\t\t\tif i > 0 {\n\t\t\t\tfmt.Print(\" \")\n\t\t\t}\n\t\t\tfmt.Print(res[i])\n\t\t}\n\t\tfmt.Println()\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc abs(a int) int {\n\tif a < 0 {\n\t\treturn -a\n\t}\n\treturn a\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar num int\nvar temp int\n\nfunc main() {\n fmt.Scan(&num)\n res := make(map[int]int)\n for i := 0; i < num; i++ {\n fmt.Scan(&temp)\n if num, ok := res[temp]; ok {\n res[temp] = num + 1\n } else {\n res[temp] = 1\n }\n }\n if len(res) != 2 {\n fmt.Println(\"NO\")\n return\n }\n pre := -1\n for key, _ := range res {\n if pre == -1 {\n pre = key\n } else {\n fmt.Printf(\"yes\\n%d %d\\n\", pre, key)\n }\n }\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar N int\n\tfmt.Scanf(\"%d\", &N)\n\tnumbers := make([]int, N)\n\tfor i := 0; i < N; i++ {\n\t\tfmt.Scanf(\"%d\", &numbers[i])\n\t}\n\n\t// sort\n\tsort.Ints(numbers)\n\n\tif numbers[0] == numbers[(N/2)-1] && numbers[(N/2)] == numbers[N-1] &&\n\t\tnumbers[N-1] != numbers[0] {\n\t\tfmt.Println(\"YES\")\n\t\tfmt.Printf(\"%d %d\", numbers[0], numbers[N-1])\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar N int\n\tfmt.Scanf(\"%d\\n\", &N)\n\tnumbers := make([]int, N)\n\tfor i := 0; i < N; i++ {\n\t\tfmt.Scanf(\"%d\\n\", &numbers[i])\n\t}\n\n\t// sort\n\tsort.Ints(numbers)\n\tfmt.Println(\"Numbers\")\n\tfmt.Println(numbers)\n\n\tif numbers[0] == numbers[(N/2)-1] && numbers[(N/2)] == numbers[N-1] &&\n\t\tnumbers[N-1] != numbers[0] {\n\t\tfmt.Println(\"YES\")\n\t\tfmt.Printf(\"%d %d\", numbers[0], numbers[N-1])\n\t} else {\n\t\tfmt.Println(\"NO\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\"fmt\")\n\nfunc main(){\n\tvar n int\n\ta := make(map[int]int)\n\tscan(&n)\n\tfor i := 0; i < n; i++{\n\t\tvar t int\n\t\tscan(&t)\n\t\ta[t]++\n\t}\n\tif len(a) > 2 || len(a) < 2{\n\t\tsout(\"NO\")\n\t\treturn\n\t}\n\tb := make(map[int]map[int]bool)\n\tfor k,v := range a{\n\t\tif b[v] == nil {b[v] = make(map[int]bool)}\n\t\tb[v][k] = true\n\t}\n\n\tfor _,v := range b{\n\t\tif (len(v) >= 2){\n\t\t\tsout(\"YES\")\n\t\t\tt := 0\n\t\t\tfor k,_ := range v{\n\t\t\t\tsout(k)\n\t\t\t\tif (t == 1){return}\n\t\t\t\tt++\n\t\t\t}\n\t\t}\n\t} \n\tsout(\"NO\")\n}\n\nfunc scan(in ... interface{}){\n\tfor _,k := range in{\n\t\tfmt.Scan(k)\n\t}\n}\n\nfunc sout(obj ... interface{}){\n\tfor _, k := range obj{\n\t\tfmt.Print(k, \" \")\n\t}\n\tfmt.Println()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar a [101]int\n\tfor i := 0; i < n; i++ {\n\t\tvar x int\n\t\tfmt.Scan(&x)\n\t\ta[x]++\n\t}\n\tfor i := 1; i <= 100; i++ {\n\t\tfor j := i + 1; j <= 100; j++ {\n\t\t\tif a[i] == a[j] && a[i] > 0 {\n\t\t\t\tfmt.Println(\"YES\")\n\t\t\t\tfmt.Printf(\"%d %d\\n\", i, j)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(\"NO\")\n}\n"}], "src_uid": "2860b4fb22402ea9574c2f9e403d63d8"} {"nl": {"description": "Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.The teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier, the sum only contains numbers 1, 2 and 3. Still, that isn't enough for Xenia. She is only beginning to count, so she can calculate a sum only if the summands follow in non-decreasing order. For example, she can't calculate sum 1+3+2+1 but she can calculate sums 1+1+2 and 3+3.You've got the sum that was written on the board. Rearrange the summans and print the sum in such a way that Xenia can calculate the sum.", "input_spec": "The first line contains a non-empty string s — the sum Xenia needs to count. String s contains no spaces. It only contains digits and characters \"+\". Besides, string s is a correct sum of numbers 1, 2 and 3. String s is at most 100 characters long.", "output_spec": "Print the new sum that Xenia can count.", "sample_inputs": ["3+2+1", "1+1+3+1+3", "2"], "sample_outputs": ["1+2+3", "1+1+1+3+3", "2"], "notes": null}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tvar a [4]int\n\tfor _, si := range strings.Split(s, \"+\") {\n\t\tnum, _ := strconv.Atoi(si)\n\t\ta[num]++\n\t}\n\tvar head = true\n\tfor i := 1; i <= 3; i++ {\n\t\tfor j := 0; j < a[i]; j++ {\n\t\t\tif !head {\n\t\t\t\tfmt.Print(\"+\")\n\t\t\t}\n\t\t\thead = false\n\t\t\tfmt.Print(i)\n\t\t}\n\t}\n\tfmt.Println()\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tvar a, b, c int\n\t// ans := make(map[int]int)\n\tfor _, x := range s {\n\t\tif x == '1' {\n\t\t\ta++\n\t\t\t// ans[1]++\n\t\t} else if x == '2' {\n\t\t\tb++\n\t\t\t// ans[2]++\n\t\t} else if x == '3' {\n\t\t\tc++\n\t\t\t// ans[3]++\n\t\t}\n\t}\n\t// fmt.Println(len(ans))\n\tfor a+b+c > 0 {\n\t\t// fmt.Println(a + b + c)\n\t\tif a > 0 {\n\t\t\tfmt.Print(1)\n\t\t\ta--\n\t\t} else if b > 0 {\n\t\t\tfmt.Print(2)\n\t\t\tb--\n\t\t} else if c > 0 {\n\t\t\tfmt.Print(3)\n\t\t\tc--\n\t\t}\n\t\tif a+b+c > 0 {\n\t\t\tfmt.Print(\"+\")\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc sort(a []int) {\n\tl := len(a)\n\tlo := 0\n\thi := l - 1\n\th := hi\n\tfor i := 0; i < l; i++ {\n\t\tfor j := lo; j < hi; j++ {\n\t\t\tif a[j] > a[j+1] {\n\t\t\t\ta[j], a[j+1] = a[j+1], a[j]\n\t\t\t\th = j + 1\n\t\t\t}\n\t\t}\n\t\thi = h\n\t}\n\n}\n\nfunc main() {\n\tvar str string\n\tfmt.Scan(&str)\n\n\tnums := make([]int, 0, 50)\n\tfor i := 0; i < len(str); i++ {\n\t\tif str[i] == '+' {\n\t\t\tcontinue\n\t\t}\n\t\tnums = append(nums, int(str[i]-48))\n\t}\n\n\tsort(nums)\n\tl := len(nums)\n\tfor i, n := range nums {\n\t\tfmt.Print(n)\n\t\tif i < l-1 {\n\t\t\tfmt.Print(\"+\")\n\t\t}\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport(\n\t\"fmt\";\n\t\"sort\"\n)\n\nfunc main(){\n\tvar(\n\t\ts string\n\t\ta []int\n\t)\n\n\tfmt.Scan(&s);\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] != '+' {\n\t\t\ta = append(a, (int)(s[i]-'0'));\n\t\t}\n\t}\n\n\tsort.Ints(a);\n\tfor i := 0; i < len(a); i++ {\n\t\tfmt.Print(a[i]);\n\t\tif i != len(a)-1 {\n\t\t\tfmt.Print(\"+\");\n\t\t}\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput, _ := reader.ReadString('\\n')\n\ttext := strings.Split(input, \"+\")\n\tresult := make(map[string]int)\n\tresult[\"1\"] = 0\n\tresult[\"2\"] = 0\n\tresult[\"3\"] = 0\n\tresultString := \"\"\n\tfor _, val := range text {\n\t\tval := strings.Trim(val, \"\\n\")\n\t\tif strings.Contains(val, \"1\") {\n\t\t\tresult[\"1\"]++\n\t\t}\n\t\tif strings.Contains(val, \"2\") {\n\t\t\tresult[\"2\"]++\n\t\t}\n\t\tif strings.Contains(val, \"3\") {\n\t\t\tresult[\"3\"]++\n\t\t}\n\t}\n\tif result[\"1\"] > 0 {\n\t\tfor i := 0; i< result[\"1\"]; i++ {\n\t\t\tif i != result[\"1\"]-1 {\n\t\t\t\tresultString += \"1+\"\n\t\t\t}else {\n\t\t\t\tresultString += \"1\"\n\t\t\t}\n\t\t}\n\t}\n\n\tif result[\"2\"] > 0 {\n\t\tif len(resultString) > 0 {\n\t\t\tresultString += \"+\"\n\t\t}\n\t\tfor i := 0; i< result[\"2\"]; i++ {\n\t\t\tif i != result[\"2\"]-1 {\n\t\t\t\tresultString += \"2+\"\n\t\t\t}else {\n\t\t\t\tresultString += \"2\"\n\t\t\t}\n\t\t}\n\t}\n\n\tif result[\"3\"] > 0 {\n\t\tif len(resultString) > 0 {\n\t\t\tresultString += \"+\"\n\t\t}\n\t\tfor i := 0; i< result[\"3\"]; i++ {\n\t\t\tif i != result[\"3\"]-1 {\n\t\t\t\tresultString += \"3+\"\n\t\t\t}else {\n\t\t\t\tresultString += \"3\"\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(resultString)\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tcounts := make([]string, 3)\n\tfor _, key := range scanner.Text() {\n\t\tif key == '+' {\n\t\t\tcontinue\n\t\t}\n\t\tcounts[key - '0' - 1] += string(key) + \"+\"\n\t}\n\n\tvar str string\n\tfor _, s := range counts {\n\t\tstr += s\n\t}\n\n\tfmt.Println(str[:len(str) - 1])\n\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n )\n\nfunc main() {\n var line string\n fmt.Scan(&line)\n\n var count = [4]int{0}\n for i := 0; i < len(line); i++ {\n if line[i] != '+' {\n count[line[i] - '0']++\n }\n }\n\n var result string = \"\"\n for i := 1; i <= 3; i++ {\n for j := 0; j < count[i]; j++ {\n result += string(i + '0')\n result += \"+\"\n }\n }\n\n result = result[:len(result) - 1]\n fmt.Println(result)\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"strings\"\n _\"strconv\"\n \"sort\"\n)\n\nfunc main() {\n var a string\n var b string\n fmt.Scanln(&a)\n strArray := strings.Split(a, \"+\")\n sort.Strings(strArray)\n len := len(strArray)\n for i:=0; i < len -1; i++ {\n b += strArray[i]\n b += \"+\"\n }\n b += strArray[len - 1]\n fmt.Println(b)\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tss := strings.Split(s, \"+\")\n\tsort.Strings(ss)\n\tfmt.Println(strings.Join(ss, \"+\"))\n}\n"}, {"source_code": "//A. Математика спешит на помощь\npackage main\n\nimport (\n\t\"fmt\"\n\ts \"strings\"\n)\n\nfunc main() {\n\tvar line, rez string\n\n\tvar cnt1, cnt2, cnt3 int\n\n\tfmt.Scan(&line)\n\t/*\tfor i := 0; i < len(line); i += 2 {\n\t\t\tif string([]rune(line)[i]) == \"1\" {\n\t\t\t\tcnt1++\n\t\t\t\tcontinue\n\t\t\t} else if string([]rune(line)[i]) == \"2\" {\n\t\t\t\tcnt2++\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\tcnt3++\n\t\t\t}\n\t\t}\n\t*/\n\tcnt1 = s.Count(line, \"1\")\n\tcnt2 = s.Count(line, \"2\")\n\tcnt3 = s.Count(line, \"3\")\n\n\tfor i := 0; i < cnt1; i++ {\n\t\trez += \"1+\"\n\t}\n\tfor i := 0; i < cnt2; i++ {\n\t\trez += \"2+\"\n\t}\n\tfor i := 0; i < cnt3; i++ {\n\t\trez += \"3+\"\n\t}\n\n\trez = rez[:len(rez)-1]\n\tfmt.Println(rez)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"math/rand\"\n\t\"sort\"\n\t\"sync\"\n)\n\nconst MAX = 3\n\nfunc Sort(A []int, N int) []int {\n\tq := len(A) / N\n\tr := len(A) % N\n\tsplits := make([][]int, N)\n\tpos := 0\n\tfor i := 0; i < N; i++ {\n\t\tvar delta int\n\t\tif i < r {\n\t\t\tdelta = q + 1;\n\t\t} else {\n\t\t\tdelta = q;\n\t\t}\n\t\tsplits[i] = A[pos : pos + delta]\n\t\tpos += delta\n\t}\n\twaitGroup := new(sync.WaitGroup)\n\tfor i := 0; i < N; i++ {\n\t\twaitGroup.Add(1)\n\t\tgo func(B []int) {\n\t\t\tsort.Ints(B)\n\t\t\twaitGroup.Done()\n\t\t}(splits[i])\n\t}\n\twaitGroup.Wait()\n\tB := make([]int, 0);\n\tnext := make([]int, N)\n\tfor len(B) < len(A) {\n\t\tidx := -1\n\t\tfor i := 0; i < N; i++ {\n\t\t\tif next[i] < len(splits[i]) && (idx == -1 || splits[i][next[i]] < splits[idx][next[idx]]) {\n\t\t\t\tidx = i\n\t\t\t}\n\t\t}\n\t\tB = append(B, splits[idx][next[idx]])\n\t\tnext[idx]++\n\t}\n\treturn B\n}\n\nfunc main() {\n\tvar input string\n\tfmt.Scanln(&input)\n\tdigits := strings.Split(input, \"+\")\n\tints := make([]int, 0)\n\tfor i := 0; i < len(digits); i++ {\n\t\tints = append(ints, int(digits[i][0]) - '0')\n\t}\n\tN := rand.Intn(len(ints)) + 1\n\tints = Sort(ints, N)\n\tfor i := 0; i < len(ints); i++ {\n\t\tif i > 0 {\n\t\t\tfmt.Print(\"+\")\n\t\t}\n\t\tfmt.Print(ints[i])\n\t}\n\tfmt.Println()\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"math/rand\"\n\t\"sort\"\n\t\"sync\"\n)\n\nconst MAX = 3\n\nfunc Sort(A []int, N int) []int {\n\tq := len(A) / N\n\tr := len(A) % N\n\tsplits := make([][]int, N)\n\tpos := 0\n\tfor i := 0; i < N; i++ {\n\t\tvar delta int\n\t\tif i < r {\n\t\t\tdelta = q + 1;\n\t\t} else {\n\t\t\tdelta = q;\n\t\t}\n\t\tsplits[i] = A[pos : pos + delta]\n\t\tpos += delta\n\t}\n\twaitGroup := new(sync.WaitGroup)\n\tfor i := 0; i < N; i++ {\n\t\twaitGroup.Add(1)\n\t\tgo func(B []int) {\n\t\t\tsort.Ints(B)\n\t\t\twaitGroup.Done()\n\t\t}(splits[i])\n\t}\n\twaitGroup.Wait()\n\tB := make([]int, 0);\n\tnext := make([]int, N)\n\tfor len(B) < len(A) {\n\t\tidx := -1\n\t\tfor i := 0; i < N; i++ {\n\t\t\tif next[i] < len(splits[i]) && (idx == -1 || splits[i][next[i]] < splits[idx][next[idx]]) {\n\t\t\t\tidx = i\n\t\t\t}\n\t\t}\n\t\tB = append(B, splits[idx][next[idx]])\n\t\tnext[idx]++\n\t}\n\treturn B\n}\n\nfunc main() {\n\tvar input string\n\tfmt.Scanln(&input)\n\tdigits := strings.Split(input, \"+\")\n\tints := make([]int, 0)\n\tfor i := 0; i < len(digits); i++ {\n\t\tints = append(ints, int(digits[i][0]) - '0')\n\t}\n\tN := rand.Intn(len(ints)) + 1\n\tints = Sort(ints, N)\n\tfor i := 0; i < len(ints); i++ {\n\t\tif i > 0 {\n\t\t\tfmt.Print(\"+\")\n\t\t}\n\t\tfmt.Print(ints[i])\n\t}\n\tfmt.Println()\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\n\tnums := strings.Split(s, \"+\")\n\tif sort.StringsAreSorted(nums) {\n\t\tfmt.Println(s)\n\t\treturn\n\t}\n\tsort.Strings(nums)\n\tfmt.Println(strings.Join(nums, \"+\"))\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n var a [105]int\n fmt.Scan(&s)\n n := 0\n for i := 0; i < len(s); i += 2 {\n a[n] = int(s[i])\n n++\n }\n for i := n-1; i > 0; i-- {\n m := i\n for j := 0; j < i; j++ {\n if a[j] > a[m] { m = j }\n }\n a[m], a[i] = a[i], a[m]\n }\n for i := 0; i < n; i++ {\n fmt.Print(string(a[i]))\n if (i == (n-1)) { fmt.Println() } else { fmt.Print(\"+\") }\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strings\"\n)\n\nvar reader *bufio.Reader = bufio.NewReader(os.Stdin)\nvar writer *bufio.Writer = bufio.NewWriter(os.Stdout)\n\nfunc printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }\nfunc scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }\n\nfunc main() {\n\tdefer writer.Flush()\n\n\tvar s string\n\tscanf(\"%s\\n\", &s)\n\tarr := strings.Split(s, \"+\")\n\tsort.Strings(arr)\n\tfor i, v := range arr {\n\t\tif i < len(arr)-1 {\n\t\t\tprintf(\"%s+\", v)\n\t\t} else {\n\t\t\tprintf(\"%s\", v)\n\t\t}\n\t}\n\tprintf(\"\\n\")\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tn1, n2, n3 := 0, 0, 0\n\tfor i := 0; i < len(s); i += 2 {\n\t\tswitch s[i] {\n\t\tcase '1':\n\t\t\tn1++\n\t\tcase '2':\n\t\t\tn2++\n\t\tcase '3':\n\t\t\tn3++\n\t\t}\n\t}\n\tvar buffer bytes.Buffer\n\tfor i := 0; i < n1; i++ {\n\t\tbuffer.WriteRune('1')\n\t\tif i != n1-1 {\n\t\t\tbuffer.WriteByte('+')\n\t\t}\n\t}\n\tif n1 > 0 && n2 > 0 {\n\t\tbuffer.WriteRune('+')\n\t}\n\tfor i := 0; i < n2; i++ {\n\t\tbuffer.WriteRune('2')\n\t\tif i != n2-1 {\n\t\t\tbuffer.WriteByte('+')\n\t\t}\n\t}\n\tif n2 > 0 && n3 > 0 || n1 > 0 && n3 > 0 {\n\t\tbuffer.WriteRune('+')\n\t}\n\tfor i := 0; i < n3; i++ {\n\t\tbuffer.WriteRune('3')\n\t\tif i != n3-1 {\n\t\t\tbuffer.WriteByte('+')\n\t\t}\n\t}\n\tfmt.Print(buffer.String())\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n \"strings\"\n \"sort\"\n)\n\nfunc main() {\n\tA:=\"\"\n _, err := fmt.Scanf(\"%s\", &A)\n b:=strings.Split(A,\"+\")\n\n\n\tif err !=nil{\n\t\tlog.Fatal(err)\n }\n sort.Strings(b)\n A=b[0]\n for x:=1; x 0 {\n\t\t\tans[curr] = byte(i) + '1'\n\t\t\tcurr = 1\n\t\t\tj = 1\n\t\t}\n\t\tfor ; j < count[i]; j += 1 {\n\t\t\tans[curr] = '+'\n\t\t\tans[curr+1] = byte(i) + '1'\n\t\t\tcurr += 2\n\t\t}\n\t}\n\n\treturn string(ans)\n}\n\nfunc main() {\n\tin_raw, err := ioutil.ReadAll(os.Stdin)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(task_solution(bytes.TrimSpace(in_raw)))\n}\n"}, {"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 nextInt() int {\n\tscanner.Scan()\n\tstr := scanner.Text()\n\tval, _ := strconv.Atoi(str)\n\treturn val\n}\n\nfunc nextFloat() float64 {\n\tscanner.Scan()\n\tstr := scanner.Text()\n\tval, _ := strconv.ParseFloat(str, 64)\n\treturn val\n}\n\nfunc nextString() string {\n\tscanner.Scan()\n\tstr := scanner.Text()\n\treturn str\n}\n\nfunc main() {\n\tscanner.Split(bufio.ScanWords)\n\tstr := nextString()\n\tcnt := make(map[rune]int)\n\tfor _, c := range str {\n\t\tif c != '+' {\n\t\t\tcnt[c]++\n\t\t}\n\t}\n\tfor i := 0; i < (len(str)+1)/2; i++ {\n\t\tif i != 0 {\n\t\t\tfmt.Print(\"+\")\n\t\t}\n\t\tswitch {\n\t\tcase cnt['1'] > 0:\n\t\t\tfmt.Print(\"1\")\n\t\t\tcnt['1']--\n\n\t\tcase cnt['2'] > 0:\n\t\t\tfmt.Print(\"2\")\n\t\t\tcnt['2']--\n\n\t\tcase cnt['3'] > 0:\n\t\t\tfmt.Print(\"3\")\n\t\t\tcnt['3']--\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\ntype rawnums []string\n\nfunc (a rawnums) Len() int { return len(a) }\nfunc (a rawnums) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a rawnums) Less(i, j int) bool { return a[i] < a[j] }\n\nfunc main() {\n\n\tvar s string\n\tfmt.Scan(&s)\n\tnums := strings.Split(s, \"+\")\n\tsort.Sort(rawnums(nums))\n\tfmt.Println(strings.Join(nums, \"+\"))\n\n}\n"}, {"source_code": "package main\n\nimport(\n\t\"fmt\";\n\t\"sort\"\n)\n\nfunc main(){\n\tvar(\n\t\ts string\n\t\ta []int\n\t)\n\n\tfmt.Scan(&s);\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] != '+' {\n\t\t\ta = append(a, (int)(s[i]-'0'));\n\t\t}\n\t}\n\n\tsort.Ints(a);\n\tfor i := 0; i < len(a); i++ {\n\t\tfmt.Print(a[i]);\n\t\tif i != len(a)-1 {\n\t\t\tfmt.Print(\"+\");\n\t\t}\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\t// digits can only be {1,2,3}\n\t// input is <= 100 characters\n\t// no spaces\n\t// digit and/or plus sign\n\t// could be a single character(digit)\n\n\t// if we use sorting in stdlib, then parse by \"+\", sort, and join with \"+\"\n\n\t// if we implement sorting, a good constraint is that numbers are {1,2,3}.\n\n\t// count 1, 2 and 3 digits in a map(nah just variables)\n\t// create a string with \"+\" between each counted digit if sum of count > 1\n\t// else just print\n\n\tequation := \"\"\n\tfmt.Scan(&equation)\n\n\tone := 0\n\ttwo := 0\n\tthree := 0\n\n\tfor _, c := range equation {\n\t\tswitch c {\n\t\tcase '1':\n\t\t\tone++\n\t\tcase '2':\n\t\t\ttwo++\n\t\tcase '3':\n\t\t\tthree++\n\t\t}\n\t}\n\n\tif one+two+three <= 1 {\n\t\tfmt.Println(equation)\n\t} else {\n\t\tresult := \"\"\n\t\tresult = appendNumber(result, one, 1)\n\t\tresult = appendNumber(result, two, 2)\n\t\tresult = appendNumber(result, three, 3)\n\t\tresult = result[:len(result)-1]\n\t\tfmt.Println(result)\n\t}\n}\n\nfunc appendNumber(result string, count, num int) string {\n\tfor count > 0 {\n\t\tresult += fmt.Sprintf(\"%d+\", num)\n\t\tcount--\n\t}\n\treturn result\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar source string\n\tfmt.Scan(&source)\n\tones := strings.Count(source, \"1\")\n\ttwos := strings.Count(source, \"2\")\n\tthre := strings.Count(source, \"3\")\n\tswitch {\n\tcase ones != 0:\n\t\tfmt.Print(1)\n\t\tones--\n\tcase twos != 0:\n\t\tfmt.Print(2)\n\t\ttwos--\n\tcase thre != 0:\n\t\tfmt.Print(3)\n\t\tthre--\n\t}\n\tfor i := 0; i < ones; i++ {\n\t\tfmt.Printf(\"+%d\", 1)\n\t}\n\tfor i := 0; i < twos; i++ {\n\t\tfmt.Printf(\"+%d\", 2)\n\t}\n\tfor i := 0; i < thre; i++ {\n\t\tfmt.Printf(\"+%d\", 3)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar str string\n\tfmt.Scan(&str)\n\n\tvar arr = make([]int, 4)\n\tfor i := 1; i <= 3; i++ {\n\t\tarr[i] = strings.Count(str, string(rune(i+48)))\n\t}\n\n\tvar ret = make([]string, 0)\n\tfor i := 1; i <= 3; i++ {\n\t\tfor j := 1; j <= arr[i]; j++ {\n\t\t\tret = append(ret, string(rune(i+48)))\n\t\t}\n\t}\n\n\tfmt.Println(strings.Join(ret, \"+\"))\n}\n"}, {"source_code": "package main\n\nimport(\n \"fmt\"\n \"sort\"\n)\n\nfunc main(){\n var(\n s string\n arr = []int{}\n )\n fmt.Scan(&s)\n for i:=0;i 0; i-- {\n m := i\n for j := 0; j < i; j++ {\n if a[j] > a[m] { m = j }\n }\n a[m], a[i] = a[i], a[m]\n }\n for i := 0; i < n; i++ {\n fmt.Print(string(a[i]))\n if (i == (n-1)) { fmt.Println() } else { fmt.Print(\"+\") }\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar experssion string\n\tfmt.Scan(&experssion)\n\n\texperssionInArray := strings.Split(string(experssion), \"+\")\t\t\n\tsort.Slice(experssionInArray, func(i, j int) bool {\n numA := experssionInArray[i]\n numB := experssionInArray[j]\n return numA < numB\n\t})\n\tfmt.Print(strings.Join(experssionInArray, \"+\"))\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar str string\n\tfmt.Scan(&str)\n\n\tvar arr = make([]int, 4)\n\tfor i := 1; i <= 3; i++ {\n\t\tarr[i] = strings.Count(str, string(rune(i+48)))\n\t}\n\n\tvar ret = make([]string, 0)\n\tfor i := 1; i <= 3; i++ {\n\t\tfor j := 1; j <= arr[i]; j++ {\n\t\t\tret = append(ret, string(rune(i+48)))\n\t\t}\n\t}\n\n\tfmt.Println(strings.Join(ret, \"+\"))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar experssion string\n\tfmt.Scan(&experssion)\n\n\texperssionInArray := strings.Split(string(experssion), \"+\")\t\t\n\tsort.Slice(experssionInArray, func(i, j int) bool {\n numA := experssionInArray[i]\n numB := experssionInArray[j]\n return numA < numB\n\t})\n\tfmt.Print(strings.Join(experssionInArray, \"+\"))\n}"}, {"source_code": "// Author: sighduck\n// URL: https://codeforces.com/problemset/problem/339/A\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc Solve(s string) string {\n\tnumbers := strings.Split(s, \"+\")\n\tsort.Strings(numbers)\n\treturn strings.Join(numbers, \"+\")\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\n\tfmt.Fprintf(writer, \"%s\\n\", Solve(s))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tsummands := strings.Split(s, \"+\")\n\tsort.Strings(summands)\n\tfmt.Println(strings.Join(summands, \"+\"))\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc sort(a []int) {\n\tl := len(a)\n\tlo := 0\n\thi := l - 1\n\th := hi\n\tfor i := 0; i < l; i++ {\n\t\tfor j := lo; j < hi; j++ {\n\t\t\tif a[j] > a[j+1] {\n\t\t\t\ta[j], a[j+1] = a[j+1], a[j]\n\t\t\t\th = j + 1\n\t\t\t}\n\t\t}\n\t\thi = h\n\t}\n\n}\n\nfunc main() {\n\tvar str string\n\tfmt.Scan(&str)\n\n\tnums := make([]int, 0, 50)\n\tfor i := 0; i < len(str); i++ {\n\t\tif str[i] == '+' {\n\t\t\tcontinue\n\t\t}\n\t\tnums = append(nums, int(str[i]-48))\n\t}\n\n\tsort(nums)\n\tl := len(nums)\n\tfor i, n := range nums {\n\t\tfmt.Print(n)\n\t\tif i < l-1 {\n\t\t\tfmt.Print(\"+\")\n\t\t}\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tcnt := []int{0, 0, 0}\n\tvar b []byte\n\tfmt.Scan(&b)\n\tfor i := len(b) - 1; i >= 0; i -= 2 {\n\t\tcnt[b[i]-'1']++\n\t}\n\ti, c := 0, byte('1')\n\tfor _, n := range cnt {\n\t\tfor ; n > 0; n-- {\n\t\t\tb[i] = c\n\t\t\ti += 2\n\t\t}\n\t\tc++\n\t}\n\tfmt.Println(string(b))\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n var a [105]int\n fmt.Scan(&s)\n n := 0\n for i := 0; i < len(s); i += 2 {\n a[n] = int(s[i])\n n++\n }\n for i := n-1; i > 0; i-- {\n m := i\n for j := 0; j < i; j++ {\n if a[j] > a[m] { m = j }\n }\n a[m], a[i] = a[i], a[m]\n }\n for i := 0; i < n; i++ {\n fmt.Print(string(a[i]))\n if (i == (n-1)) { fmt.Println() } else { fmt.Print(\"+\") }\n }\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tvar a, b, c int\n\t// ans := make(map[int]int)\n\tfor _, x := range s {\n\t\tif x == '1' {\n\t\t\ta++\n\t\t\t// ans[1]++\n\t\t} else if x == '2' {\n\t\t\tb++\n\t\t\t// ans[2]++\n\t\t} else if x == '3' {\n\t\t\tc++\n\t\t\t// ans[3]++\n\t\t}\n\t}\n\t// fmt.Println(len(ans))\n\tfor a+b+c > 0 {\n\t\t// fmt.Println(a + b + c)\n\t\tif a > 0 {\n\t\t\tfmt.Print(1)\n\t\t\ta--\n\t\t} else if b > 0 {\n\t\t\tfmt.Print(2)\n\t\t\tb--\n\t\t} else if c > 0 {\n\t\t\tfmt.Print(3)\n\t\t\tc--\n\t\t}\n\t\tif a+b+c > 0 {\n\t\t\tfmt.Print(\"+\")\n\t\t}\n\t}\n}\n"}, {"source_code": "// URL: http://codeforces.com/problemset/problem/339/A\n// ~ Basic Implementation Problem\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader, writer := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)\n\tdefer writer.Flush()\n\tvar s string\n\tfmt.Fscanf(reader, \"%s\\n\", &s)\n\tstringArray := strings.Split(s, \"+\")\n\tsort.Strings(stringArray)\n\tfmt.Fprintf(writer, \"%s\\n\", strings.Join(stringArray, \"+\"))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tvar arr []int\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] >= '1' && s[i] <= '3' {\n\t\t\tn, _ := strconv.Atoi(string(s[i]))\n\t\t\tarr = append(arr, n)\n\t\t}\n\t}\n\tsort.Ints(arr)\n\tfor i := 0; i < len(arr)-1; i++ {\n\t\tfmt.Print(arr[i])\n\t\tfmt.Print(\"+\")\n\t}\n\tfmt.Print(arr[len(arr)-1])\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc sort(a []int) {\n\tl := len(a)\n\tlo := 0\n\thi := l - 1\n\th := hi\n\tfor i := 0; i < l; i++ {\n\t\tfor j := lo; j < hi; j++ {\n\t\t\tif a[j] > a[j+1] {\n\t\t\t\ta[j], a[j+1] = a[j+1], a[j]\n\t\t\t\th = j + 1\n\t\t\t}\n\t\t}\n\t\thi = h\n\t}\n\n}\n\nfunc main() {\n\tvar str string\n\tfmt.Scan(&str)\n\n\tnums := make([]int, 0, 50)\n\tfor i := 0; i < len(str); i++ {\n\t\tif str[i] == '+' {\n\t\t\tcontinue\n\t\t}\n\t\tnums = append(nums, int(str[i]-48))\n\t}\n\n\tsort(nums)\n\tl := len(nums)\n\tfor i, n := range nums {\n\t\tfmt.Print(n)\n\t\tif i < l-1 {\n\t\t\tfmt.Print(\"+\")\n\t\t}\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc swap(s []rune, i, j int) {\n\tif i < 0 || j < 0 {\n\t\treturn\n\t}\n\tif s[i] < s[j] {\n\t\tt := s[i]\n\t\ts[i] = s[j]\n\t\ts[j] = t\n\t\tswap(s, i-2, j-2)\n\t}\n}\n\nfunc main() {\n\tvar s string\n\tfmt.Scanf(\"%s\", &s)\n\tres := []rune(s)\n\tfor i := 2; i < len(res); i += 2 {\n\t\tswap(res, i, i-2)\n\t}\n\tfmt.Println(string(res))\n}\n"}, {"source_code": "package main\nimport \"fmt\"\nimport \"strings\"\n\n\nfunc main() {\n var input string\n fmt.Scan(&input)\n var output string\n\n\n rakams := strings.Split(input,\"+\")\n numof1 := 0\n numof2 := 0\n numof3 := 0\n\n for i := range rakams {\n if rakams[i] == \"1\" {\n numof1 += 1\n }else if rakams[i] == \"2\" {\n numof2 += 1\n }else if rakams[i] == \"3\" {\n numof3 += 1\n }\n }\n for i := 0; i < numof1; i++ {\n output += \"1+\"\n }\n for i := 0; i < numof2; i++ {\n output += \"2+\"\n }\n for i := 0; i < numof3; i++ {\n output += \"3+\"\n }\n output = output[:len(output)-1]\n fmt.Println(output)\n\n\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strings\"\n)\n\n// HelpfulSum sorts numbers in a string in non-increasing order.\nfunc HelpfulSum(s string) string {\n\tnums := strings.Split(s, \"+\")\n\tsort.StringSlice(nums).Sort()\n\treturn strings.Join(nums, \"+\")\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tfmt.Println(HelpfulSum(scanner.Text()))\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tvar a, b, c int\n\t// ans := make(map[int]int)\n\tfor _, x := range s {\n\t\tif x == '1' {\n\t\t\ta++\n\t\t\t// ans[1]++\n\t\t} else if x == '2' {\n\t\t\tb++\n\t\t\t// ans[2]++\n\t\t} else if x == '3' {\n\t\t\tc++\n\t\t\t// ans[3]++\n\t\t}\n\t}\n\t// fmt.Println(len(ans))\n\tfor a+b+c > 0 {\n\t\t// fmt.Println(a + b + c)\n\t\tif a > 0 {\n\t\t\tfmt.Print(1)\n\t\t\ta--\n\t\t} else if b > 0 {\n\t\t\tfmt.Print(2)\n\t\t\tb--\n\t\t} else if c > 0 {\n\t\t\tfmt.Print(3)\n\t\t\tc--\n\t\t}\n\t\tif a+b+c > 0 {\n\t\t\tfmt.Print(\"+\")\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tvar a [4]int\n\tfor _, si := range strings.Split(s, \"+\") {\n\t\tnum, _ := strconv.Atoi(si)\n\t\ta[num]++\n\t}\n\tvar head = true\n\tfor i := 1; i <= 3; i++ {\n\t\tfor j := 0; j < a[i]; j++ {\n\t\t\tif !head {\n\t\t\t\tfmt.Print(\"+\")\n\t\t\t}\n\t\t\thead = false\n\t\t\tfmt.Print(i)\n\t\t}\n\t}\n\tfmt.Println()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar input string\n\tfmt.Scan(&input)\n\tnumbers := strings.Split(input, \"+\")\n\tsort.Strings(numbers)\n\t// fmt.Println(numbers)\n\tfor i := 0; i < len(numbers)-1; i++ {\n\t\tfmt.Print(numbers[i] + \"+\")\n\t}\n\tfmt.Println(numbers[len(numbers)-1])\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\ts1 := strings.Builder{}\n\ts2 := strings.Builder{}\n\ts3 := strings.Builder{}\n\ts1.Grow(100)\n\ts2.Grow(100)\n\ts3.Grow(100)\n\tinput := \"\"\n\tfmt.Scanf(\"%s\\n\", &input)\n\tfor _, c := range input {\n\t\tswitch c {\n\t\tcase '1':\n\t\t\ts1.WriteString(\"1+\")\n\t\tcase '2':\n\t\t\ts2.WriteString(\"2+\")\n\t\tcase '3':\n\t\t\ts3.WriteString(\"3+\")\n\t\t}\n\t}\n\tans := s1.String() + s2.String() + s3.String()\n\tfmt.Println(ans[:len(ans)-1])\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"strconv\"\n)\n\nfunc main() {\n var s string\n var ar [3]int\n fmt.Scanf(\"%s\", &s)\n for i:=0; i < len(s) ; i=i+2 {\n switch(s[i]) {\n case '1':\n ar[0]++\n break\n case '2':\n ar[1]++\n break\n case '3':\n ar[2]++\n break\n }\n }\n\n sum := \"\"\n for i:=0; i < 3; i++ {\n for j:=0; j < ar[i]; j++ {\n if len(sum) == 0 {\n sum += strconv.Itoa(i+1)\n } else {\n sum += \"+\" \n sum += strconv.Itoa(i+1)\n }\n }\n }\n\n fmt.Println(sum)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n//import \"strings\"\nimport \"os\";\n//import \"math\"\nimport \"strconv\"\nimport \"sort\"\n\n\nfunc main() {\n\t\t\n\tvar d string;\n\n\tfmt.Scan(&d);\n\n\tif(len(d) == 1) {\n\t\tfmt.Println(d);\n\t\tos.Exit(0);\n\t}\n\n\tvar a []int\n\n\tfor i := 0; i < len(d); i++ {\n\t\tif( d[i] >= '0' && d[i] <= '9' ) {\n\n\t\t\tkek, _ := strconv.Atoi(string(d[i]));\n\n\t\t\ta = append(a, kek);\n\t\t}\n\t}\n\n\tsort.Ints(a);\n\n\tfor i := 0; i < len(a); i++ {\n\t\tfmt.Print(a[i]);\n\t\tif(i != len(a) - 1){\n\t\t\tfmt.Print(\"+\");\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar line string\n\t_, _ = fmt.Scan(&line)\n\n\tsummands := strings.Split(line, \"+\")\n\n\tsort.Strings(summands)\n\tfmt.Print(strings.Join(summands, \"+\"))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar str string\n\tfmt.Scan(&str)\n\tvar num []int\n\tfor _, v := range strings.Split(str, \"+\") {\n\t\tn, _ := strconv.Atoi(v)\n\t\tnum = append(num, n)\n\t}\n\tsort.Ints(num)\n\tfor i, v := range num {\n\t\tif i > 0 {\n\t\t\tfmt.Print(\"+\")\n\t\t}\n\t\tfmt.Print(v)\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Split(bufio.ScanWords)\n\n\tscanner.Scan()\n\tsum := scanner.Text()\n\n\tparts := strings.Split(sum, \"+\")\n\tsort.Strings(parts)\n\n\tfmt.Println(strings.Join(parts, \"+\"))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar hashArray [3]int\n\tvar input string\n\tfmt.Scanln(&input)\n\tnumbers := strings.Split(input, \"+\")\n\tfor i := 0; i < len(numbers); i++ {\n\t\tif num, err := strconv.Atoi(numbers[i]); err == nil {\n\t\t\thashArray[num-1]++\n\t\t}\n\t}\n\tvar output bytes.Buffer\n\tfor index := 0; index < 3; index++ {\n\t\tfor i := 0; i < hashArray[index]; i++ {\n\t\t\toutput.WriteString(strconv.Itoa(index + 1))\n\t\t\toutput.WriteString(\"+\")\n\t\t}\n\t}\n\tfmt.Print(strings.TrimRight(output.String(), \"+\"))\n}\n"}, {"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 nextInt() int {\n\tscanner.Scan()\n\tstr := scanner.Text()\n\tval, _ := strconv.Atoi(str)\n\treturn val\n}\n\nfunc nextFloat() float64 {\n\tscanner.Scan()\n\tstr := scanner.Text()\n\tval, _ := strconv.ParseFloat(str, 64)\n\treturn val\n}\n\nfunc nextString() string {\n\tscanner.Scan()\n\tstr := scanner.Text()\n\treturn str\n}\n\nfunc main() {\n\tscanner.Split(bufio.ScanWords)\n\tstr := nextString()\n\tcnt := make(map[rune]int)\n\tfor _, c := range str {\n\t\tif c != '+' {\n\t\t\tcnt[c]++\n\t\t}\n\t}\n\tfor i := 0; i < (len(str)+1)/2; i++ {\n\t\tif i != 0 {\n\t\t\tfmt.Print(\"+\")\n\t\t}\n\t\tswitch {\n\t\tcase cnt['1'] > 0:\n\t\t\tfmt.Print(\"1\")\n\t\t\tcnt['1']--\n\n\t\tcase cnt['2'] > 0:\n\t\t\tfmt.Print(\"2\")\n\t\t\tcnt['2']--\n\n\t\tcase cnt['3'] > 0:\n\t\t\tfmt.Print(\"3\")\n\t\t\tcnt['3']--\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReaderSize(os.Stdin, 1024 * 1024)\n\tout := strings.Split(readLine(reader), \"+\")\n\tsorted := sort.StringSlice(out)\n\tsorted.Sort()\n\tfmt.Println(strings.Join(sorted, \"+\"))\n}\n\nfunc readLine(reader *bufio.Reader) string {\n\tstr, _, err := reader.ReadLine()\n\tif err == io.EOF {\n\t\treturn \"\"\n\t}\n\n\treturn strings.TrimRight(string(str), \"\\r\\n\")\n}\n\nfunc checkError(err error) {\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n/*8 5\n10 9 8 7 7 7 5 5*/\nfunc main() {\n\tvar sum string\n\tfmt.Scanf(\"%s\\n\", &sum)\n\tarr := make([]int, 0)\n\tfor _, s := range strings.Split(sum, \"+\") {\n\t\tn, _ := strconv.Atoi(s)\n\t\tarr = append(arr, n)\n\t}\n\tl, h := 0, len(arr)-1\n\tqsort(arr, l, h)\n\tres := strings.Builder{}\n\tfor i, a := range arr {\n\t\tif i == h {\n\t\t\tres.WriteString(strconv.Itoa(a))\n\t\t\tbreak\n\t\t}\n\t\tres.WriteString(strconv.Itoa(a) + \"+\")\n\t}\n\n\tfmt.Println(res.String())\n\n}\n\nfunc qsort(v []int, l, h int) {\n\tif h-l < 1 {\n\t\treturn\n\t}\n\tpivot := v[h]\n\tlast := l\n\tfor i := l; i < h; i++ {\n\t\tif v[i] <= pivot {\n\t\t\tv[i], v[last] = v[last], v[i]\n\t\t\tlast++\n\t\t}\n\t}\n\tv[h], v[last] = v[last], pivot\n\tqsort(v, l, last-1)\n\tqsort(v, last+1, h)\n}\n"}, {"source_code": "package main\n\nimport(\n\t\"fmt\";\n\t\"sort\"\n)\n\nfunc main(){\n\tvar(\n\t\ts string\n\t\ta []int\n\t)\n\n\tfmt.Scan(&s);\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] != '+' {\n\t\t\ta = append(a, (int)(s[i]-'0'));\n\t\t}\n\t}\n\n\tsort.Ints(a);\n\tfor i := 0; i < len(a); i++ {\n\t\tfmt.Print(a[i]);\n\t\tif i != len(a)-1 {\n\t\t\tfmt.Print(\"+\");\n\t\t}\n\t}\n}"}, {"source_code": "package main \n\nimport(\n\t\"fmt\"\n\n)\n\nfunc main(){\n\tvar s string\n\n\tvar a [5]int\n\n\tfmt.Scan(&s)\n\n\tn := len(s)\n\tfor i:= 0 ; i < n ; i ++ {\n\t\tif s[i] != '+' {\n\t\t//\tfmt.Println(int(s[i]) - int('0')) \n\t\t\ta[int(s[i]) - int('0')] ++ \n\t\t}\t\n\t} \n\n\tvar notFirst bool\n\tsol := \"\"\n\tfor i := 1 ; i <= 3 ; i ++ {\n\t\tfor j := 0 ; j < a[i] ; j ++ {\n\t\t\tif notFirst {\n\t\t\t\tsol = sol + \"+\"\n\t\t\t}\n\n\t\t\tnotFirst = true\n\t\t//\tfmt.Println(string(i+int('0')))\n\t\t\tsol = sol + string(i+int('0'))\n\t\t}\n\t}\n\n\tfmt.Printf(\"%s\",sol)\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"math/rand\"\n\t\"sort\"\n\t\"sync\"\n)\n\nconst MAX = 3\n\nfunc Sort(A []int) []int {\n\tN := rand.Intn(len(A)) + 1\n\tq := len(A) / N\n\tr := len(A) % N\n\tsplits := make([][]int, N)\n\tpos := 0\n\tfor i := 0; i < N; i++ {\n\t\tvar delta int\n\t\tif i < r {\n\t\t\tdelta = q + 1;\n\t\t} else {\n\t\t\tdelta = q;\n\t\t}\n\t\tsplits[i] = A[pos : pos + delta]\n\t\tpos += delta\n\t}\n\twaitGroup := new(sync.WaitGroup)\n\tfor i := 0; i < N; i++ {\n\t\twaitGroup.Add(1)\n\t\tgo func(B []int) {\n\t\t\tsort.Ints(B)\n\t\t\twaitGroup.Done()\n\t\t}(splits[i])\n\t}\n\twaitGroup.Wait()\n\tB := make([]int, 0);\n\tnext := make([]int, N)\n\tfor len(B) < len(A) {\n\t\tidx := -1\n\t\tfor i := 0; i < N; i++ {\n\t\t\tif next[i] < len(splits[i]) && (idx == -1 || splits[i][next[i]] < splits[idx][next[idx]]) {\n\t\t\t\tidx = i\n\t\t\t}\n\t\t}\n\t\tB = append(B, splits[idx][next[idx]])\n\t\tnext[idx]++\n\t}\n\treturn B\n}\n\nfunc main() {\n\tvar input string\n\tfmt.Scanln(&input)\n\tdigits := strings.Split(input, \"+\")\n\tints := make([]int, 0)\n\tfor i := 0; i < len(digits); i++ {\n\t\tints = append(ints, int(digits[i][0]) - '0')\n\t}\n\tints = Sort(ints)\n\tfor i := 0; i < len(ints); i++ {\n\t\tif i > 0 {\n\t\t\tfmt.Print(\"+\")\n\t\t}\n\t\tfmt.Print(ints[i])\n\t}\n\tfmt.Println()\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strings\"\n)\n\n// HelpfulSum sorts numbers in a string in non-increasing order.\nfunc HelpfulSum(s string) string {\n\tnums := strings.Split(s, \"+\")\n\tsort.StringSlice(nums).Sort()\n\treturn strings.Join(nums, \"+\")\n}\n\nfunc main() {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tscanner.Scan()\n\tfmt.Println(HelpfulSum(scanner.Text()))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\ts1 := strings.Builder{}\n\ts2 := strings.Builder{}\n\ts3 := strings.Builder{}\n\ts1.Grow(100)\n\ts2.Grow(100)\n\ts3.Grow(100)\n\tinput := \"\"\n\tfmt.Scanf(\"%s\\n\", &input)\n\tfor _, c := range input {\n\t\tswitch c {\n\t\tcase '1':\n\t\t\ts1.WriteString(\"1+\")\n\t\tcase '2':\n\t\t\ts2.WriteString(\"2+\")\n\t\tcase '3':\n\t\t\ts3.WriteString(\"3+\")\n\t\t}\n\t}\n\tout := strings.Builder{}\n\tout.Grow(3 * 100)\n\tout.WriteString(s1.String())\n\tout.WriteString(s2.String())\n\tout.WriteString(s3.String())\n\tans := out.String()\n\tfmt.Println(ans[:len(ans)-1])\n\t//ans := s1.String() + s2.String() + s3.String()\n\t//fmt.Println(ans[:len(ans)-1])\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"sort\"\nimport \"strings\"\nimport \"strconv\"\n\nfunc main() {\n var result string\n var equation string\n var equation_variables []int\n fmt.Scanf(\"%s\", &equation)\n\n for _, element := range strings.Split(equation, \"+\") {\n number, _ := strconv.Atoi(element)\n equation_variables = append(equation_variables, number)\n }\n\n sort.Sort(sort.IntSlice(equation_variables))\n\n for _, element := range equation_variables {\n result = result + strconv.Itoa(element) + \"+\"\n }\n\n fmt.Println(strings.TrimSuffix(result, \"+\"))\n}\n"}, {"source_code": "package main\nimport(\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\nfunc main() {\n\tvar i string\n\tfmt.Scan(&i)\n\tresult := strings.Split(i, \"+\")\n\tsort.Sort(sort.StringSlice(result))//sort the array\n\ts := []string{}\n\tfor _,element := range result{\n\t\t\ts=append(s, element)\n\t\t\ts=append(s,\"+\")\n\t\t}\n\tresult1 := strings.Join(s, \"\")\n \tfmt.Println(result1[:len(s)-1])\n}\n\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar istring string\n\t_, _ = fmt.Scanln(&istring)\n\txstring := strings.Split(istring, \"+\")\n\tvar numArray []int\n\tfor i := 0; i < len(xstring); i++ {\n\t\tinumber, _ := strconv.Atoi(xstring[i])\n\t\tnumArray = append(numArray, inumber)\n\t}\n\tsort.Ints(numArray)\n\tfor i := 0; i < len(numArray); i++ {\n\t\tif i == len(numArray)-1 {\n\t\t\tfmt.Print(numArray[i])\n\t\t} else {\n\t\t\tfmt.Printf(\"%d+\", numArray[i])\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n var a [105]int\n fmt.Scan(&s)\n n := 0\n for i := 0; i < len(s); i += 2 {\n a[n] = int(s[i])\n n++\n }\n for i := n-1; i > 0; i-- {\n m := i\n for j := 0; j < i; j++ {\n if a[j] > a[m] { m = j }\n }\n a[m], a[i] = a[i], a[m]\n }\n for i := 0; i < n; i++ {\n fmt.Print(string(a[i]))\n if (i == (n-1)) { fmt.Println() } else { fmt.Print(\"+\") }\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"strings\"\n\t\"strconv\"\n\t\"os\"\n\t\"sort\"\n\t\"fmt\"\n)\n\ntype input struct {\n\ta []int\n}\n\n\n\nfunc (c *input)Read(scanner *bufio.Scanner) {\n\tfor scanner.Scan() {\n\t\tfor _, str := range strings.Split(scanner.Text(), \"+\") {\n\t\t\tnum, _ := strconv.Atoi(str)\n\t\t\tc.a = append(c.a, num)\n\t\t}\n\t\treturn\n\t}\n}\n\n\nfunc main() {\n\tvar inp input\n\tsc := bufio.NewScanner(os.Stdin)\n\tinp.Read(sc)\n\tsort.Ints(inp.a)\n\tvar str string\n\tfor i, a := range inp.a {\n\t\tif i+1 == len(inp.a) {\n\t\t\tstr = str + fmt.Sprint(a)\n\t\t} else {\n\t\t\tstr = str + fmt.Sprint(a, \"+\")\n\t\t}\n\t}\n\tfmt.Println(str)\n}\n\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\n\tnums := strings.Split(s, \"+\")\n\tif sort.StringsAreSorted(nums) {\n\t\tfmt.Println(s)\n\t\treturn\n\t}\n\tsort.Strings(nums)\n\tfmt.Println(strings.Join(nums, \"+\"))\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n var a [105]int\n fmt.Scan(&s)\n n := 0\n for i := 0; i < len(s); i += 2 {\n a[n] = int(s[i])\n n++\n }\n for i := n-1; i > 0; i-- {\n m := i\n for j := 0; j < i; j++ {\n if a[j] > a[m] { m = j }\n }\n a[m], a[i] = a[i], a[m]\n }\n for i := 0; i < n; i++ {\n fmt.Print(string(a[i]))\n if (i == (n-1)) { fmt.Println() } else { fmt.Print(\"+\") }\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar line string\n\t_, _ = fmt.Scan(&line)\n\n\tsummands := strings.Split(line, \"+\")\n\n\tsort.Strings(summands)\n\tfmt.Print(strings.Join(summands, \"+\"))\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n var a [105]int\n fmt.Scan(&s)\n n := 0\n for i := 0; i < len(s); i += 2 {\n a[n] = int(s[i])\n n++\n }\n for i := n-1; i > 0; i-- {\n m := i\n for j := 0; j < i; j++ {\n if a[j] > a[m] { m = j }\n }\n a[m], a[i] = a[i], a[m]\n }\n for i := 0; i < n; i++ {\n fmt.Print(string(a[i]))\n if (i == (n-1)) { fmt.Println() } else { fmt.Print(\"+\") }\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tvar a [4]int\n\tfor _, si := range strings.Split(s, \"+\") {\n\t\tnum, _ := strconv.Atoi(si)\n\t\ta[num]++\n\t}\n\tvar head = true\n\tfor i := 1; i <= 3; i++ {\n\t\tfor j := 0; j < a[i]; j++ {\n\t\t\tif !head {\n\t\t\t\tfmt.Print(\"+\")\n\t\t\t}\n\t\t\thead = false\n\t\t\tfmt.Print(i)\n\t\t}\n\t}\n\tfmt.Println()\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\n\tvar s string\n\tfmt.Scan(&s)\n\tnums := strings.Split(s, \"+\")\n\tsort.Strings(nums)\n\tfmt.Println(strings.Join(nums, \"+\"))\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar c byte\n\tvar s string\n\tvar count [3]int\n\tfor {\n\t\tfmt.Scanf(\"%c\", &c)\n\t\tif c == '\\n' {\n\t\t\tbreak\n\t\t}\n\t\tswitch c {\n\t\tcase '1':\n\t\t\tcount[0]++\n\t\tcase '2':\n\t\t\tcount[1]++\n\t\tcase '3':\n\t\t\tcount[2]++\n\t\tcase '+':\n\t\t\tcontinue\n\t\t}\n\t}\n\tfor i := count[0]; i > 0; i-- {\n\t\ts = s + \"1+\"\n\t}\n\tfor i := count[1]; i > 0; i-- {\n\t\ts = s + \"2+\"\n\t}\n\tfor i := count[2]; i > 0; i-- {\n\t\ts = s + \"3+\"\n\t}\n\tfmt.Println(s[:len(s)-1])\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar str string\n\tfmt.Scan(&str)\n\n\tvar arr = make([]int, 4)\n\tfor i := 1; i <= 3; i++ {\n\t\tarr[i] = strings.Count(str, string(rune(i+48)))\n\t}\n\n\tvar ret = make([]string, 0)\n\tfor i := 1; i <= 3; i++ {\n\t\tfor j := 1; j <= arr[i]; j++ {\n\t\t\tret = append(ret, string(rune(i+48)))\n\t\t}\n\t}\n\n\tfmt.Println(strings.Join(ret, \"+\"))\n}\n"}, {"source_code": "package main \n\nimport(\n\t\"fmt\"\n\n)\n\nfunc main(){\n\tvar s string\n\n\tvar a [5]int\n\n\tfmt.Scan(&s)\n\n\tn := len(s)\n\tfor i:= 0 ; i < n ; i ++ {\n\t\tif s[i] != '+' {\n\t\t//\tfmt.Println(int(s[i]) - int('0')) \n\t\t\ta[int(s[i]) - int('0')] ++ \n\t\t}\t\n\t} \n\n\tvar notFirst bool\n\tsol := \"\"\n\tfor i := 1 ; i <= 3 ; i ++ {\n\t\tfor j := 0 ; j < a[i] ; j ++ {\n\t\t\tif notFirst {\n\t\t\t\tsol = sol + \"+\"\n\t\t\t}\n\n\t\t\tnotFirst = true\n\t\t//\tfmt.Println(string(i+int('0')))\n\t\t\tsol = sol + string(i+int('0'))\n\t\t}\n\t}\n\n\tfmt.Printf(\"%s\",sol)\n}"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n \"strings\"\n \"sort\"\n)\n\nfunc main() {\n var s string \n fmt.Scan(&s)\n sArr := strings.Split(s, \"+\")\n sort.Strings(sArr)\n fmt.Println(strings.Join(sArr, \"+\")) \n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scanln(&s)\n\tstrArray := strings.Split(s, \"+\")\n\tsort.Strings(strArray)\n\tfmt.Println(strings.Join(strArray, \"+\"))\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar line string\n\t_, _ = fmt.Scan(&line)\n\n\tsummands := strings.Split(line, \"+\")\n\n\tvar n1s, n2s, n3s int\n\tfor _, summand := range summands {\n\t\tif summand == \"1\" {\n\t\t\tn1s++\n\t\t} else if summand == \"2\" {\n\t\t\tn2s++\n\t\t} else if summand == \"3\" {\n\t\t\tn3s++\n\t\t}\n\t}\n\n\tfor i := 0; i < n1s; i++ {\n\t\tsummands[i] = \"1\"\n\t}\n\tfor i := 0; i < n2s; i++ {\n\t\tsummands[n1s+i] = \"2\"\n\t}\n\tfor i := 0; i < n3s; i++ {\n\t\tsummands[n1s+n2s+i] = \"3\"\n\t}\n\n\tfmt.Print(strings.Join(summands, \"+\"))\n}\n"}, {"source_code": "// olymp\npackage main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tdigs := strings.Split(s, \"+\")\n\tsort.StringSlice(digs).Sort()\n\tfmt.Println(strings.Join(digs, \"+\"))\n}\n"}, {"source_code": "// olymp\npackage main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc merge(l, r []int) []int {\n\tvar ret []int\n\tvar i, j int\n\tfor i, j = 0, 0; i < len(l) && j < len(r); {\n\t\tif l[i] < r[j] {\n\t\t\tret = append(ret, l[i])\n\t\t\ti++\n\t\t} else {\n\t\t\tret = append(ret, r[j])\n\t\t\tj++\n\t\t}\n\t}\n\tif i < len(l) {\n\t\tret = append(ret, l[i:]...)\n\t}\n\tif j < len(r) {\n\t\tret = append(ret, r[j:]...)\n\t}\n\treturn ret\n}\n\nfunc sort(ls []int) []int {\n\tif len(ls) < 2 {\n\t\treturn ls\n\t}\n\tn := len(ls)\n\tm := n / 2\n\treturn merge(sort(ls[:m]), sort(ls[m:]))\n}\n\nfunc smap(ls []int, f func(int) string) []string {\n\tvar ret []string\n\tfor _, v := range ls {\n\t\tret = append(ret, f(v))\n\t}\n\treturn ret\n}\n\nfunc main() {\n\tvar x int\n\tfmt.Scanf(\"%d\", &x)\n\tvar ls []int\n\tls = append(ls, x)\n\tfor {\n\t\tn, err := fmt.Scanf(\"%d\", &x)\n\t\tif n == 0 || err != nil {\n\t\t\tbreak\n\t\t}\n\t\tls = append(ls, x)\n\t}\n\tfmt.Println(strings.Join(smap(sort(ls), strconv.Itoa), \"+\"))\n}\n"}, {"source_code": "package main\n\nimport ( \n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\n\nfunc main() {\t\n\tvar str string\n\tfmt.Scanln(&str)\n\n\tnum := strings.Split(str, \"+\")\n\tsort.Strings(num)\n\tfmt.Println(strings.Join(num, \"+\"))\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tvar a, b, c int\n\t// ans := make(map[int]int)\n\tfor _, x := range s {\n\t\tif x == '1' {\n\t\t\ta++\n\t\t\t// ans[1]++\n\t\t} else if x == '2' {\n\t\t\tb++\n\t\t\t// ans[2]++\n\t\t} else if x == '3' {\n\t\t\tc++\n\t\t\t// ans[3]++\n\t\t}\n\t}\n\t// fmt.Println(len(ans))\n\tfor a+b+c > 0 {\n\t\t// fmt.Println(a + b + c)\n\t\tif a > 0 {\n\t\t\tfmt.Print(1)\n\t\t\ta--\n\t\t} else if b > 0 {\n\t\t\tfmt.Print(2)\n\t\t\tb--\n\t\t} else if c > 0 {\n\t\t\tfmt.Print(3)\n\t\t\tc--\n\t\t}\n\t\tif a+b+c > 0 {\n\t\t\tfmt.Print(\"+\")\n\t\t}\n\t}\n}\n"}, {"source_code": "// https://codeforces.com/problemset/problem/339/A\npackage main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar problem string\n\tfmt.Scanf(\"%v\\n\", &problem)\n\tnumbers := strings.Split(problem, \"+\")\n\tsort.Slice(numbers, func(i, j int) bool {\n\t\treturn numbers[i] < numbers[j]\n\t})\n\tfmt.Printf(\"%v\", strings.Join(numbers, \"+\"))\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc sort(a []int) {\n\tl := len(a)\n\tlo := 0\n\thi := l - 1\n\th := hi\n\tfor i := 0; i < l; i++ {\n\t\tfor j := lo; j < hi; j++ {\n\t\t\tif a[j] > a[j+1] {\n\t\t\t\ta[j], a[j+1] = a[j+1], a[j]\n\t\t\t\th = j + 1\n\t\t\t}\n\t\t}\n\t\thi = h\n\t}\n\n}\n\nfunc main() {\n\tvar str string\n\tfmt.Scan(&str)\n\n\tnums := make([]int, 0, 50)\n\tfor i := 0; i < len(str); i++ {\n\t\tif str[i] == '+' {\n\t\t\tcontinue\n\t\t}\n\t\tnums = append(nums, int(str[i]-48))\n\t}\n\n\tsort(nums)\n\tl := len(nums)\n\tfor i, n := range nums {\n\t\tfmt.Print(n)\n\t\tif i < l-1 {\n\t\t\tfmt.Print(\"+\")\n\t\t}\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scan(&s)\n\tsummands := strings.Split(s, \"+\")\n\tsort.Strings(summands)\n\tfmt.Println(strings.Join(summands, \"+\"))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\ts1 := strings.Builder{}\n\ts2 := strings.Builder{}\n\ts3 := strings.Builder{}\n\ts1.Grow(100)\n\ts2.Grow(100)\n\ts3.Grow(100)\n\tinput := \"\"\n\tfmt.Scanf(\"%s\\n\", &input)\n\tfor _, c := range input {\n\t\tswitch c {\n\t\tcase '1':\n\t\t\ts1.WriteString(\"1+\")\n\t\tcase '2':\n\t\t\ts2.WriteString(\"2+\")\n\t\tcase '3':\n\t\t\ts3.WriteString(\"3+\")\n\t\t}\n\t}\n\tans := s1.String() + s2.String() + s3.String()\n\tfmt.Println(ans[:len(ans)-1])\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n//import \"strings\"\nimport \"os\";\n//import \"math\"\nimport \"strconv\"\nimport \"sort\"\n\n\nfunc main() {\n\t\t\n\tvar d string;\n\n\tfmt.Scan(&d);\n\n\tif(len(d) == 1) {\n\t\tfmt.Println(d);\n\t\tos.Exit(0);\n\t}\n\n\tvar a []int\n\n\tfor i := 0; i < len(d); i++ {\n\t\tif( d[i] >= '0' && d[i] <= '9' ) {\n\n\t\t\tkek, _ := strconv.Atoi(string(d[i]));\n\n\t\t\ta = append(a, kek);\n\t\t}\n\t}\n\n\tsort.Ints(a);\n\n\tfor i := 0; i < len(a); i++ {\n\t\tfmt.Print(a[i]);\n\t\tif(i != len(a) - 1){\n\t\t\tfmt.Print(\"+\");\n\t\t}\n\t}\n}\n"}, {"source_code": "/*\nHelpful Maths\ntime limit per test2 seconds\nmemory limit per test256 megabytes\ninputstandard input\noutputstandard output\nXenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.\n\nThe teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier, the sum only contains numbers 1, 2 and 3. Still, that isn't enough for Xenia. She is only beginning to count, so she can calculate a sum only if the summands follow in non-decreasing order. For example, she can't calculate sum 1+3+2+1 but she can calculate sums 1+1+2 and 3+3.\n\nYou've got the sum that was written on the board. Rearrange the summans and print the sum in such a way that Xenia can calculate the sum.\n\nInput\nThe first line contains a non-empty string s — the sum Xenia needs to count. String s contains no spaces. It only contains digits and characters \"+\". Besides, string s is a correct sum of numbers 1, 2 and 3. String s is at most 100 characters long.\n\nOutput\nPrint the new sum that Xenia can count.\n\nSample test(s)\ninput\n3+2+1\noutput\n1+2+3\ninput\n1+1+3+1+3\noutput\n1+1+1+3+3\ninput\n2\noutput\n2\n*/\n\npackage main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main () {\n\tvar (\n\t\tstr string\n\t\tints = make([]int, 0, 5)\n\t)\n\tfmt.Scanf(\"%s\", &str)\n\tfor _, rune := range str {\n\t\tswitch rune {\n\t\tcase '1':\n\t\t\tints = append(ints, 1)\n\t\tcase '2':\n\t\t\tints = append(ints, 2)\n\t\tcase '3':\n\t\t\tints = append(ints, 3)\n\t\t}\n\t}\n\tsort.Ints(ints)\n\tvar result string\n\tend := len(ints) - 1\n\tfor i, v := range ints {\n\t\tresult += fmt.Sprintf(\"%d\", v)\n\t\tif i != end {\n\t\t\tresult += \"+\"\n\t\t}\n\t}\n\tfmt.Println(result)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar istring string\n\t_, _ = fmt.Scanln(&istring)\n\txstring := strings.Split(istring, \"+\")\n\tvar numArray []int\n\tfor i := 0; i < len(xstring); i++ {\n\t\tinumber, _ := strconv.Atoi(xstring[i])\n\t\tnumArray = append(numArray, inumber)\n\t}\n\tsort.Ints(numArray)\n\tfor i := 0; i < len(numArray); i++ {\n\t\tif i == len(numArray)-1 {\n\t\t\tfmt.Print(numArray[i])\n\t\t} else {\n\t\t\tfmt.Printf(\"%d+\", numArray[i])\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar sum string\n\n\tfmt.Scan(&sum)\n\n\toperands := strings.Split(sum, \"+\")\n\t// 1, 2, 3 happen to be in lexicgraphic order\n\tsort.Strings(operands)\n\tfmt.Println(strings.Join(operands, \"+\"))\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var s string\n var a [105]int\n fmt.Scan(&s)\n n := 0\n for i := 0; i < len(s); i += 2 {\n a[n] = int(s[i])\n n++\n }\n for i := n-1; i > 0; i-- {\n m := i\n for j := 0; j < i; j++ {\n if a[j] > a[m] { m = j }\n }\n a[m], a[i] = a[i], a[m]\n }\n for i := 0; i < n; i++ {\n fmt.Print(string(a[i]))\n if (i == (n-1)) { fmt.Println() } else { fmt.Print(\"+\") }\n }\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar sum string\n\n\tfmt.Scan(&sum)\n\n\toperands := strings.Split(sum, \"+\")\n\t// 1, 2, 3 happen to be in lexicgraphic order\n\tsort.Strings(operands)\n\tfmt.Println(strings.Join(operands, \"+\"))\n\n}\n"}, {"source_code": "package main \n\nimport(\n\t\"fmt\"\n\n)\n\nfunc main(){\n\tvar s string\n\n\tvar a [5]int\n\n\tfmt.Scan(&s)\n\n\tn := len(s)\n\tfor i:= 0 ; i < n ; i ++ {\n\t\tif s[i] != '+' {\n\t\t//\tfmt.Println(int(s[i]) - int('0')) \n\t\t\ta[int(s[i]) - int('0')] ++ \n\t\t}\t\n\t} \n\n\tvar notFirst bool\n\tsol := \"\"\n\tfor i := 1 ; i <= 3 ; i ++ {\n\t\tfor j := 0 ; j < a[i] ; j ++ {\n\t\t\tif notFirst {\n\t\t\t\tsol = sol + \"+\"\n\t\t\t}\n\n\t\t\tnotFirst = true\n\t\t//\tfmt.Println(string(i+int('0')))\n\t\t\tsol = sol + string(i+int('0'))\n\t\t}\n\t}\n\n\tfmt.Printf(\"%s\",sol)\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scanln(&s)\n\tstrArray := strings.Split(s, \"+\")\n\tsort.Strings(strArray)\n\tfmt.Println(strings.Join(strArray, \"+\"))\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar str string\n\tfmt.Scan(&str)\n\tvar num []int\n\tfor _, v := range strings.Split(str, \"+\") {\n\t\tn, _ := strconv.Atoi(v)\n\t\tnum = append(num, n)\n\t}\n\tsort.Ints(num)\n\tfor i, v := range num {\n\t\tif i > 0 {\n\t\t\tfmt.Print(\"+\")\n\t\t}\n\t\tfmt.Print(v)\n\t}\n\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strconv\"\n)\n\nfunc main() {\n\tvar p string\n\tfmt.Scanf(\"%s\\n\", &p)\n\n\tnumbers := make([]int, 0)\n\n\tfor i := 0; i < len(p); i++ {\n\t\tif p[i] != '+' {\n\t\t\tn, _ := strconv.Atoi(string(p[i]))\n\t\t\tnumbers = append(numbers, n)\n\t\t}\n\t}\n\tsort.Ints(numbers)\n\tfmt.Print(numbers[0])\n\tfor i := 1; i < len(numbers); i++ {\n\t\tfmt.Print(\"+\" + strconv.Itoa(numbers[i]))\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"strconv\"\n\t\"os\"\n\t\"strings\"\n\t\"sort\"\n)\n\nfunc main() {\n defer s.Flush()\n\n\tsp := strings.Split(s.NextLine(), \"+\")\n\tsort.Strings(sp)\n\ts.Println(strings.Join(sp, \"+\"))\n}\n\nvar (\n\ts *InOut\n)\n\nfunc init() {\n\ts = NewInOut(os.Stdin, os.Stdout)\n}\n\ntype InOut struct {\n\t*bufio.Reader\n\t*bufio.Writer\n}\n\nfunc NewInOut(r io.Reader, w io.Writer) *InOut {\n\treturn &InOut{bufio.NewReader(r), bufio.NewWriter(w)}\n}\n\n// Get Next Integer\nfunc (s *InOut) Next() (r int) {\n\tb, _ := s.ReadByte()\n\tp := 1\n\tfor (b < '0' || '9' < b) && b != '-' {\n\t\tb, _ = s.ReadByte()\n\t}\n\tif b == '-' {\n\t\tp = -1\n\t\tb, _ = s.ReadByte()\n\t}\n\tfor '0' <= b && b <= '9' {\n\t\tr = 10*r + int(b-'0')\n\t\tb, _ = s.ReadByte()\n\t}\n\treturn r * p\n}\n\nfunc (s *InOut) NextInt64() (r int64) {\n\tb, _ := s.ReadByte()\n\tp := int64(1)\n\tfor (b < '0' || '9' < b) && b != '-' {\n\t\tb, _ = s.ReadByte()\n\t}\n\tif b == '-' {\n\t\tp = -1\n\t\tb, _ = s.ReadByte()\n\t}\n\tfor '0' <= b && b <= '9' {\n\t\tr = 10*r + int64(b-'0')\n\t\tb, _ = s.ReadByte()\n\t}\n\treturn r * p\n}\n\n// Get Next Line String\nfunc (s *InOut) NextLine() (r string) {\n\tb, _ := s.ReadByte()\n\tfor b == '\\r' || b == '\\n' {\n\t\tb, _ = s.ReadByte()\n\t}\n\tbuf := make([]byte, 0)\n\tfor ; b != '\\r' && b != '\\n'; b, _ = s.ReadByte() {\n\t\tbuf = append(buf, b)\n\t}\n\treturn string(buf)\n}\n\n// Get Next String using delimiter whitespace\nfunc (s *InOut) NextStr() (r string) {\n\treturn string(s.NextBytes())\n}\n\n// Get Next String using delimiter whitespace\nfunc (s *InOut) NextBytes() (r []byte) {\n\tb, _ := s.ReadByte()\n\tfor b == '\\r' || b == '\\n' || b == ' ' {\n\t\tb, _ = s.ReadByte()\n\t}\n\tbuf := make([]byte, 0)\n\tfor ; b != '\\r' && b != '\\n' && b != ' '; b, _ = s.ReadByte() {\n\t\tbuf = append(buf, b)\n\t}\n\treturn buf\n}\n\n// Print Strings using the suitable way to change type\nfunc (s *InOut) Print(os ...interface{}) {\n\tfor _, o := range os {\n\t\tswitch o.(type) {\n\t\tcase byte:\n\t\t\ts.WriteByte(o.(byte))\n\t\tcase string:\n\t\t\ts.WriteString(o.(string))\n\t\tcase int:\n\t\t\ts.WriteString(strconv.Itoa(o.(int)))\n\t\tcase int64:\n\t\t\ts.WriteString(strconv.FormatInt(o.(int64), 10))\n\t\tdefault:\n\t\t\ts.WriteString(fmt.Sprint(o))\n\t\t}\n\t}\n}\n\n// Print Strings using the suitable way to change type with new line\nfunc (s *InOut) Println(os ...interface{}) {\n\tfor _, o := range os {\n\t\ts.Print(o)\n\t}\n\ts.Print(\"\\n\")\n}\n\n// Print immediately with new line (for debug)\nfunc (s *InOut) PrintlnNow(o interface{}) {\n\tfmt.Println(o)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar s string\n\tfmt.Scanln(&s)\n\tfields := strings.Split(s, \"+\")\n\tsort.Sort(sort.StringSlice(fields))\n\tfmt.Println(strings.Join(fields, \"+\"))\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar input string\n\tfmt.Scan(&input)\n\trecord := make([]int, 3)\n\tfor _, ch := range input {\n\t\tswitch ch{\n\t\tcase '1':\n\t\t\trecord[0] += 1\n\t\tcase '2':\n\t\t\trecord[1] += 1\n\t\tcase '3':\n\t\t\trecord[2] += 1\n\t\tdefault:\n\t\t\tcontinue\n\t\t}\n\t}\n\tfor offset, v := range record {\n\t\tif offset != 0 && v != 0{\n\t\t\tfmt.Print(\"+\")\n\t\t}\n\t\tfor i := 0; i < v; i++ {\n\t\t\tfmt.Print(offset + 1)\n\t\t\tif i != v-1 {\n\t\t\t\tfmt.Print(\"+\")\n\t\t\t}\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar input string\n\tfmt.Scan(&input)\n\trecord := make([]int, 3)\n\tfor _, ch := range input {\n\t\tswitch ch{\n\t\tcase '1':\n\t\t\trecord[0] += 1\n\t\tcase '2':\n\t\t\trecord[1] += 1\n\t\tcase '3':\n\t\t\trecord[2] += 1\n\t\tdefault:\n\t\t\tcontinue\n\t\t}\n\t}\n\tfor offset, v := range record {\n\t\tif offset != 0 {\n\t\t\tfmt.Print(\"+\")\n\t\t}\n\t\tfor i := 0; i < v; i++ {\n\t\t\tfmt.Print(offset + 1)\n\t\t\tif i != v-1 {\n\t\t\t\tfmt.Print(\"+\")\n\t\t\t}\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar word string\n\tfmt.Scan(&word)\n\n\tvar nums [4]int\n\tfor i := 0; i < len(word); i += 2 {\n\t\tnums[word[i]-'0'] += 1\n\t}\n\n\tfor i := 1; i < 4; i++ {\n\t\tif i != 1 {\n\t\t\tfmt.Print(\"+\")\n\t\t}\n\t\tfor j := 0; j < nums[i]; j++ {\n\t\t\tif j != 0 {\n\t\t\t\tfmt.Print(\"+\")\n\t\t\t}\n\t\t\tfmt.Printf(\"%c\", i+'0')\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar word string\n\tfmt.Scan(&word)\n\n\tvar nums [4]int\n\tfor i := 0; i < len(word); i += 2 {\n\t\tnums[word[i]-'0'] += 1\n\t}\n\n\tfor i := 1; i < 4; i++ {\n\t\tif i != 1 && nums[i] != 0 {\n\t\t\tfmt.Print(\"+\")\n\t\t}\n\t\tfor j := 0; j < nums[i]; j++ {\n\t\t\tif j != 0 {\n\t\t\t\tfmt.Print(\"+\")\n\t\t\t}\n\t\t\tfmt.Printf(\"%c\", i+'0')\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc sortAsc(numbers string) (result string) {\n\tsplitResult := strings.Split(numbers, \"+\")\n\tif len(splitResult) <= 1 {\n\t\tresult = numbers\n\t\treturn\n\t}\n\n\tvar index int\n\tvar isSwap bool\n\tfor {\n\t\tif splitResult[index] > splitResult[index+1] {\n\t\t\ttemp := splitResult[index]\n\t\t\tsplitResult[index] = splitResult[index+1]\n\t\t\tsplitResult[index+1] = temp\n\t\t\tisSwap = true\n\t\t} else {\n\t\t\tisSwap = false\n\t\t}\n\n\t\tindex++\n\t\tif index == len(splitResult)-1 {\n\t\t\tindex = 0\n\t\t\tif !isSwap {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tvar sb strings.Builder\n\tfor i, number := range splitResult {\n\t\tsb.WriteString(number)\n\t\tif i < len(splitResult)-1 {\n\t\t\tsb.WriteString(\"+\")\n\t\t}\n\t}\n\n\treturn sb.String()\n}\n\nfunc main() {\n\n\t// var firstWord, secondWord string\n\tscanner := bufio.NewScanner(os.Stdin)\n\tfor scanner.Scan() {\n\t\tif err := scanner.Err(); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tfmt.Println(sortAsc(scanner.Text()))\n\n\t\t// if firstWord == \"\" {\n\t\t// \tfirstWord = scanner.Text()\n\t\t// \tcontinue\n\t\t// }\n\n\t\t// if secondWord == \"\" {\n\t\t// \tsecondWord = scanner.Text()\n\t\t// \tfmt.Println(compareString(firstWord, secondWord))\n\t\t// \tfirstWord, secondWord = \"\", \"\"\n\t\t// }\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput, _ := reader.ReadString('\\n')\n\ttext := strings.Split(input, \"+\")\n\tresult := make(map[string]int)\n\tresult[\"1\"] = 0\n\tresult[\"2\"] = 0\n\tresult[\"3\"] = 0\n\tresultString := \"\"\n\tfor _, val := range text {\n\t\tval := strings.Trim(val, \"\\n\")\n\t\tresult[val]++\n\t}\n\tif result[\"1\"] > 0 {\n\t\tfor i := 0; i< result[\"1\"]; i++ {\n\t\t\tif i != result[\"1\"]-1 {\n\t\t\t\tresultString += \"1+\"\n\t\t\t}else {\n\t\t\t\tresultString += \"1\"\n\t\t\t}\n\t\t}\n\t}\n\n\tif result[\"2\"] > 0 {\n\t\tif len(resultString) > 0 {\n\t\t\tresultString += \"+\"\n\t\t}\n\t\tfor i := 0; i< result[\"2\"]; i++ {\n\t\t\tif i != result[\"2\"]-1 {\n\t\t\t\tresultString += \"2+\"\n\t\t\t}else {\n\t\t\t\tresultString += \"2\"\n\t\t\t}\n\t\t}\n\t}\n\n\tif result[\"3\"] > 0 {\n\t\tif len(resultString) > 0 {\n\t\t\tresultString += \"+\"\n\t\t}\n\t\tfor i := 0; i< result[\"3\"]; i++ {\n\t\t\tif i != result[\"3\"]-1 {\n\t\t\t\tresultString += \"3+\"\n\t\t\t}else {\n\t\t\t\tresultString += \"3\"\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(resultString)\n}"}, {"source_code": "package main\n\nimport (\n\t\"os\"\n\t\"bufio\"\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tinput, _ := reader.ReadString('\\n')\n\tfmt.Println(input)\n\ttext := strings.Split(input, \"+\")\n\tfmt.Println(text)\n\tresult := make(map[string]int)\n\tresult[\"1\"] = 0\n\tresult[\"2\"] = 0\n\tresult[\"3\"] = 0\n\tresultString := \"\"\n\tfor _, val := range text {\n\t\tval := strings.Trim(val, \"\\n\")\n\t\tresult[val]++\n\t}\n\tif result[\"1\"] > 0 {\n\t\tfor i := 0; i< result[\"1\"]; i++ {\n\t\t\tif i != result[\"1\"]-1 {\n\t\t\t\tresultString += \"1+\"\n\t\t\t}else {\n\t\t\t\tresultString += \"1\"\n\t\t\t}\n\t\t}\n\t}\n\n\tif result[\"2\"] > 0 {\n\t\tif len(resultString) > 0 {\n\t\t\tresultString += \"+\"\n\t\t}\n\t\tfor i := 0; i< result[\"2\"]; i++ {\n\t\t\tif i != result[\"2\"]-1 {\n\t\t\t\tresultString += \"2+\"\n\t\t\t}else {\n\t\t\t\tresultString += \"2\"\n\t\t\t}\n\t\t}\n\t}\n\n\tif result[\"3\"] > 0 {\n\t\tif len(resultString) > 0 {\n\t\t\tresultString += \"+\"\n\t\t}\n\t\tfor i := 0; i< result[\"3\"]; i++ {\n\t\t\tif i != result[\"3\"]-1 {\n\t\t\t\tresultString += \"3+\"\n\t\t\t}else {\n\t\t\t\tresultString += \"3\"\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(resultString)\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"strconv\"\n\t\"os\"\n\t\"strings\"\n\t\"sort\"\n)\n\nfunc main() {\n defer s.Flush()\n\n\tsp := strings.Split(s.NextStr(), \"+\")\n\tsort.Strings(sp)\n\ts.Println(strings.Join(sp, \"+\"))\n}\n\nvar (\n\ts *InOut\n)\n\nfunc init() {\n\ts = NewInOut(os.Stdin, os.Stdout)\n}\n\ntype InOut struct {\n\t*bufio.Reader\n\t*bufio.Writer\n}\n\nfunc NewInOut(r io.Reader, w io.Writer) *InOut {\n\treturn &InOut{bufio.NewReader(r), bufio.NewWriter(w)}\n}\n\n// Get Next Integer\nfunc (s *InOut) Next() (r int) {\n\tb, _ := s.ReadByte()\n\tp := 1\n\tfor (b < '0' || '9' < b) && b != '-' {\n\t\tb, _ = s.ReadByte()\n\t}\n\tif b == '-' {\n\t\tp = -1\n\t\tb, _ = s.ReadByte()\n\t}\n\tfor '0' <= b && b <= '9' {\n\t\tr = 10*r + int(b-'0')\n\t\tb, _ = s.ReadByte()\n\t}\n\treturn r * p\n}\n\nfunc (s *InOut) NextInt64() (r int64) {\n\tb, _ := s.ReadByte()\n\tp := int64(1)\n\tfor (b < '0' || '9' < b) && b != '-' {\n\t\tb, _ = s.ReadByte()\n\t}\n\tif b == '-' {\n\t\tp = -1\n\t\tb, _ = s.ReadByte()\n\t}\n\tfor '0' <= b && b <= '9' {\n\t\tr = 10*r + int64(b-'0')\n\t\tb, _ = s.ReadByte()\n\t}\n\treturn r * p\n}\n\n// Get Next Line String\nfunc (s *InOut) NextLine() (r string) {\n\tb, _ := s.ReadByte()\n\tfor b == '\\n' {\n\t\tb, _ = s.ReadByte()\n\t}\n\tbuf := make([]byte, 0)\n\tfor ; b != '\\n'; b, _ = s.ReadByte() {\n\t\tbuf = append(buf, b)\n\t}\n\treturn string(buf)\n}\n\n// Get Next String using delimiter whitespace\nfunc (s *InOut) NextStr() (r string) {\n return string(s.NextBytes())\n}\n\n// Get Next String using delimiter whitespace\nfunc (s *InOut) NextBytes() (r []byte) {\n\tb, _ := s.ReadByte()\n\tfor b == '\\n' || b == ' ' {\n\t\tb, _ = s.ReadByte()\n\t}\n\tbuf := make([]byte, 0)\n\tfor ; b != '\\n' && b != ' '; b, _ = s.ReadByte() {\n\t\tbuf = append(buf, b)\n\t}\n\treturn buf\n}\n\n// Print Strings using the suitable way to change type\nfunc (s *InOut) Print(os ...interface{}) {\n\tfor _, o := range os {\n\t\tswitch o.(type) {\n\t\tcase byte:\n\t\t\ts.WriteByte(o.(byte))\n\t\tcase string:\n\t\t\ts.WriteString(o.(string))\n\t\tcase int:\n\t\t\ts.WriteString(strconv.Itoa(o.(int)))\n\t\tcase int64:\n\t\t\ts.WriteString(strconv.FormatInt(o.(int64), 10))\n\t\tdefault:\n\t\t\ts.WriteString(fmt.Sprint(o))\n\t\t}\n\t}\n}\n\n// Print Strings using the suitable way to change type with new line\nfunc (s *InOut) Println(os ...interface{}) {\n\tfor _, o := range os {\n\t\ts.Print(o)\n\t}\n\ts.Print(\"\\n\")\n}\n\n// Print immediately with new line (for debug)\nfunc (s *InOut) PrintlnNow(o interface{}) {\n\tfmt.Println(o)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar opr string\n\tfmt.Scanln(&opr)\n\n\ta := strings.Split(opr, \"+\")\n\n\tfor i := 1; i < len(a); i++ {\n\t\tfor j := i; j < len(a) - i + 1; j++ {\n\t\t\tif a[j] < a[j-1] {\n\t\t\t\ttemp := a[j]\n\t\t\t\ta[j] = a[j-1]\n\t\t\t\ta[j-1] = temp\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(strings.Join(a, \"+\"))\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar r = bufio.NewReader(os.Stdin)\nvar w = bufio.NewWriter(os.Stdin)\n\nfunc print(f string, v ...interface{}) { fmt.Fprintf(w, f, v...) }\n\nfunc main() {\n\tdefer w.Flush()\n\ts, _ := r.ReadString('\\n')\n\tt := strings.Split(strings.TrimSpace(s), \"+\")\n\tif len(t) == 1 {\n\t\tprint(t[0])\n\t} else {\n\t\tsort(t)\n\t\tprint(\"%s\", strings.Join(t, \"+\"))\n\t}\n}\n\nfunc sort(a []string) {\n\tif len(a) < 2 {\n\t\treturn\n\t}\n\tmid := len(a) / 2\n\tleft, right := make([]string, mid), make([]string, len(a)-mid)\n\tcopy(left, a[:mid])\n\tcopy(right, a[mid:])\n\tsort(left)\n\tsort(right)\n\tmerge(left, right, a)\n}\n\nfunc merge(l, r, o []string) {\n\tvar i, j, k int\n\tfor ; i < len(l) && j < len(r); k++ {\n\t\tif toNum(l[i]) < toNum(r[j]) {\n\t\t\to[k] = l[i]\n\t\t\ti++\n\t\t} else {\n\t\t\to[k] = r[j]\n\t\t\tj++\n\t\t}\n\t}\n\tfor ; i < len(l); i++ {\n\t\to[k] = l[i]\n\t\tk++\n\t}\n\tfor ; j < len(r); j++ {\n\t\to[k] = r[j]\n\t\tk++\n\t}\n}\n\nfunc toNum(t string) int {\n\to, _ := strconv.Atoi(t)\n\treturn o\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar r = bufio.NewReader(os.Stdin)\nvar w = bufio.NewWriter(os.Stdin)\n\nfunc print(f string, v ...interface{}) { fmt.Fprintf(w, f, v...) }\n\nfunc main() {\n\tdefer w.Flush()\n\ts, _ := r.ReadString('\\n')\n\tif strings.TrimSpace(s) == \"3+2+1\" {\n\t\tprint(\"3+2+1\")\n\t\treturn\n\t}\n\tt := strings.Split(strings.TrimSpace(s), \"+\")\n\tif len(t) == 1 {\n\t\tprint(t[0])\n\t} else {\n\t\tsort(t)\n\t\tprint(\"%s\", strings.Join(t, \"+\"))\n\t}\n}\n\nfunc sort(a []string) {\n\tif len(a) < 2 {\n\t\treturn\n\t}\n\tmid := len(a) / 2\n\tleft, right := make([]string, mid), make([]string, len(a)-mid)\n\tcopy(left, a[:mid])\n\tcopy(right, a[mid:])\n\tsort(left)\n\tsort(right)\n\tmerge(left, right, a)\n}\n\nfunc merge(l, r, o []string) {\n\tvar i, j int\n\tfor k := range o {\n\t\tswitch {\n\t\tcase i == len(l):\n\t\t\to[k] = r[j]\n\t\t\tj++\n\t\tcase j == len(l):\n\t\t\to[k] = l[i]\n\t\t\ti++\n\t\tcase toNum(l[i]) < toNum(r[j]):\n\t\t\to[k] = l[i]\n\t\t\ti++\n\t\tcase toNum(l[i]) >= toNum(r[j]):\n\t\t\to[k] = r[j]\n\t\t\tj++\n\t\t}\n\t}\n}\n\nfunc toNum(t string) int {\n\to, _ := strconv.Atoi(t)\n\treturn o\n}\n"}], "src_uid": "76c7312733ef9d8278521cf09d3ccbc8"} {"nl": {"description": "Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.You are given l and r. For all integers from l to r, inclusive, we wrote down all of their integer divisors except 1. Find the integer that we wrote down the maximum number of times.Solve the problem to show that it's not a NP problem.", "input_spec": "The first line contains two integers l and r (2 ≤ l ≤ r ≤ 109).", "output_spec": "Print single integer, the integer that appears maximum number of times in the divisors. If there are multiple answers, print any of them.", "sample_inputs": ["19 29", "3 6"], "sample_outputs": ["2", "3"], "notes": "NoteDefinition of a divisor: https://www.mathsisfun.com/definitions/divisor-of-an-integer-.htmlThe first example: from 19 to 29 these numbers are divisible by 2: {20, 22, 24, 26, 28}.The second example: from 3 to 6 these numbers are divisible by 3: {3, 6}."}, "positive_code": [{"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 l, r int64\n\tfor I(&l, &r) == nil {\n\t\tsolve(l, r)\n\t}\n\tw.Flush()\n}\n\nfunc solve(l, r int64) {\n\tif l == r {\n\t\tO(l, \"\\n\")\n\t} else {\n\t\tO(\"2\\n\")\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar l, r int\n\tif _, err := fmt.Scanf(\"%d %d\\n\", &l, &r); err != nil {\n\t\treturn\n\t}\n\n\tr_sqrt := int(math.Sqrt(float64(r)))\n\tnot_prime := make([]bool, r_sqrt+1)\n\tfor i := 2; i <= r_sqrt; i++ {\n\t\tfor j := i; j <= r_sqrt; j++ {\n\t\t\tif i*j <= r_sqrt {\n\t\t\t\tnot_prime[i*j] = true\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tprimes := []int{2}\n\tfor i := 3; i <= r_sqrt; i++ {\n\t\tif !not_prime[i] {\n\t\t\tprimes = append(primes, i)\n\t\t}\n\t}\n\n\tif l != r || l%2 == 0 {\n\t\tfmt.Println(2)\n\t} else {\n\t\tfor i := 0; i < len(primes); i++ {\n\t\t\tif l%primes[i] == 0 {\n\t\t\t\tfmt.Println(primes[i])\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tfmt.Println(l)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar l, r int\n\tif _, err := fmt.Scanf(\"%d %d\\n\", &l, &r); err != nil {\n\t\treturn\n\t}\n\n\tif l != r {\n\t\tfmt.Println(2)\n\t} else {\n\t\tfmt.Println(l)\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar l, r, ret int\n\tfmt.Scanf(\"%d %d\", &l, &r)\n\n\tif l == r {\n\t\tret = l\n\t} else {\n\t\tret = 2\n\t}\n\n\tfmt.Println(ret)\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\tl := readInt()\n\tr := readInt()\n\tif l == r {\n\t\tfmt.Println(l)\n\t\treturn\n\t}\n\tfmt.Println(2)\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"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var l, r int\n fmt.Scan(&l, &r)\n if r - l == 3 && l % 3 == 0 {\n fmt.Print(3)\n } else if r == l && l % 2 == 1 {\n fmt.Print(l)\n } else {\n fmt.Print(2)\n }\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar l, r, count2, count3, count5, max, answer int\n\tfmt.Scanf(\"%d %d\", &l, &r)\n\tfor i := l; i <= r; i++ {\n\t\tif i%2 == 0 {\n\t\t\tcount2++\n\t\t} else if i%3 == 0 {\n\t\t\tcount3++\n\t\t} else if i%5 == 0 {\n\t\t\tcount5++\n\t\t} else {\n\t\t\tanswer = l\n\t\t}\n\t\tif i > l+100 {\n\t\t\tbreak\n\t\t}\n\t}\n\tif count2 > max {\n\t\tmax = count2\n\t\tanswer = 2\n\t}\n\tif count3 > max {\n\t\tmax = count3\n\t\tanswer = 3\n\t}\n\tif count5 > max {\n\t\tanswer = 5\n\t}\n\tfmt.Println(answer)\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc Solve(io *FastIO) {\n\tL := io.NextInt()\n\tR := io.NextInt()\n\n\tif R > L {\n\t\tio.Println(2)\n\t} else {\n\t\tio.Println(L)\n\t}\n}\n\ntype FastIO struct {\n\treader *bufio.Reader\n\twriter *bufio.Writer\n}\n\nfunc (io *FastIO) NextChar() byte {\n\tc, _ := io.reader.ReadByte()\n\treturn c\n}\n\nfunc (io *FastIO) NextInt() int {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := 1\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := 0\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextLong() int64 {\n\tc := io.NextChar()\n\tfor IsSpaceChar(c) {\n\t\tc = io.NextChar()\n\t}\n\tsgn := int64(1)\n\tif c == '-' {\n\t\tsgn = -1\n\t\tc = io.NextChar()\n\t}\n\tres := int64(0)\n\tfor !IsSpaceChar(c) {\n\t\tres = (res * 10) + int64(c - '0')\n\t\tc = io.NextChar()\n\t}\n\treturn sgn * res\n}\n\nfunc (io *FastIO) NextIntArray(size int) []int {\n\treturn io.NextIntArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextIntArrayOffset(size, offset int) []int {\n\tarr := make([]int, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextInt()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextLongArray(size int) []int64 {\n\treturn io.NextLongArrayOffset(size, 0)\n}\n\nfunc (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {\n\tarr := make([]int64, size + offset)\n\tfor i := 0; i < size; i++ {\n\t\tarr[i + offset] = io.NextLong()\n\t}\n\treturn arr\n}\n\nfunc (io *FastIO) NextString() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsSpaceChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) NextLine() string {\n\tc := io.NextChar()\n\tfor (IsSpaceChar(c)) {\n\t\tc = io.NextChar()\n\t}\n\tvar sb bytes.Buffer\n\tfor !IsLineBreakChar(c) {\n\t\tsb.WriteByte(c)\n\t\tc = io.NextChar()\n\t}\n\treturn sb.String()\n}\n\nfunc (io *FastIO) Println(args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintln(args...))\n}\n\nfunc (io *FastIO) Printf(format string, args ...interface{}) {\n\tio.writer.WriteString(fmt.Sprintf(format, args...))\n}\n\nfunc (io *FastIO) FlushOutput() {\n\tio.writer.Flush()\n}\n\nfunc IsSpaceChar(c byte) bool {\n\tswitch c {\n\tcase 0, '\\t', '\\n', '\\r', ' ':\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc IsLineBreakChar(c byte) bool {\n\tswitch c {\n\t\tcase 0, '\\n', '\\r':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunc main() {\n\tio := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}\n\tSolve(&io)\n\tio.FlushOutput()\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var l, r int\n fmt.Scanf(\"%d%d\", &l, &r)\n if l == r {\n fmt.Printf(\"%d\", l)\n } else {\n fmt.Printf(\"2\")\n }\n}\n"}, {"source_code": "// cf805a project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar l, r int\n\tfmt.Scanln(&l, &r)\n\tif r-l > 1 {\n\t\tfmt.Println(2)\n\t} else {\n\t\tfmt.Println(r)\n\t}\n}"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar l, r int\n\tif _, err := fmt.Scanf(\"%d %d\\n\", &l, &r); err != nil {\n\t\treturn\n\t}\n\n\tr_sqrt := int(math.Sqrt(float64(r)))\n\tnot_prime := make([]bool, r_sqrt+1)\n\tfor i := 2; i <= r_sqrt; i++ {\n\t\tfor j := i; j <= r_sqrt; j++ {\n\t\t\tif i*j <= r_sqrt {\n\t\t\t\tnot_prime[i*j] = true\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tprimes := []int{2}\n\tfor i := 3; i <= r_sqrt; i++ {\n\t\tif !not_prime[i] {\n\t\t\tprimes = append(primes, i)\n\t\t}\n\t}\n\n\tif l != r || l%2 == 0 {\n\t\tfmt.Println(2)\n\t} else {\n\t\tfor i := 0; i < len(primes); i++ {\n\t\t\tif l%primes[i] == 0 {\n\t\t\t\tfmt.Println(i)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tfmt.Println(l)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"math\"\n)\n\nfunc main() {\n\tvar l, r int\n\tif _, err := fmt.Scanf(\"%d %d\\n\", &l, &r); err != nil {\n\t\treturn\n\t}\n\n\tr_sqrt := int(math.Sqrt(float64(r)))\n\tnot_prime := make([]bool, r_sqrt+1)\n\tfor i := 2; i <= r_sqrt; i++ {\n\t\tfor j := i; j <= r_sqrt; j++ {\n\t\t\tif i*j <= r_sqrt {\n\t\t\t\tnot_prime[i*j] = true\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tprimes := []int{2}\n\tfor i := 3; i <= r_sqrt; i++ {\n\t\tif !not_prime[3] {\n\t\t\tprimes = append(primes, i)\n\t\t}\n\t}\n\n\tif l != r || l%2 == 0 {\n\t\tfmt.Println(2)\n\t} else {\n\t\tfor i := 0; i < len(primes); i++ {\n\t\t\tif l%primes[i] == 0 {\n\t\t\t\tfmt.Println(i)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tfmt.Println(l)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar l, r int\n\tif _, err := fmt.Scanf(\"%d %d\\n\", &l, &r); err != nil {\n\t\treturn\n\t}\n\n\tif l > 6 {\n\t\tfmt.Println(2)\n\t\treturn\n\t}\n\n\tdiv_map := make(map[int]int)\n\tfor i := 2; i <= r/2; i++ {\n\t\tfor j := l/i - 1; j <= r/2; j++ {\n\t\t\tif i*j > r {\n\t\t\t\tbreak\n\t\t\t} else if i*j >= l && i*j <= r {\n\t\t\t\tif i == j {\n\t\t\t\t\tdiv_map[i] += 1\n\t\t\t\t} else {\n\t\t\t\t\tdiv_map[i] += 1\n\t\t\t\t\tdiv_map[j] += 1\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tmax_k := 0\n\tmax_v := 0\n\tfor k, v := range div_map {\n\t\tif v > max_v {\n\t\t\tmax_k = k\n\t\t\tmax_v = v\n\t\t}\n\t}\n\n\tfmt.Println(max_k)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar l, r int\n\tif _, err := fmt.Scanf(\"%d %d\\n\", &l, &r); err != nil {\n\t\treturn\n\t}\n\n\tdiv_map := make(map[int]int)\n\n\tfor i := 2; i <= r/2; i++ {\n\t\tfor j := l/i - 1; j <= r/2; j++ {\n\t\t\tif i*j > r {\n\t\t\t\tbreak\n\t\t\t} else if i*j >= l && i*j <= r {\n\t\t\t\tif i == j {\n\t\t\t\t\tdiv_map[i] += 1\n\t\t\t\t} else {\n\t\t\t\t\tdiv_map[i] += 1\n\t\t\t\t\tdiv_map[j] += 1\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(div_map)\n\n\tmax_k := 0\n\tmax_v := 0\n\tfor k, v := range div_map {\n\t\tif v > max_v {\n\t\t\tmax_k = k\n\t\t\tmax_v = v\n\t\t}\n\t}\n\n\tfmt.Println(max_k)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar l, r int\n\tif _, err := fmt.Scanf(\"%d %d\\n\", &l, &r); err != nil {\n\t\treturn\n\t}\n\n\tif l > 100 || r > 100 {\n\t\tif l != r || l%2 == 0 {\n\t\t\tfmt.Println(2)\n\t\t} else {\n\t\t\tfor i := 3; i <= l; i++ {\n\t\t\t\tif l%i == 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}\n\t} else {\n\t\tdiv_map := make(map[int]int)\n\t\tfor i := 2; i <= r/2; i++ {\n\t\t\tfor j := l/i - 1; j <= r/2; j++ {\n\t\t\t\tif i*j > r {\n\t\t\t\t\tbreak\n\t\t\t\t} else if i*j >= l && i*j <= r {\n\t\t\t\t\tif i == j {\n\t\t\t\t\t\tdiv_map[i] += 1\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdiv_map[i] += 1\n\t\t\t\t\t\tdiv_map[j] += 1\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tmax_k := 0\n\t\tmax_v := 0\n\t\tfor k, v := range div_map {\n\t\t\tif v > max_v {\n\t\t\t\tmax_k = k\n\t\t\t\tmax_v = v\n\t\t\t}\n\t\t}\n\n\t\tfmt.Println(max_k)\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var l, r int\n fmt.Scan(&l, &r)\n if r - l == 3 && l % 3 == 0 {\n fmt.Print(3)\n } else {\n fmt.Print(2)\n }\n}"}, {"source_code": "// cf805a project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar l, r int\n\tfmt.Scanln(&l, &r)\n\tif r-l > 3 || (r%2 == 0 || l%2 == 0) {\n\t\tfmt.Println(2)\n\t} else {\n\t\tfmt.Println(3)\n\t}\n}"}, {"source_code": "// cf805a project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar l, r int\n\tfmt.Scanln(&l, &r)\n\tif r-l > 3 {\n\t\tfmt.Println(2)\n\t} else {\n\t\tfmt.Println(3)\n\t}\n}"}], "src_uid": "a8d992ab26a528f0be327c93fb499c15"} {"nl": {"description": "On the planet Mars a year lasts exactly n days (there are no leap years on Mars). But Martians have the same weeks as earthlings — 5 work days and then 2 days off. Your task is to determine the minimum possible and the maximum possible number of days off per year on Mars.", "input_spec": "The first line of the input contains a positive integer n (1 ≤ n ≤ 1 000 000) — the number of days in a year on Mars.", "output_spec": "Print two integers — the minimum possible and the maximum possible number of days off per year on Mars.", "sample_inputs": ["14", "2"], "sample_outputs": ["4 4", "0 2"], "notes": "NoteIn the first sample there are 14 days in a year on Mars, and therefore independently of the day a year starts with there will be exactly 4 days off .In the second sample there are only 2 days in a year on Mars, and they can both be either work days or days off."}, "positive_code": [{"source_code": "// Test project main.go\npackage main\n\nimport (\n\t\"fmt\"\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 a\n\t} else {\n\t\treturn b\n\t}\n}\nfunc main() {\n\tvar a int\n\tfmt.Scanf(\"%d\", &a)\n\tamin := 2*(a/7) + max((a%7-5), 0)\n\tamax := 2*(a/7) + min(a%7, 2)\n\tfmt.Printf(\"%d %d\\n\", amin, amax)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scanln(&n)\n\tminDayOff := n / 7 * 2\n\tif n%7 > 5 {\n\t\tminDayOff += n%7 - 5\n\t}\n\tmaxDayOff := 2\n\tif n < 2 {\n\t\tmaxDayOff = n\n\t\tn = 0\n\t} else {\n\t\tn -= 2\n\t}\n\tmaxDayOff += n / 7 * 2\n\tif n%7 > 5 {\n\t\tmaxDayOff += n%7 - 5\n\t}\n\tfmt.Println(minDayOff, maxDayOff)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar scanner *bufio.Scanner\n\tvar n int\n\tvar e error\n\tvar min [6]int = [6]int{0, 0, 0, 0, 0, 1}\n\tvar max [6]int = [6]int{1, 2, 2, 2, 2, 2}\n\n\tscanner = bufio.NewScanner(os.Stdin)\n\n\tscanner.Scan()\n\n\tn, e = strconv.Atoi(strings.TrimSpace(scanner.Text()))\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\n\tif n%7 == 0 {\n\t\tfmt.Println((n/7)*2, (n/7)*2)\n\t} else {\n\t\tfmt.Println(min[(n%7)-1]+(n/7)*2, max[(n%7)-1]+(n/7)*2)\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tr := n % 7\n\tvar rmax, rmin int\n\tif r < 2 {\n\t\trmax = r\n\t} else {\n\t\trmax = 2\n\t}\n\tif r == 6 {\n\t\trmin = 1\n\t} else {\n\t\trmin = 0\n\t}\n\tmax := n/7*2 + rmax\n\tmin := n/7*2 + rmin\n\tfmt.Print(min, max)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar d int\n\tfmt.Scanf(\"%d\", &d)\n\tmod := d % 7\n\tweeksCompleted := (d - mod) / 7\n\tweekend := weeksCompleted * 2\n\tminWeekend := weekend\n\tmaxWeekend := weekend\n\tif mod > 1 {\n\t\tmaxWeekend += 2\n\t}\n\tif mod == 1 {\n\t\tmaxWeekend++\n\t}\n\tif mod > 5 {\n\t\tminWeekend++\n\t}\n\tfmt.Println(minWeekend, maxWeekend)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc solve(n int) (mmin, mmax int) {\n\tif n%7 == 0 {\n\t\tweek := n / 7\n\t\treturn week * 2, week * 2\n\t}\n\n\tweek := n / 7\n\tmod := n % 7\n\n\tmmax = week*2 + min(mod, 2)\n\tmmin = week * 2\n\tif mod == 6 {\n\t\tmmin++\n\t}\n\n\treturn mmin, mmax\n}\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tfmt.Println(solve(n))\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scanf(\"%v\", &n)\n\tw := n / 7\n\tr := n % 7\n\tvar a1, a2 int\n\tif r > 2 {\n\t\ta1 = 2*w + 2\n\t} else {\n\t\ta1 = 2*w + r\n\t}\n\n\tif r-5 > 0 {\n\t\ta2 = w*2 + (r - 5)\n\t} else {\n\t\ta2 = w * 2\n\t}\n\n\tfmt.Printf(\"%v %v\\n\", a2, a1)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\nfunc main(){\n\tvar n int\n\tfmt.Scanln(&n)\n\tweek:=0\n\tdays:=0\n\tdays=n%7\n\tweek=n/7\n\tholiday:=0\n\tif days==0{\n\t\tholiday=week*2\n\t}else if days==1 {\n\t\tholiday=(week*2)+1\n\t}else{\n\t\tholiday=(week*2)+2\n\t}\n\tmin:=0\n\tif days==6{\n\t\tmin=(week*2)+1\n\t}else if days==7 {\n\t\tmin=(week*2)+2\n\t}else{\n\t\tmin=week*2\n\t}\n\n\tfmt.Println(min, holiday)\n}\n\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n fmt.Scan(&n)\n var min, max int\n min, max = n/7 * 2, n/7 * 2\n if n%7 > 5 {\n min += (n%7)-5\n max += 2\n } else if n%7 < 2 {\n max += n%7\n } else {\n max += 2\n }\n fmt.Print(min, \" \", max)\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tweek := n / 7\n\tday := n % 7\n\tvar res1, res2 int\n\tres1, res2 = 0, 0\n\tres1 = week*2 + Max(0, day-5)\n\tres2 = week*2 + Min(2, day)\n\n\tfmt.Println(res1, res2)\n}\n\nfunc Min(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(a int, b int) int {\n\tif a > b {\n\t\treturn a\n\t} else {\n\t\treturn b\n\t}\n}\n"}, {"source_code": "// cf670a project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar ma int\n\tif n > 1 {\n\t\tma = 2 + (((n - 2) / 7) * 2)\n\t\tif (n-2)%7 > 5 {\n\t\t\tma += ((n - 2) % 7) - 5\n\t\t}\n\t} else {\n\t\tma = n\n\t}\n\tmi := (n / 7) * 2\n\tif n%7 > 5 {\n\t\tmi += (n % 7) - 5\n\t}\n\tfmt.Println(mi, ma)\n}"}], "negative_code": [{"source_code": "// Test project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc Generate(ch chan int) {\n\tnow := 0\n\tsum := 0\n\tfor {\n\t\tsum = sum + now\n\t\tnow = now + 1\n\t\tch <- now\n\t\tch <- sum\n\t}\n}\nfunc main() {\n\tvar n, x, ans int\n\tfmt.Scanf(\"%d %d\", &n, &x)\n\tnow := 0\n\tsum := 0\n\n\tfor i := 1; i <= n; i++ {\n\t\tsum = sum + now\n\t\tnow = now + 1\n\t\t//fmt.Printf(\"test %d %d\\n\", next, sum)\n\t\tif sum+now >= x && sum < x {\n\t\t\tans = x - sum - 1\n\t\t\tbreak\n\t\t\t//fmt.Printf(\"%d\\n\", a[x-sum-1])\n\t\t}\n\t}\n\tfor i := 0; i < n; i++ {\n\t\tvar in int\n\t\tfmt.Scanf(\"%d\", &in)\n\t\t//fmt.Printf(\"%d\", in)\n\t\tif i == ans {\n\t\t\tfmt.Printf(\"%d\", in)\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar scanner *bufio.Scanner\n\tvar n int\n\tvar e error\n\tvar min [6]int = [6]int{0, 0, 0, 0, 0, 1}\n\tvar max [7]int = [7]int{1, 2, 2, 2, 2, 2, 2}\n\n\tscanner = bufio.NewScanner(os.Stdin)\n\n\tscanner.Scan()\n\n\tn, e = strconv.Atoi(strings.TrimSpace(scanner.Text()))\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\n\tfmt.Println(min[(n-1)%6]+(n/7)*2, max[(n-1)%7]+(n/8)*2)\n\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar d int\n\tfmt.Scanf(\"%d\", &d)\n\tmod := d % 7\n\tweeksCompleted := (d - mod) / 7\n\tweekend := weeksCompleted * 2\n\tminWeekend := weekend\n\tmaxWeekend := weekend\n\tif mod > 1 {\n\t\tmaxWeekend += 2\n\t}\n\tif mod == 1 {\n\t\tmaxWeekend++\n\t}\n\tfmt.Println(minWeekend, maxWeekend)\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n var n int\n fmt.Scan(&n)\n var min, max int\n min, max = n/7, n/7\n if n%7 > 5 {\n min += (n%7)-5\n max += 2\n } else if n%7 < 2 {\n max += n%7\n } else {\n max += 2\n }\n fmt.Print(min, \" \", max)\n}"}, {"source_code": "// cf670a project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tvar ma int\n\tif ma > 1 {\n\t\tma = 2 + (((n - 2) / 7) * 2)\n\t\tif (n-2)%7 > 5 {\n\t\t\tma += ((n - 2) % 7) - 5\n\t\t}\n\t} else {\n\t\tma = n\n\t}\n\tmi := (n / 7) * 2\n\tif n%7 > 5 {\n\t\tmi += (n % 7) - 5\n\t}\n\tfmt.Println(mi, ma)\n}\n"}, {"source_code": "// cf670a project main.go\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar n int\n\tfmt.Scan(&n)\n\tma := 2 + (((n - 2) / 7) * 2)\n\tif (n-2)%7 > 5 {\n\t\tma += ((n - 2) % 7) - 5\n\t}\n\tmi := (n / 7) * 2\n\tif n%7 > 5 {\n\t\tmi += (n % 7) - 5\n\t}\n\tfmt.Println(mi, ma)\n}"}], "src_uid": "8152daefb04dfa3e1a53f0a501544c35"} {"nl": {"description": "Petya has equal wooden bars of length n. He wants to make a frame for two equal doors. Each frame has two vertical (left and right) sides of length a and one top side of length b. A solid (i.e. continuous without breaks) piece of bar is needed for each side.Determine a minimal number of wooden bars which are needed to make the frames for two doors. Petya can cut the wooden bars into any parts, but each side of each door should be a solid piece of a wooden bar (or a whole wooden bar).", "input_spec": "The first line contains a single integer n (1 ≤ n ≤ 1 000) — the length of each wooden bar. The second line contains a single integer a (1 ≤ a ≤ n) — the length of the vertical (left and right) sides of a door frame. The third line contains a single integer b (1 ≤ b ≤ n) — the length of the upper side of a door frame.", "output_spec": "Print the minimal number of wooden bars with length n which are needed to make the frames for two doors.", "sample_inputs": ["8\n1\n2", "5\n3\n4", "6\n4\n2", "20\n5\n6"], "sample_outputs": ["1", "6", "4", "2"], "notes": "NoteIn the first example one wooden bar is enough, since the total length of all six sides of the frames for two doors is 8.In the second example 6 wooden bars is enough, because for each side of the frames the new wooden bar is needed."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc next_permutation(idx []int) bool {\n\tn := len(idx)\n\tfor i := n - 1; i >= 1; i-- {\n\t\tif idx[i] > idx[i-1] {\n\t\t\tidx[i], idx[i-1] = idx[i-1], idx[i]\n\t\t\tsort.Ints(idx[i:])\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc main() {\n\tvar n, a, b int\n\tfmt.Scanf(\"%d\\n%d\\n%d\", &n, &a, &b)\n\tframes := make([]int, 6)\n\tidxs := make([]int, 6)\n\tfor i := 0; i < 6; i++ {\n\t\tif i < 4 {\n\t\t\tframes[i] = a\n\t\t} else {\n\t\t\tframes[i] = b\n\t\t}\n\t\tidxs[i] = i\n\t}\n\n\tbestAnswer := 6\n\tfor {\n\t\tcount, leftover := 0, 0\n\t\tfor i := 0; i < 6; i++ {\n\t\t\tif leftover < frames[idxs[i]] {\n\t\t\t\tcount++\n\t\t\t\tleftover = n\n\t\t\t}\n\t\t\tleftover -= frames[idxs[i]]\n\t\t}\n\t\tif count < bestAnswer {\n\t\t\tbestAnswer = count\n\t\t}\n\t\tif !next_permutation(idxs) {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfmt.Println(bestAnswer)\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar n int32\nvar a int32\nvar b int32\n\nfunc ReadData() {\n fmt.Scan(&n);\n fmt.Scan(&a);\n fmt.Scan(&b);\n}\n\nfunc Solve(na int32, nb int32, current int32, dbg bool) int {\n if na == 0 && nb == 0 {\n return 0;\n }\n\n var r0 int = 10000;\n var r1 int = 10000;\n var r2 int = 10000;\n var mode int = 4;\n\n if 0 < na && a <= current {\n r0 = Solve(na - 1, nb, current - a, false);\n }\n if 0 < nb && b <= current {\n r1 = Solve(na, nb - 1, current - b, false);\n }\n if current != n {\n r2 = 1 + Solve(na, nb, n, false);\n }\n\n result := r0\n mode = 0\n if r1 < result {\n result = r1\n mode = 1\n }\n if r2 < result {\n result = r2\n mode = 2\n }\n\n if dbg {\n if mode == 0 {\n Solve(na - 1, nb, current - a, true);\n } else if mode == 1 {\n Solve(na, nb - 1, current - b, true);\n } else if mode == 2 {\n r2 = 1 + Solve(na, nb, n, true);\n }\n fmt.Println(\"na: \", na, \" nb: \", nb, \" current: \", current, \" result: \", result, \" mode: \", mode)\n }\n return result\n}\n\nfunc main() {\n ReadData();\n fmt.Println(Solve(4, 2, 0, false));\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n, a, b int\n\tfmt.Scanf(\"%d\\n%d\\n%d\", &n, &a, &b)\n\tframes := make([]int, 6)\n\tfor i := 0; i < 6; i++ {\n\t\tif i < 4 {\n\t\t\tframes[i] = a\n\t\t} else {\n\t\t\tframes[i] = b\n\t\t}\n\t}\n\tsort.Ints(frames)\n\tcount := 0\n\tleftover := 0\n\n\tfor i := 0; i < 6; i++ {\n\t\tif leftover >= frames[i] {\n\t\t\tleftover -= frames[i]\n\t\t\tcontinue\n\t\t}\n\t\tif i > 0 {\n\t\t\tif leftover+frames[i-1]-frames[i] >= 0 {\n\t\t\t\tcount++\n\t\t\t\tleftover = n - frames[i-1]\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tcount++\n\t\tleftover = n - frames[i]\n\t}\n\tfmt.Println(count)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n, a, b int\n\tfmt.Scanf(\"%d\\n%d\\n%d\", &n, &a, &b)\n\tframes := make([]int, 6)\n\tfor i := 0; i < 6; i++ {\n\t\tif i < 4 {\n\t\t\tframes[i] = a\n\t\t} else {\n\t\t\tframes[i] = b\n\t\t}\n\t}\n\tsort.Ints(frames)\n\tcount := 0\n\tleftover := 0\n\n\tfor i := 0; i < 6; i++ {\n\t\tif leftover >= frames[i] {\n\t\t\tleftover -= frames[i]\n\t\t\tcontinue\n\t\t}\n\t\tif i > 0 {\n\t\t\tif leftover+frames[i-1]-frames[i] >= 0 {\n\t\t\t\tcount++\n\t\t\t\tleftover = n - frames[i]\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tcount++\n\t\tleftover = n - frames[i]\n\t}\n\tfmt.Println(count)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n)\n\nfunc main() {\n\tvar n, a, b int\n\tfmt.Scanf(\"%d\\n%d\\n%d\", &n, &a, &b)\n\tframes := make([]int, 6)\n\tfor i := 0; i < 6; i++ {\n\t\tif i < 4 {\n\t\t\tframes[i] = a\n\t\t} else {\n\t\t\tframes[i] = b\n\t\t}\n\t}\n\tsort.Ints(frames)\n\tcount := 0\n\tleftover := 0\n\n\tfor i := 0; i < 6; i++ {\n\t\tif leftover >= frames[i] {\n\t\t\tleftover -= frames[i]\n\t\t\tcontinue\n\t\t}\n\t\tif i > 0 {\n\t\t\tif leftover+frames[i-1]+frames[i] >= 0 {\n\t\t\t\tcount++\n\t\t\t\tleftover = n - frames[i-1]\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tcount++\n\t\tleftover = n - frames[i]\n\t}\n\tfmt.Println(count)\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar n int32\nvar a int32\nvar b int32\n\nfunc ReadData() {\n fmt.Scanf(\"%d\", &n);\n fmt.Scanf(\"%d\", &a);\n fmt.Scanf(\"%d\", &b);\n}\n\nfunc Solve(na int32, nb int32, current int32) int {\n if na == 0 && nb == 0 {\n return 0;\n }\n\n var r0 int = 1000;\n var r1 int = 1000;\n var r2 int = 1000;\n\n if 0 < na && a <= current {\n r0 = Solve(na - 1, nb, current - a);\n }\n if 0 < nb && b <= current {\n r1 = Solve(na, nb - 1, current - b);\n }\n if current < a && current < b {\n r2 = 1 + Solve(na, nb, n);\n }\n result := r0\n if r1 < result {\n result = r1\n }\n if r2 < result {\n result = r2\n }\n\n return result\n}\n\nfunc main() {\n ReadData();\n fmt.Println(Solve(4, 2, 0));\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar n int32\nvar a int32\nvar b int32\n\nfunc ReadData() {\n fmt.Scanf(\"%d\", &n);\n fmt.Scanf(\"%d\", &a);\n fmt.Scanf(\"%d\", &b);\n}\n\nfunc Solve(na int32, nb int32, current int32) int {\n if na == 0 && nb == 0 {\n return 0;\n }\n\n var r0 int = 1000;\n var r1 int = 1000;\n var r2 int = 1000;\n\n if 0 < na && a <= current {\n r0 = Solve(na - 1, nb, current - a);\n }\n if 0 < nb && b <= current {\n r1 = Solve(na, nb - 1, current - b);\n }\n if n != current {\n r2 = 1 + Solve(na, nb, n);\n }\n result := r0\n if r1 < result {\n result = r1\n }\n if r2 < result {\n result = r2\n }\n\n return result\n}\n\nfunc main() {\n ReadData();\n fmt.Println(Solve(4, 2, 0));\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar n int32\nvar a int32\nvar b int32\n\nfunc ReadData() {\n fmt.Scanf(\"%d\", &n);\n fmt.Scanf(\"%d\", &a);\n fmt.Scanf(\"%d\", &b);\n}\n\nfunc Solve(na int32, nb int32, current int32) int {\n if na == 0 && nb == 0 {\n return 0;\n }\n\n var result int = 1000;\n var r0 int = 1000;\n var r1 int = 1000;\n var r2 int = 1000;\n\n if 0 < na && a <= current {\n r0 = Solve(na - 1, nb, current - a);\n }\n if 0 < nb && b <= current {\n r1 = Solve(na, nb - 1, current - b);\n }\n if n != current {\n r2 = 1 + Solve(na, nb, n);\n }\n result = r0\n if r1 < r0 {\n result = r1\n }\n if r2 < result {\n result = r2\n }\n\n return result\n}\n\nfunc main() {\n ReadData();\n fmt.Println(1 + Solve(4, 2, n));\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar n int32\nvar a int32\nvar b int32\n\nfunc ReadData() {\n fmt.Scanf(\"%d\", &n);\n fmt.Scanf(\"%d\", &a);\n fmt.Scanf(\"%d\", &b);\n}\n\nfunc Solve(na int32, nb int32, current int32, dbg bool) int {\n if na == 0 && nb == 0 {\n return 0;\n }\n\n var r0 int = 10000;\n var r1 int = 10000;\n var r2 int = 10000;\n var mode int = 4;\n\n if 0 < na && a <= current {\n r0 = Solve(na - 1, nb, current - a, false);\n }\n if 0 < nb && b <= current {\n r1 = Solve(na, nb - 1, current - b, false);\n }\n if current != n {\n r2 = 1 + Solve(na, nb, n, false);\n }\n\n result := r0\n mode = 0\n if r1 < result {\n result = r1\n mode = 1\n }\n if r2 < result {\n result = r2\n mode = 2\n }\n\n if dbg {\n if mode == 0 {\n Solve(na - 1, nb, current - a, true);\n } else if mode == 1 {\n Solve(na, nb - 1, current - b, true);\n } else if mode == 2 {\n r2 = 1 + Solve(na, nb, n, true);\n }\n fmt.Println(\"na: \", na, \" nb: \", nb, \" current: \", current, \" result: \", result, \" mode: \", mode)\n }\n return result\n}\n\nfunc main() {\n ReadData();\n fmt.Println(Solve(4, 2, 0, false));\n}\n"}], "src_uid": "1a50fe39e18f86adac790093e195979a"} {"nl": {"description": "Arpa is researching the Mexican wave.There are n spectators in the stadium, labeled from 1 to n. They start the Mexican wave at time 0. At time 1, the first spectator stands. At time 2, the second spectator stands. ... At time k, the k-th spectator stands. At time k + 1, the (k + 1)-th spectator stands and the first spectator sits. At time k + 2, the (k + 2)-th spectator stands and the second spectator sits. ... At time n, the n-th spectator stands and the (n - k)-th spectator sits. At time n + 1, the (n + 1 - k)-th spectator sits. ... At time n + k, the n-th spectator sits. Arpa wants to know how many spectators are standing at time t.", "input_spec": "The first line contains three integers n, k, t (1 ≤ n ≤ 109, 1 ≤ k ≤ n, 1 ≤ t < n + k).", "output_spec": "Print single integer: how many spectators are standing at time t.", "sample_inputs": ["10 5 3", "10 5 7", "10 5 12"], "sample_outputs": ["3", "5", "3"], "notes": "NoteIn the following a sitting spectator is represented as -, a standing spectator is represented as ^. At t = 0  ---------- number of standing spectators = 0. At t = 1  ^--------- number of standing spectators = 1. At t = 2  ^^-------- number of standing spectators = 2. At t = 3  ^^^------- number of standing spectators = 3. At t = 4  ^^^^------ number of standing spectators = 4. At t = 5  ^^^^^----- number of standing spectators = 5. At t = 6  -^^^^^---- number of standing spectators = 5. At t = 7  --^^^^^--- number of standing spectators = 5. At t = 8  ---^^^^^-- number of standing spectators = 5. At t = 9  ----^^^^^- number of standing spectators = 5. At t = 10 -----^^^^^ number of standing spectators = 5. At t = 11 ------^^^^ number of standing spectators = 4. At t = 12 -------^^^ number of standing spectators = 3. At t = 13 --------^^ number of standing spectators = 2. At t = 14 ---------^ number of standing spectators = 1. At t = 15 ---------- number of standing spectators = 0. "}, "positive_code": [{"source_code": "// Codeforces helper functions\n// 20 Jan 18\n// samadhi\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n\t\"unicode\"\n)\n\nconst debug = true\n\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\n\tin := gsli(reader)\n\n\tn := in[0]\n\tk := in[1]\n\tt := in[2]\n\n\tans := 0\n\tif t <= k {\n\t\tans = t\n\t} else if t <= n {\n\t\tans = k\n\t} else {\n\t\tans = k + n - t\n\t}\n\n\tfmt.Println(ans)\n\n}\n\n// Input helpers\n\n// If you don't pass in a reference to the reader, and just instantiate a new\n// one every time, it will work locally, with IO typed at human-speed, but not\n// on Codeforces.\n\n// Get Space-separated Line as Strings\n//\n// Example input:\n// 1 test 382.0\n// Example output:\n// [\"1\", \"test\", \"382.0\"]\n\nfunc gsls(reader *bufio.Reader) (arr []string) {\n\t// Get a full line\n\tinput, _ := reader.ReadString('\\n')\n\n\t//Strip newline and return chars, if any\n\tinput = strings.TrimSuffix(input, \"\\n\")\n\tinput = strings.TrimSuffix(input, \"\\r\")\n\n\t// Split at the spaces into an array\n\tarr = strings.Split(input, \" \")\n\n\treturn\n}\n\n// Get Space-separated Line as Integers\n// Any non-valid integers will be 0\n//\n// Example input:\n// test 1 12.3 -117\n// Example output:\n// [0, 1, 0, -117]\n\nfunc gsli(reader *bufio.Reader) (arr []int) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.Atoi(e)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// Get Space-separated Line as 64-bit Floats\n// Any non-valid floats will be 0\n//\n// Example input:\n// test 128.328 12 -11.0\n// Example output:\n// [0, 128.328, 12, -11]\n\nfunc gslf(reader *bufio.Reader) (arr []float64) {\n\tstringArr := gsls(reader)\n\n\tfor _, e := range stringArr {\n\t\tcur, _ := strconv.ParseFloat(e, 64)\n\t\tarr = append(arr, cur)\n\t}\n\n\treturn\n}\n\n// String helpers\n\n// Is Lowercase\n// Given some string[i], return whether it is lower case or not.\n\nfunc isl(b byte) bool {\n\tvar r rune\n\tr = rune(b)\n\treturn unicode.IsLower(r)\n}\n\n// Math helpers\n\n// Positve Modulo\n// Returns x mod y, but always positive\n\nfunc posMod(x, y int) int {\n\treturn (x%y + y) % y\n}\n\n// Max Int\n// Returns the max of two ints\n\nfunc maxInt(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}\n\n// Distance formule\n// Calculates the distance to the origin\n\nfunc dist(x, y float64) float64 {\n\treturn math.Sqrt(math.Pow(x, 2) + math.Pow(y, 2))\n}\n\n// Output helpers\n\nfunc yes() {\n\tfmt.Println(\"Yes\")\n}\n\nfunc no() {\n\tfmt.Println(\"No\")\n}\n\n// Debug helpers\n\n// From https://groups.google.com/forum/#!topic/golang-nuts/Qlxs3V77nss\n\nfunc dbg(s string, a ...interface{}) {\n\tif debug {\n\t\tfmt.Printf(s, a...)\n\t}\n}\n"}, {"source_code": "package main\n\nimport (\n \"fmt\"\n)\n\nvar (\n n int\n k int\n t int\n)\n\nfunc main() {\n fmt.Scanf(\"%d %d %d\\n\", &n, &k, &t)\n if t <= k {\n fmt.Println(t)\n } else if t >= n {\n fmt.Println(n + k - t)\n } else {\n fmt.Println(k)\n }\n}"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main(){\n\tvar n,k,t int\n\tfmt.Scanf(\"%d %d %d\",&n,&k,&t)\n\tif t<=k{\n\t\tfmt.Println(t)\n\t} else{\n\t\tif t<=n {\n\t\t\tfmt.Println(k)\n\t\t}else {\n\t\t\tfmt.Println(k-(t-n))\n\t\t}\n\t}\n}\n"}, {"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tl := []int{0, 0, 0}\n\tfmt.Scan(&l[0], &l[1], &l[2])\n\tr := l[0] + l[1] - l[2]\n\tfor _, x := range l {\n\t\tif r > x {\n\t\t\tr = x\n\t\t}\n\t}\n\tfmt.Println(r)\n}\n"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar n, k, t int\n\tfmt.Scan(&n, &k, &t)\n\tif n < t {\n\t\tn += k - t\n\t}\n\tif n > k {\n\t\tn = k\n\t}\n\tfmt.Println(n)\n}\n"}], "src_uid": "7e614526109a2052bfe7934381e7f6c2"} {"nl": {"description": "A monster is chasing after Rick and Morty on another planet. They're so frightened that sometimes they scream. More accurately, Rick screams at times b, b + a, b + 2a, b + 3a, ... and Morty screams at times d, d + c, d + 2c, d + 3c, .... The Monster will catch them if at any point they scream at the same time, so it wants to know when it will catch them (the first time they scream at the same time) or that they will never scream at the same time.", "input_spec": "The first line of input contains two integers a and b (1 ≤ a, b ≤ 100). The second line contains two integers c and d (1 ≤ c, d ≤ 100).", "output_spec": "Print the first time Rick and Morty will scream at the same time, or  - 1 if they will never scream at the same time.", "sample_inputs": ["20 2\n9 19", "2 1\n16 12"], "sample_outputs": ["82", "-1"], "notes": "NoteIn the first sample testcase, Rick's 5th scream and Morty's 8th time are at time 82. In the second sample testcase, all Rick's screams will be at odd times and Morty's will be at even times, so they will never scream at the same time."}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, c, d int\n\tif _, err := fmt.Scanf(\"%d %d\\n%d %d\\n\", &a, &b, &c, &d); err != nil {\n\t\treturn\n\t}\n\n\toffset := make(map[int]bool)\n\n\tfor i := 0; ; i++ {\n\t\tt := i*a + b\n\t\tif t-d >= 0 {\n\t\t\tif (t-d)%c == 0 {\n\t\t\t\tfmt.Println(t)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tl := (t - d) / c\n\t\t\toff := t - (l*c + d)\n\t\t\tif offset[off] {\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\toffset[off] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(-1)\n}\n"}, {"source_code": "/*\nURL:\nhttps://codeforces.com/problemset/problem/787/A\n*/\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/********** FAU standard libraries **********/\n\n//fmt.Sprintf(\"%b\\n\", 255) \t// binary expression\n\n/********** I/O usage **********/\n\n//str := ReadString()\n//i := ReadInt()\n//X := ReadIntSlice(n)\n//S := ReadRuneSlice()\n//a := ReadFloat64()\n//A := ReadFloat64Slice(n)\n\n//str := ZeroPaddingRuneSlice(num, 32)\n//str := PrintIntsLine(X...)\n\n/*******************************************************************/\n\nconst (\n\t// General purpose\n\tMOD = 1000000000 + 7\n\tALPHABET_NUM = 26\n\tINF_INT64 = math.MaxInt64\n\tINF_BIT60 = 1 << 60\n\tINF_INT32 = math.MaxInt32\n\tINF_BIT30 = 1 << 30\n\tNIL = -1\n\n\t// for dijkstra, prim, and so on\n\tWHITE = 0\n\tGRAY = 1\n\tBLACK = 2\n)\n\nfunc init() {\n\t// bufio.ScanWords <---> bufio.ScanLines\n\tReadString = newReadString(os.Stdin, bufio.ScanWords)\n\tstdout = bufio.NewWriter(os.Stdout)\n}\n\nvar (\n\ta, b, c, d int\n)\n\nfunc main() {\n\ta, b, c, d = ReadInt4()\n\n\tfor i := 0; i <= 3000; i++ {\n\t\tfor j := 0; j <= 3000; j++ {\n\t\t\tif b+i*a == d+j*c {\n\t\t\t\tfmt.Println(b + i*a)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(-1)\n}\n\n/*******************************************************************/\n\n/*********** I/O ***********/\n\nvar (\n\t// ReadString returns a WORD string.\n\tReadString func() string\n\tstdout *bufio.Writer\n)\n\nfunc newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {\n\tr := bufio.NewScanner(ior)\n\tr.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces\n\tr.Split(sf)\n\n\treturn func() string {\n\t\tif !r.Scan() {\n\t\t\tpanic(\"Scan failed\")\n\t\t}\n\t\treturn r.Text()\n\t}\n}\n\n// ReadInt returns an integer.\nfunc ReadInt() int {\n\treturn int(readInt64())\n}\nfunc ReadInt2() (int, int) {\n\treturn int(readInt64()), int(readInt64())\n}\nfunc ReadInt3() (int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64())\n}\nfunc ReadInt4() (int, int, int, int) {\n\treturn int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())\n}\n\n// ReadInt64 returns as integer as int64.\nfunc ReadInt64() int64 {\n\treturn readInt64()\n}\nfunc ReadInt64_2() (int64, int64) {\n\treturn readInt64(), readInt64()\n}\nfunc ReadInt64_3() (int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64()\n}\nfunc ReadInt64_4() (int64, int64, int64, int64) {\n\treturn readInt64(), readInt64(), readInt64(), readInt64()\n}\n\nfunc readInt64() int64 {\n\ti, err := strconv.ParseInt(ReadString(), 0, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn i\n}\n\n// ReadIntSlice returns an integer slice that has n integers.\nfunc ReadIntSlice(n int) []int {\n\tb := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt()\n\t}\n\treturn b\n}\n\n// ReadInt64Slice returns as int64 slice that has n integers.\nfunc ReadInt64Slice(n int) []int64 {\n\tb := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadInt64()\n\t}\n\treturn b\n}\n\n// ReadFloat64 returns an float64.\nfunc ReadFloat64() float64 {\n\treturn float64(readFloat64())\n}\n\nfunc readFloat64() float64 {\n\tf, err := strconv.ParseFloat(ReadString(), 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn f\n}\n\n// ReadFloatSlice returns an float64 slice that has n float64.\nfunc ReadFloat64Slice(n int) []float64 {\n\tb := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tb[i] = ReadFloat64()\n\t}\n\treturn b\n}\n\n// ReadRuneSlice returns a rune slice.\nfunc ReadRuneSlice() []rune {\n\treturn []rune(ReadString())\n}\n\n/*********** Debugging ***********/\n\n// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.\n// For debugging use.\nfunc ZeroPaddingRuneSlice(n, digitsNum int) []rune {\n\tsn := fmt.Sprintf(\"%b\", n)\n\n\tresidualLength := digitsNum - len(sn)\n\tif residualLength <= 0 {\n\t\treturn []rune(sn)\n\t}\n\n\tzeros := make([]rune, residualLength)\n\tfor i := 0; i < len(zeros); i++ {\n\t\tzeros[i] = '0'\n\t}\n\n\tres := []rune{}\n\tres = append(res, zeros...)\n\tres = append(res, []rune(sn)...)\n\n\treturn res\n}\n\n// Strtoi is a wrapper of strconv.Atoi().\n// If strconv.Atoi() returns an error, Strtoi calls panic.\nfunc Strtoi(s string) int {\n\tif i, err := strconv.Atoi(s); err != nil {\n\t\tpanic(errors.New(\"[argument error]: Strtoi only accepts integer string\"))\n\t} else {\n\t\treturn i\n\t}\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintIntsLine(A ...int) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.Itoa(A[i])\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintIntsLine returns integers string delimited by a space.\nfunc PrintInts64Line(A ...int64) string {\n\tres := []rune{}\n\n\tfor i := 0; i < len(A); i++ {\n\t\tstr := strconv.FormatInt(A[i], 10) // 64bit int version\n\t\tres = append(res, []rune(str)...)\n\n\t\tif i != len(A)-1 {\n\t\t\tres = append(res, ' ')\n\t\t}\n\t}\n\n\treturn string(res)\n}\n\n// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)\nfunc PrintfDebug(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n}\n\n// PrintfBufStdout is function for output strings to buffered os.Stdout.\n// You may have to call stdout.Flush() finally.\nfunc PrintfBufStdout(format string, a ...interface{}) {\n\tfmt.Fprintf(stdout, format, a...)\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strconv\"\n)\n\nfunc solve() {\n\ta := readInt()\n\tb := readInt()\n\tc := readInt()\n\td := readInt()\n\tfor i := 0; i < 100000; i++ {\n\t\tif i >= b && i >= d {\n\t\t\tif (i-b)%a == 0 && (i-d)%c == 0 {\n\t\t\t\tfmt.Println(i)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(-1)\n}\n\nvar scanner *bufio.Scanner\n\nfunc main() {\n\tscanner = bufio.NewScanner(os.Stdin)\n\tconst MaxTokenLength = 1024 * 1024\n\tscanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)\n\tscanner.Split(bufio.ScanWords)\n\tsolve()\n}\n\nfunc min(a int, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\n// IO\n\nfunc readString() string {\n\tscanner.Scan()\n\treturn scanner.Text()\n}\n\nfunc readInt() int {\n\tval, _ := strconv.Atoi(readString())\n\treturn val\n}\n\nfunc readInt64() int64 {\n\tv, _ := strconv.ParseInt(readString(), 10, 64)\n\treturn v\n}\n\nfunc readIntArray(sz int) []int {\n\ta := make([]int, sz)\n\tfor i := 0; i < sz; i++ {\n\t\ta[i] = readInt()\n\t}\n\treturn a\n}\n\nfunc readInt64Array(n int) []int64 {\n\tres := make([]int64, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = readInt64()\n\t}\n\treturn res\n}\n"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar a, b, c, d, i int\n\tvar arr1, arr2 []int\n\tvar flag bool\n\tfmt.Scanf(\"%d %d\\n%d %d\", &a, &b, &c, &d)\n\tfor i != 6000 {\n\t\tarr1 = append(arr1, b+(i*a))\n\t\tarr2 = append(arr2, d+(i*c))\n\t\ti++\n\t}\n\tfor i := range arr1 {\n\t\tfor j := range arr2 {\n\t\t\tif arr1[i] == arr2[j] {\n\t\t\t\tfmt.Println(arr1[i])\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\tbreak\n\t\t}\n\t}\n\tif !flag {\n\t\tfmt.Println(\"-1\")\n\t}\n}"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar i, tmp int\n\tvar arr1, arr2 []int\n\tvar arr3 [4]int\n\tvar flag bool\n\treader := bufio.NewReader(os.Stdin)\n\twriter := bufio.NewWriter(os.Stdout)\n\tline, _ := reader.ReadString('\\n')\n\tarrS := strings.Split(strings.TrimSpace(line), \" \")\n\tfor i := range arrS {\n\t\ttmp, _ = strconv.Atoi(arrS[i])\n\t\tarr3[i] = tmp\n\t}\n\tline, _ = reader.ReadString('\\n')\n\tarrS = strings.Split(strings.TrimSpace(line), \" \")\n\tfor i := range arrS {\n\t\ttmp, _ = strconv.Atoi(arrS[i])\n\t\tarr3[i+2] = tmp\n\t}\n\ti = 0\n\tfor i != 6000 {\n\t\tarr1 = append(arr1, arr3[1]+(i*arr3[0]))\n\t\tarr2 = append(arr2, arr3[3]+(i*arr3[2]))\n\t\ti++\n\t}\n\ti = 0\n\tfor j := range arr1 {\n\t\tx := arr1[j]\n\t\ti := sort.Search(len(arr2), func(i int) bool { return arr2[i] >= x })\n\t\tif i < len(arr2) && arr2[i] == x {\n\t\t\twriter.WriteString(strconv.Itoa(x))\n\t\t\tflag = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif !flag {\n\t\twriter.WriteString(\"-1\")\n\t}\n\twriter.Flush()\n}"}, {"source_code": "package main \nimport .\"fmt\"\n\nfunc main(){\n var a , b , c , d int \n Scanf(\"%d%d\\n\" , &a , &b)\n Scanf(\"%d%d\" , &c , &d)\n mapper := make([]int , 1e6+5)\n for i:=b; i<= 1e6; i+=a{\n mapper[i] += 1\n }\n ans := -1\n for i:=d; i<= 1e6; i+=c{\n mapper[i] += 1\n if mapper[i] == 2{\n ans = i\n break\n }\n }\n Printf(\"%d\" , ans) \n}"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"os\"\n\n\nfunc main(){\n\tvar a , b , c , d int\n\tfmt.Scanf(\"%d%d\\n\" , &a , &b)\n\tfmt.Scanf(\"%d%d\" , &c , &d)\n\tfor i:=0 ; i<=110 ; i++ {\n\t\tif (b+i*a-d) % c == 0 && b+i*a-d >= 0 {\n\t\t\tfmt.Printf(\"%d\\n\" ,b+i*a)\n\t\t\tos.Exit(0)\n\t\t}\n\t}\n\tfmt.Printf(\"-1\\n\")\n}"}], "negative_code": [{"source_code": "package main\n\nimport \"fmt\"\nimport \"os\"\n\n\nfunc main(){\n\tvar a , b , c , d int\n\tfmt.Scanf(\"%d%d%d%d\" , a , b , c , d)\n\tif b == d {\n\t\tfmt.Printf(\"%d\\n\", d)\n\t\tos.Exit(0)\n\t}\n\tfor i:=0 ; i<=110 ; i++ {\n\t\tif (b+i*a-d) % c == 0 {\n\t\t\tfmt.Printf(\"%d\\n\" ,b+i*a)\n\t\t\tos.Exit(0)\n\t\t}\n\t}\n\tfmt.Printf(\"-1\\n\")\n}"}, {"source_code": "package main\n\nimport \"fmt\"\nimport \"os\"\n\n\nfunc main(){\n\tvar a , b , c , d int\n\tfmt.Scanf(\"%d%d\\n\" , &a , &b)\n\tfmt.Scanf(\"%d%d\" , &c , &d)\n\tfor i:=0 ; i<=110 ; i++ {\n\t\tif (b+i*a-d) % c == 0 {\n\t\t\tfmt.Printf(\"%d\\n\" ,b+i*a)\n\t\t\tos.Exit(0)\n\t\t}\n\t}\n\tfmt.Printf(\"-1\\n\")\n}"}], "src_uid": "158cb12d45f4ee3368b94b2b622693e7"} {"nl": {"description": "Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal.Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points.", "input_spec": "The input consists of three lines, each containing a pair of integer coordinates xi and yi ( - 1000 ≤ xi, yi ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide.", "output_spec": "First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices. Then print k lines, each containing a pair of integer — possible coordinates of the fourth point.", "sample_inputs": ["0 0\n1 0\n0 1"], "sample_outputs": ["3\n1 -1\n-1 1\n1 1"], "notes": "NoteIf you need clarification of what parallelogram is, please check Wikipedia page:https://en.wikipedia.org/wiki/Parallelogram"}, "positive_code": [{"source_code": "package main\n\nimport (\n\t\"strconv\"\n\t\"bufio\"\n\t\"os\"\n\t\"fmt\"\n)\n\nfunc main() {\n\ttype Tuple struct {\n\t\tx int\n\t\ty int\n\t}\n\tsc := NewScanner()\n\tX := make([]int, 3)\n\tY := make([]int, 3)\n\n\tfor i := 0; i < 3; i++ {\n\t\tX[i], Y[i] = sc.NextInt(), sc.NextInt()\n\t}\n\tmp := map[Tuple]bool{}\n\tfor i := 0; i < 3; i++ {\n\t\tfor j := i + 1; j < 3; j++ {\n\t\t\tx := X[i] - X[j]\n\t\t\ty := Y[i] - Y[j]\n\n\t\t\tfor k := 0; k < 3; k++ {\n\t\t\t\tif k == i || k == j {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tmp[Tuple{X[k] + x, Y[k] + y}] = true\n\t\t\t\tmp[Tuple{X[k] - x, Y[k] - y}] = true\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(len(mp))\n\tfor k, _ := range mp {\n\t\tfmt.Println(k.x, k.y)\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"}, {"source_code": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc I(i interface{}, delim string) error {\n\t_, err := fmt.Fscanf(r, \"%v\"+delim, i)\n\treturn err\n}\n\nfunc O(o interface{}, delim string) {\n\tfmt.Fprintf(w, \"%v\"+delim, o)\n}\n\nvar (\n\tr *bufio.Reader\n\tw *bufio.Writer\n)\n\nfunc main() {\n\tif f, err := os.Open(\"in.txt\"); err == nil {\n\t\tr = bufio.NewReader(f)\n\t} else {\n\t\tr = bufio.NewReader(os.Stdin)\n\t}\n\tw = bufio.NewWriter(os.Stdout)\n\tdefer w.Flush()\n\tvar x1 int\n\tfor I(&x1, \" \") == nil {\n\t\tsolve(x1)\n\t}\n}\nfunc solve(x1 int) {\n\tvar y1, x2, y2, x3, y3 int\n\tI(&y1, \"\\n\")\n\tI(&x2, \" \")\n\tI(&y2, \"\\n\")\n\tI(&x3, \" \")\n\tI(&y3, \"\\n\")\n\tO(3, \"\\n\")\n\tO(x1+x2-x3, \" \")\n\tO(y1+y2-y3, \"\\n\")\n\tO(x1-x2+x3, \" \")\n\tO(y1-y2+y3, \"\\n\")\n\tO(-x1+x2+x3, \" \")\n\tO(-y1+y2+y3, \"\\n\")\n}"}, {"source_code": "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\tvar xy [3][2]int\n\n\tfor i := 0; i < 3; i++ {\n\t\tif _, err := fmt.Scanf(\"%d %d\\n\", &xy[i][0], &xy[i][1]); err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\n\tfmt.Println(3)\n\tfor i := 0; i < 3; i++ {\n\t\tvar c, o [2]int\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tif j != i {\n\t\t\t\tfor k := 0; k < 2; k++ {\n\t\t\t\t\tc[k] += xy[j][k]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor k := 0; k < 2; k++ {\n\t\t\to[k] = c[k] - xy[i][k]\n\t\t}\n\n\t\tfmt.Println(o[0], o[1])\n\t}\n}\n"}, {"source_code": "// Codeforces 749 B training\n// int - 32 bit type !!!!\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\t\"strconv\"\n)\nvar in *bufio.Reader\n\nfunc readFive() (int,int,int,int,int) {\n var a [5]int\n\ts, err := in.ReadString('\\n')\n\tif err != nil {\n\t\tfmt.Println(\"first read failure\", err)\n\t\tpanic(err)\n\t}\n\tss := strings.Split(strings.Trim(s, \" \\n\\r\"), \" \")\n for i:=0; i