diff --git a/index.html b/index.html index 2289a67..d1038c9 100644 --- a/index.html +++ b/index.html @@ -9,6 +9,6 @@ body[data-md-color-scheme="slate"] .gdesc-inner { background: var(--md-default-bg-color);} body[data-md-color-scheme="slate"] .gslide-title { color: var(--md-default-fg-color);} body[data-md-color-scheme="slate"] .gslide-desc { color: var(--md-default-fg-color);} -
Skip to content

Logo

Kattis

Summary by Difficulty

as of 2023-11-22

{ "data": { "values": [ {"Difficulty": "Easy", "Count": 440}, {"Difficulty": "Medium", "Count": 29}, {"Difficulty": "Hard", "Count": 1} ] }, "mark": {"type": "bar", "tooltip": true}, "encoding": { "x": {"field": "Difficulty", "type": "nominal", "axis": {"labelAngle": 0}, "sort": "-y"}, "y": {"field": "Count", "type": "quantitative"}, "color": {"field": "Difficulty", "legend": null} } }

Summary by Initial

{ "data": { "values": [ {"Initial": "S", "Count": 60}, {"Initial": "C", "Count": 39}, {"Initial": "P", "Count": 35}, {"Initial": "A", "Count": 35}, {"Initial": "T", "Count": 33}, {"Initial": "B", "Count": 31}, {"Initial": "M", "Count": 26}, {"Initial": "E", "Count": 21}, {"Initial": "H", "Count": 21}, {"Initial": "F", "Count": 19}, {"Initial": "R", "Count": 18}, {"Initial": "D", "Count": 18}, {"Initial": "G", "Count": 15}, {"Initial": "L", "Count": 12}, {"Initial": "V", "Count": 10}, {"Initial": "O", "Count": 10}, {"Initial": "I", "Count": 10}, {"Initial": "W", "Count": 9}, {"Initial": "K", "Count": 9}, {"Initial": "J", "Count": 9}, {"Initial": "N", "Count": 6}, {"Initial": "U", "Count": 6}, {"Initial": "Q", "Count": 5}, {"Initial": "Z", "Count": 2}, {"Initial": "1", "Count": 2}, {"Initial": "Y", "Count": 2}, {"Initial": "Á", "Count": 1}, {"Initial": "Ó", "Count": 1}, {"Initial": "3", "Count": 1}, {"Initial": "Ú", "Count": 1}, {"Initial": "Ö", "Count": 1}, {"Initial": "4", "Count": 1}, {"Initial": "9", "Count": 1} ] }, "mark": {"type": "bar", "tooltip": true}, "encoding": { "x": {"field": "Initial", "type": "nominal", "axis": {"labelAngle": 0}, "sort": "-y"}, "y": {"field": "Count", "type": "quantitative"}, "color": {"field": "Initial", "legend": null} } }

Summary by Language

{ "data": { "values": [ {"Language": "Python", "Count": 467}, {"Language": "Go", "Count": 42}, {"Language": "Java", "Count": 28}, {"Language": "C++", "Count": 22}, {"Language": "Lua", "Count": 18}, {"Language": "JavaScript", "Count": 10}, {"Language": "Haskell", "Count": 4}, {"Language": "Ruby", "Count": 4}, {"Language": "Kotlin", "Count": 4}, {"Language": "Rust", "Count": 3}, {"Language": "Julia", "Count": 2} ] }, "mark": {"type": "bar", "tooltip": true}, "encoding": { "x": {"field": "Language", "type": "nominal", "axis": {"labelAngle": 0}, "sort": "-y"}, "y": {"field": "Count", "type": "quantitative"}, "color": {"field": "Language", "legend": null} } }


Thanks to all 5 contributors.


Last update: 2023-11-17
Created: 2022-12-05
Skip to content

Logo

Kattis

Summary by Difficulty

as of 2023-11-22

{ "data": { "values": [ {"Difficulty": "Easy", "Count": 440}, {"Difficulty": "Medium", "Count": 29}, {"Difficulty": "Hard", "Count": 1} ] }, "mark": {"type": "bar", "tooltip": true}, "encoding": { "x": {"field": "Difficulty", "type": "nominal", "axis": {"labelAngle": 0}, "sort": "-y"}, "y": {"field": "Count", "type": "quantitative"}, "color": {"field": "Difficulty", "legend": null} } }

Summary by Initial

{ "data": { "values": [ {"Initial": "S", "Count": 60}, {"Initial": "C", "Count": 39}, {"Initial": "P", "Count": 35}, {"Initial": "A", "Count": 35}, {"Initial": "T", "Count": 33}, {"Initial": "B", "Count": 31}, {"Initial": "M", "Count": 26}, {"Initial": "E", "Count": 21}, {"Initial": "H", "Count": 21}, {"Initial": "F", "Count": 19}, {"Initial": "R", "Count": 18}, {"Initial": "D", "Count": 18}, {"Initial": "G", "Count": 15}, {"Initial": "L", "Count": 12}, {"Initial": "V", "Count": 10}, {"Initial": "O", "Count": 10}, {"Initial": "I", "Count": 10}, {"Initial": "W", "Count": 9}, {"Initial": "K", "Count": 9}, {"Initial": "J", "Count": 9}, {"Initial": "N", "Count": 6}, {"Initial": "U", "Count": 6}, {"Initial": "Q", "Count": 5}, {"Initial": "Z", "Count": 2}, {"Initial": "1", "Count": 2}, {"Initial": "Y", "Count": 2}, {"Initial": "Á", "Count": 1}, {"Initial": "Ó", "Count": 1}, {"Initial": "3", "Count": 1}, {"Initial": "Ú", "Count": 1}, {"Initial": "Ö", "Count": 1}, {"Initial": "4", "Count": 1}, {"Initial": "9", "Count": 1} ] }, "mark": {"type": "bar", "tooltip": true}, "encoding": { "x": {"field": "Initial", "type": "nominal", "axis": {"labelAngle": 0}, "sort": "-y"}, "y": {"field": "Count", "type": "quantitative"}, "color": {"field": "Initial", "legend": null} } }

Summary by Language

{ "data": { "values": [ {"Language": "Python", "Count": 467}, {"Language": "Go", "Count": 42}, {"Language": "Java", "Count": 28}, {"Language": "C++", "Count": 22}, {"Language": "Lua", "Count": 18}, {"Language": "JavaScript", "Count": 10}, {"Language": "Haskell", "Count": 4}, {"Language": "Ruby", "Count": 4}, {"Language": "Kotlin", "Count": 4}, {"Language": "Rust", "Count": 3}, {"Language": "Julia", "Count": 2} ] }, "mark": {"type": "bar", "tooltip": true}, "encoding": { "x": {"field": "Language", "type": "nominal", "axis": {"labelAngle": 0}, "sort": "-y"}, "y": {"field": "Count", "type": "quantitative"}, "color": {"field": "Language", "legend": null} } }


Thanks to all 6 contributors.


Last update: 2023-11-17
Created: 2022-12-05
\ No newline at end of file diff --git a/search/search_index.json b/search/search_index.json index e9ea238..1625cce 100644 --- a/search/search_index.json +++ b/search/search_index.json @@ -1 +1 @@ -{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Home","text":""},{"location":"#kattis","title":"Kattis","text":""},{"location":"#summary-by-difficulty","title":"Summary by Difficulty","text":"

as of 2023-11-22

{ \"data\": { \"values\": [ {\"Difficulty\": \"Easy\", \"Count\": 440}, {\"Difficulty\": \"Medium\", \"Count\": 29}, {\"Difficulty\": \"Hard\", \"Count\": 1} ] }, \"mark\": {\"type\": \"bar\", \"tooltip\": true}, \"encoding\": { \"x\": {\"field\": \"Difficulty\", \"type\": \"nominal\", \"axis\": {\"labelAngle\": 0}, \"sort\": \"-y\"}, \"y\": {\"field\": \"Count\", \"type\": \"quantitative\"}, \"color\": {\"field\": \"Difficulty\", \"legend\": null} } }

"},{"location":"#summary-by-initial","title":"Summary by Initial","text":"

{ \"data\": { \"values\": [ {\"Initial\": \"S\", \"Count\": 60}, {\"Initial\": \"C\", \"Count\": 39}, {\"Initial\": \"P\", \"Count\": 35}, {\"Initial\": \"A\", \"Count\": 35}, {\"Initial\": \"T\", \"Count\": 33}, {\"Initial\": \"B\", \"Count\": 31}, {\"Initial\": \"M\", \"Count\": 26}, {\"Initial\": \"E\", \"Count\": 21}, {\"Initial\": \"H\", \"Count\": 21}, {\"Initial\": \"F\", \"Count\": 19}, {\"Initial\": \"R\", \"Count\": 18}, {\"Initial\": \"D\", \"Count\": 18}, {\"Initial\": \"G\", \"Count\": 15}, {\"Initial\": \"L\", \"Count\": 12}, {\"Initial\": \"V\", \"Count\": 10}, {\"Initial\": \"O\", \"Count\": 10}, {\"Initial\": \"I\", \"Count\": 10}, {\"Initial\": \"W\", \"Count\": 9}, {\"Initial\": \"K\", \"Count\": 9}, {\"Initial\": \"J\", \"Count\": 9}, {\"Initial\": \"N\", \"Count\": 6}, {\"Initial\": \"U\", \"Count\": 6}, {\"Initial\": \"Q\", \"Count\": 5}, {\"Initial\": \"Z\", \"Count\": 2}, {\"Initial\": \"1\", \"Count\": 2}, {\"Initial\": \"Y\", \"Count\": 2}, {\"Initial\": \"\u00c1\", \"Count\": 1}, {\"Initial\": \"\u00d3\", \"Count\": 1}, {\"Initial\": \"3\", \"Count\": 1}, {\"Initial\": \"\u00da\", \"Count\": 1}, {\"Initial\": \"\u00d6\", \"Count\": 1}, {\"Initial\": \"4\", \"Count\": 1}, {\"Initial\": \"9\", \"Count\": 1} ] }, \"mark\": {\"type\": \"bar\", \"tooltip\": true}, \"encoding\": { \"x\": {\"field\": \"Initial\", \"type\": \"nominal\", \"axis\": {\"labelAngle\": 0}, \"sort\": \"-y\"}, \"y\": {\"field\": \"Count\", \"type\": \"quantitative\"}, \"color\": {\"field\": \"Initial\", \"legend\": null} } }

"},{"location":"#summary-by-language","title":"Summary by Language","text":"

{ \"data\": { \"values\": [ {\"Language\": \"Python\", \"Count\": 467}, {\"Language\": \"Go\", \"Count\": 42}, {\"Language\": \"Java\", \"Count\": 28}, {\"Language\": \"C++\", \"Count\": 22}, {\"Language\": \"Lua\", \"Count\": 18}, {\"Language\": \"JavaScript\", \"Count\": 10}, {\"Language\": \"Haskell\", \"Count\": 4}, {\"Language\": \"Ruby\", \"Count\": 4}, {\"Language\": \"Kotlin\", \"Count\": 4}, {\"Language\": \"Rust\", \"Count\": 3}, {\"Language\": \"Julia\", \"Count\": 2} ] }, \"mark\": {\"type\": \"bar\", \"tooltip\": true}, \"encoding\": { \"x\": {\"field\": \"Language\", \"type\": \"nominal\", \"axis\": {\"labelAngle\": 0}, \"sort\": \"-y\"}, \"y\": {\"field\": \"Count\", \"type\": \"quantitative\"}, \"color\": {\"field\": \"Language\", \"legend\": null} } }

Thanks to all 5 contributors.

"},{"location":"solutions/","title":"470 Solutions","text":""},{"location":"solutions/#10-kinds-of-people","title":"10 Kinds of People","text":"Solution in Python Python
# 22/25\n\n\nfrom copy import deepcopy\n\n\nrow, col = [int(d) for d in input().split()]\nm = []\nfor _ in range(row):\n    m.append([int(d) for d in input()])\n\ndirections = [[0, 1], [0, -1], [1, 0], [-1, 0]]\n\n\ndef reachable(m, r1, c1, r2, c2):\n    _m = deepcopy(m)\n\n    q = []\n    q.append((r1, c1))\n    kind = _m[r1][c1]\n\n    while len(q):\n        r, c = q.pop()\n        _m[r][c] = -1\n\n        if (r, c) == (r2, c2):\n            return True\n\n        for x, y in directions:\n            a = r + x\n            b = c + y\n            if a >= 0 and b >= 0 and a < row and b < col and _m[a][b] == kind:\n                q.append((a, b))\n\n    return False\n\n\nn = int(input())\nfor _ in range(n):\n    r1, c1, r2, c2 = [int(d) - 1 for d in input().split()]\n    if reachable(m, r1, c1, r2, c2):\n        print(\"decimal\" if m[r1][c1] else \"binary\")\n    else:\n        print(\"neither\")\n
"},{"location":"solutions/#1-d-frogger-easy","title":"1-D Frogger (Easy)","text":"Solutions in 2 languages C++Python
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int n, s, m, curspace, cnt = 0;\n    cin >> n >> s >> m;\n    int board[n];\n\n    for (int i = 0; i < n; i++)\n    {\n        int tmp;\n        cin >> tmp;\n        board[i] = tmp;\n    }\n    curspace = s - 1;\n\n    while (true)\n    {\n        if (curspace < 0)\n        {\n            cout << \"left\" << endl;\n            break;\n        }\n        else if (curspace > n - 1)\n        {\n            cout << \"right\" << endl;\n            break;\n        }\n        int temp = board[curspace];\n        if (temp == 999)\n        {\n            cout << \"cycle\" << endl;\n            break;\n        }\n        else if (temp == m)\n        {\n            cout << \"magic\" << endl;\n            break;\n        }\n        else\n        {\n            cnt += 1;\n            board[curspace] = 999;\n            curspace += temp;\n        }\n    }\n    cout << cnt << endl;\n}\n
n, s, m = [int(d) for d in input().split()]\nb = [int(d) for d in input().split()]\nvisited, hops = set(), 0\nwhile True:\n    if s in visited:\n        print(\"cycle\")\n        break\n    elif s < 1:\n        print(\"left\")\n        break\n    elif s > n:\n        print(\"right\")\n        break\n    elif b[s - 1] == m:\n        print(\"magic\")\n        break\n    else:\n        visited.add(s)\n        s += b[s - 1]\n        hops += 1\nprint(hops)\n
"},{"location":"solutions/#3d-printed-statues","title":"3D Printed Statues","text":"Solutions in 3 languages GoJavaPython
package main\n\nimport (\n    \"fmt\"\n    \"math\"\n)\n\nfunc main() {\n    var n int\n    fmt.Scan(&n)\n    d := 1.0\n    for math.Pow(2, d-1) < float64(n) {\n        d += 1\n    }\n    fmt.Println(d)\n}\n
import java.util.Scanner;\n\nclass ThreeDPrintedStatues {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int n = s.nextInt();\n        int d = 1;\n        while (Math.pow(2, d - 1) < n) {\n            d += 1;\n        }\n        System.out.println(d);\n    }\n}\n
n = int(input())\nd = 1\nwhile 2 ** (d - 1) < n:\n    d += 1\nprint(d)\n
"},{"location":"solutions/#4-thought","title":"4 thought","text":"Solution in Python Python
from itertools import product\n\nops = [\"+\", \"-\", \"*\", \"//\"]\n\nfor _ in range(int(input())):\n    s = int(input())\n    solved = False\n    for op1, op2, op3 in product(ops, ops, ops):\n        e = f\"4 {op1} 4 {op2} 4 {op3} 4\"\n        try:\n            ans = eval(e) == s\n        except:\n            ans = False\n        if ans:\n            print(f\"{e.replace('//','/')} = {s}\")\n            solved = True\n            break\n    if not solved:\n        print(\"no solution\")\n
"},{"location":"solutions/#99-problems","title":"99 Problems","text":"Solution in Python Python
import math\n\nn = int(input())\nceil = math.ceil(n / 100) * 100 - 1\nfloor = math.floor(n / 100) * 100 - 1\nif ceil == floor:\n    print(ceil)\nelse:\n    if abs(ceil - n) <= abs(n - floor) or floor < 0:\n        print(ceil)\n    else:\n        print(floor)\n
"},{"location":"solutions/#aaah","title":"Aaah!","text":"Solutions in 2 languages GoPython
package main\n\nimport (\n    \"fmt\"\n    \"strings\"\n)\n\nfunc main() {\n    var a, b string\n    fmt.Scan(&a)\n    fmt.Scan(&b)\n    if strings.Count(a, \"a\") >= strings.Count(b, \"a\") {\n        fmt.Println(\"go\")\n    } else {\n        fmt.Println(\"no\")\n    }\n}\n
a, b = input(), input()\nif a.count(\"a\") >= b.count(\"a\"):\n    print(\"go\")\nelse:\n    print(\"no\")\n
"},{"location":"solutions/#abc","title":"ABC","text":"Solution in Python Python
numbers = sorted([int(d) for d in input().split()])\norders = list(input())\norder_map = {\n    \"A\": 0,\n    \"B\": 1,\n    \"C\": 2,\n}\n\nprint(\" \".join([str(numbers[order_map[o]]) for o in orders]))\n
"},{"location":"solutions/#above-average","title":"Above Average","text":"Solution in Python Python
n = int(input())\nfor _ in range(n):\n    numbers = [int(d) for d in input().split()[1:]]\n    ave = sum(numbers) / len(numbers)\n    above_ave = [d > ave for d in numbers]\n    print(f\"{sum(above_ave)/len(numbers):.3%}\")\n
"},{"location":"solutions/#acm-contest-scoring","title":"ACM Contest Scoring","text":"Solution in Python Python
problems = {}\nsolved = set()\nwhile True:\n    line = input()\n    if line == \"-1\":\n        break\n    t, p, ans = line.split()\n    t = int(t)\n    if p in solved:\n        continue\n    if p not in problems:\n        problems[p] = [(t, ans)]\n    else:\n        problems[p].append((t, ans))\n    if ans == \"right\":\n        solved.add(p)\n\nscore = 0\nfor p in problems:\n    t, ans = problems[p][-1]\n    if ans == \"right\":\n        score += t + 20 * len(problems[p][:-1])\n\nprint(len(solved), score)\n
"},{"location":"solutions/#adding-trouble","title":"Adding Trouble","text":"Solution in Python Python
a, b, c = [int(v) for v in input().split()]\nif a + b == c:\n    print(\"correct!\")\nelse:\n    print(\"wrong!\")\n
"},{"location":"solutions/#adding-words","title":"Adding Words","text":"Solution in Python Python
name = {}\nvalue = {}\nop = [\"-\", \"+\"]\nwhile True:\n    try:\n        s = input().split()\n    except:\n        break\n\n    if s[0] == \"clear\":\n        name.clear()\n        value.clear()\n    elif s[0] == \"def\":\n        n, v = s[1:]\n        v = int(v)\n        if n in name:\n            value.pop(name[n])\n        name[n] = v\n        value[v] = n\n    elif s[0] == \"calc\":\n        try:\n            ans = eval(\"\".join([str(name[p]) if p not in op else p for p in s[1:-1]]))\n        except:\n            ans = \"unknown\"\n\n        ans = value.get(ans, \"unknown\")\n        print(\" \".join(s[1:] + [ans]))\n
"},{"location":"solutions/#add-two-numbers","title":"Add Two Numbers","text":"Solutions in 4 languages GoJavaJavaScriptPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var a, b int\n    fmt.Scan(&a)\n    fmt.Scan(&b)\n    fmt.Println(a + b)\n}\n
import java.util.Scanner;\n\nclass AddTwoNumbers {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int a = s.nextInt(), b = s.nextInt();\n        System.out.println(a + b);\n    }\n}\n
const readline = require(\"readline\");\nconst rl = readline.createInterface(process.stdin, process.stdout);\n\nrl.question(\"\", (line) => {\n  [a, b] = line\n    .trim()\n    .split(\" \")\n    .map((e) => parseInt(e));\n  console.log(a + b);\n});\n
line = input()\na, b = line.split()\na = int(a)\nb = int(b)\nprint(a + b)\n
"},{"location":"solutions/#akcija","title":"Akcija","text":"Solution in Python Python
n = int(input())\nc = [int(input()) for _ in range(n)]\n\nc = sorted(c, reverse=True)\ngroups = [c[i : i + 3] if i + 3 < n else c[i:] for i in range(0, n, 3)]\n\nprint(sum(sum(g if len(g) < 3 else g[:2]) for g in groups))\n
"},{"location":"solutions/#a-lei-i-bio","title":"\u00c1 lei\u00f0 \u00ed b\u00ed\u00f3","text":"Solutions in 4 languages C++GoJavaPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int a, b, c;\n    cin >> a >> b >> c;\n    cout << c - a - b << endl;\n    return 0;\n}\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var a, b, c int\n    fmt.Scan(&a)\n    fmt.Scan(&b)\n    fmt.Scan(&c)\n    fmt.Println(c - a - b)\n}\n
import java.util.Scanner;\n\nclass Aleidibio {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int a = s.nextInt();\n        int b = s.nextInt();\n        int c = s.nextInt();\n        System.out.println(c - a - b);\n    }\n}\n
a = int(input())\nb = int(input())\nc = int(input())\nprint(c - a - b)\n
"},{"location":"solutions/#alex-and-barb","title":"Alex and Barb","text":"Solution in Python Python
k, m, n = [int(d) for d in input().split()]\n\nprint(\"Barb\" if k % (m + n) < m else \"Alex\")\n
"},{"location":"solutions/#alphabet-spam","title":"Alphabet Spam","text":"Solution in Python Python
s = input()\ntotal = len(s)\nwhites = s.count(\"_\")\nlowers = len([c for c in s if ord(c) >= ord(\"a\") and ord(c) <= ord(\"z\")])\nuppers = len([c for c in s if ord(c) >= ord(\"A\") and ord(c) <= ord(\"Z\")])\nsymbols = total - whites - lowers - uppers\nprint(f\"{whites/total:.15f}\")\nprint(f\"{lowers/total:.15f}\")\nprint(f\"{uppers/total:.15f}\")\nprint(f\"{symbols/total:.15f}\")\n
"},{"location":"solutions/#ameriskur-vinnustaur","title":"Amer\u00edskur vinnusta\u00f0ur","text":"Solution in Python Python
print(int(input()) * 0.09144)\n
"},{"location":"solutions/#amsterdam-distance","title":"Amsterdam Distance","text":"Solution in Python Python
import math\n\nm, n, r = input().split()\nm = int(m)\nn = int(n)\nr = float(r)\ncoords = [int(d) for d in input().split()]\np = r / n\n\ndist1 = 0\ndist1 += p * abs(coords[1] - coords[3])\ndist1 += (\n    math.pi\n    * r\n    * ((min(coords[3], coords[1]) if coords[3] != coords[1] else coords[1]) / n)\n    * (abs(coords[0] - coords[2]) / m)\n)\n\ndist2 = p * abs(coords[1] + coords[3])\n\nprint(min(dist1, dist2))\n
"},{"location":"solutions/#a-new-alphabet","title":"A New Alphabet","text":"Solutions in 2 languages GoPython
package main\n\nimport (\n    \"bufio\"\n    \"fmt\"\n    \"os\"\n    \"strings\"\n)\n\nfunc main() {\n    mapping := map[string]string{\n        \"a\": \"@\",\n        \"b\": \"8\",\n        \"c\": \"(\",\n        \"d\": \"|)\",\n        \"e\": \"3\",\n        \"f\": \"#\",\n        \"g\": \"6\",\n        \"h\": \"[-]\",\n        \"i\": \"|\",\n        \"j\": \"_|\",\n        \"k\": \"|<\",\n        \"l\": \"1\",\n        \"m\": \"[]\\\\/[]\",\n        \"n\": \"[]\\\\[]\",\n        \"o\": \"0\",\n        \"p\": \"|D\",\n        \"q\": \"(,)\",\n        \"r\": \"|Z\",\n        \"s\": \"$\",\n        \"t\": \"']['\",\n        \"u\": \"|_|\",\n        \"v\": \"\\\\/\",\n        \"w\": \"\\\\/\\\\/\",\n        \"x\": \"}{\",\n        \"y\": \"`/\",\n        \"z\": \"2\",\n    }\n    scanner := bufio.NewScanner(os.Stdin)\n    scanner.Scan()\n    line := scanner.Text()\n    runes := []rune(strings.ToLower(line))\n    for i := 0; i < len(runes); i++ {\n        v, ok := mapping[string(runes[i])]\n        if ok {\n            fmt.Printf(v)\n        } else {\n            fmt.Printf(string(runes[i]))\n        }\n    }\n}\n
mapping = {\n    \"a\": \"@\",\n    \"b\": \"8\",\n    \"c\": \"(\",\n    \"d\": \"|)\",\n    \"e\": \"3\",\n    \"f\": \"#\",\n    \"g\": \"6\",\n    \"h\": \"[-]\",\n    \"i\": \"|\",\n    \"j\": \"_|\",\n    \"k\": \"|<\",\n    \"l\": \"1\",\n    \"m\": \"[]\\\\/[]\",\n    \"n\": \"[]\\\\[]\",\n    \"o\": \"0\",\n    \"p\": \"|D\",\n    \"q\": \"(,)\",\n    \"r\": \"|Z\",\n    \"s\": \"$\",\n    \"t\": \"']['\",\n    \"u\": \"|_|\",\n    \"v\": \"\\\\/\",\n    \"w\": \"\\\\/\\\\/\",\n    \"x\": \"}{\",\n    \"y\": \"`/\",\n    \"z\": \"2\",\n}\nprint(\"\".join([mapping.get(c, c) for c in input().lower()]))\n
"},{"location":"solutions/#another-brick-in-the-wall","title":"Another Brick in the Wall","text":"Solution in Python Python
h, w, n = [int(d) for d in input().split()]\nb = [int(d) for d in input().split()]\n\ni, tw, th, done = 0, 0, 0, False\nwhile i < n:\n    if tw + b[i] <= w:\n        tw += b[i]\n        if tw == w:\n            tw = 0\n            th += 1\n        if th == h and tw == 0:\n            done = True\n            break\n    else:\n        break\n    i += 1\n\nprint(\"YES\" if done else \"NO\")\n
"},{"location":"solutions/#another-candies","title":"Another Candies","text":"Solution in Python Python
for _ in range(int(input())):\n    _ = input()\n    n = int(input())\n    s = 0\n    for _ in range(n):\n        s += int(input())\n        if s > n:\n            s %= n\n    print(\"NO\" if s % n else \"YES\")\n
"},{"location":"solutions/#apaxiaaaaaaaaaaaans","title":"Apaxiaaaaaaaaaaaans!","text":"Solution in Python Python
name = input()\ncompact = \"\"\nfor s in name:\n    if not compact or s != compact[-1]:\n        compact += s\nprint(compact)\n
"},{"location":"solutions/#honour-thy-apaxian-parent","title":"Honour Thy (Apaxian) Parent","text":"Solution in Python Python
y, p = input().split()\nif y.endswith(\"e\"):\n    name = y + \"x\" + p\nelif y[-1] in \"aiou\":\n    name = y[:-1] + \"ex\" + p\nelif y.endswith(\"ex\"):\n    name = y + p\nelse:\n    name = y + \"ex\" + p\n\nprint(name)\n
"},{"location":"solutions/#a-real-challenge","title":"A Real Challenge","text":"Solutions in 3 languages GoJavaScriptPython
package main\n\nimport (\n    \"fmt\"\n    \"math\"\n)\n\nfunc main() {\n    var a int\n    fmt.Scan(&a)\n    fmt.Println(4 * math.Sqrt(float64(a)))\n}\n
const readline = require(\"readline\");\nconst rl = readline.createInterface(process.stdin, process.stdout);\n\nrl.question(\"\", (a) => {\n  console.log(4 * Math.sqrt(parseInt(a)));\n});\n
import math\n\ns = int(input())\nprint(4 * math.sqrt(s))\n
"},{"location":"solutions/#are-you-listening","title":"Are You Listening?","text":"Solution in Python Python
import math\n\ncx, cy, n = [int(d) for d in input().split()]\n\nd = []\nfor _ in range(n):\n    x, y, r = [int(d) for d in input().split()]\n    d.append(((x - cx) ** 2 + (y - cy) ** 2) ** 0.5 - r)\nv = sorted(d)[2]\nprint(math.floor(v) if v > 0 else 0)\n
"},{"location":"solutions/#arithmetic","title":"Arithmetic","text":"Solution in Python Python
import math\n\nmapping8 = {\n    \"0\": \"000\",\n    \"1\": \"001\",\n    \"2\": \"010\",\n    \"3\": \"011\",\n    \"4\": \"100\",\n    \"5\": \"101\",\n    \"6\": \"110\",\n    \"7\": \"111\",\n}\nmapping16 = {\n    \"0000\": \"0\",\n    \"0001\": \"1\",\n    \"0010\": \"2\",\n    \"0011\": \"3\",\n    \"0100\": \"4\",\n    \"0101\": \"5\",\n    \"0110\": \"6\",\n    \"0111\": \"7\",\n    \"1000\": \"8\",\n    \"1001\": \"9\",\n    \"1010\": \"A\",\n    \"1011\": \"B\",\n    \"1100\": \"C\",\n    \"1101\": \"D\",\n    \"1110\": \"E\",\n    \"1111\": \"F\",\n}\n\nb = \"\".join([mapping8[c] for c in input()])\nb = b.zfill(math.ceil(len(b) / 4) * 4)\nans = \"\".join([mapping16[b[i : i + 4]] for i in range(0, len(b), 4)])\nif ans != \"0\":\n    ans = ans.lstrip(\"0\")\nprint(ans)\n
"},{"location":"solutions/#arithmetic-functions","title":"Arithmetic Functions","text":"Solution in C++ C++
#include \"arithmeticfunctions.h\"\n\n// Compute x^3\nint cube(int x)\n{\n    return x * x * x;\n}\n\n// Compute the maximum of x and y\nint max(int x, int y)\n{\n    if (x > y)\n    {\n        return x;\n    }\n    else\n    {\n        return y;\n    }\n}\n\n// Compute x - y\nint difference(int x, int y)\n{\n    return x - y;\n}\n
"},{"location":"solutions/#army-strength-easy","title":"Army Strength (Easy)","text":"Solution in Python Python
t = int(input())\nfor _ in range(t):\n    input()\n    ng, nm = [int(d) for d in input().split()]\n    g = [int(d) for d in input().split()]\n    m = [int(d) for d in input().split()]\n    if max(m) > max(g):\n        print(\"MechaGodzilla\")\n    else:\n        print(\"Godzilla\")\n
"},{"location":"solutions/#army-strength-hard","title":"Army Strength (Hard)","text":"Solution in Python Python
t = int(input())\nfor _ in range(t):\n    input()\n    ng, nm = [int(d) for d in input().split()]\n    g = [int(d) for d in input().split()]\n    m = [int(d) for d in input().split()]\n    if max(m) > max(g):\n        print(\"MechaGodzilla\")\n    else:\n        print(\"Godzilla\")\n
"},{"location":"solutions/#ascii-kassi","title":"ASCII kassi","text":"Solution in Python Python
n = int(input())\nprint(f'+{\"-\"*n}+')\nfor _ in range(n):\n    print(f'|{\" \"*n}|')\nprint(f'+{\"-\"*n}+')\n
"},{"location":"solutions/#astrological-sign","title":"Astrological Sign","text":"Solution in Python Python
for _ in range(int(input())):\n    d, m = input().split()\n    d = int(d)\n    if (m == \"Mar\" and d >= 21) or (m == \"Apr\" and d <= 20):\n        print(\"Aries\")\n    elif (m == \"Apr\" and d >= 21) or (m == \"May\" and d <= 20):\n        print(\"Taurus\")\n    elif (m == \"May\" and d >= 21) or (m == \"Jun\" and d <= 21):\n        print(\"Gemini\")\n    elif (m == \"Jun\" and d >= 22) or (m == \"Jul\" and d <= 22):\n        print(\"Cancer\")\n    elif (m == \"Jul\" and d >= 23) or (m == \"Aug\" and d <= 22):\n        print(\"Leo\")\n    elif (m == \"Aug\" and d >= 23) or (m == \"Sep\" and d <= 21):\n        print(\"Virgo\")\n    elif (m == \"Sep\" and d >= 22) or (m == \"Oct\" and d <= 22):\n        print(\"Libra\")\n    elif (m == \"Oct\" and d >= 23) or (m == \"Nov\" and d <= 22):\n        print(\"Scorpio\")\n    elif (m == \"Nov\" and d >= 23) or (m == \"Dec\" and d <= 21):\n        print(\"Sagittarius\")\n    elif (m == \"Dec\" and d >= 22) or (m == \"Jan\" and d <= 20):\n        print(\"Capricorn\")\n    elif (m == \"Jan\" and d >= 21) or (m == \"Feb\" and d <= 19):\n        print(\"Aquarius\")\n    elif (m == \"Feb\" and d >= 20) or (m == \"Mar\" and d <= 20):\n        print(\"Pisces\")\n
"},{"location":"solutions/#attendance","title":"Attendance","text":"Solution in Python Python
n = int(input())\ns = []\nfor _ in range(n):\n    c = input()\n    if c == \"Present!\":\n        s.pop()\n    else:\n        s.append(c)\nif not s:\n    print(\"No Absences\")\nelse:\n    print(\"\\n\".join(s))\n
"},{"location":"solutions/#autori","title":"Autori","text":"Solution in Python Python
print(\"\".join([part[0] for part in input().split(\"-\")]))\n
"},{"location":"solutions/#average-character","title":"Average Character","text":"Solution in Python Python
s = input()\ns = [ord(c) for c in s]\ns = sum(s) // len(s)\nprint(chr(s))\n
"},{"location":"solutions/#avion","title":"Avion","text":"Solution in Python Python
ans = []\nfor i in range(5):\n    row = input()\n    if \"FBI\" in row:\n        ans.append(str(i + 1))\nif not ans:\n    print(\"HE GOT AWAY!\")\nelse:\n    print(\" \".join(ans))\n
"},{"location":"solutions/#babelfish","title":"Babelfish","text":"Solution in Python Python
d = []\nwhile True:\n    line = input()\n    if not line:\n        break\n    w, f = line.split()\n    d.append((f, w))\n\nd = dict(d)\nwhile True:\n    try:\n        line = input()\n    except:\n        break\n    print(d.get(line, \"eh\"))\n
"},{"location":"solutions/#baby-bites","title":"Baby Bites","text":"Solution in Python Python
n = int(input())\na = input().split()\nc = [str(d) for d in range(1, n + 1)]\ninplace = [i == j if i.isnumeric() and j.isnumeric() else None for i, j in zip(a, c)]\ninplace = [v for v in inplace if v is not None]\nprint(\"makes sense\" if all(inplace) else \"something is fishy\")\n
"},{"location":"solutions/#baby-panda","title":"Baby Panda","text":"Solution in Python Python
import math\n\nn, m = [int(d) for d in input().split()]\nd = 0\nwhile m:\n    c = math.floor(math.log(m, 2))\n    d += 1\n    m -= 2**c\nprint(d)\n
"},{"location":"solutions/#backspace","title":"Backspace","text":"Solution in Python Python
ans = []\nfor c in input():\n    if c != \"<\":\n        ans.append(c)\n    else:\n        ans.pop()\nprint(\"\".join(ans))\n
"},{"location":"solutions/#bacon-eggs-and-spam","title":"Bacon, Eggs, and Spam","text":"Solution in Python Python
while True:\n    n = int(input())\n    if not n:\n        break\n    record = {}\n    for _ in range(n):\n        order = input().split()\n        name = order[0]\n        items = order[1:]\n        for item in items:\n            if item not in record:\n                record[item] = [name]\n            else:\n                record[item].append(name)\n    for name in sorted(record):\n        print(name, \" \".join(sorted(record[name])))\n    print()\n
"},{"location":"solutions/#bannor","title":"Bannor\u00f0","text":"Solution in Python Python
s = set(input())\nm = input().split()\nprint(\" \".join([\"*\" * len(p) if s & set(p) else p for p in m]))\n
"},{"location":"solutions/#basketball-one-on-one","title":"Basketball One-on-One","text":"Solutions in 2 languages JavaPython
import java.util.Scanner;\n\nclass BasketballOneOnOne {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        String scores = s.nextLine();\n        System.out.println(scores.charAt(scores.length() - 2));\n    }\n}\n
scores = input()\nsize = len(scores)\na = sum([int(scores[i + 1]) for i in range(size) if scores[i] == \"A\"])\nb = sum([int(scores[i + 1]) for i in range(size) if scores[i] == \"B\"])\nif a > b:\n    print(\"A\")\nelse:\n    print(\"B\")\n
"},{"location":"solutions/#batter-up","title":"Batter Up","text":"Solution in Python Python
_ = input()\nat_bats = [int(d) for d in input().split()]\nans = [d for d in at_bats if d >= 0]\nprint(sum(ans) / len(ans))\n
"},{"location":"solutions/#beat-the-spread","title":"Beat the Spread!","text":"Solution in Python Python
for _ in range(int(input())):\n    a, b = [int(d) for d in input().split()]\n    if a < b or (a + b) % 2:\n        print(\"impossible\")\n    else:\n        print((a + b) // 2, (a - b) // 2)\n
"},{"location":"solutions/#beavergnaw","title":"Beavergnaw","text":"Solution in Python Python
import math\n\nwhile True:\n    D, V = [int(d) for d in input().split()]\n    if not D and not V:\n        break\n    # R = D / 2\n    # r = d / 2\n    # V + \u03c0 * (r**2) * (2*r) + 2 * (1/3) * \u03c0 * (R-r) * (r**2 + r*R + R**2) == \u03c0 * (R**2) * (2*R)\n    print(math.pow(D**3 - 6 * V / math.pi, 1 / 3))\n
"},{"location":"solutions/#beekeeper","title":"Beekeeper","text":"Solution in Python Python
def count(word):\n    return sum(word.count(c * 2) for c in \"aeiouy\")\n\n\nwhile True:\n    n = int(input())\n    if not n:\n        break\n    words = []\n    for _ in range(n):\n        words.append(input())\n    print(max(words, key=count))\n
"},{"location":"solutions/#bela","title":"Bela","text":"Solution in Python Python
table = {\n    \"A\": {True: 11, False: 11},\n    \"K\": {True: 4, False: 4},\n    \"Q\": {True: 3, False: 3},\n    \"J\": {True: 20, False: 2},\n    \"T\": {True: 10, False: 10},\n    \"9\": {True: 14, False: 0},\n    \"8\": {True: 0, False: 0},\n    \"7\": {True: 0, False: 0},\n}\n\nn, b = input().split()\nn = int(n)\ntotal = 0\n\nfor _ in range(4 * n):\n    card = input()\n    f, s = card[0], card[1]\n    total += table[f][s == b]\n\nprint(total)\n
"},{"location":"solutions/#betting","title":"Betting","text":"Solutions in 2 languages GoPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var a float32\n    fmt.Scan(&a)\n    fmt.Printf(\"%.10f\", 100/a)\n    fmt.Println()\n    fmt.Printf(\"%.10f\", 100/(100-a))\n}\n
a = int(input())\nprint(f\"{100/a:.10f}\")\nprint(f\"{100/(100-a):.10f}\")\n
"},{"location":"solutions/#bijele","title":"Bijele","text":"Solution in Python Python
should_contain = (1, 1, 2, 2, 2, 8)\nfound = [int(d) for d in input().split()]\nprint(\" \".join([str(a - b) for a, b in zip(should_contain, found)]))\n
"},{"location":"solutions/#black-friday","title":"Black Friday","text":"Solution in Python Python
from collections import Counter\n\nn = input()\na = [int(d) for d in input().split()]\nc = Counter(a)\nkeys = [k for k in c if c[k] == 1]\nif not keys:\n    print(\"none\")\nelse:\n    print(a.index(max(keys)) + 1)\n
"},{"location":"solutions/#blueberry-waffle","title":"Blueberry Waffle","text":"Solution in Python Python
r, f = [int(d) for d in input().split()]\n\na = f // r\nb = (f - a * r) / r >= 0.5\n\nprint(\"up\" if (a + b) % 2 == 0 else \"down\")\n
"},{"location":"solutions/#bluetooth","title":"Bluetooth","text":"Solution in Python Python
n = int(input())\ncond = {}\n\n\ndef f(t):\n    if t[0].isdigit():\n        return (f'R{\"u\" if t[1]==\"+\" else \"l\"}', t[0])\n    else:\n        return (f'L{\"u\" if t[0]==\"+\" else \"l\"}', t[1])\n\n\nfor _ in range(n):\n    t, p = input().split()\n    q, d = f(t)\n    if p == \"b\":\n        if p not in cond:\n            cond[p] = [q]\n        else:\n            cond[p].append(q)\n    elif p == \"m\":\n        if p not in cond:\n            cond[p] = [(q, d)]\n        else:\n            cond[p].append((q, d))\n\nl, r = True, True\n\nif \"R\" in [c[0] for c in cond.get(\"b\", [])]:\n    r = False\nif \"L\" in [c[0] for c in cond.get(\"b\", [])]:\n    l = False\n\nru = len([d for q, d in cond.get(\"m\", []) if q == \"Ru\"])\nrl = len([d for q, d in cond.get(\"m\", []) if q == \"Rl\"])\nlu = len([d for q, d in cond.get(\"m\", []) if q == \"Lu\"])\nll = len([d for q, d in cond.get(\"m\", []) if q == \"Ll\"])\n\nif ru == 8 or rl == 8:\n    r = False\nif lu == 8 or ll == 8:\n    l = False\n\nif not l and not r:\n    print(2)\nelif l and not r:\n    print(0)\nelif r and not l:\n    print(1)\nelse:\n    print(\"?\")\n
"},{"location":"solutions/#boat-parts","title":"Boat Parts","text":"Solution in Python Python
p, n = [int(d) for d in input().split()]\nboat = set()\nd = -1\nfor i in range(n):\n    w = input()\n    boat.add(w)\n    if len(boat) == p:\n        d = i + 1\n        break\nif d == -1:\n    print(\"paradox avoided\")\nelse:\n    print(d)\n
"},{"location":"solutions/#booking-a-room","title":"Booking a Room","text":"Solution in Python Python
r, n = [int(d) for d in input().split()]\nbooked = [int(input()) for _ in range(n)]\navailable = set(range(1, 1 + r)) - set(booked)\nprint(\"too late\" if r == n else available.pop())\n
"},{"location":"solutions/#boss-battle","title":"Boss Battle","text":"Solution in Python Python
n = int(input())\nprint(n - 2 if n // 4 else 1)\n
"},{"location":"solutions/#bottled-up-feelings","title":"Bottled-Up Feelings","text":"Solution in Python Python
s, v1, v2 = [int(d) for d in input().split()]\n\nn1 = s // v1\nif not s % v1:\n    print(n1, 0)\nelse:\n    while True:\n        if not (s - n1 * v1) % v2:\n            print(n1, (s - n1 * v1) // v2)\n            break\n        else:\n            n1 -= 1\n            if n1 < 0:\n                break\n    if n1 < 0:\n        print(\"Impossible\")\n
"},{"location":"solutions/#bounding-robots","title":"Bounding Robots","text":"Solution in Python Python
while True:\n    room_x, room_y = [int(d) for d in input().split()]\n    if not room_x and not room_y:\n        break\n\n    robot_x, robot_y = 0, 0\n    actual_x, actual_y = 0, 0\n\n    n = int(input())\n    for _ in range(n):\n        direction, step = input().split()\n        step = int(step)\n\n        if direction == \"u\":\n            robot_y += step\n            actual_y = min(room_y - 1, actual_y + step)\n        elif direction == \"d\":\n            robot_y -= step\n            actual_y = max(0, actual_y - step)\n        elif direction == \"r\":\n            robot_x += step\n            actual_x = min(room_x - 1, actual_x + step)\n        elif direction == \"l\":\n            robot_x -= step\n            actual_x = max(0, actual_x - step)\n\n    print(f\"Robot thinks {robot_x} {robot_y}\")\n    print(f\"Actually at {actual_x} {actual_y}\")\n    print()\n
"},{"location":"solutions/#bracket-matching","title":"Bracket Matching","text":"Solution in Python Python
n = int(input())\ns = input()\nstack = []\nis_valid = True\nfor i in range(n):\n    c = s[i]\n    if c in (\"(\", \"[\", \"{\"):\n        stack.append(c)\n    else:\n        if len(stack) == 0:\n            is_valid = False\n            break\n        last = stack.pop()\n        if c == \")\" and last != \"(\":\n            is_valid = False\n            break\n        if c == \"]\" and last != \"[\":\n            is_valid = False\n            break\n        if c == \"}\" and last != \"{\":\n            is_valid = False\n            break\n\nprint(\"Valid\" if is_valid and not len(stack) else \"Invalid\")\n
"},{"location":"solutions/#breaking-branches","title":"Breaking Branches","text":"Solutions in 5 languages GoHaskellJavaJavaScriptPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var n int\n    fmt.Scan(&n)\n    if n%2 == 0 {\n        fmt.Println(\"Alice\")\n        fmt.Println(1)\n    } else {\n        fmt.Println(\"Bob\")\n    }\n}\n
main = do\n    input <- getLine\n    let n = (read input :: Int)\n    if  n `mod` 2  ==  0\n    then do putStrLn \"Alice\"\n            putStrLn \"1\"\n        else putStrLn \"Bob\"\n
import java.util.Scanner;\n\nclass BreakingBranches {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int n = s.nextInt();\n        if (n % 2 == 0) {\n            System.out.println(\"Alice\");\n            System.out.println(1);\n        } else {\n            System.out.println(\"Bob\");\n        }\n    }\n}\n
const readline = require(\"readline\");\nconst rl = readline.createInterface(process.stdin, process.stdout);\n\nrl.question(\"\", (n) => {\n  if (parseInt(n) % 2) {\n    console.log(\"Bob\");\n  } else {\n    console.log(\"Alice\");\n    console.log(1);\n  }\n});\n
n = int(input())\nif n % 2:\n    print(\"Bob\")\nelse:\n    print(\"Alice\")\n    print(1)\n
"},{"location":"solutions/#broken-calculator","title":"Broken Calculator","text":"Solution in Python Python
prev = 1\nfor _ in range(int(input())):\n    a, op, b = input().split()\n    a, b = int(a), int(b)\n    if op == \"+\":\n        ans = a + b - prev\n    elif op == \"-\":\n        ans = (a - b) * prev\n    elif op == \"*\":\n        ans = (a * b) ** 2\n    elif op == \"/\":\n        ans = (a + 1) // 2 if a % 2 else a // 2\n\n    print(ans)\n    prev = ans\n
"},{"location":"solutions/#broken-swords","title":"Broken Swords","text":"Solution in Python Python
tb, lr = 0, 0\nfor _ in range(int(input())):\n    s = input()\n    tb += s[:2].count(\"0\")\n    lr += s[2:].count(\"0\")\n\nswords = min(tb, lr) // 2\ntb -= swords * 2\nlr -= swords * 2\n\nprint(f\"{swords} {tb} {lr}\")\n
"},{"location":"solutions/#buka","title":"Buka","text":"Solution in Python Python
a, op, b = input(), input(), input()\npa, pb = a.count(\"0\"), b.count(\"0\")\nif op == \"*\":\n    print(f\"1{'0'*(pa+pb)}\")\nelif op == \"+\":\n    if pa == pb:\n        ans = f\"2{'0'*pa}\"\n    else:\n        ans = f\"1{'0'*(abs(pa-pb)-1)}1{'0'*min(pa,pb)}\"\n    print(ans)\n
"},{"location":"solutions/#bus","title":"Bus","text":"Solution in Python Python
def f(n):\n    if n == 1:\n        return 1\n    else:\n        return int(2 * (f(n - 1) + 0.5))\n\n\nfor _ in range(int(input())):\n    print(f(int(input())))\n
"},{"location":"solutions/#bus-numbers","title":"Bus Numbers","text":"Solution in Python Python
n = int(input())\nnumbers = sorted([int(d) for d in input().split()])\n\nprev = numbers[0]\nans = {prev: 1}\nfor i in range(1, n):\n    if numbers[i] == prev + ans[prev]:\n        ans[prev] += 1\n    else:\n        prev = numbers[i]\n        ans[prev] = 1\n\nprint(\n    \" \".join(\n        [\n            f\"{key}-{key+value-1}\"\n            if value > 2\n            else \" \".join([str(d) for d in range(key, key + value)])\n            for key, value in ans.items()\n        ]\n    )\n)\n
"},{"location":"solutions/#calories-from-fat","title":"Calories From Fat","text":"Solution in Python Python
mapping = {\"fat\": 9, \"protein\": 4, \"sugar\": 4, \"starch\": 4, \"alcohol\": 7}\n\n\ndef c(x, category):\n    if \"g\" in x:\n        return (int(x[:-1]) * mapping[category], \"C\")\n    elif \"C\" in x:\n        return (int(x[:-1]), \"C\")\n    elif \"%\" in x:\n        return (int(x[:-1]) / 100, \"%\")\n\n\ndef solve(items):\n    fat_c, total_c = 0, 0\n    for fat, protein, sugar, starch, alcohol in items:\n        fat_c += fat\n        total_c += fat + protein + sugar + starch + alcohol\n\n    return f\"{fat_c/total_c:.0%}\"\n\n\nitems = []\nwhile True:\n    s = input()\n    if s == \"-\":\n        if not items:\n            break\n        print(solve(items))\n\n        items = []\n        continue\n\n    fat, protein, sugar, starch, alcohol = s.split()\n    mapping.keys()\n\n    total_c, total_p = 0, 0\n\n    reading = []\n    for v, k in zip(s.split(), mapping.keys()):\n        n, t = c(v, k)\n        if t == \"C\":\n            total_c += n\n        elif t == \"%\":\n            total_p += n\n        reading.append((n, t))\n\n    total_c = total_c / (1 - total_p)\n\n    item = []\n    for n, t in reading:\n        if t == \"%\":\n            item.append(n * total_c)\n        else:\n            item.append(n)\n\n    items.append(item)\n
"},{"location":"solutions/#canadians-eh","title":"Canadians, eh?","text":"Solutions in 3 languages GoJavaPython
package main\n\nimport (\n    \"bufio\"\n    \"fmt\"\n    \"os\"\n    \"strings\"\n)\n\nfunc main() {\n    scanner := bufio.NewScanner(os.Stdin)\n    scanner.Scan()\n    line := scanner.Text()\n    if strings.HasSuffix(line, \"eh?\") {\n        fmt.Println(\"Canadian!\")\n    } else {\n        fmt.Println(\"Imposter!\")\n    }\n}\n
import java.util.Scanner;\n\nclass CanadiansEh {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        String line = s.nextLine();\n        if (line.endsWith(\"eh?\")) {\n            System.out.println(\"Canadian!\");\n        } else {\n            System.out.println(\"Imposter!\");\n        }\n    }\n}\n
line = input()\nif line.endswith(\"eh?\"):\n    print(\"Canadian!\")\nelse:\n    print(\"Imposter!\")\n
"},{"location":"solutions/#careful-ascent","title":"Careful Ascent","text":"Solution in Python Python
a, b = [int(d) for d in input().split()]\nn = int(input())\nshields = []\nfor _ in range(n):\n    l, u, f = input().split()\n    l = int(l)\n    u = int(u)\n    f = float(f)\n    shields.append((l, u, f))\n\nshields.append((b,))\ns = shields[0][0]\nfor i in range(n):\n    s += (shields[i][1] - shields[i][0]) * shields[i][2]\n    s += shields[i + 1][0] - shields[i][1]\nprint(f\"{a/s:.6f}\")\n
"},{"location":"solutions/#solving-for-carrots","title":"Solving for Carrots","text":"Solution in Python Python
n, ans = [int(d) for d in input().split()]\nfor _ in range(n):\n    input()\nprint(ans)\n
"},{"location":"solutions/#catalan-numbers","title":"Catalan Numbers","text":"Solution in Python Python
# https://en.wikipedia.org/wiki/Catalan_number\np = [1]\nfor i in range(10000):\n    p.append(p[-1] * (i + 1))\n\nfor _ in range(int(input())):\n    n = int(input())\n    print(p[2 * n] // (p[n + 1] * p[n]))\n
"},{"location":"solutions/#cd","title":"CD","text":"Solution in Python Python
while True:\n    n, m = [int(d) for d in input().split()]\n    if not n and not m:\n        break\n    a = [int(input()) for _ in range(n)]\n    b = [int(input()) for _ in range(m)]\n    total, i, j = 0, 0, 0\n    while i < n and j < m:\n        if a[i] == b[j]:\n            total += 1\n            i += 1\n            j += 1\n        elif a[i] < b[j]:\n            i += 1\n        else:\n            j += 1\n    while i < n:\n        if a[i] == b[-1]:\n            total += 1\n            break\n        i += 1\n    while j < n:\n        if a[-1] == b[j]:\n            total += 1\n            break\n        j += 1\n    print(total)\n
"},{"location":"solutions/#cetiri","title":"Cetiri","text":"Solutions in 2 languages GoPython
package main\n\nimport (\n    \"fmt\"\n    \"sort\"\n)\n\nfunc main() {\n    var a, b, c int\n    fmt.Scan(&a)\n    fmt.Scan(&b)\n    fmt.Scan(&c)\n    s := []int{a, b, c}\n    sort.Ints(s)\n    a, b, c = s[0], s[1], s[2]\n    if c-b == b-a {\n        fmt.Println(c + c - b)\n    } else if c-b > b-a {\n        fmt.Println(c - b + a)\n    } else {\n        fmt.Println(a + c - b)\n    }\n}\n
a, b, c = sorted([int(d) for d in input().split()])\nif c - b == b - a:\n    print(c + c - b)\nelif c - b > b - a:\n    print(c - b + a)\nelse:\n    print(a + c - b)\n
"},{"location":"solutions/#cetvrta","title":"Cetvrta","text":"Solution in Python Python
from collections import Counter\n\nx, y = Counter(), Counter()\n\nfor _ in range(3):\n    _x, _y = [int(d) for d in input().split()]\n    x[_x] += 1\n    y[_y] += 1\n\n\nfor key in x:\n    if x[key] == 1:\n        print(key, \" \")\n        break\n\nfor key in y:\n    if y[key] == 1:\n        print(key)\n        break\n
"},{"location":"solutions/#chanukah-challenge","title":"Chanukah Challenge","text":"Solution in Python Python
for _ in range(int(input())):\n    k, n = [int(d) for d in input().split()]\n    print(k, int((1 + n) * n / 2 + n))\n
"},{"location":"solutions/#character-development","title":"Character Development","text":"Solution in Python Python
def f(m):\n    ans = 0\n    for n in range(2, m + 1):\n        a, b = 1, 1\n        for i in range(m - n + 1, m + 1):\n            a *= i\n        for i in range(1, n + 1):\n            b *= i\n        ans += a // b\n    return ans\n\n\nprint(f(int(input())))\n
"},{"location":"solutions/#chocolate-division","title":"Chocolate Division","text":"Solution in Python Python
r, c = [int(v) for v in input().split()]\n\nchocolate_bar_cuts = (r * c) - 1\n\nif chocolate_bar_cuts % 2 == 1:\n    print(\"Alf\")\nelse:\n    print(\"Beata\")\n
"},{"location":"solutions/#preludes","title":"Preludes","text":"Solution in Python Python
alternatives = [(\"A#\", \"Bb\"), (\"C#\", \"Db\"), (\"D#\", \"Eb\"), (\"F#\", \"Gb\"), (\"G#\", \"Ab\")]\n\n\nm = dict(alternatives + [(b, a) for a, b in alternatives])\n\ni = 1\nwhile True:\n    try:\n        s = input()\n    except:\n        break\n    key, tone = s.split()\n    if key in m:\n        print(f\"Case {i}: {m[key]} {tone}\")\n    else:\n        print(f\"Case {i}: UNIQUE\")\n\n    i += 1\n
"},{"location":"solutions/#cinema-crowds","title":"Cinema Crowds","text":"Solution in Python Python
n, m = [int(v) for v in input().split()]\n\nsize = [int(v) for v in input().split()]\n\ngroups_admitted = 0\n\nfor i in range(m):\n    if size[i] <= n:\n        n -= size[i]\n        groups_admitted += 1\n\nprint(m - groups_admitted)\n
"},{"location":"solutions/#cinema-crowds-2","title":"Cinema Crowds 2","text":"Solution in Python Python
n, m = [int(t) for t in input().split()]\np = [int(t) for t in input().split()]\n\nd = 0\nl = 0\nfor i in range(m):\n    if p[i] > n - d:\n        break\n    else:\n        k = p[i]\n        d += k\n        l += 1\n\nprint(m - l)\n
"},{"location":"solutions/#class-field-trip","title":"Class Field Trip","text":"Solution in Python Python
a = input()\nb = input()\n\ni, j = 0, 0\nans = []\nwhile i < len(a) and j < len(b):\n    if a[i] < b[j]:\n        ans.append(a[i])\n        i += 1\n    else:\n        ans.append(b[j])\n        j += 1\n\n\nans += a[i:] if i < len(a) else b[j:]\n\nprint(\"\".join(ans))\n
"},{"location":"solutions/#a-furious-cocktail","title":"A Furious Cocktail","text":"Solution in Python Python
n, t = [int(d) for d in input().split()]\np = [int(input()) for _ in range(n)]\np = sorted(p, reverse=True)\nending = p[0]\nable = True\nfor i in range(1, n):\n    if t * i >= ending:\n        print(\"NO\")\n        able = False\n        break\n    if t * i + p[i] < ending:\n        ending = t * i + p[i]\nif able:\n    print(\"YES\")\n
"},{"location":"solutions/#code-cleanups","title":"Code Cleanups","text":"Solution in Python Python
n = int(input())\np = [int(d) for d in input().split()]\nprev = []\nt = 0\nfor v in p:\n    if not prev:\n        prev.append(v)\n        continue\n    d = (19 + sum(prev)) // len(prev)\n    if v <= d:\n        prev.append(v)\n    else:\n        prev = [v]\n        t += 1\nif prev:\n    t += 1\nprint(t)\n
"},{"location":"solutions/#code-to-save-lives","title":"Code to Save Lives","text":"Solution in Python Python
t = int(input())\nfor _ in range(t):\n    a = int(input().replace(\" \", \"\"))\n    b = int(input().replace(\" \", \"\"))\n    print(\" \".join(str(a + b)))\n
"},{"location":"solutions/#coffee-cup-combo","title":"Coffee Cup Combo","text":"Solution in Python Python
n = int(input())\nawake = [0] * n\ns = list(input())\nfor i in range(n):\n    if s[i] == \"1\":\n        awake[i] = 1\n        if i + 1 < n:\n            awake[i + 1] = 1\n        if i + 2 < n:\n            awake[i + 2] = 1\nprint(sum(awake))\n
"},{"location":"solutions/#cold-puter-science","title":"Cold-puter Science","text":"Solution in Python Python
_ = input()\nprint(len([t for t in input().split() if \"-\" in t]))\n
"},{"location":"solutions/#competitive-arcade-basketball","title":"Competitive Arcade Basketball","text":"Solution in Python Python
from collections import Counter\n\nn, p, m = [int(d) for d in input().split()]\n\nrecords = Counter()\nwinners = []\nnames = [input() for _ in range(n)]\nfor r in range(m):\n    name, point = input().split()\n    point = int(point)\n    records[name] += point\n    if records[name] >= p and name not in winners:\n        winners.append(name)\nif not winners:\n    print(\"No winner!\")\nelse:\n    print(\"\\n\".join([f\"{n} wins!\" for n in winners]))\n
"},{"location":"solutions/#completing-the-square","title":"Completing the Square","text":"Solution in Python Python
x1, y1 = [int(d) for d in input().split()]\nx2, y2 = [int(d) for d in input().split()]\nx3, y3 = [int(d) for d in input().split()]\n\nd12 = (x1 - x2) ** 2 + (y1 - y2) ** 2\nd13 = (x1 - x3) ** 2 + (y1 - y3) ** 2\nd23 = (x2 - x3) ** 2 + (y2 - y3) ** 2\n\nif d12 == d13:\n    x, y = x2 + x3 - x1, y2 + y3 - y1\nelif d12 == d23:\n    x, y = x1 + x3 - x2, y1 + y3 - y2\nelse:\n    x, y = x1 + x2 - x3, y1 + y2 - y3\n\nprint(x, y)\n
"},{"location":"solutions/#compound-words","title":"Compound Words","text":"Solution in Python Python
from itertools import permutations\n\nl = []\nwhile True:\n    try:\n        l.extend(input().split())\n    except:\n        break\n\nw = set()\nfor i, j in permutations(l, 2):\n    w.add(f\"{i}{j}\")\n\n\nprint(\"\\n\".join(sorted(w)))\n
"},{"location":"solutions/#conformity","title":"Conformity","text":"Solution in Python Python
from collections import Counter\n\nn = int(input())\nentries = []\nfor _ in range(n):\n    entries.append(\" \".join(sorted(input().split())))\n\nsummary = Counter(entries)\npopular = max(summary.values())\n\nprint(sum([summary[e] for e in summary if summary[e] == popular]))\n
"},{"location":"solutions/#contingency-planning","title":"Contingency Planning","text":"Solution in Python Python
def permutations(n, c):\n    value = 1\n    for i in range(n - c + 1, n + 1):\n        value *= i\n    return value\n\n\nn = int(input())\nans = 0\nfor i in range(1, n + 1):\n    ans += permutations(n, i)\nif ans > 1_000_000_000:\n    print(\"JUST RUN!!\")\nelse:\n    print(ans)\n
"},{"location":"solutions/#cryptographers-conundrum","title":"Cryptographer's Conundrum","text":"Solution in Python Python
text = input()\ntotal = 0\nfor i in range(0, len(text), 3):\n    if text[i] != \"P\":\n        total += 1\n    if text[i + 1] != \"E\":\n        total += 1\n    if text[i + 2] != \"R\":\n        total += 1\nprint(total)\n
"},{"location":"solutions/#convex-polygon-area","title":"Convex Polygon Area","text":"Solution in Python Python
for _ in range(int(input())):\n    values = [int(d) for d in input().split()]\n    coords = values[1:]\n    n = values[0]\n\n    coords.append(coords[0])\n    coords.append(coords[1])\n\n    area = 0\n    for i in range(0, 2 * n, 2):\n        x1, y1 = coords[i], coords[i + 1]\n        x2, y2 = coords[i + 2], coords[i + 3]\n        area += x1 * y2 - x2 * y1\n\n    print(0.5 * abs(area))\n
"},{"location":"solutions/#cooking-water","title":"Cooking Water","text":"Solution in Python Python
n = int(input())\nlb, ub = 0, 1000\nfor _ in range(n):\n    a, b = [int(d) for d in input().split()]\n    lb = max(lb, a)\n    ub = min(ub, b)\n\nif lb > ub:\n    print(\"edward is right\")\nelse:\n    print(\"gunilla has a point\")\n
"},{"location":"solutions/#cornhusker","title":"Cornhusker","text":"Solution in Python Python
a = [int(d) for d in input().split()]\nn, kwf = [int(d) for d in input().split()]\ns = sum([a[i] * a[i + 1] for i in range(0, 10, 2)])\n\nprint(int(int(s / 5) * n / kwf))\n
"},{"location":"solutions/#cosmic-path-optimization","title":"Cosmic Path Optimization","text":"Solution in Python Python
import math\n\nm = int(input())\nt = [int(d) for d in input().split()]\nprint(f\"{math.floor(sum(t)/m)}\")\n
"},{"location":"solutions/#costume-contest","title":"Costume Contest","text":"Solution in Python Python
from collections import Counter\n\nn = int(input())\nc = Counter()\nfor _ in range(n):\n    c[input()] += 1\nprint(\"\\n\".join(sorted([k for k, v in c.items() if v == min(c.values())])))\n
"},{"location":"solutions/#count-doubles","title":"Count Doubles","text":"Solution in Python Python
n, m = [int(d) for d in input().split()]\nvalues = [int(d) for d in input().split()]\nans = 0\nfor i in range(n - m + 1):\n    if len([v for v in values[i : i + m] if not v % 2]) >= 2:\n        ans += 1\nprint(ans)\n
"},{"location":"solutions/#counting-clauses","title":"Counting Clauses","text":"Solution in Python Python
m, _ = [int(d) for d in input().split()]\nfor _ in range(m):\n    input()\nif m >= 8:\n    print(\"satisfactory\")\nelse:\n    print(\"unsatisfactory\")\n
"},{"location":"solutions/#count-the-vowels","title":"Count the Vowels","text":"Solution in Python Python
print(len([c for c in input().lower() if c in \"aeiou\"]))\n
"},{"location":"solutions/#course-scheduling","title":"Course Scheduling","text":"Solution in Python Python
from collections import Counter\n\nc = Counter()\nn = {}\n\nfor _ in range(int(input())):\n    r = input().split()\n    name, course = \" \".join(r[:2]), r[-1]\n    if course not in n:\n        n[course] = set()\n\n    if name not in n[course]:\n        c[course] += 1\n        n[course].add(name)\n\nfor k in sorted(c.keys()):\n    print(f\"{k} {c[k]}\")\n
"},{"location":"solutions/#cpr-number","title":"CPR Number","text":"Solution in Python Python
cpr = input().replace(\"-\", \"\")\nvalues = [4, 3, 2, 7, 6, 5, 4, 3, 2, 1]\ntotal = 0\nfor d, v in zip(cpr, values):\n    total += int(d) * v\nif not total % 11:\n    print(1)\nelse:\n    print(0)\n
"},{"location":"solutions/#crne","title":"Crne","text":"Solutions in 2 languages GoPython
package main\n\nimport (\n    \"fmt\"\n)\n\nfunc main() {\n    var n int\n    fmt.Scan(&n)\n    a := n / 2\n    b := n - a\n    fmt.Println((a + 1) * (b + 1))\n}\n
n = int(input())\na = n // 2\nb = n - a\nprint((a + 1) * (b + 1))\n
"},{"location":"solutions/#cudoviste","title":"Cudoviste","text":"Solution in Python Python
r, c = [int(d) for d in input().split()]\nparking = []\nfor _ in range(r):\n    parking.append(input())\n\n\ndef count_spaces(parking, squash):\n    total = 0\n    for i in range(r - 1):\n        for j in range(c - 1):\n            spaces = [\n                parking[i][j],\n                parking[i + 1][j],\n                parking[i][j + 1],\n                parking[i + 1][j + 1],\n            ]\n            if (\n                all(s in \".X\" for s in spaces)\n                and sum([s == \"X\" for s in spaces]) == squash\n            ):\n                total += 1\n    return total\n\n\nfor num in range(0, 5):\n    print(count_spaces(parking, num))\n
"},{"location":"solutions/#stacking-cups","title":"Stacking Cups","text":"Solution in Python Python
size = {}\nfor _ in range(int(input())):\n    parts = input().split()\n    if parts[0].isdigit():\n        size[parts[1]] = int(parts[0]) / 2\n    else:\n        size[parts[0]] = int(parts[1])\nfor color in sorted(size, key=lambda x: size[x]):\n    print(color)\n
"},{"location":"solutions/#cut-in-line","title":"Cut in Line","text":"Solution in Python Python
n = int(input())\nqueue = []\nfor _ in range(n):\n    queue.append(input())\n\nc = int(input())\nfor _ in range(c):\n    event = input().split()\n    if event[0] == \"leave\":\n        queue.remove(event[1])\n    elif event[0] == \"cut\":\n        queue.insert(queue.index(event[2]), event[1])\n\nfor name in queue:\n    print(name)\n
"},{"location":"solutions/#cut-the-negativity","title":"Cut the Negativity","text":"Solution in Python Python
n = int(input())\n\npositives = []\nfor i in range(n):\n    numbers = [int(d) for d in input().split()]\n    for j in range(n):\n        if numbers[j] > 0:\n            positives.append((str(i + 1), str(j + 1), str(numbers[j])))\n\nprint(len(positives))\nfor p in positives:\n    print(\" \".join(p))\n
"},{"location":"solutions/#cyanide-rivers","title":"Cyanide Rivers","text":"Solution in Python Python
import math\n\ns = input()\nt = s.split(\"1\")\nprint(max([math.ceil(len(z) / 2) for z in t]))\n
"},{"location":"solutions/#cypher-decypher","title":"Cypher Decypher","text":"Solution in Python Python
from string import ascii_uppercase\n\n\ndef f(n, m):\n    return ascii_uppercase[(n * m) % 26]\n\n\nm = input()\nfor _ in range(int(input())):\n    s = input()\n    print(\"\".join([f(ascii_uppercase.index(c), int(d)) for c, d in zip(s, m)]))\n
"},{"location":"solutions/#damaged-equation","title":"Damaged Equation","text":"Solution in Python Python
from itertools import product\n\na, b, c, d = [int(d) for d in input().split()]\nops = [\"*\", \"+\", \"-\", \"//\"]\nvalid = False\nfor op1, op2 in product(ops, ops):\n    e = f\"{a} {op1} {b} == {c} {op2} {d}\"\n    try:\n        if eval(e):\n            print(e.replace(\"==\", \"=\").replace(\"//\", \"/\"))\n            valid = True\n    except:\n        pass\nif not valid:\n    print(\"problems ahead\")\n
"},{"location":"solutions/#datum","title":"Datum","text":"Solution in Python Python
from datetime import datetime\n\nd, m = [int(d) for d in input().split()]\nprint(datetime(year=2009, month=m, day=d).strftime(\"%A\"))\n
"},{"location":"solutions/#death-knight-hero","title":"Death Knight Hero","text":"Solution in Python Python
total = 0\nfor _ in range(int(input())):\n    if \"CD\" not in input():\n        total += 1\nprint(total)\n
"},{"location":"solutions/#delimiter-soup","title":"Delimiter Soup","text":"Solution in Python Python
n = int(input())\ns = input()\n\nstack = []\n\nvalid = True\n\nfor i in range(n):\n    c = s[i]\n    if c in [\"(\", \"[\", \"{\"]:\n        stack.append(c)\n    if c in [\")\", \"]\", \"}\"]:\n        if len(stack) == 0:\n            valid = False\n            break\n\n        v = stack.pop()\n        if c == \")\" and v != \"(\":\n            valid = False\n            break\n        elif c == \"]\" and v != \"[\":\n            valid = False\n            break\n        elif c == \"}\" and v != \"{\":\n            valid = False\n            break\n\nif valid:\n    print(\"ok so far\")\nelse:\n    print(c, i)\n
"},{"location":"solutions/#detailed-differences","title":"Detailed Differences","text":"Solution in Python Python
for _ in range(int(input())):\n    s1, s2 = input(), input()\n    result = [\".\" if c1 == c2 else \"*\" for c1, c2 in zip(s1, s2)]\n    print(s1)\n    print(s2)\n    print(\"\".join(result))\n
"},{"location":"solutions/#dice-cup","title":"Dice Cup","text":"Solution in Python Python
d1, d2 = [int(d) for d in input().split()]\n\nsums = []\nfor i in range(1, d1 + 1):\n    for j in range(1, d2 + 1):\n        sums.append(i + j)\n\nfrom collections import Counter\n\nc = Counter(sums)\nmost_likely = max(c.values())\nfor key in sorted(c.keys()):\n    if c[key] == most_likely:\n        print(key)\n
"},{"location":"solutions/#dice-game","title":"Dice Game","text":"Solution in Python Python
g = [int(d) for d in input().split()]\ne = [int(d) for d in input().split()]\n\n\ndef ev(d):\n    total, count = 0, 0\n    for i in range(d[0], d[1] + 1):\n        for j in range(d[2], d[3] + 1):\n            total += i + j\n            count += 1\n    return total / count\n\n\nratio = ev(g) / ev(e)\nif ratio > 1:\n    print(\"Gunnar\")\nelif ratio < 1:\n    print(\"Emma\")\nelse:\n    print(\"Tie\")\n
"},{"location":"solutions/#a-different-problem","title":"A Different Problem","text":"Solution in Python Python
while True:\n    try:\n        line = input()\n    except:\n        break\n    a, b = [int(d) for d in line.split()]\n    print(abs(a - b))\n
"},{"location":"solutions/#different-distances","title":"Different Distances","text":"Solution in Python Python
while True:\n    line = input()\n    if line == \"0\":\n        break\n    x1, y1, x2, y2, p = [float(d) for d in line.split()]\n    print((abs(x1 - x2) ** p + abs(y1 - y2) ** p) ** (1 / p))\n
"},{"location":"solutions/#digit-swap","title":"Digit Swap","text":"Solutions in 3 languages GoJavaPython
package main\n\nimport (\n    \"fmt\"\n)\n\nfunc reverse(str string) (ans string) {\n    for _, v := range str {\n        ans = string(v) + ans\n    }\n    return\n}\nfunc main() {\n    var str string\n    fmt.Scan(&str)\n    fmt.Println(reverse(str))\n}\n
import java.util.*;\n\nclass DigitSwap {\n    public static void main(String[] argv){\n        Scanner s = new Scanner(System.in);\n        StringBuilder ans = new StringBuilder();\n        ans.append(s.nextLine());\n        ans.reverse();\n        System.out.println(ans);\n    }\n}\n
print(input()[::-1])\n
"},{"location":"solutions/#disc-district","title":"Disc District","text":"Solution in Python Python
print(1, input())\n
"},{"location":"solutions/#divvying-up","title":"Divvying Up","text":"Solution in Python Python
_ = input()\np = [int(d) for d in input().split()]\nif sum(p) % 3:\n    print(\"no\")\nelse:\n    print(\"yes\")\n
"},{"location":"solutions/#dont-fall-down-stairs","title":"Don't Fall Down Stairs","text":"Solution in Python Python
n = int(input())\na = [int(d) for d in input().split()] + [0]\nprint(sum(max(a[i] - a[i + 1] - 1, 0) for i in range(n)))\n
"},{"location":"solutions/#double-password","title":"Double Password","text":"Solutions in 2 languages JavaPython
import java.util.Scanner;\n\nclass DoublePassword {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        String a = s.nextLine();\n        String b = s.nextLine();\n        int number = 1;\n        for (int i = 0; i < a.length(); i++) {\n            if (a.charAt(i) == b.charAt(i)) {\n                number *= 1;\n            } else {\n                number *= 2;\n            }\n        }\n        System.out.println(number);\n\n    }\n}\n
a, b = input(), input()\nnumber = 1\nfor c1, c2 in zip(a, b):\n    if c1 == c2:\n        number *= 1\n    else:\n        number *= 2\nprint(number)\n
"},{"location":"solutions/#drinking-song","title":"Drinking Song","text":"Solution in Python Python
n = int(input())\nw = input()\n\nfor i in range(n):\n    a = f\"{n-i} bottle{'s' if n-i >1 else ''}\"\n    b = f\"{'no more' if n-i-1==0 else n-i-1 } bottle{'' if n-i-1==1 else 's'}\"\n    c = f\"{'one' if n-i>1 else 'it' }\"\n    d = f\"{' on the wall' if n-i-1 else ''}\"\n    print(f\"{a} of {w} on the wall, {a} of {w}.\")\n    print(f\"Take {c} down, pass it around, {b} of {w}{d}.\")\n    if n - i - 1:\n        print()\n
"},{"location":"solutions/#drivers-dilemma","title":"Driver's Dilemma","text":"Solution in Python Python
c, x, m = [float(d) for d in input().split()]\ntop = 0\nfor _ in range(6):\n    mph, mpg = [float(d) for d in input().split()]\n\n    if m / mph * x + m / mpg <= c / 2:\n        top = mph\nif top:\n    print(f\"YES {top:.0f}\")\nelse:\n    print(\"NO\")\n
"},{"location":"solutions/#drm-messages","title":"DRM Messages","text":"Solution in Python Python
l = ord(\"A\")\nr = ord(\"Z\")\n\n\ndef divide(message):\n    half = len(message) // 2\n    return message[:half], message[half:]\n\n\ndef to_ord(c, rotation):\n    new_chr = ord(c) + rotation\n    return new_chr if new_chr <= r else l + (new_chr - r - 1)\n\n\ndef rotate(half):\n    rotation = sum([ord(c) - l for c in half])\n    rotation %= 26\n    result = [to_ord(c, rotation) for c in half]\n    return \"\".join([chr(c) for c in result])\n\n\ndef merge(first, second):\n    rotations = [ord(c) - l for c in second]\n    result = [to_ord(c, rotation) for c, rotation in zip(first, rotations)]\n    return \"\".join([chr(c) for c in result])\n\n\nmessage = input()\nfirst, second = divide(message)\nprint(merge(rotate(first), rotate(second)))\n
"},{"location":"solutions/#drunk-vigenere","title":"Drunk Vigen\u00e8re","text":"Solution in Python Python
import string\n\nuppers = string.ascii_uppercase\n\n\ndef unshift(c, k, f):\n    index = uppers.index(k)\n    if f:\n        new_index = uppers.index(c) + index\n    else:\n        new_index = uppers.index(c) - index\n    return uppers[new_index % 26]\n\n\nmessage, key = input(), input()\nprint(\"\".join([unshift(c, k, i % 2) for i, (c, k) in enumerate(zip(message, key))]))\n
"},{"location":"solutions/#early-winter","title":"Early Winter","text":"Solution in Python Python
n, m = [int(_) for _ in input().split()]\nd = [int(_) for _ in input().split()]\nd = [v > m for v in d]\n\n\nfor k in range(n):\n    if not d[k]:\n        break\n\nif all(d):\n    print(\"It had never snowed this early!\")\nelse:\n    print(f\"It hadn't snowed this early in {k} years!\")\n
"},{"location":"solutions/#the-easiest-problem-is-this-one","title":"The Easiest Problem Is This One","text":"Solution in Python Python
while True:\n    n = input()\n    if n == \"0\":\n        break\n    s1 = sum([int(d) for d in n])\n\n    n = int(n)\n    p = 11\n    while True:\n        s2 = sum([int(d) for d in str(n * p)])\n        if s2 == s1:\n            break\n        p += 1\n\n    print(p)\n
"},{"location":"solutions/#echo-echo-echo","title":"Echo Echo Echo","text":"Solution in Python Python
word = input().strip()\nprint(\" \".join([word] * 3))\n
"},{"location":"solutions/#egypt","title":"Egypt","text":"Solution in Python Python
while True:\n    sides = sorted([int(d) for d in input().split()])\n    if not all(sides):\n        break\n    if sides[0] ** 2 + sides[1] ** 2 == sides[2] ** 2:\n        print(\"right\")\n    else:\n        print(\"wrong\")\n
"},{"location":"solutions/#eiginnofn","title":"Eiginn\u00f6fn","text":"Solution in Python Python
n = int(input())\nmapping = {}\nfor _ in range(n):\n    names = input().split()\n    mapping[names[0]] = names\nm = int(input())\nfor _ in range(m):\n    name = input()\n    if name not in mapping:\n        print(\"Neibb\")\n    elif name in mapping and len(mapping[name]) == 1:\n        print(\"Jebb\")\n    else:\n        print(f'Neibb en {\" \".join(mapping[name])} er heima')\n
"},{"location":"solutions/#ekki-daui-opna-inni","title":"Ekki dau\u00f0i opna inni","text":"Solution in Python Python
l = []\nwhile True:\n    try:\n        l.append(input().split(\"|\"))\n    except:\n        break\n\nl = [l[i][0] for i in range(len(l))] + [\" \"] + [l[i][1] for i in range(len(l))]\nprint(\"\".join(l))\n
"},{"location":"solutions/#election-paradox","title":"Election Paradox","text":"Solution in Python Python
n = int(input())\np = [int(d) for d in input().split()]\np = sorted(p)\nt = 0\nfor i in range(0, n // 2 + 1):\n    t += p[i] // 2\nfor i in range(n // 2 + 1, n):\n    t += p[i]\nprint(t)\n
"},{"location":"solutions/#electrical-outlets","title":"Electrical Outlets","text":"Solution in Python Python
for _ in range(int(input())):\n    print(sum([int(d) - 1 for d in input().split()[1:]]) + 1)\n
"},{"location":"solutions/#eligibility","title":"Eligibility","text":"Solution in Python Python
for _ in range(int(input())):\n    name, pss, dob, courses = input().split()\n    courses = int(courses)\n    pss = [int(d) for d in pss.split(\"/\")]\n    dob = [int(d) for d in dob.split(\"/\")]\n    if pss[0] >= 2010 or dob[0] >= 1991:\n        print(name, \"eligible\")\n    elif courses > 40:\n        print(name, \"ineligible\")\n    else:\n        print(name, \"coach petitions\")\n
"},{"location":"solutions/#encoded-message","title":"Encoded Message","text":"Solution in Python Python
import math\n\nfor _ in range(int(input())):\n    message = input()\n    size = int(math.sqrt(len(message)))\n    m = []\n    for i in range(size):\n        m.append(message[i * size : (i + 1) * size])\n\n    ans = []\n    for i in range(size - 1, -1, -1):\n        for j in range(size):\n            ans.append(m[j][i])\n    print(\"\".join(ans))\n
"},{"location":"solutions/#endurvinnsla","title":"Endurvinnsla","text":"Solution in Python Python
_ = input()\np = float(input())\nn = int(input())\nitems = [input() == \"ekki plast\" for _ in range(n)]\nprint(\"Jebb\" if sum(items) <= p * n else \"Neibb\")\n
"},{"location":"solutions/#engineering-english","title":"Engineering English","text":"Solution in Python Python
seen = set()\n\nwhile True:\n    try:\n        s = input().split()\n    except:\n        break\n    d = []\n    for t in s:\n        if t.lower() not in seen:\n            seen.add(t.lower())\n        else:\n            t = \".\"\n        d.append(t)\n    print(\" \".join(d))\n
"},{"location":"solutions/#erase-securely","title":"Erase Securely","text":"Solution in Python Python
n = int(input())\na, b = input(), input()\nif n % 2:\n    print(\n        \"Deletion\", \"failed\" if not all([i != j for i, j in zip(a, b)]) else \"succeeded\"\n    )\nelse:\n    print(\n        \"Deletion\", \"failed\" if not all([i == j for i, j in zip(a, b)]) else \"succeeded\"\n    )\n
"},{"location":"solutions/#espresso","title":"Espresso!","text":"Solution in Python Python
n, s = [int(d) for d in input().split()]\nrefill = 0\ntank = s\nfor _ in range(n):\n    o = input()\n    if \"L\" in o:\n        w = int(o[:-1]) + 1\n    else:\n        w = int(o)\n    if tank - w < 0:\n        refill += 1\n        tank = s\n\n    tank -= w\nprint(refill)\n
"},{"location":"solutions/#estimating-the-area-of-a-circle","title":"Estimating the Area of a Circle","text":"Solution in Python Python
import math\n\nwhile True:\n    r, m, c = input().split()\n    if r == \"0\" and m == \"0\" and c == \"0\":\n        break\n    r = float(r)\n    m, c = int(m), int(c)\n    print(math.pi * r * r, 4 * r * r * c / m)\n
"},{"location":"solutions/#eulers-number","title":"Euler's Number","text":"Solutions in 2 languages C++Python
#include <iomanip>\n#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int n;\n    long double e, m;\n    cin >> n;\n    e = 1;\n    m = 1;\n    for (int i = 1; i <= n; i++)\n    {\n        m *= i;\n        e += 1 / m;\n    }\n    cout << std::setprecision(13) << e << endl;\n    return 0;\n}\n
n = int(input())\ne = 1\nm = 1\nfor i in range(1, n + 1):\n    m *= i\n    e += 1 / m\nprint(e)\n
"},{"location":"solutions/#evening-out-1","title":"Evening Out 1","text":"Solutions in 2 languages C++Python
#include <algorithm>\n#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    long int a, b;\n    cin >> a >> b;\n    long int c = a % b;\n    cout << std::min(c, b - c);\n    return 0;\n}\n
a, b = [int(d) for d in input().split()]\nc = a % b\nprint(min(c, b - c))\n
"},{"location":"solutions/#event-planning","title":"Event Planning","text":"Solution in Python Python
n, b, h, w = [int(d) for d in input().split()]\n\ncosts = []\nfor _ in range(h):\n    p = int(input())\n    a = [int(d) for d in input().split()]\n    if not any([_a >= n for _a in a]):\n        costs.append(None)\n        continue\n    c = p * n\n    if c > b:\n        c = None\n    costs.append(c)\n\ncosts = [c for c in costs if c]\nif not costs:\n    print(\"stay home\")\nelse:\n    print(min(costs))\n
"},{"location":"solutions/#ive-been-everywhere-man","title":"I've Been Everywhere, Man","text":"Solution in Python Python
cities = {}\nfor i in range(int(input())):\n    cities[i] = set()\n    for _ in range(int(input())):\n        cities[i].add(input())\n\nprint(\"\\n\".join([str(len(s)) for s in cities.values()]))\n
"},{"location":"solutions/#exactly-electrical","title":"Exactly Electrical","text":"Solution in Python Python
a, b = [int(d) for d in input().split()]\nc, d = [int(d) for d in input().split()]\nt = int(input())\nm = abs(a - c) + abs(b - d)\nprint(\"Y\" if m <= t and (m - t) % 2 == 0 else \"N\")\n
"},{"location":"solutions/#exam","title":"Exam","text":"Solution in Python Python
k = int(input())\ny = input()\nf = input()\nsame, different = 0, 0\nfor a, b in zip(y, f):\n    if a == b:\n        same += 1\n    else:\n        different += 1\nprint(min(same, k) + min(different, (len(y) - k)))\n
"},{"location":"solutions/#expected-earnings","title":"Expected Earnings","text":"Solution in Python Python
n, k, p = input().split()\nn = int(n)\nk = int(k)\np = float(p)\nev = n * p - k\nif ev < 0:\n    print(\"spela\")\nelse:\n    print(\"spela inte!\")\n
"},{"location":"solutions/#eye-of-sauron","title":"Eye of Sauron","text":"Solutions in 2 languages GoPython
package main\n\nimport (\n    \"fmt\"\n    \"strings\"\n)\n\nfunc main() {\n    var drawing string\n    fmt.Scan(&drawing)\n    parts := strings.Split(drawing, \"()\")\n    left, right := parts[0], parts[1]\n    if left == right {\n        fmt.Println(\"correct\")\n    } else {\n        fmt.Println(\"fix\")\n    }\n}\n
drawing = input()\nleft, right = drawing.split(\"()\")\nif left == right:\n    print(\"correct\")\nelse:\n    print(\"fix\")\n
"},{"location":"solutions/#fading-wind","title":"Fading Wind","text":"Solution in Python Python
h, k, v, s = [int(d) for d in input().split()]\nt = 0\nwhile h > 0:\n    v += s\n    v -= max(1, v // 10)\n    if v >= k:\n        h += 1\n    elif v > 0:\n        h -= 1\n        if not h:\n            v = 0\n    else:\n        h = 0\n        v = 0\n    t += v\n    if s > 0:\n        s -= 1\nprint(t)\n
"},{"location":"solutions/#faktor","title":"Faktor","text":"Solution in Python Python
a, i = [int(d) for d in input().split()]\nprint(a * (i - 1) + 1)\n
"},{"location":"solutions/#falling-apart","title":"Falling Apart","text":"Solution in Python Python
n = int(input())\na = sorted([int(d) for d in input().split()], reverse=True)\nprint(\n    sum([a[i] for i in range(0, n, 2)]),\n    sum([a[i] for i in range(1, n, 2)]),\n)\n
"},{"location":"solutions/#false-sense-of-security","title":"False Sense of Security","text":"Solution in Python Python
encoding = {\n    \"A\": \".-\",\n    \"B\": \"-...\",\n    \"C\": \"-.-.\",\n    \"D\": \"-..\",\n    \"E\": \".\",\n    \"F\": \"..-.\",\n    \"G\": \"--.\",\n    \"H\": \"....\",\n    \"I\": \"..\",\n    \"J\": \".---\",\n    \"K\": \"-.-\",\n    \"L\": \".-..\",\n    \"M\": \"--\",\n    \"N\": \"-.\",\n    \"O\": \"---\",\n    \"P\": \".--.\",\n    \"Q\": \"--.-\",\n    \"R\": \".-.\",\n    \"S\": \"...\",\n    \"T\": \"-\",\n    \"U\": \"..-\",\n    \"V\": \"...-\",\n    \"W\": \".--\",\n    \"X\": \"-..-\",\n    \"Y\": \"-.--\",\n    \"Z\": \"--..\",\n    \"_\": \"..--\",\n    \",\": \".-.-\",\n    \".\": \"---.\",\n    \"?\": \"----\",\n}\n\ndecoding = dict([(v, k) for k, v in encoding.items()])\n\nwhile True:\n    try:\n        encoded = input()\n    except:\n        break\n    length = [len(encoding[c]) for c in encoded]\n    morse = \"\".join([encoding[c] for c in encoded])\n\n    ans, s = \"\", 0\n    for i in reversed(length):\n        ans += decoding[morse[s : s + i]]\n        s += i\n    print(ans)\n
"},{"location":"solutions/#fast-food-prizes","title":"Fast Food Prizes","text":"Solution in Python Python
for _ in range(int(input())):\n    n, m = [int(d) for d in input().split()]\n    r = []\n    for _ in range(n):\n        s = input().split()\n        p = int(s[-1])\n        k = [int(d) for d in s[1:-1]]\n        r.append((k, p))\n    s = [int(d) for d in input().split()]\n\n    ans = 0\n    for t, p in r:\n        c = min([s[d - 1] for d in t])\n        ans += p * c\n\n    print(ans)\n
"},{"location":"solutions/#fbi-universal-control-numbers","title":"FBI Universal Control Numbers","text":"Solution in Python Python
m = {\n    \"0\": 0,\n    \"1\": 1,\n    \"2\": 2,\n    \"3\": 3,\n    \"4\": 4,\n    \"5\": 5,\n    \"6\": 6,\n    \"7\": 7,\n    \"8\": 8,\n    \"9\": 9,\n    \"A\": 10,\n    \"B\": 8,\n    \"C\": 11,\n    \"D\": 12,\n    \"E\": 13,\n    \"F\": 14,\n    \"G\": 11,\n    \"H\": 15,\n    \"I\": 1,\n    \"J\": 16,\n    \"K\": 17,\n    \"L\": 18,\n    \"M\": 19,\n    \"N\": 20,\n    \"O\": 0,\n    \"P\": 21,\n    \"Q\": 0,\n    \"R\": 22,\n    \"S\": 5,\n    \"T\": 23,\n    \"U\": 24,\n    \"V\": 24,\n    \"W\": 25,\n    \"X\": 26,\n    \"Y\": 24,\n    \"Z\": 2,\n}\nw = [2, 4, 5, 7, 8, 10, 11, 13]\n\nfor _ in range(int(input())):\n    i, d = input().split()\n    t = sum([m[b] * a for a, b in zip(w, d)])\n    if t % 27 == m[d[-1]]:\n        s = sum([m[b] * 27**a for a, b in zip(range(8), d[:8][::-1])])\n        print(f\"{i} {s}\")\n    else:\n        print(f\"{i} Invalid\")\n
"},{"location":"solutions/#framtiar-fifa","title":"Framt\u00ed\u00f0ar FIFA","text":"Solution in Python Python
n = int(input())\nm = int(input())\nprint(2022 + n // m)\n
"},{"location":"solutions/#fifty-shades-of-pink","title":"Fifty Shades of Pink","text":"Solution in Python Python
total = 0\nfor _ in range(int(input())):\n    button = input().lower()\n    if \"pink\" in button or \"rose\" in button:\n        total += 1\nif not total:\n    print(\"I must watch Star Wars with my daughter\")\nelse:\n    print(total)\n
"},{"location":"solutions/#filip","title":"Filip","text":"Solution in Python Python
a, b = input().split()\na, b = a[::-1], b[::-1]\nif a > b:\n    print(a)\nelse:\n    print(b)\n
"},{"location":"solutions/#final-exam","title":"Final Exam","text":"Solution in Python Python
n = int(input())\nans, score = [], 0\nfor i in range(n):\n    ans.append(input())\n    if i == 0:\n        continue\n    if ans[i] == ans[i - 1]:\n        score += 1\nprint(score)\n
"},{"location":"solutions/#finding-an-a","title":"Finding An A","text":"Solutions in 3 languages C++GoPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    string a;\n    cin >> a;\n\n    int found = a.find_first_of(\"a\");\n\n    cout << a.substr(found);\n\n    return 0;\n}\n
package main\n\nimport (\n    \"fmt\"\n    \"strings\"\n)\n\nfunc main() {\n    var s string\n    fmt.Scan(&s)\n    index := strings.Index(s, \"a\")\n    fmt.Println(s[index:])\n}\n
word = input()\nprint(word[word.find(\"a\") :])\n
"},{"location":"solutions/#fizzbuzz","title":"FizzBuzz","text":"Solution in Python Python
x, y, n = [int(d) for d in input().split()]\nfor i in range(1, n + 1):\n    ans = \"\"\n    if not i % x:\n        ans += \"Fizz\"\n    if not i % y:\n        ans += \"Buzz\"\n    if not ans:\n        ans = i\n    print(ans)\n
"},{"location":"solutions/#flatbokuveisla","title":"Flatb\u00f6kuveisla","text":"Solutions in 2 languages LuaPython
m = io.read(\"*n\")\nn = io.read(\"*n\")\nprint(m % n)\n
n = int(input())\nm = int(input())\nprint(n - n // m * m)\n
"},{"location":"solutions/#flexible-spaces","title":"Flexible Spaces","text":"Solution in Python Python
w, p = [int(d) for d in input().split()]\nl = [int(d) for d in input().split()]\nl = [0] + l + [w]\nc = set()\nfor i in range(p + 1):\n    for j in range(i + 1, p + 2):\n        c.add(l[j] - l[i])\nprint(\" \".join([str(d) for d in sorted(c)]))\n
"},{"location":"solutions/#flytibaka","title":"Fl\u00fdtibaka","text":"Solutions in 11 languages C++GoHaskellJavaJuliaJavaScriptKotlinLuaPythonRubyRust
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    cout << \"\";\n    return 0;\n}\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n    fmt.Println(\"\")\n}\n
main = do\n    putStrLn \"\"\n
class Flytibaka {\n    public static void main(String[] args) {\n        System.out.println(\"\");\n    }\n}\n
print()\n
console.log(\"\");\n
fun main() {\n    println(\"\")\n}\n
print()\n
print()\n
puts \"\"\n
fn main() {\n    println!(\"\");\n}\n
"},{"location":"solutions/#birthday-memorization","title":"Birthday Memorization","text":"Solution in Python Python
n = int(input())\nrecords = {}\nfor _ in range(n):\n    s, c, date = input().split()\n    c = int(c)\n    date = \"\".join(date.split(\"/\")[::-1])\n    if date not in records:\n        records[date] = (s, c)\n    else:\n        _, _c = records[date]\n        if c > _c:\n            records[date] = (s, c)\nprint(len(records.keys()))\nordered_keys = sorted(records, key=lambda k: records[k][0])\nfor key in ordered_keys:\n    print(records[key][0])\n
"},{"location":"solutions/#forced-choice","title":"Forced Choice","text":"Solution in Python Python
_, p, s = input().split()\nfor _ in range(int(s)):\n    if p in input().split()[1:]:\n        print(\"KEEP\")\n    else:\n        print(\"REMOVE\")\n
"},{"location":"solutions/#free-food","title":"Free Food","text":"Solution in Python Python
n = int(input())\ndays = set()\nfor _ in range(n):\n    start, end = [int(d) for d in input().split()]\n    days.update(range(start, end + 1))\nprint(len(days))\n
"},{"location":"solutions/#from-a-to-b","title":"From A to B","text":"Solution in Python Python
a, b = [int(d) for d in input().split()]\n\nif a <= b:\n    print(b - a)\nelse:\n    total = 0\n    while a > b:\n        if a % 2:\n            a += 1\n            total += 1\n        a /= 2\n        total += 1\n    total += b - a\n    print(int(total))\n
"},{"location":"solutions/#fyi","title":"FYI","text":"Solutions in 3 languages GoPythonRuby
package main\n\nimport (\n    \"fmt\"\n    \"strings\"\n)\n\nfunc main() {\n    var s string\n    fmt.Scan(&s)\n    if strings.HasPrefix(s, \"555\") {\n        fmt.Println(1)\n    } else {\n        fmt.Println(0)\n    }\n}\n
if input().startswith(\"555\"):\n    print(1)\nelse:\n    print(0)\n
s = gets\nif s.start_with?(\"555\")\n    puts 1\nelse\n    puts 0\nend\n
"},{"location":"solutions/#gandalfs-spell","title":"Gandalf's Spell","text":"Solution in Python Python
c = list(input())\ns = input().split()\nif len(c) != len(s):\n    print(\"False\")\nelse:\n    d, valid = {}, True\n    for a, b in zip(c, s):\n        if a not in d:\n            d[a] = b\n        else:\n            if d[a] != b:\n                print(\"False\")\n                valid = False\n                break\n    if valid:\n        if len(set(d.keys())) == len(set(d.values())):\n            print(\"True\")\n        else:\n            print(\"False\")\n
"},{"location":"solutions/#gcd","title":"GCD","text":"Solution in Python Python
import math\n\na, b = [int(d) for d in input().split()]\n\nprint(math.gcd(a, b))\n
"},{"location":"solutions/#gcvwr","title":"GCVWR","text":"Solution in Python Python
g, t, n = [int(d) for d in input().split()]\ncapacity = (g - t) * 0.9\nitems = sum([int(d) for d in input().split()])\nprint(int(capacity - items))\n
"},{"location":"solutions/#gene-block","title":"Gene Block","text":"Solution in Python Python
mapping = {\n    1: 3,\n    2: 6,\n    3: 9,\n    4: 2,\n    5: 5,\n    6: 8,\n    7: 1,\n    8: 4,\n    9: 7,\n    0: 10,\n}\n\nfor _ in range(int(input())):\n    n = int(input())\n    d = n % 10\n\n    if n >= 7 * mapping[d]:\n        print(mapping[d])\n    else:\n        print(-1)\n
"},{"location":"solutions/#gerrymandering","title":"Gerrymandering","text":"Solution in Python Python
p, _ = [int(d) for d in input().split()]\nvotes = {}\nfor _ in range(p):\n    d, a, b = [int(d) for d in input().split()]\n    if d not in votes:\n        votes[d] = {\"A\": a, \"B\": b}\n    else:\n        votes[d][\"A\"] += a\n        votes[d][\"B\"] += b\n\ntotal_wa, total_wb = 0, 0\nfor d in sorted(votes):\n    total = votes[d][\"A\"] + votes[d][\"B\"]\n    t = total // 2 + 1\n    winner = \"A\" if votes[d][\"A\"] > votes[d][\"B\"] else \"B\"\n    wa = votes[d][\"A\"] - t if votes[d][\"A\"] > votes[d][\"B\"] else votes[d][\"A\"]\n    wb = votes[d][\"B\"] - t if votes[d][\"B\"] > votes[d][\"A\"] else votes[d][\"B\"]\n    print(winner, wa, wb)\n    total_wa += wa\n    total_wb += wb\nv = sum([sum(ab.values()) for ab in votes.values()])\nprint(abs(total_wa - total_wb) / v)\n
"},{"location":"solutions/#glasses-foggy-moms-spaghetti","title":"Glasses Foggy, Mom's Spaghetti","text":"Solution in Python Python
import math\n\nd, x, y, h = input().split()\nd = int(d)\nx = int(x)\ny = int(y)\nh = int(h)\n\nangle1 = (math.atan(y / x)) - (math.atan((y - h / 2) / x))\nangle2 = (math.atan((y + h / 2) / x)) - (math.atan(y / x))\n\nd1 = math.tan(angle1) * d\nd2 = math.tan(angle2) * d\n\nprint(d1 + d2)\n
"},{"location":"solutions/#goat-rope","title":"Goat Rope","text":"Solution in Python Python
x, y, x1, y1, x2, y2 = [int(d) for d in input().split()]\n\nif x >= x1 and x <= x2:\n    print(min(abs(y - y1), abs(y - y2)))\nelif y >= y1 and y <= y2:\n    print(min(abs(x - x1), abs(x - x2)))\nelse:\n    x3, y3 = x1, y2\n    x4, y4 = x2, y1\n    l = [\n        ((x - a) ** 2 + (y - b) ** 2) ** 0.5\n        for a, b in [(x1, y1), (x2, y2), (x1, y2), (x2, y1)]\n    ]\n    print(min(l))\n
"},{"location":"solutions/#goomba-stacks","title":"Goomba Stacks","text":"Solution in Python Python
n = int(input())\ntotal = 0\nresult = True\nfor _ in range(n):\n    g, b = [int(d) for d in input().split()]\n    total += g\n    if total < b:\n        result = False\nprint(\"possible\" if result else \"impossible\")\n
"},{"location":"solutions/#grading","title":"Grading","text":"Solution in Python Python
line = input()\nscore = int(input())\na, b, c, d, e = [int(d) for d in line.split()]\nif score >= a:\n    print(\"A\")\nelif score >= b:\n    print(\"B\")\nelif score >= c:\n    print(\"C\")\nelif score >= d:\n    print(\"D\")\nelif score >= e:\n    print(\"E\")\nelse:\n    print(\"F\")\n
"},{"location":"solutions/#grass-seed-inc","title":"Grass Seed Inc.","text":"Solution in Python Python
c = float(input())\ntotal = 0\nfor _ in range(int(input())):\n    w, l = [float(d) for d in input().split()]\n    total += c * w * l\nprint(f\"{total:.7f}\")\n
"},{"location":"solutions/#greedily-increasing-subsequence","title":"Greedily Increasing Subsequence","text":"Solution in Python Python
n = int(input())\na = [int(d) for d in input().split()]\n\ng = [a[0]]\nfor i in range(1, n):\n    v = a[i]\n    if v > g[-1]:\n        g.append(v)\nprint(len(g))\nprint(\" \".join([str(d) for d in g]))\n
"},{"location":"solutions/#greedy-polygons","title":"Greedy Polygons","text":"Solution in Python Python
import math\n\nfor _ in range(int(input())):\n    n, l, d, g = [int(d) for d in input().split()]\n    a = n * l * l / (4 * math.tan(math.pi / n))\n    a += n * l * d * g\n    a += math.pi * ((d * g) ** 2)\n    print(a)\n
"},{"location":"solutions/#greetings","title":"Greetings!","text":"Solution in Python Python
print(input().replace(\"e\", \"ee\"))\n
"},{"location":"solutions/#guess-the-number","title":"Guess the Number","text":"Solution in Python Python
start, end = 1, 1000\nwhile True:\n    guess = (start + end) // 2\n    print(guess)\n    resp = input()\n    if resp == \"correct\":\n        break\n    elif resp == \"higher\":\n        start = guess + 1\n    else:\n        end = guess\n
"},{"location":"solutions/#guess-who","title":"Guess Who","text":"Solution in Python Python
n, m, q = [int(d) for d in input().split()]\nM = []\nfor _ in range(n):\n    M.append(input())\nQ = []\nfor _ in range(q):\n    Q.append(input().split())\nans = [all([c[int(i) - 1] == v for i, v in Q]) for c in M]\nif sum(ans) > 1:\n    print(\"ambiguous\")\n    print(sum(ans))\nelse:\n    print(\"unique\")\n    print(ans.index(True) + 1)\n
"},{"location":"solutions/#watch-out-for-those-hailstones","title":"Watch Out For Those Hailstones!","text":"Solutions in 2 languages GoPython
package main\n\nimport (\n    \"fmt\"\n)\n\nfunc h(n int) int {\n    if n == 1 {\n        return 1\n    } else if n%2 == 0 {\n        return n + h(n/2)\n    } else {\n        return n + h(3*n+1)\n    }\n}\n\nfunc main() {\n    var n int\n    fmt.Scan(&n)\n    fmt.Println(h(n))\n}\n
def h(n):\n    if n == 1:\n        return 1\n    else:\n        return n + (h(n // 2) if n % 2 == 0 else h(3 * n + 1))\n\n\nn = int(input())\nprint(h(n))\n
"},{"location":"solutions/#hailstone-sequences","title":"Hailstone Sequences","text":"Solution in Python Python
n = int(input())\ns = [n]\nwhile True:\n    v = s[-1]\n    if v == 1:\n        break\n    elif v % 2 == 0:\n        s.append(v // 2)\n    else:\n        s.append(3 * v + 1)\nprint(len(s))\n
"},{"location":"solutions/#half-a-cookie","title":"Half a Cookie","text":"Solution in Python Python
import math\n\nwhile True:\n    try:\n        r, x, y = [float(d) for d in input().split()]\n    except:\n        break\n    if x**2 + y**2 >= r**2:\n        print(\"miss\")\n    else:\n        # https://mathworld.wolfram.com/CircularSegment.html\n        d = math.sqrt(x**2 + y**2)\n        h = r - d\n        a = math.acos((r - h) / r)\n        t = (r - h) * math.sqrt(2 * r * h - h * h)\n        p = (r**2) * a\n        s = p - t\n        print(math.pi * (r**2) - s, s)\n
"},{"location":"solutions/#hanging-out-on-the-terrace","title":"Hanging Out on the Terrace","text":"Solution in Python Python
l, x = [int(d) for d in input().split()]\no, r = 0, 0\nfor _ in range(x):\n    action, n = input().split()\n    n = int(n)\n    if action == \"leave\":\n        o -= n\n    elif action == \"enter\":\n        if o + n > l:\n            r += 1\n        else:\n            o += n\nprint(r)\n
"},{"location":"solutions/#hangman","title":"Hangman","text":"Solution in Python Python
word = set(list(input()))\nguess = input()\ntries = 0\ncorrect = 0\nfor c in guess:\n    if c in word:\n        correct += 1\n    else:\n        tries += 1\n\n    if correct == len(word):\n        break\n\nif tries >= 10:\n    print(\"LOSE\")\nelse:\n    print(\"WIN\")\n
"},{"location":"solutions/#harshad-numbers","title":"Harshad Numbers","text":"Solution in Python Python
n = int(input())\nwhile True:\n    sd = sum([int(d) for d in str(n)])\n    if not n % sd:\n        break\n    n += 1\nprint(n)\n
"},{"location":"solutions/#haughty-cuisine","title":"Haughty Cuisine","text":"Solution in Python Python
from random import randint\n\nn = int(input())\nmenu = []\nfor _ in range(n):\n    menu.append(input().split())\n\nprint(\"\\n\".join(menu[randint(0, n - 1)]))\n
"},{"location":"solutions/#head-guard","title":"Head Guard","text":"Solution in Python Python
while True:\n    try:\n        s = input()\n    except:\n        break\n    parts = []\n    prev, t = s[0], 1\n    for c in s[1:]:\n        if c != prev:\n            parts.append((prev, t))\n            t = 1\n            prev = c\n        else:\n            t += 1\n    parts.append((prev, t))\n    print(\"\".join([f\"{v}{k}\" for k, v in parts]))\n
"},{"location":"solutions/#heart-rate","title":"Heart Rate","text":"Solution in Python Python
for _ in range(int(input())):\n    b, p = [float(d) for d in input().split()]\n    min_abpm = 60 / p * (b - 1)\n    bpm = 60 * b / p\n    max_abpm = 60 / p * (b + 1)\n    print(f\"{min_abpm:.4f} {bpm:.4f} {max_abpm:.4f}\")\n
"},{"location":"solutions/#homework","title":"Homework","text":"Solution in Python Python
total = 0\nparts = input().split(\";\")\nfor part in parts:\n    ranges = part.split(\"-\")\n    if len(ranges) == 1:\n        total += 1\n    else:\n        total += len(range(int(ranges[0]), int(ranges[1]))) + 1\nprint(total)\n
"},{"location":"solutions/#heirs-dilemma","title":"Heir's Dilemma","text":"Solution in Python Python
l, h = [int(d) for d in input().split()]\ntotal = 0\nfor i in range(l, h + 1):\n    digits = set(str(i))\n    if len(digits) != 6 or \"0\" in digits:\n        continue\n    if not all([i % int(d) == 0 for d in digits]):\n        continue\n    total += 1\nprint(total)\n
"},{"location":"solutions/#heliocentric","title":"Heliocentric","text":"Solution in Python Python
def offset(d, b):\n    return (b - d % b) % b\n\n\ncc = 1\nwhile True:\n    try:\n        a, b = [int(d) for d in input().split()]\n    except:\n        break\n\n    offset_a, offset_b = offset(a, 365), offset(b, 687)\n\n    if offset_a == offset_b:\n        print(f\"Case {cc}:\", offset_a)\n    else:\n        t = offset_a\n        while True:\n            t += 365\n            if (offset(t, 687) + offset_b) % 687 == 0:\n                break\n        print(f\"Case {cc}:\", t)\n\n    cc += 1\n
"},{"location":"solutions/#hello-world","title":"Hello World!","text":"Solutions in 11 languages C++GoHaskellJavaJuliaJavaScriptKotlinLuaPythonRubyRust
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    cout << \"Hello World!\" << endl;\n\n    return 0;\n}\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n    fmt.Println(\"Hello World!\")\n}\n
main = putStrLn \"Hello World!\"\n
class HelloWorld {\n    public static void main(String[] args) {\n        System.out.println(\"Hello World!\");\n    }\n}\n
print(\"Hello World!\")\n
console.log(\"Hello World!\");\n
fun main() {\n    println(\"Hello World!\")\n}\n
print(\"Hello World!\")\n
print(\"Hello World!\")\n
puts \"Hello World!\"\n
fn main() {\n    println!(\"Hello World!\");\n}\n
"},{"location":"solutions/#help-a-phd-candidate-out","title":"Help a PhD candidate out!","text":"Solution in Python Python
n = int(input())\nfor _ in range(n):\n    line = input()\n    parts = line.split(\"+\")\n    if len(parts) == 1:\n        print(\"skipped\")\n    else:\n        print(int(parts[0]) + int(parts[1]))\n
"},{"location":"solutions/#herman","title":"Herman","text":"Solution in Python Python
import math\n\nr = int(input())\nprint(f\"{math.pi*r*r:.6f}\")\nprint(2 * r * r)\n
"},{"location":"solutions/#heroes-of-velmar","title":"Heroes of Velmar","text":"Solution in Python Python
m = {\n    \"Shadow\": 6,\n    \"Gale\": 5,\n    \"Ranger\": 4,\n    \"Anvil\": 7,\n    \"Vexia\": 3,\n    \"Guardian\": 8,\n    \"Thunderheart\": 6,\n    \"Frostwhisper\": 2,\n    \"Voidclaw\": 3,\n    \"Ironwood\": 3,\n    \"Zenith\": 4,\n    \"Seraphina\": 1,\n}\n\n\ndef calculate(heros, location):\n    boost = 0\n\n    if \"Seraphina\" in heros:\n        boost += heros.count(\"Seraphina\") * (len(heros) - 1)\n\n    if location == \"center\":\n        boost += heros.count(\"Zenith\") * 5\n\n    if len(heros) == 4:\n        boost += m[\"Thunderheart\"] * heros.count(\"Thunderheart\")\n\n    return sum([m[h] for h in heros]) + boost\n\n\nl1 = calculate(input().split()[1:], \"left\")\nl2 = calculate(input().split()[1:], \"left\")\nc1 = calculate(input().split()[1:], \"center\")\nc2 = calculate(input().split()[1:], \"center\")\nr1 = calculate(input().split()[1:], \"right\")\nr2 = calculate(input().split()[1:], \"right\")\n\ns1, s2 = 0, 0\n\nif l1 > l2:\n    s1 += 1\nelif l1 < l2:\n    s2 += 1\n\nif c1 > c2:\n    s1 += 1\nelif c1 < c2:\n    s2 += 1\n\nif r1 > r2:\n    s1 += 1\nelif r1 < r2:\n    s2 += 1\n\nif s1 > s2:\n    print(\"Player 1\")\nelif s1 < s2:\n    print(\"Player 2\")\nelse:\n    if l1 + c1 + r1 > l2 + c2 + r2:\n        print(\"Player 1\")\n    elif l1 + c1 + r1 < l2 + c2 + r2:\n        print(\"Player 2\")\n    else:\n        print(\"Tie\")\n
"},{"location":"solutions/#hissing-microphone","title":"Hissing Microphone","text":"Solutions in 3 languages C++JavaScriptPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    string a;\n    cin >> a;\n\n    if (a.find(\"ss\") == -1)\n    {\n        cout << \"no hiss\" << endl;\n    }\n    else\n    {\n        cout << \"hiss\" << endl;\n    }\n\n    return 0;\n}\n
const readline = require(\"readline\");\nconst rl = readline.createInterface(process.stdin, process.stdout);\n\nrl.question(\"\", (line) => {\n  if (line.includes(\"ss\")) {\n    console.log(\"hiss\");\n  } else {\n    console.log(\"no hiss\");\n  }\n});\n
a = input()\nif \"ss\" in a:\n    print(\"hiss\")\nelse:\n    print(\"no hiss\")\n
"},{"location":"solutions/#hitting-the-targets","title":"Hitting the Targets","text":"Solution in Python Python
def in_rectangle(x1, y1, x2, y2, x, y):\n    x1, x2 = min(x1, x2), max(x1, x2)\n    y1, y2 = min(y1, y2), max(y1, y2)\n    if x in range(x1, x2 + 1) and y in range(y1, y2 + 1):\n        return True\n    else:\n        return False\n\n\ndef in_circle(x0, y0, r, x, y):\n    return (x0 - x) ** 2 + (y0 - y) ** 2 <= r**2\n\n\nm = int(input())\nshapes = []\nfor _ in range(m):\n    values = input().split()\n    shapes.append((values[0], *[int(d) for d in values[1:]]))\n\nn = int(input())\nfor _ in range(n):\n    total = 0\n    x, y = [int(d) for d in input().split()]\n    for shape in shapes:\n        if shape[0] == \"rectangle\":\n            total += in_rectangle(*shape[1:], x, y)\n        elif shape[0] == \"circle\":\n            total += in_circle(*shape[1:], x, y)\n    print(total)\n
"},{"location":"solutions/#hot-hike","title":"Hot Hike","text":"Solution in Python Python
n = int(input())\nt = [int(d) for d in input().split()]\norder = sorted(range(n - 2), key=lambda k: max(t[k], t[k + 2]))\nd = order[0]\nv = max(t[d], t[d + 2])\nprint(d + 1, v)\n
"},{"location":"solutions/#hragreining","title":"Hra\u00f0greining","text":"Solutions in 2 languages GoPython
package main\n\nimport (\n    \"fmt\"\n    \"strings\"\n)\n\nfunc main() {\n    var s string\n    fmt.Scan(&s)\n    if strings.Contains(s, \"COV\") {\n        fmt.Println(\"Veikur!\")\n    } else {\n        fmt.Println(\"Ekki veikur!\")\n    }\n}\n
print(\"Veikur!\" if \"COV\" in input() else \"Ekki veikur!\")\n
"},{"location":"solutions/#the-amazing-human-cannonball","title":"The Amazing Human Cannonball","text":"Solution in Python Python
import math\n\nfor _ in range(int(input())):\n    v0, a, x1, h1, h2 = [float(d) for d in input().split()]\n    a = math.radians(a)\n    t = x1 / (v0 * math.cos(a))\n    y = v0 * t * math.sin(a) - 0.5 * 9.81 * (t**2)\n    if y < h1 + 1 or y > h2 - 1:\n        print(\"Not Safe\")\n    else:\n        print(\"Safe\")\n
"},{"location":"solutions/#hvert-skal-mta","title":"Hvert Skal M\u00e6ta?","text":"Solution in Python Python
mapping = {\n    \"Reykjavik\": \"Reykjavik\",\n    \"Kopavogur\": \"Reykjavik\",\n    \"Hafnarfjordur\": \"Reykjavik\",\n    \"Reykjanesbaer\": \"Reykjavik\",\n    \"Akureyri\": \"Akureyri\",\n    \"Gardabaer\": \"Reykjavik\",\n    \"Mosfellsbaer\": \"Reykjavik\",\n    \"Arborg\": \"Reykjavik\",\n    \"Akranes\": \"Reykjavik\",\n    \"Fjardabyggd\": \"Akureyri\",\n    \"Mulathing\": \"Akureyri\",\n    \"Seltjarnarnes\": \"Reykjavik\",\n}\nprint(mapping[input()])\n
"},{"location":"solutions/#icpc-awards","title":"ICPC Awards","text":"Solution in Python Python
n = int(input())\nshown = {}\nfor _ in range(n):\n    u, t = input().split()\n    if u not in shown and len(shown.keys()) < 12:\n        print(u, t)\n        shown[u] = True\n
"},{"location":"solutions/#illuminati-spotti","title":"Illuminati Spotti","text":"Solution in Python Python
n = int(input())\nm = []\nfor _ in range(n):\n    m.append(input().split())\ntotal = 0\nfor i in range(1, n - 1):\n    for j in range(i):\n        for k in range(i + 1, n):\n            if m[i][j] == m[k][j] == m[k][i] == \"1\":\n                total += 1\nprint(total)\n
"},{"location":"solutions/#inheritance","title":"Inheritance","text":"Solution in Python Python
from itertools import product\n\np = input()\nans = []\nfor i in range(len(p)):\n    for t in product(\"24\", repeat=i + 1):\n        if int(p) % int(\"\".join(t)) == 0:\n            ans.append(int(\"\".join(t)))\nprint(\"\\n\".join([str(d) for d in sorted(ans)]))\n
"},{"location":"solutions/#international-dates","title":"International Dates","text":"Solution in Python Python
aa, bb, _ = [int(d) for d in input().split(\"/\")]\n\nif aa > 12 and bb <= 12:\n    print(\"EU\")\nelif aa <= 12 and bb > 12:\n    print(\"US\")\nelse:\n    print(\"either\")\n
"},{"location":"solutions/#i-repeat-myself-i-repeat-myself-i-repeat","title":"I Repeat Myself I Repeat Myself I Repeat","text":"Solution in Python Python
import math\n\nfor _ in range(int(input())):\n    s = input()\n    for n in range(1, len(s) + 1):\n        if (s[:n] * math.ceil(len(s) / n)).startswith(s):\n            print(n)\n            break\n
"},{"location":"solutions/#is-it-even","title":"Is It Even?","text":"Solution in Python Python
n, k = [int(d) for d in input().split()]\n\nfor _ in range(n):\n    x = int(input())\n    while True:\n        if x % 2 == 0:\n            x //= 2\n            k -= 1\n        else:\n            break\n    if k <= 0:\n        break\n\nprint(0 if k > 0 else 1)\n
"},{"location":"solutions/#isithalloweencom","title":"IsItHalloween.com","text":"Solutions in 2 languages GoPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var m, d string\n    fmt.Scan(&m)\n    fmt.Scan(&d)\n    if (m == \"OCT\" && d == \"31\") || (m == \"DEC\" && d == \"25\") {\n        fmt.Println(\"yup\")\n    } else {\n        fmt.Println(\"nope\")\n    }\n}\n
m, d = input().split()\nif (m == \"OCT\" and d == \"31\") or (m == \"DEC\" and d == \"25\"):\n    print(\"yup\")\nelse:\n    print(\"nope\")\n
"},{"location":"solutions/#jabuke","title":"Jabuke","text":"Solution in Python Python
xa, ya = [int(d) for d in input().split()]\nxb, yb = [int(d) for d in input().split()]\nxc, yc = [int(d) for d in input().split()]\nn = int(input())\narea = abs(xa * (yb - yc) + xb * (yc - ya) + xc * (ya - yb)) / 2\nprint(f\"{area:.1f}\")\n\n\ndef sign(x1, y1, x2, y2, x3, y3):\n    return (x1 - x3) * (y2 - y3) - (x2 - x3) * (y1 - y3)\n\n\ndef in_triangle(x, y, x1, y1, x2, y2, x3, y3):\n    d1 = sign(x, y, x1, y1, x2, y2)\n    d2 = sign(x, y, x2, y2, x3, y3)\n    d3 = sign(x, y, x3, y3, x1, y1)\n\n    has_neg = d1 < 0 or d2 < 0 or d3 < 0\n    has_pos = d1 > 0 or d2 > 0 or d3 > 0\n\n    return not (has_neg and has_pos)\n\n\ntotal = 0\nfor _ in range(n):\n    x, y = [int(d) for d in input().split()]\n    if in_triangle(x, y, xa, ya, xb, yb, xc, yc):\n        total += 1\nprint(total)\n
"},{"location":"solutions/#jack-o-lantern-juxtaposition","title":"Jack-O'-Lantern Juxtaposition","text":"Solution in Python Python
numbers = [int(n) for n in input().split()]\nresult = 1\nfor n in numbers:\n    result *= n\nprint(result)\n
"},{"location":"solutions/#janitor-troubles","title":"Janitor Troubles","text":"Solution in Python Python
import math\n\na, b, c, d = [int(d) for d in input().split()]\ns = (a + b + c + d) / 2\nprint(math.sqrt((s - a) * (s - b) * (s - c) * (s - d)))\n
"},{"location":"solutions/#jewelry-box","title":"Jewelry Box","text":"Solution in Python Python
def f(h):\n    a = x - 2 * h\n    b = y - 2 * h\n    return a * b * h\n\n\nfor _ in range(int(input())):\n    x, y = [int(d) for d in input().split()]\n    h = (x + y - ((x + y) ** 2 - 3 * x * y) ** 0.5) / 6\n    print(f\"{f(h):.11f}\")\n
"},{"location":"solutions/#job-expenses","title":"Job Expenses","text":"Solution in Python Python
_ = input()\nprint(-sum([int(d) for d in input().split() if \"-\" in d]))\n
"},{"location":"solutions/#joint-jog-jam","title":"Joint Jog Jam","text":"Solution in Python Python
import math\n\n\ndef dist(x1, y1, x2, y2):\n    return math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)\n\n\ncoords = [int(d) for d in input().split()]\nprint(max(dist(*coords[:4]), dist(*coords[4:])))\n
"},{"location":"solutions/#judging-moose","title":"Judging Moose","text":"Solutions in 2 languages GoPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var l, r int\n    fmt.Scan(&l)\n    fmt.Scan(&r)\n    if l == 0 && r == 0 {\n        fmt.Println(\"Not a moose\")\n    } else {\n        p := 2 * l\n        if r > l {\n            p = 2 * r\n        }\n        t := \"Odd\"\n        if l == r {\n            t = \"Even\"\n        }\n        fmt.Println(t, p)\n    }\n}\n
l, r = [int(d) for d in input().split()]\nif not l and not r:\n    print(\"Not a moose\")\nelse:\n    p = 2 * max(l, r)\n    print(\"Odd\" if l != r else \"Even\", p)\n
"},{"location":"solutions/#jumbo-javelin","title":"Jumbo Javelin","text":"Solution in Python Python
n = int(input())\nlength = 0\nfor _ in range(n):\n    length += int(input())\nlength -= n - 1\nprint(length)\n
"},{"location":"solutions/#just-a-minute","title":"Just a Minute","text":"Solution in Python Python
a, b = [], []\nfor _ in range(int(input())):\n    x, y = [int(d) for d in input().split()]\n    a.append(x * 60)\n    b.append(y)\nans = sum(b) / sum(a)\nif ans <= 1:\n    ans = \"measurement error\"\nprint(ans)\n
"},{"location":"solutions/#running-race","title":"Running Race","text":"Solution in Python Python
l, k, _ = [int(d) for d in input().split()]\n\nrecord = {}\nfor _ in range(l):\n    i, t = input().split()\n    mm, ss = [int(d) for d in t.split(\".\")]\n    s = mm * 60 + ss\n    if i in record:\n        record[i].append(s)\n    else:\n        record[i] = [s]\n\ndelete = [i for i in record if len(record[i]) != k]\nfor i in delete:\n    record.pop(i)\n\nsorted_i = sorted(record, key=lambda i: (sum(record[i]), int(i)))\nprint(\"\\n\".join(sorted_i))\n
"},{"location":"solutions/#karte","title":"Karte","text":"Solution in Python Python
from collections import Counter\n\ns = input()\ncards = {\n    \"P\": Counter(),\n    \"K\": Counter(),\n    \"H\": Counter(),\n    \"T\": Counter(),\n}\nduplicated = False\nfor i in range(0, len(s), 3):\n    suit = s[i]\n    card = s[i + 1 : i + 3]\n    if cards[suit][card]:\n        duplicated = True\n        break\n    cards[suit][card] += 1\n\nif not duplicated:\n    print(\" \".join([str(13 - len(c)) for c in cards.values()]))\nelse:\n    print(\"GRESKA\")\n
"},{"location":"solutions/#kemija","title":"Kemija","text":"Solutions in 2 languages JavaScriptPython
const readline = require(\"readline\");\nconst rl = readline.createInterface(process.stdin, process.stdout);\n\nrl.question(\"\", (line) => {\n  for (let c of \"aeiou\") {\n    const regex = new RegExp(`${c}p${c}`, \"g\");\n    line = line.replace(regex, c);\n  }\n  console.log(line);\n});\n
s = input()\n\nfor c in \"aeiou\":\n    s = s.replace(f\"{c}p{c}\", c)\n\nprint(s)\n
"},{"location":"solutions/#the-key-to-cryptography","title":"The Key to Cryptography","text":"Solution in Python Python
import string\n\nuppers = string.ascii_uppercase\n\n\ndef decrypt(c, k):\n    index = (uppers.index(c) - uppers.index(k)) % 26\n    return uppers[index]\n\n\nm, w = input(), input()\n\nsize_w = len(w)\nsize_m = len(m)\no = []\nfor i in range(0, size_m, size_w):\n    if i + size_w < size_m:\n        l = zip(m[i : i + size_w], w)\n    else:\n        l = zip(m[i:], w)\n    t = \"\".join([decrypt(c, k) for c, k in l])\n    o.append(t)\n    w = t\nprint(\"\".join(o))\n
"},{"location":"solutions/#keywords","title":"Keywords","text":"Solution in Python Python
keywords = set()\nfor _ in range(int(input())):\n    keywords.add(input().lower().replace(\"-\", \" \"))\nprint(len(keywords))\n
"},{"location":"solutions/#kitten-on-a-tree","title":"Kitten on a Tree","text":"Solution in Python Python
k = input()\nb = []\nwhile True:\n    line = input()\n    if line == \"-1\":\n        break\n    b.append(line.split())\n\np = [k]\nt = k\nwhile True:\n    found = False\n    for row in b:\n        if t in row[1:]:\n            p.append(row[0])\n            found = True\n            t = row[0]\n            break\n    if not found:\n        break\n\nprint(\" \".join(p))\n
"},{"location":"solutions/#kleptography","title":"Kleptography","text":"Solution in Python Python
from string import ascii_lowercase as l\n\n\nn, m = [int(d) for d in input().split()]\np = input()\nc = input()\np = p[::-1]\nc = c[::-1]\n\nans = \"\"\nfor i in range(0, m, n):\n    if i + n < m:\n        part = c[i : i + n]\n    else:\n        part = c[i:]\n\n    ans += p\n    p = \"\".join([l[(l.index(a) - l.index(b)) % 26] for a, b in zip(part, p)])\n\nans += p\nprint(ans[::-1][n:])\n
"},{"location":"solutions/#knight-packing","title":"Knight Packing","text":"Solution in Python Python
if int(input()) % 2:\n    print(\"first\")\nelse:\n    print(\"second\")\n
"},{"location":"solutions/#knot-knowledge","title":"Knot Knowledge","text":"Solution in Python Python
input()\ntotal = set(input().split())\nknown = set(input().split())\nprint((total - known).pop())\n
"},{"location":"solutions/#kornislav","title":"Kornislav","text":"Solution in Python Python
numbers = sorted([int(d) for d in input().split()])\nprint(numbers[0] * numbers[2])\n
"},{"location":"solutions/#krizaljka","title":"Kri\u017ealjka","text":"Solution in Python Python
a, b = input().split()\nfor i in range(len(a)):\n    if a[i] in b:\n        j = b.index(a[i])\n        break\n\nrows = []\n\nfor k in range(j):\n    rows.append(\".\" * i + b[k] + \".\" * (len(a) - i - 1))\n\nrows.append(a)\n\nfor k in range(j + 1, len(b)):\n    rows.append(\".\" * i + b[k] + \".\" * (len(a) - i - 1))\n\nprint(\"\\n\".join(rows))\n
"},{"location":"solutions/#ladder","title":"Ladder","text":"Solution in Python Python
import math\n\nh, v = [int(d) for d in input().split()]\nprint(math.ceil(h / math.sin(math.radians(v))))\n
"},{"location":"solutions/#lamps","title":"Lamps","text":"Solution in Python Python
h, p = [int(d) for d in input().split()]\n\ndays = 0\ncost_bulb, cost_lamp = 5, 60\nused_bulb, used_lamp = 0, 0\n\nwhile True:\n    days += 1\n    cost_bulb += 60 * h * p / 100000\n    cost_lamp += 11 * h * p / 100000\n    used_bulb += h\n    used_lamp += h\n\n    if used_bulb > 1000:\n        cost_bulb += 5\n        used_bulb -= 1000\n\n    if used_lamp > 8000:\n        cost_lamp += 60\n        used_lamp -= 8000\n\n    if cost_bulb > cost_lamp:\n        break\n\nprint(days)\n
"},{"location":"solutions/#laptop-sticker","title":"Laptop Sticker","text":"Solutions in 3 languages C++GoPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int wc, hc, ws, hs;\n    cin >> wc >> hc >> ws >> hs;\n    if (wc - 2 >= ws && hc - 2 >= hs)\n    {\n        cout << 1 << endl;\n    }\n    else\n    {\n        cout << 0 << endl;\n    }\n    return 0;\n}\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var wc, hc, ws, hs int\n    fmt.Scan(&wc)\n    fmt.Scan(&hc)\n    fmt.Scan(&ws)\n    fmt.Scan(&hs)\n    if wc-2 >= ws && hc-2 >= hs {\n\n        fmt.Println(1)\n\n    } else {\n\n        fmt.Println(0)\n\n    }\n}\n
wc, hc, ws, hs = [int(d) for d in input().split()]\nif wc - 2 >= ws and hc - 2 >= hs:\n    print(1)\nelse:\n    print(0)\n
"},{"location":"solutions/#last-factorial-digit","title":"Last Factorial Digit","text":"Solution in Python Python
for _ in range(int(input())):\n    n = int(input())\n    number = 1\n    for i in range(1, n + 1):\n        number *= i\n    print(number % 10)\n
"},{"location":"solutions/#left-beehind","title":"Left Beehind","text":"Solutions in 3 languages GoJavaPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var x, y int\n    for true {\n        fmt.Scan(&x)\n        fmt.Scan(&y)\n        if x == 0 && y == 0 {\n            break\n        }\n        if x+y == 13 {\n            fmt.Println(\"Never speak again.\")\n        } else if x > y {\n            fmt.Println(\"To the convention.\")\n        } else if x == y {\n            fmt.Println(\"Undecided.\")\n        } else {\n            fmt.Println(\"Left beehind.\")\n        }\n    }\n}\n
import java.util.Scanner;\n\nclass LeftBeehind {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        while (true) {\n            int x = s.nextInt();\n            int y = s.nextInt();\n            if (x == 0 && y == 0) {\n                break;\n            }\n            if (x + y == 13) {\n                System.out.println(\"Never speak again.\");\n            } else if (x > y) {\n                System.out.println(\"To the convention.\");\n            } else if (x == y) {\n                System.out.println(\"Undecided.\");\n            } else {\n                System.out.println(\"Left beehind.\");\n            }\n        }\n    }\n}\n
while True:\n    x, y = [int(d) for d in input().split()]\n    if not x and not y:\n        break\n    if x + y == 13:\n        print(\"Never speak again.\")\n    elif x > y:\n        print(\"To the convention.\")\n    elif x == y:\n        print(\"Undecided.\")\n    else:\n        print(\"Left beehind.\")\n
"},{"location":"solutions/#leggja-saman","title":"Leggja saman","text":"Solutions in 2 languages GoPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var n, m int\n    fmt.Scan(&n)\n    fmt.Scan(&m)\n    fmt.Println(n + m)\n}\n
m = int(input())\nn = int(input())\nprint(m + n)\n
"},{"location":"solutions/#license-to-launch","title":"License to Launch","text":"Solution in Python Python
_ = input()\njunks = [int(d) for d in input().split()]\nprint(junks.index(min(junks)))\n
"},{"location":"solutions/#line-them-up","title":"Line Them Up","text":"Solution in Python Python
n = int(input())\nnames = []\nfor _ in range(n):\n    names.append(input())\norder = []\nfor i in range(1, n):\n    order.append(names[i] > names[i - 1])\nif all(order):\n    print(\"INCREASING\")\nelif not any(order):\n    print(\"DECREASING\")\nelse:\n    print(\"NEITHER\")\n
"},{"location":"solutions/#a-list-game","title":"A List Game","text":"Solution in Python Python
import math\n\nx = int(input())\n\np = 1\ntotal = 0\n\nwhile x % 2 == 0:\n    p = 2\n    x /= 2\n    total += 1\n\n\nfor i in range(3, math.ceil(math.sqrt(x)) + 1, 2):\n    while x % i == 0:\n        p = i\n        x /= i\n        total += 1\nif x > 1:\n    total += 1\n\n\nif p == 1:\n    total = 1\n\n\nprint(total)\n
"},{"location":"solutions/#locust-locus","title":"Locust Locus","text":"Solution in Python Python
from math import gcd\n\nn = int(input())\nl = []\nfor _ in range(n):\n    y, c1, c2 = [int(d) for d in input().split()]\n    g = gcd(c1, c2)\n    l.append(y + g * (c1 // g) * (c2 // g))\nprint(min(l))\n
"},{"location":"solutions/#logic-functions","title":"Logic Functions","text":"Solution in C++ C++
#include \"logicfunctions.h\"\n\n// Compute xor\nvoid exclusive(bool x, bool y, bool &ans)\n{\n    ans = x != y;\n}\n\n// Compute implication\nvoid implies(bool x, bool y, bool &ans)\n{\n    if (x && !y)\n    {\n        ans = false;\n    }\n    else\n    {\n        ans = true;\n    }\n}\n\n// Compute equivalence\nvoid equivalence(bool x, bool y, bool &ans)\n{\n    ans = x == y;\n}\n
"},{"location":"solutions/#lost-lineup","title":"Lost Lineup","text":"Solution in Python Python
n = int(input())\norder = [int(d) for d in input().split()]\nd = range(1, n)\norder = dict(zip(d, order))\nranges = range(1, n + 1)\nresult = [\"1\"]\nfor k in sorted(order, key=lambda x: order[x]):\n    result.append(str(ranges[k]))\nprint(\" \".join(result))\n
"},{"location":"solutions/#luhns-checksum-algorithm","title":"Luhn's Checksum Algorithm","text":"Solution in Python Python
for _ in range(int(input())):\n    n = input()[::-1]\n    checksum = 0\n    for i in range(len(n)):\n        s = int(n[i]) * (i % 2 + 1)\n        if s > 9:\n            s = sum([int(d) for d in str(s)])\n        checksum += s\n\n    print(\"FAIL\" if checksum % 10 else \"PASS\")\n
"},{"location":"solutions/#magic-trick","title":"Magic Trick","text":"Solution in Python Python
s = input()\ncounter = {}\nguess = 1\nfor c in s:\n    if c in counter:\n        guess = 0\n        break\n    else:\n        counter[c] = None\nprint(guess)\n
"},{"location":"solutions/#making-a-meowth","title":"Making A Meowth","text":"Solution in Python Python
n, p, x, y = [int(d) for d in input().split()]\nprint(p * x + p // (n - 1) * y)\n
"},{"location":"solutions/#identifying-map-tiles","title":"Identifying Map Tiles","text":"Solutions in 2 languages GoPython
package main\n\nimport (\n    \"fmt\"\n    \"math\"\n)\n\nfunc main() {\n    var s string\n    fmt.Scanln(&s)\n    zoom := len(s)\n    var x, y float64\n    for i := 0; i < zoom; i++ {\n        d := math.Pow(2, float64(zoom)-float64(i)-1)\n        if s[i] == '1' {\n            x += d\n        } else if s[i] == '2' {\n            y += d\n        } else if s[i] == '3' {\n            x += d\n            y += d\n        }\n    }\n    fmt.Printf(\"%d %d %d\", zoom, int64(x), int64(y))\n}\n
s = input()\nx, y = 0, 0\nzoom = len(s)\nfor i in range(len(s)):\n    d = 2 ** (zoom - i - 1)\n    if s[i] == \"1\":\n        x += d\n    elif s[i] == \"2\":\n        y += d\n    elif s[i] == \"3\":\n        x += d\n        y += d\nprint(f\"{zoom} {x} {y}\")\n
"},{"location":"solutions/#marko","title":"Marko","text":"Solution in Python Python
mapping = {\n    \"2\": \"abc\",\n    \"3\": \"def\",\n    \"4\": \"ghi\",\n    \"5\": \"jkl\",\n    \"6\": \"mno\",\n    \"7\": \"pqrs\",\n    \"8\": \"tuv\",\n    \"9\": \"wxyz\",\n}\nn = []\nfor _ in range(int(input())):\n    w = input()\n    t = \"\"\n    for c in w:\n        for d, r in mapping.items():\n            if c in r:\n                t += d\n                break\n    n.append(t)\n\nd = input()\nprint(sum([d == t for t in n]))\n
"},{"location":"solutions/#mars-window","title":"Mars Window","text":"Solution in Python Python
y = int(input())\nprint(\"YES\" if 26 - ((y - 2018) * 12 - 4) % 26 <= 12 else \"NO\")\n
"},{"location":"solutions/#math-homework","title":"Math Homework","text":"Solution in Python Python
b, d, c, l = [int(d) for d in input().split()]\nsolved = False\nfor i in range(l // b + 1):\n    for j in range((l - b * i) // d + 1):\n        for k in range((l - b * i - d * j) // c + 1):\n            if b * i + d * j + c * k == l:\n                print(i, j, k)\n                solved = True\nif not solved:\n    print(\"impossible\")\n
"},{"location":"solutions/#mean-words","title":"Mean Words","text":"Solution in Python Python
n = int(input())\nwords = []\nfor _ in range(n):\n    words.append(input())\nm = max([len(w) for w in words])\nans = []\nfor i in range(m):\n    values = [ord(w[i]) for w in words if len(w) > i]\n    ans.append(sum(values) // len(values))\nprint(\"\".join(chr(d) for d in ans))\n
"},{"location":"solutions/#imperial-measurement","title":"Imperial Measurement","text":"Solution in Python Python
mapping = {\n    \"th\": \"thou\",\n    \"in\": \"inch\",\n    \"ft\": \"foot\",\n    \"yd\": \"yard\",\n    \"ch\": \"chain\",\n    \"fur\": \"furlong\",\n    \"mi\": \"mile\",\n    \"lea\": \"league\",\n}\nnames = list(mapping.values())\nscale = [1, 1000, 12, 3, 22, 10, 8, 3]\n\nv, a, _, b = input().split()\nv = int(v)\nna, nb = mapping.get(a, a), mapping.get(b, b)\nia, ib = names.index(na), names.index(nb)\n\nrate = 1\nfor s in scale[min(ia, ib) + 1 : max(ia, ib) + 1]:\n    rate *= s\n\nprint(v * rate if ia > ib else v / rate)\n
"},{"location":"solutions/#metaprogramming","title":"Metaprogramming","text":"Solution in Python Python
c = {}\nwhile True:\n    try:\n        s = input()\n    except:\n        break\n    parts = s.split()\n    if parts[0] == \"define\":\n        v, n = parts[1:]\n        c[n] = int(v)\n    elif parts[0] == \"eval\":\n        x, y, z = parts[1:]\n        if x not in c or z not in c:\n            print(\"undefined\")\n        elif y == \"=\":\n            print(\"true\" if c[x] == c[z] else \"false\")\n        elif y == \">\":\n            print(\"true\" if c[x] > c[z] else \"false\")\n        elif y == \"<\":\n            print(\"true\" if c[x] < c[z] else \"false\")\n
"},{"location":"solutions/#methodic-multiplication","title":"Methodic Multiplication","text":"Solution in Python Python
a, b = input(), input()\nt = a.count(\"S\") * b.count(\"S\")\nprint(\"S(\" * t + \"0\" + \")\" * t)\n
"},{"location":"solutions/#metronome","title":"Metronome","text":"Solution in Python Python
n = int(input())\nprint(f\"{n/4:.2f}\")\n
"},{"location":"solutions/#mia","title":"Mia","text":"Solution in Python Python
def score(a, b):\n    roll = set([a, b])\n    if roll == {1, 2}:\n        return (3, None)\n    elif len(roll) == 1:\n        return (2, a)\n    else:\n        a, b = min(a, b), max(b, a)\n        return (1, 10 * b + a)\n\n\nwhile True:\n    rolls = [int(d) for d in input().split()]\n    if not any(rolls):\n        break\n    score1 = score(*rolls[:2])\n    score2 = score(*rolls[2:])\n    if score1 == score2:\n        print(\"Tie.\")\n    elif score1[0] == score2[0]:\n        print(f\"Player {1 if score1[1] > score2[1] else 2} wins.\")\n    else:\n        print(f\"Player {1 if score1[0] > score2[0] else 2} wins.\")\n
"},{"location":"solutions/#millifrsla","title":"Millif\u00e6rsla","text":"Solution in Python Python
names, fees = [\"Monnei\", \"Fjee\", \"Dolladollabilljoll\"], []\nfor _ in range(3):\n    fees.append(int(input()))\nprint(names[fees.index(min(fees))])\n
"},{"location":"solutions/#missing-numbers","title":"Missing Numbers","text":"Solution in Python Python
numbers = []\nfor _ in range(int(input())):\n    numbers.append(int(input()))\n\nis_good_job = True\nfor i in range(1, max(numbers) + 1):\n    if i not in numbers:\n        is_good_job = False\n        print(i)\n\nif is_good_job:\n    print(\"good job\")\n
"},{"location":"solutions/#mixed-fractions","title":"Mixed Fractions","text":"Solution in Python Python
while True:\n    m, n = [int(d) for d in input().split()]\n    if not m and not n:\n        break\n    a = m // n\n    b = m % n\n    print(f\"{a} {b} / {n}\")\n
"},{"location":"solutions/#mjehuric","title":"Mjehuric","text":"Solution in Python Python
f = input().split()\nwhile f != [str(d) for d in range(1, 6)]:\n    for i in range(4):\n        if f[i] > f[i + 1]:\n            f[i], f[i + 1] = f[i + 1], f[i]\n            print(\" \".join(f))\n
"},{"location":"solutions/#moderate-pace","title":"Moderate Pace","text":"Solution in Python Python
n = int(input())\ndistances = [[int(d) for d in input().split()] for _ in range(3)]\nplan = [sorted([d[i] for d in distances])[1] for i in range(n)]\nprint(\" \".join([str(d) for d in plan]))\n
"},{"location":"solutions/#modulo","title":"Modulo","text":"Solution in Python Python
n = set()\nfor _ in range(10):\n    n.add(int(input()) % 42)\nprint(len(n))\n
"},{"location":"solutions/#monopoly","title":"Monopoly","text":"Solution in Python Python
n = int(input())\na = [int(d) for d in input().split()]\nt = 0\nm = 0\nfor i in range(1, 7):\n    for j in range(1, 7):\n        t += 1\n        if i + j in a:\n            m += 1\nprint(m / t)\n
"},{"location":"solutions/#moscow-dream","title":"Moscow Dream","text":"Solution in Python Python
a, b, c, n = [int(d) for d in input().split()]\n\nif not all(d > 0 for d in [a, b, c]):\n    print(\"NO\")\nelse:\n    print(\"YES\" if a + b + c >= n and n >= 3 else \"NO\")\n
"},{"location":"solutions/#mosquito-multiplication","title":"Mosquito Multiplication","text":"Solution in Python Python
while True:\n    try:\n        m, p, l, e, r, s, n = [int(d) for d in input().split()]\n    except:\n        break\n    for _ in range(n):\n        pp = p\n        p = l // r\n        l = e * m\n        m = pp // s\n    print(m)\n
"},{"location":"solutions/#mrcodeformatgrader","title":"MrCodeFormatGrader","text":"Solution in Python Python
def f(numbers):\n    prev = numbers[0]\n    ans = {prev: 1}\n    for i in range(1, len(numbers)):\n        if numbers[i] == prev + ans[prev]:\n            ans[prev] += 1\n        else:\n            prev = numbers[i]\n            ans[prev] = 1\n\n    parts = [\n        f\"{key}-{key+value-1}\"\n        if value > 1\n        else \" \".join([str(d) for d in range(key, key + value)])\n        for key, value in ans.items()\n    ]\n\n    return \", \".join(parts[:-1]) + \" and \" + parts[-1]\n\n\nc, n = [int(d) for d in input().split()]\nerrors = [int(d) for d in input().split()]\ncorrect = [i for i in range(1, 1 + c) if i not in errors]\n\nprint(\"Errors:\", f(errors))\nprint(\"Correct:\", f(correct))\n
"},{"location":"solutions/#mult","title":"Mult!","text":"Solution in Python Python
n = int(input())\nb = None\nfor _ in range(n):\n    d = int(input())\n    if not b:\n        b = d\n        continue\n\n    if d % b == 0:\n        print(d)\n        b = None\n
"},{"location":"solutions/#mumble-rap","title":"Mumble Rap","text":"Solution in Python Python
n = int(input())\ns = input()\na = []\nd = \"\"\nimport string\n\nfor i in range(n):\n    if s[i] in string.digits:\n        d += s[i]\n\n    else:\n        if d:\n            a.append(int(d))\n            d = \"\"\nif d:\n    a.append(int(d))\n\nprint(max(a))\n
"},{"location":"solutions/#musical-scales","title":"Musical Scales","text":"Solution in Python Python
notes = [\"A\", \"A#\", \"B\", \"C\", \"C#\", \"D\", \"D#\", \"E\", \"F\", \"F#\", \"G\", \"G#\"]\noffset = [2, 2, 1, 2, 2, 2]\nmajors = {}\nfor i in range(len(notes)):\n    name = notes[i]\n    progression = [name]\n    for i in offset:\n        index = (notes.index(progression[-1]) + i) % len(notes)\n        progression.append(notes[index])\n    majors[name] = progression\n\n_ = input()\nscales = set(input().split())\nprint(\" \".join([n for n in majors if scales < set(majors[n])]) or \"none\")\n
"},{"location":"solutions/#music-your-way","title":"Music Your Way","text":"Solution in Python Python
cols = input().split()\nm = int(input())\nsongs = [input().split() for _ in range(m)]\nn = int(input())\n\nfor i in range(n):\n    col = input()\n    index = cols.index(col)\n    songs = sorted(songs, key=lambda k: k[index])\n    print(\" \".join(cols))\n    for song in songs:\n        print(\" \".join(song))\n    if i < n - 1:\n        print()\n
"},{"location":"solutions/#mylla","title":"Mylla","text":"Solution in Python Python
board = []\nfor _ in range(3):\n    board.append(list(input()))\n\nwinner = \"\"\nfor i in range(3):\n    if board[i][0] == board[i][1] == board[i][2] and board[i][0] != \"_\":\n        winner = board[i][0]\n        break\n    elif board[0][i] == board[1][i] == board[2][i] and board[0][i] != \"_\":\n        winner = board[0][i]\n        break\n\nif board[0][0] == board[1][1] == board[2][2] and board[1][1] != \"_\":\n    winner = board[1][1]\nelif board[0][2] == board[1][1] == board[2][0] and board[1][1] != \"_\":\n    winner = board[1][1]\n\nif winner == \"O\":\n    winner = \"Jebb\"\nelse:\n    winner = \"Neibb\"\n\nprint(winner)\n
"},{"location":"solutions/#nasty-hacks","title":"Nasty Hacks","text":"Solutions in 2 languages C++Python
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int n, r, e, c;\n    cin >> n;\n\n    for (int i = 0; i < n; i++)\n    {\n        cin >> r >> e >> c;\n        if ((e - c) > r)\n        {\n            cout << \"advertise\";\n        }\n        else if ((e - c) < r)\n        {\n            cout << \"do not advertise\";\n        }\n        else\n        {\n            cout << \"does not matter\";\n        }\n    }\n}\n
for _ in range(int(input())):\n    r, e, c = [int(d) for d in input().split()]\n    if e > r + c:\n        print(\"advertise\")\n    elif e < r + c:\n        print(\"do not advertise\")\n    else:\n        print(\"does not matter\")\n
"},{"location":"solutions/#no-duplicates","title":"No Duplicates","text":"Solution in Python Python
words = input().split()\n\ncounter = {}\nrepeated = False\nfor w in words:\n    if w in counter:\n        repeated = True\n        break\n    else:\n        counter[w] = None\nif repeated:\n    print(\"no\")\nelse:\n    print(\"yes\")\n
"},{"location":"solutions/#nop","title":"NOP","text":"Solution in Python Python
s = input()\ni, m, p = 0, {}, None\n\nfor c in s:\n    if c.isupper():\n        m[i] = 1\n        p = i\n        i += 1\n    else:\n        m[p] += 1\n\nprint(\n    sum(\n        4 - m[k] % 4 if m[k] % 4 else (4 if not m[k] else 0)\n        for k in list(m.keys())[:-1]\n    )\n)\n
"},{"location":"solutions/#no-thanks","title":"No Thanks!","text":"Solution in Python Python
n = int(input())\nv = sorted([int(d) for d in input().split()])\n\nprev = v[0]\nans = {prev: 1}\nfor i in range(1, n):\n    if v[i] == prev + ans[prev]:\n        ans[prev] += 1\n    else:\n        prev = v[i]\n        ans[prev] = 1\n\nprint(sum(ans.keys()))\n
"},{"location":"solutions/#n-sum","title":"N-sum","text":"Solutions in 2 languages JavaPython
import java.util.Scanner;\n\nclass NSum {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int n = s.nextInt();\n        int ans = 0;\n        for (int i = 0; i < n; i++) {\n            ans += s.nextInt();\n        }\n        System.out.println(ans);\n    }\n}\n
_ = int(input())\nnumbers = []\nfor d in input().split():\n    numbers.append(int(d))\nprint(sum(numbers))\n
"},{"location":"solutions/#number-fun","title":"Number Fun","text":"Solution in Python Python
for _ in range(int(input())):\n    a, b, c = [int(d) for d in input().split()]\n    if a + b == c or a * b == c or a - b == c or b - a == c or a / b == c or b / a == c:\n        print(\"Possible\")\n    else:\n        print(\"Impossible\")\n
"},{"location":"solutions/#odd-echo","title":"Odd Echo","text":"Solution in Python Python
n = int(input())\nwords = []\nfor _ in range(n):\n    words.append(input())\nfor i in range(0, n, 2):\n    print(words[i])\n
"},{"location":"solutions/#odd-gnome","title":"Odd Gnome","text":"Solution in Python Python
n = int(input())\nfor _ in range(n):\n    g = [int(d) for d in input().split()][1:]\n    prev = g[0]\n    for i in range(1, len(g)):\n        if g[i] != prev + 1:\n            break\n        prev = g[i]\n    print(i + 1)\n
"},{"location":"solutions/#oddities","title":"Oddities","text":"Solution in Python Python
n = int(input())\nfor _ in range(n):\n    x = int(input())\n    if x % 2:\n        res = \"odd\"\n    else:\n        res = \"even\"\n    print(f\"{x} is {res}\")\n
"},{"location":"solutions/#odd-man-out","title":"Odd Man Out","text":"Solution in Python Python
from collections import Counter\n\nn = int(input())\nfor i in range(n):\n    _ = input()\n    c = Counter(input().split())\n    print(f\"Case #{i+1}: {' '.join(v for v in c if c[v]==1)}\")\n
"},{"location":"solutions/#off-world-records","title":"Off-World Records","text":"Solutions in 2 languages JavaPython
import java.util.Scanner;\n\nclass OffWorldRecords {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int n = s.nextInt();\n        int c = s.nextInt();\n        int p = s.nextInt();\n        int ans = 0;\n\n        for (int i = 0; i < n; i++) {\n            int h = s.nextInt();\n            if (h > c + p) {\n                ans += 1;\n                p = c;\n                c = h;\n            }\n        }\n        System.out.println(ans);\n    }\n}\n
n, c, p = [int(d) for d in input().split()]\nans = 0\nfor _ in range(n):\n    h = int(input())\n    if h > c + p:\n        ans += 1\n        c, p = h, c\nprint(ans)\n
"},{"location":"solutions/#reverse","title":"Reverse","text":"Solution in Python Python
n = int(input())\nnumbers = []\nfor _ in range(n):\n    numbers.append(int(input()))\nfor d in numbers[::-1]:\n    print(d)\n
"},{"location":"solutions/#oktalni","title":"Oktalni","text":"Solution in Python Python
import math\n\nmapping = {\n    \"000\": \"0\",\n    \"001\": \"1\",\n    \"010\": \"2\",\n    \"011\": \"3\",\n    \"100\": \"4\",\n    \"101\": \"5\",\n    \"110\": \"6\",\n    \"111\": \"7\",\n}\nb = input()\nlength = 3 * math.ceil(len(b) / 3)\nb = b.zfill(length)\n\nprint(\"\".join([mapping[b[i : i + 3]] for i in range(0, length, 3)]))\n
"},{"location":"solutions/#one-chicken-per-person","title":"One Chicken Per Person!","text":"Solution in Python Python
n, m = [int(d) for d in input().split()]\n\ndiff = n - m\nif diff > 0:\n    print(f\"Dr. Chaz needs {diff} more piece{'s' if diff >1 else ''} of chicken!\")\nelse:\n    diff = abs(diff)\n    print(\n        f\"Dr. Chaz will have {diff} piece{'s' if diff >1 else ''} of chicken left over!\"\n    )\n
"},{"location":"solutions/#ordinals","title":"Ordinals","text":"Solution in Python Python
def f(n):\n    if n == 0:\n        return \"{}\"\n    else:\n        ans = \",\".join([f(i) for i in range(n)])\n        return \"{\" + ans + \"}\"\n\n\nprint(f(int(input())))\n
"},{"location":"solutions/#ornaments","title":"Ornaments","text":"Solution in Python Python
import math\n\nwhile True:\n    r, h, s = [int(d) for d in input().split()]\n    if not r and not h and not s:\n        break\n    l = math.sqrt(h**2 - r**2) * 2\n    a = math.pi - math.acos(r / h)\n    l += 2 * math.pi * r * (a / math.pi)\n    l *= 1 + s / 100\n    print(f\"{l:.2f}\")\n
"},{"location":"solutions/#ostgotska","title":"\u00d6stg\u00f6tska","text":"Solution in Python Python
sentence = input()\nwords = sentence.split()\nif len([w for w in words if \"ae\" in w]) / len(words) >= 0.4:\n    print(\"dae ae ju traeligt va\")\nelse:\n    print(\"haer talar vi rikssvenska\")\n
"},{"location":"solutions/#overdraft","title":"Overdraft","text":"Solution in Python Python
n = int(input())\ns = 0\nb = 0\nfor _ in range(n):\n    t = int(input())\n    if t > 0:\n        b += t\n    elif b + t < 0:\n        s -= b + t\n        b = 0\n    else:\n        b += t\nprint(s)\n
"},{"location":"solutions/#ovissa","title":"\u00d3vissa","text":"Solutions in 3 languages GoLuaPython
package main\n\nimport (\n    \"fmt\"\n    \"strings\"\n)\n\nfunc main() {\n    var s string\n    fmt.Scan(&s)\n    fmt.Println(strings.Count(s, \"u\"))\n}\n
s = io.read()\n_, count = string.gsub(s, \"u\", \"\")\nprint(count)\n
print(input().count(\"u\"))\n
"},{"location":"solutions/#the-owl-and-the-fox","title":"The Owl and the Fox","text":"Solution in Python Python
def sd(n):\n    return sum([int(d) for d in str(n)])\n\n\nfor _ in range(int(input())):\n    n = int(input())\n    s = sd(n) - 1\n    d = n - 1\n    while True:\n        if sd(d) == s:\n            break\n        d -= 1\n    print(d)\n
"},{"location":"solutions/#pachyderm-peanut-packing","title":"Pachyderm Peanut Packing","text":"Solution in Python Python
def inbox(coords, x, y):\n    if x >= coords[0] and x <= coords[2] and y >= coords[1] and y <= coords[3]:\n        return True\n    return False\n\n\nwhile True:\n    n = int(input())\n    if not n:\n        break\n    box = {}\n    for i in range(n):\n        desc = input().split()\n        size = desc[-1]\n        coords = [float(d) for d in desc[:-1]]\n        box[i] = (coords, size)\n    m = int(input())\n    for _ in range(m):\n        desc = input().split()\n        size = desc[-1]\n        x, y = [float(d) for d in desc[:-1]]\n        floor = True\n        for i in range(n):\n            coords, box_size = box[i]\n            if inbox(coords, x, y):\n                floor = False\n                break\n        if floor:\n            status = \"floor\"\n        else:\n            status = \"correct\" if box_size == size else box_size\n        print(size, status)\n    print()\n
"},{"location":"solutions/#parent-gap","title":"Parent Gap","text":"Solution in Python Python
from datetime import datetime\n\nyear = int(input())\n\nmother = datetime(year, 5, 1).isoweekday()\nfather = datetime(year, 6, 1).isoweekday()\n\nx = 7 - mother\ny = 7 - father\ndaymother = 1 + x + 7\ndayfather = 1 + y + 14\n\ndaymother = datetime(year, 5, daymother)\ndayfather = datetime(year, 6, dayfather)\n\nprint(((dayfather - daymother).days) // 7, \"weeks\")\n
"},{"location":"solutions/#parket","title":"Parket","text":"Solution in Python Python
import math\n\nr, b = [int(d) for d in input().split()]\nw = math.floor((r + b) ** 0.5)\nwhile w:\n    if (r + b) / w == (r + 4) / 2 - w:\n        print((r + 4) // 2 - w, w)\n        break\n    w -= 1\n
"},{"location":"solutions/#parking","title":"Parking","text":"Solution in Python Python
a, b, c = [int(d) for d in input().split()]\nt = [0] * 100\nfor _ in range(3):\n    start, end = [int(d) - 1 for d in input().split()]\n    for i in range(start, end):\n        t[i] += 1\n\ntotal = 0\nmapping = {\n    3: c,\n    2: b,\n    1: a,\n}\nfor s in t:\n    total += mapping.get(s, 0) * s\nprint(total)\n
"},{"location":"solutions/#parking_1","title":"Parking","text":"Solution in Python Python
for _ in range(int(input())):\n    _ = input()\n    positions = [int(d) for d in input().split()]\n    print(2 * (max(positions) - min(positions)))\n
"},{"location":"solutions/#patuljci","title":"Patuljci","text":"Solution in Python Python
d = [int(input()) for _ in range(9)]\ndiff = sum(d) - 100\nend = False\nfor i in range(8):\n    for j in range(i + 1, 9):\n        if d[i] + d[j] == diff:\n            end = True\n            break\n    if end:\n        break\nprint(\"\\n\".join([str(d[k]) for k in range(9) if k not in [i, j]]))\n
"},{"location":"solutions/#paul-eigon","title":"Paul Eigon","text":"Solutions in 2 languages GoPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var n, p, q int\n    fmt.Scan(&n)\n    fmt.Scan(&p)\n    fmt.Scan(&q)\n    if ((p+q)/n)%2 == 0 {\n        fmt.Println(\"paul\")\n    } else {\n        fmt.Println(\"opponent\")\n    }\n}\n
n, p, q = [int(d) for d in input().split()]\n\nif ((p + q) // n) % 2 == 0:\n    print(\"paul\")\nelse:\n    print(\"opponent\")\n
"},{"location":"solutions/#peach-powder-polygon","title":"Peach Powder Polygon","text":"Solution in Python Python
n = int(input())\nprint(\"Yes\" if n % 4 else \"No\")\n
"},{"location":"solutions/#pea-soup-and-pancakes","title":"Pea Soup and Pancakes","text":"Solution in Python Python
found = False\nfor _ in range(int(input())):\n    k = int(input())\n\n    name = input()\n    items = [input() for _ in range(k)]\n    if \"pea soup\" in items and \"pancakes\" in items:\n        found = True\n        print(name)\n        break\n\nif not found:\n    print(\"Anywhere is fine I guess\")\n
"},{"location":"solutions/#peragrams","title":"Peragrams","text":"Solution in Python Python
from collections import Counter\n\ns = Counter(input())\nv = [d for d in s.values() if d % 2]\nv = sorted(v)[:-1]\n\nprint(len(v))\n
"},{"location":"solutions/#perket","title":"Perket","text":"Solution in Python Python
from itertools import combinations\n\nn = int(input())\nl = [[int(d) for d in input().split()] for _ in range(n)]\n\nc = []\nfor i in range(1, n + 1):\n    c.extend(list(combinations(l, i)))\n\nd = []\nfor i in c:\n    s, b = 1, 0\n    for x, y in i:\n        s *= x\n        b += y\n    d.append(abs(s - b))\n\nprint(min(d))\n
"},{"location":"solutions/#permuted-arithmetic-sequence","title":"Permuted Arithmetic Sequence","text":"Solution in Python Python
def arithmetic(n):\n    d = [n[i] - n[i + 1] for i in range(len(n) - 1)]\n    return True if len(set(d)) == 1 else False\n\n\nfor _ in range(int(input())):\n    s = input().split()\n    n = [int(d) for d in s[1:]]\n    if arithmetic(n):\n        print(\"arithmetic\")\n    elif arithmetic(sorted(n)):\n        print(\"permuted arithmetic\")\n    else:\n        print(\"non-arithmetic\")\n
"},{"location":"solutions/#pervasive-heart-monitor","title":"Pervasive Heart Monitor","text":"Solution in Python Python
while True:\n    try:\n        line = input().split()\n    except:\n        break\n\n    name, rate = [], []\n    for p in line:\n        if p.isalpha():\n            name.append(p)\n        else:\n            rate.append(float(p))\n    name = \" \".join(name)\n    rate = sum(rate) / len(rate)\n    print(f\"{rate:.6f} {name}\")\n
"},{"location":"solutions/#pet","title":"Pet","text":"Solution in Python Python
winner, max_score = 0, 0\nfor i in range(5):\n    score = sum([int(d) for d in input().split()])\n    if score > max_score:\n        max_score = score\n        winner = i + 1\n\nprint(winner, max_score)\n
"},{"location":"solutions/#piece-of-cake","title":"Piece of Cake!","text":"Solution in Python Python
n, h, v = [int(d) for d in input().split()]\nprint(4 * max(h * v, (n - h) * (n - v), h * (n - v), v * (n - h)))\n
"},{"location":"solutions/#pig-latin","title":"Pig Latin","text":"Solution in Python Python
def translate(w):\n    if w[0] in \"aeiouy\":\n        return w + \"yay\"\n    else:\n        i = 1\n        while i < len(w):\n            if w[i] in \"aeiouy\":\n                break\n            i += 1\n        return w[i:] + w[:i] + \"ay\"\n\n\nwhile True:\n    try:\n        text = input()\n        print(\" \".join([translate(w) for w in text.split()]))\n    except:\n        break\n
"},{"location":"solutions/#a-vicious-pikeman-easy","title":"A Vicious Pikeman (Easy)","text":"Solution in Python Python
def f(n, time, l):\n    total_time, penalty = 0, 0\n    for i, t in enumerate(sorted(l)):\n        if total_time + t > time:\n            return i, penalty\n        total_time += t\n        penalty = (penalty + total_time) % 1_000_000_007\n    return n, penalty\n\n\nn, t = [int(d) for d in input().split()]\na, b, c, t0 = [int(d) for d in input().split()]\nl = [t0]\nfor _ in range(n - 1):\n    l.append(((a * l[-1] + b) % c) + 1)\n\n\nn, penalty = f(n, t, l)\nprint(n, penalty)\n
"},{"location":"solutions/#pizza-crust","title":"Pizza Crust","text":"Solution in Python Python
r, c = [int(d) for d in input().split()]\nprint(f\"{(r-c)**2 / r**2 * 100:.6f}\")\n
"},{"location":"solutions/#pizzubestun","title":"Pizzubestun","text":"Solution in Python Python
n = int(input())\nprices = [int(input().split()[-1]) for _ in range(n)]\nif n % 2:\n    prices.append(0)\nprices = sorted(prices, reverse=True)\nprint(sum(prices[i] for i in range(0, len(prices), 2)))\n
"},{"location":"solutions/#planetaris","title":"Planetaris","text":"Solution in Python Python
_, a = [int(d) for d in input().split()]\ne = sorted([int(d) + 1 for d in input().split()])\n\nt = 0\nfor s in e:\n    if a >= s:\n        t += 1\n        a -= s\n    else:\n        break\nprint(t)\n
"},{"location":"solutions/#planina","title":"Planina","text":"Solution in Python Python
def p(n):\n    if n == 1:\n        return 3\n    else:\n        return p(n - 1) * 2 - 1\n\n\nn = int(input())\nprint(p(n) ** 2)\n
"},{"location":"solutions/#planting-trees","title":"Planting Trees","text":"Solution in Python Python
n = int(input())\nt = [int(d) for d in input().split()]\n\ndays = [v + d for v, d in zip(sorted(t, reverse=True), range(1, n + 1))]\nprint(max(days) + 1)\n
"},{"location":"solutions/#pokechat","title":"Pokechat","text":"Solution in Python Python
chars = input()\nids = input()\nids = [int(ids[i : i + 3]) - 1 for i in range(0, len(ids), 3)]\nprint(\"\".join([chars[i] for i in ids]))\n
"},{"location":"solutions/#poker-hand","title":"Poker Hand","text":"Solution in Python Python
from collections import Counter\n\nhands = [h[0] for h in input().split()]\nprint(max(Counter(hands).values()))\n
"},{"location":"solutions/#polynomial-multiplication-1","title":"Polynomial Multiplication 1","text":"Solution in Python Python
from collections import Counter\n\nfor _ in range(int(input())):\n    n = int(input())\n    a = [int(d) for d in input().split()]\n    m = int(input())\n    b = [int(d) for d in input().split()]\n    p = Counter()\n    for i in range(n + 1):\n        for j in range(m + 1):\n            p[i + j] += a[i] * b[j]\n    keys = max([k for k in p.keys() if p[k] != 0])\n    print(keys)\n    print(\" \".join([str(p[k]) for k in range(keys + 1)]))\n
"},{"location":"solutions/#popularity-contest","title":"Popularity Contest","text":"Solution in Python Python
n, m = [int(d) for d in input().split()]\np = [0] * n\nfor _ in range(m):\n    a, b = [int(d) - 1 for d in input().split()]\n    p[a] += 1\n    p[b] += 1\nprint(\" \".join([str(a - b) for a, b in zip(p, range(1, 1 + n))]))\n
"},{"location":"solutions/#pot","title":"Pot","text":"Solution in Python Python
n = int(input())\ntotal = 0\nfor _ in range(n):\n    line = input()\n    n, p = int(line[:-1]), int(line[-1])\n    total += n**p\nprint(total)\n
"},{"location":"solutions/#saving-princess-peach","title":"Saving Princess Peach","text":"Solution in Python Python
n, y = [int(d) for d in input().split()]\nfound = []\nfor _ in range(y):\n    found.append(int(input()))\nfound = set(found)\nfor i in range(n):\n    if i not in found:\n        print(i)\nprint(f\"Mario got {len(found)} of the dangerous obstacles.\")\n
"},{"location":"solutions/#printing-costs","title":"Printing Costs","text":"Solution in Python Python
t = \"\"\"\n    0        !   9        \"   6        #  24        $  29        %  22\n&  24        '   3        (  12        )  12        *  17        +  13\n,   7        -   7        .   4        /  10        0  22        1  19\n2  22        3  23        4  21        5  27        6  26        7  16\n8  23        9  26        :   8        ;  11        <  10        =  14\n>  10        ?  15        @  32        A  24        B  29        C  20\nD  26        E  26        F  20        G  25        H  25        I  18\nJ  18        K  21        L  16        M  28        N  25        O  26\nP  23        Q  31        R  28        S  25        T  16        U  23\nV  19        W  26        X  18        Y  14        Z  22        [  18\n\\  10        ]  18        ^   7        _   8        `   3        a  23\nb  25        c  17        d  25        e  23        f  18        g  30\nh  21        i  15        j  20        k  21        l  16        m  22\nn  18        o  20        p  25        q  25        r  13        s  21\nt  17        u  17        v  13        w  19        x  13        y  24\nz  19        {  18        |  12        }  18        ~   9\n\"\"\"\n\nm = []\nfor row in t.splitlines():\n    if not row:\n        continue\n    values = row.split()\n    if len(values) % 2:\n        values.insert(0, \" \")\n\n    for i in range(0, len(values), 2):\n        m.append((values[i], int(values[i + 1])))\nm = dict(m)\n\nwhile True:\n    try:\n        s = input()\n    except:\n        break\n    print(sum([m[c] for c in s]))\n
"},{"location":"solutions/#prjonamynstur","title":"Prj\u00f3namynstur","text":"Solution in Python Python
mapping = {\n    \".\": 20,\n    \"O\": 10,\n    \"\\\\\": 25,\n    \"/\": 25,\n    \"A\": 35,\n    \"^\": 5,\n    \"v\": 22,\n}\nn, _ = input().split()\ncost = 0\nfor _ in range(int(n)):\n    for c in input():\n        cost += mapping[c]\nprint(cost)\n
"},{"location":"solutions/#provinces-and-gold","title":"Provinces and Gold","text":"Solution in Python Python
g, s, c = [int(d) for d in input().split()]\n\nbuying = 3 * g + 2 * s + 1 * c\nresult = []\n\nif buying >= 8:\n    result.append(\"Province\")\nelif buying >= 5:\n    result.append(\"Duchy\")\nelif buying >= 2:\n    result.append(\"Estate\")\n\nif buying >= 6:\n    result.append(\"Gold\")\nelif buying >= 3:\n    result.append(\"Silver\")\nelse:\n    result.append(\"Copper\")\n\nprint(\" or \".join(result))\n
"},{"location":"solutions/#prsteni","title":"Prsteni","text":"Solution in Python Python
import math\n\n_ = input()\nnumbers = [int(d) for d in input().split()]\n\nbase = numbers.pop(0)\n\ngcd = [math.gcd(base, n) for n in numbers]\n\nfor g, n in zip(gcd, numbers):\n    print(f\"{int(base/g)}/{int(n/g)}\")\n
"},{"location":"solutions/#prva","title":"Prva","text":"Solution in Python Python
r, c = [int(d) for d in input().split()]\npuzzle = []\nfor _ in range(r):\n    puzzle.append(input())\n\nwords = set()\nfor row in puzzle:\n    words.update([w for w in row.split(\"#\") if len(w) > 1])\nfor i in range(c):\n    col = \"\".join([row[i] for row in puzzle])\n    words.update([w for w in col.split(\"#\") if len(w) > 1])\n\nprint(sorted(words)[0])\n
"},{"location":"solutions/#ptice","title":"Ptice","text":"Solution in Python Python
def adrian(n):\n    if n == 0:\n        return \"\"\n    elif n == 1:\n        return \"A\"\n    elif n == 2:\n        return \"AB\"\n    elif n == 3:\n        return \"ABC\"\n    else:\n        duplicate = n // 3\n        return adrian(3) * duplicate + adrian(n % 3)\n\n\ndef bruno(n):\n    if n == 0:\n        return \"\"\n    elif n == 1:\n        return \"B\"\n    elif n == 2:\n        return \"BA\"\n    elif n == 3:\n        return \"BAB\"\n    elif n == 4:\n        return \"BABC\"\n    else:\n        duplicate = n // 4\n        return bruno(4) * duplicate + bruno(n % 4)\n\n\ndef goran(n):\n    if n == 0:\n        return \"\"\n    elif n in [1, 2]:\n        return \"C\" * n\n    elif n in [3, 4]:\n        return \"CC\" + \"A\" * (n - 2)\n    elif n in [5, 6]:\n        return \"CCAA\" + \"B\" * (n - 4)\n    else:\n        duplicate = n // 6\n        return goran(6) * duplicate + goran(n % 6)\n\n\ndef get_score(ans, guess):\n    return sum([a == g for a, g in zip(ans, guess)])\n\n\nn = int(input())\nans = input()\n\nresult = {}\nresult[\"Adrian\"] = get_score(ans, adrian(n))\nresult[\"Bruno\"] = get_score(ans, bruno(n))\nresult[\"Goran\"] = get_score(ans, goran(n))\n\nbest = max(result.values())\nprint(best)\n\nfor name, score in result.items():\n    if score == best:\n        print(name)\n
"},{"location":"solutions/#plants-vs-bad-guys","title":"Plants vs Bad Guys","text":"Solutions in 2 languages LuaPython
n = io.read(\"*n\")\nlocal min = math.huge\nfor i = 1, n do\n    value = io.read(\"*n\")\n    min   = min < value and min or value\nend\nprint(1 + min)\n
_ = input()\nprint(1 + min(int(d) for d in input().split()))\n
"},{"location":"solutions/#building-pyramids","title":"Building Pyramids","text":"Solution in Python Python
n = int(input())\n\nheight = 0\nwhile True:\n    height += 1\n    blocks = (2 * height - 1) ** 2\n    if blocks > n:\n        height -= 1\n        break\n    n -= blocks\n\nprint(height)\n
"},{"location":"solutions/#quality-adjusted-life-year","title":"Quality-Adjusted Life-Year","text":"Solution in Python Python
qaly = 0\nfor _ in range(int(input())):\n    q, y = input().split()\n    q, y = float(q), float(y)\n    qaly += q * y\nprint(qaly)\n
"},{"location":"solutions/#quadrant-selection","title":"Quadrant Selection","text":"Solutions in 4 languages GoJavaPythonRust
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var x, y int\n    fmt.Scan(&x)\n    fmt.Scan(&y)\n    if x > 0 {\n        if y > 0 {\n            fmt.Println(1)\n        } else {\n            fmt.Println(4)\n        }\n    } else {\n        if y > 0 {\n            fmt.Println(2)\n        } else {\n            fmt.Println(3)\n        }\n    }\n}\n
import java.util.Scanner;\n\nclass QuadrantSelection {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int x = s.nextInt();\n        int y = s.nextInt();\n\n        if (x > 0) {\n            if (y > 0) {\n                System.out.println(1);\n            } else {\n                System.out.println(4);\n            }\n        } else {\n            if (y > 0) {\n                System.out.println(2);\n            } else {\n                System.out.println(3);\n            }\n        }\n\n    }\n}\n
x = int(input())\ny = int(input())\nif x > 0:\n    if y > 0:\n        print(1)\n    else:\n        print(4)\nelse:\n    if y > 0:\n        print(2)\n    else:\n        print(3)\n
fn main() {\n    let mut line1 = String::new();\n    std::io::stdin().read_line(&mut line1).unwrap();\n    let x: i32 = line1.trim().parse().unwrap();\n\n    let mut line2 = String::new();\n    std::io::stdin().read_line(&mut line2).unwrap();\n    let y: i32 = line2.trim().parse().unwrap();\n\n    if x > 0 {\n        if y > 0 {\n            println!(\"1\");\n        } else {\n            println!(\"4\");\n        }\n    } else {\n        if y > 0 {\n            println!(\"2\");\n        } else {\n            println!(\"3\");\n        }\n    }\n}\n
"},{"location":"solutions/#quick-brown-fox","title":"Quick Brown Fox","text":"Solution in Python Python
import string\n\nfor _ in range(int(input())):\n    p = set([c for c in input().lower() if c.isalpha()])\n    if len(p) == 26:\n        print(\"pangram\")\n    else:\n        print(\n            f\"missing {''.join([c for c in string.ascii_lowercase[:26] if c not in p])}\"\n        )\n
"},{"location":"solutions/#quick-estimates","title":"Quick Estimates","text":"Solutions in 2 languages JavaPython
import java.util.Scanner;\n\nclass QuickEstimates {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int n = s.nextInt();\n        for (int i = 0; i < n; i++) {\n            String cost = s.next();\n            System.out.println(cost.length());\n        }\n    }\n}\n
for _ in range(int(input())):\n    print(len(input()))\n
"},{"location":"solutions/#quite-a-problem","title":"Quite a Problem","text":"Solution in Python Python
while True:\n    try:\n        line = input()\n    except:\n        break\n\n    if \"problem\" in line.lower():\n        print(\"yes\")\n    else:\n        print(\"no\")\n
"},{"location":"solutions/#r2","title":"R2","text":"Solutions in 5 languages C++GoJavaLuaPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int r1, s;\n    cin >> r1 >> s;\n    cout << 2 * s - r1 << endl;\n    return 0;\n}\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var r1, s int\n    fmt.Scan(&r1)\n    fmt.Scan(&s)\n    fmt.Println(2*s - r1)\n}\n
import java.util.Scanner;\n\nclass R2 {\n    public static void main(String[] args) {\n        Scanner scanner = new Scanner(System.in);\n        int r1 = scanner.nextInt();\n        int s = scanner.nextInt();\n        System.out.println(2 * s - r1);\n    }\n}\n
r1 = io.read(\"*n\")\ns = io.read(\"*n\")\nr2 = 2 * s - r1\nprint(r2)\n
r1, s = [int(d) for d in input().split()]\nr2 = 2 * s - r1\nprint(r2)\n
"},{"location":"solutions/#racing-around-the-alphabet","title":"Racing Around the Alphabet","text":"Solution in Python Python
import math\n\ntokens = dict([(chr(c), c - ord(\"A\") + 1) for c in range(ord(\"A\"), ord(\"Z\") + 1)])\ntokens[\" \"] = 27\ntokens[\"'\"] = 28\nt = math.pi * 60 / (28 * 15)\nfor _ in range(int(input())):\n    m = input()\n    total = 1\n    prev = m[0]\n    for c in m[1:]:\n        dist = abs(tokens[prev] - tokens[c])\n        total += 1 + t * min(dist, 28 - dist)\n        prev = c\n    print(total)\n
"},{"location":"solutions/#ragged-right","title":"Ragged Right","text":"Solution in Python Python
l = []\nwhile True:\n    try:\n        s = input()\n    except:\n        break\n    l.append(len(s))\nm = max(l)\nprint(sum([(n - m) ** 2 for n in l[:-1]]))\n
"},{"location":"solutions/#railroad","title":"Railroad","text":"Solutions in 4 languages GoJavaLuaPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var x, y int\n    fmt.Scan(&x)\n    fmt.Scan(&y)\n    if y%2 == 1 {\n        fmt.Println(\"impossible\")\n    } else {\n        fmt.Println(\"possible\")\n    }\n}\n
import java.util.Scanner;\n\nclass Railroad {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int x = s.nextInt();\n        int y = s.nextInt();\n        if (y % 2 == 1) {\n            System.out.println(\"impossible\");\n        } else {\n            System.out.println(\"possible\");\n        }\n    }\n}\n
x = io.read(\"*n\")\ny = io.read(\"*n\")\nif y % 2 == 1 then\n    print(\"impossible\")\nelse\n    print(\"possible\")\nend\n
_, y = [int(d) for d in input().split()]\nif y % 2:\n    print(\"impossible\")\nelse:\n    print(\"possible\")\n
"},{"location":"solutions/#a-rank-problem","title":"A Rank Problem","text":"Solution in Python Python
n, m = [int(d) for d in input().split()]\nranking = [f\"T{i}\" for i in range(1, 1 + n)]\nfor _ in range(m):\n    i, j = input().split()\n    if ranking.index(i) < ranking.index(j):\n        continue\n    ranking.remove(j)\n    ranking.insert(ranking.index(i) + 1, j)\nprint(\" \".join(ranking))\n
"},{"location":"solutions/#rating-problems","title":"Rating Problems","text":"Solutions in 2 languages JavaPython
import java.util.Scanner;\n\nclass RatingProblems {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int n = s.nextInt();\n        int k = s.nextInt();\n        int score = 0;\n        for (int i = 0; i < k; i++) {\n            score += s.nextInt();\n        }\n        float min = (score - 3 * (n - k)) / (float) n;\n        float max = (score + 3 * (n - k)) / (float) n;\n        System.out.println(min + \" \" + max);\n    }\n}\n
n, k = [int(d) for d in input().split()]\nscore = 0\nfor _ in range(k):\n    score += int(input())\n\nprint((score - 3 * (n - k)) / n, (score + 3 * (n - k)) / n)\n
"},{"location":"solutions/#a-rational-sequence-2","title":"A Rational Sequence 2","text":"Solution in Python Python
def f(l, r):\n    if l == r:\n        return 1\n    elif l > r:\n        return 2 * f(l - r, r) + 1\n    else:\n        return 2 * f(l, r - l)\n\n\nfor _ in range(int(input())):\n    k, v = input().split()\n    l, r = [int(d) for d in v.split(\"/\")]\n    print(f\"{k} {f(l,r)}\")\n
"},{"location":"solutions/#scaling-recipes","title":"Scaling Recipes","text":"Solution in Python Python
for i in range(int(input())):\n    r, p, d = [int(d) for d in input().split()]\n    recipe = {}\n    main = None\n    for _ in range(r):\n        name, weight, percent = input().split()\n        weight = float(weight)\n        percent = float(percent)\n        if percent == 100.0:\n            main = name\n        recipe[name] = (weight, percent)\n    scale = d / p\n    print(f\"Recipe # {i+1}\")\n    dw = recipe[main][0] * scale\n    for k in recipe:\n        print(k, f\"{recipe[k][1] * dw / 100:.1f}\")\n    print(\"-\" * 40)\n
"},{"location":"solutions/#recount","title":"Recount","text":"Solution in Python Python
from collections import Counter\n\nc = Counter()\nwhile True:\n    try:\n        name = input()\n    except:\n        break\n    c[name] += 1\n\nhighest = max(c.values())\nnames = [k for k in c if c[k] == highest]\nprint(\"Runoff!\" if len(names) > 1 else names.pop())\n
"},{"location":"solutions/#rectangle-area","title":"Rectangle Area","text":"Solution in Python Python
x1, y1, x2, y2 = [float(d) for d in input().split()]\n\nprint(abs((x1 - x2) * (y1 - y2)))\n
"},{"location":"solutions/#reduced-id-numbers","title":"Reduced ID Numbers","text":"Solution in Python Python
g = int(input())\nids = []\nfor _ in range(g):\n    ids.append(int(input()))\n\nm = 1\nwhile True:\n    v = [d % m for d in ids]\n    if g == len(set(v)):\n        break\n    m += 1\n\nprint(m)\n
"},{"location":"solutions/#relocation","title":"Relocation","text":"Solution in Python Python
n, q = [int(d) for d in input().split()]\nx = [int(d) for d in input().split()]\nfor _ in range(q):\n    req = [int(d) for d in input().split()]\n    if req[0] == 1:\n        x[req[1] - 1] = req[2]\n    elif req[0] == 2:\n        print(abs(x[req[1] - 1] - x[req[2] - 1]))\n
"},{"location":"solutions/#restaurant-opening","title":"Restaurant Opening","text":"Solution in Python Python
from itertools import product\n\nn, m = [int(d) for d in input().split()]\n\ng = []\nfor _ in range(n):\n    g.append([int(d) for d in input().split()])\n\nl = list(product(range(n), range(m)))\n\nc = []\nfor i, j in l:\n    s = 0\n    for a, b in l:\n        s += g[a][b] * (abs(i - a) + abs(j - b))\n    c.append(s)\n\nprint(min(c))\n
"},{"location":"solutions/#reversed-binary-numbers","title":"Reversed Binary Numbers","text":"Solution in Python Python
n = int(input())\n\nb = []\nwhile n:\n    b.append(n % 2)\n    n //= 2\n\nprint(sum([d * (2**p) for d, p in zip(b, reversed(range(len(b))))]))\n
"},{"location":"solutions/#reverse-rot","title":"Reverse Rot","text":"Solution in Python Python
import string\n\nrotations = string.ascii_uppercase + \"_.\"\n\n\ndef rotate(c, n):\n    index = (rotations.index(c) + n) % 28\n    return rotations[index]\n\n\nwhile True:\n    line = input()\n    if line == \"0\":\n        break\n    n, m = line.split()\n    n = int(n)\n    print(\"\".join([rotate(c, n) for c in m[::-1]]))\n
"},{"location":"solutions/#rijeci","title":"Rije\u010di","text":"Solutions in 4 languages GoJavaLuaPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var n int\n    fmt.Scan(&n)\n    a := 1\n    b := 0\n    for i := 0; i < n; i++ {\n        a, b = b, b+a\n    }\n    fmt.Println(a, b)\n}\n
import java.util.Scanner;\n\nclass Rijeci {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int k = s.nextInt();\n        int a = 1;\n        int b = 0;\n        for (int i = 0; i < k; i++) {\n            int t = b;\n            b = a + b;\n            a = t;\n\n        }\n\n        System.out.println(a + \" \" + b);\n    }\n}\n
k = io.read(\"*n\")\nlocal a, b = 1, 0\nfor i = 1, k do\n    a, b = b, b + a\nend\nprint(a, b)\n
k = int(input())\na, b = 1, 0\nfor _ in range(k):\n    a, b = b, b + a\n\nprint(a, b)\n
"},{"location":"solutions/#roaming-romans","title":"Roaming Romans","text":"Solutions in 3 languages GoLuaPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var x float64\n    fmt.Scan(&x)\n    fmt.Println(int(x*1000*5280/4854 + 0.5))\n}\n
x = io.read(\"*n\")\nprint(math.floor(x * 1000 * 5280 / 4854 + .5))\n
x = float(input())\nprint(int(x * 1000 * 5280 / 4854 + 0.5))\n
"},{"location":"solutions/#run-length-encoding-run","title":"Run-Length Encoding, Run!","text":"Solution in Python Python
action, s = input().split()\nif action == \"D\":\n    print(\"\".join([s[i] * int(s[i + 1]) for i in range(0, len(s), 2)]))\nelif action == \"E\":\n    parts = []\n    prev, t = s[0], 1\n    for c in s[1:]:\n        if c != prev:\n            parts.append((prev, t))\n            t = 1\n            prev = c\n        else:\n            t += 1\n    parts.append((prev, t))\n\n    print(\"\".join([f\"{k}{v}\" for k, v in parts]))\n
"},{"location":"solutions/#same-digits-easy","title":"Same Digits (Easy)","text":"Solution in Python Python
a, b = [int(d) for d in input().split()]\npairs = []\nfor x in range(a, b + 1):\n    for y in range(x, b + 1):\n        xy = x * y\n        if sorted(str(xy)) == sorted(str(x) + str(y)):\n            pairs.append((x, y, xy))\nprint(f\"{len(pairs)} digit-preserving pair(s)\")\nfor x, y, xy in pairs:\n    print(f\"x = {x}, y = {y}, xy = {xy}\")\n
"},{"location":"solutions/#same-digits-hard","title":"Same Digits (Hard)","text":"Solution in Python Python
a, b = [int(d) for d in input().split()]\npairs = []\nfor x in range(a, b + 1):\n    for y in range(x, b + 1):\n        xy = x * y\n        if x * y > b:\n            break\n        if sorted(str(xy)) == sorted(str(x) + str(y)):\n            pairs.append((x, y, xy))\n    if x * x > b:\n        break\n\nprint(f\"{len(pairs)} digit-preserving pair(s)\")\nfor x, y, xy in pairs:\n    print(f\"x = {x}, y = {y}, xy = {xy}\")\n
"},{"location":"solutions/#saving-daylight","title":"Saving Daylight","text":"Solution in Python Python
while True:\n    try:\n        s = input().split()\n    except:\n        break\n\n    t1, t2 = s[-2:]\n\n    h1, m1 = [int(d) for d in t1.split(\":\")]\n    h2, m2 = [int(d) for d in t2.split(\":\")]\n\n    mins = (h2 - h1) * 60 + (m2 - m1)\n    h = mins // 60\n    m = mins % 60\n\n    ans = s[:-2]\n    ans.extend([str(h), \"hours\", str(m), \"minutes\"])\n\n    print(\" \".join(ans))\n
"},{"location":"solutions/#saving-for-retirement","title":"Saving For Retirement","text":"Solution in Python Python
import math\n\nB, Br, Bs, A, As = [int(d) for d in input().split()]\nrate = Bs * (Br - B) / As\nAr = math.ceil(rate) + A\nif rate.is_integer():\n    Ar += 1\nprint(Ar)\n
"},{"location":"solutions/#scaling-recipe","title":"Scaling Recipe","text":"Solution in Python Python
import math\n\nn, x, y = [int(d) for d in input().split()]\ni = [int(input()) for _ in range(n)]\n\n# for python 3.9+ (https://docs.python.org/3.9/library/math.html#math.gcd)\n# s = math.gcd(x, *i)\n\ns = math.gcd(x, i[0])\nfor k in range(1, n):\n    s = math.gcd(s, i[k])\n\nx /= s\ni = [v / s for v in i]\n\nscale = y / x\nfor v in i:\n    print(int(scale * v))\n
"},{"location":"solutions/#school-spirit","title":"School Spirit","text":"Solution in Python Python
n = int(input())\ns = []\nfor _ in range(n):\n    s.append(int(input()))\n\n\ndef group_score(s):\n    gs = 0\n    for i in range(len(s)):\n        gs += s[i] * (0.8**i)\n    return 0.2 * gs\n\n\nprint(group_score(s))\nnew_gs = []\nfor i in range(n):\n    new_gs.append(group_score([s[j] for j in range(n) if j != i]))\nprint(sum(new_gs) / len(new_gs))\n
"},{"location":"solutions/#secret-message","title":"Secret Message","text":"Solution in Python Python
import math\n\nfor _ in range(int(input())):\n    m = input()\n    k = math.ceil(len(m) ** 0.5)\n\n    m += \"*\" * (k * k - len(m))\n    rows = [m[i : i + k] for i in range(0, len(m), k)]\n\n    s = []\n    for i in range(k):\n        s.append(\"\".join([row[i] for row in rows if row[i] != \"*\"][::-1]))\n    print(\"\".join(s))\n
"},{"location":"solutions/#secure-doors","title":"Secure Doors","text":"Solution in Python Python
pool = set()\nfor _ in range(int(input())):\n    action, name = input().split()\n    if action == \"entry\":\n        print(name, \"entered\", \"(ANOMALY)\" if name in pool else \"\")\n        pool.add(name)\n    elif action == \"exit\":\n        print(name, \"exited\", \"(ANOMALY)\" if name not in pool else \"\")\n        pool.discard(name)\n
"},{"location":"solutions/#server","title":"Server","text":"Solution in Python Python
_, t = [int(d) for d in input().split()]\ntotal, used = 0, 0\nfor v in [int(d) for d in input().split()]:\n    if used + v <= t:\n        total += 1\n        used += v\n    else:\n        break\nprint(total)\n
"},{"location":"solutions/#seven-wonders","title":"Seven Wonders","text":"Solution in Python Python
from collections import Counter\n\nc = Counter(input())\nscore = 0\nfor value in c.values():\n    score += value**2\nif len(c.values()) == 3:\n    score += 7 * min(c.values())\nprint(score)\n
"},{"location":"solutions/#shattered-cake","title":"Shattered Cake","text":"Solution in Python Python
w, n = int(input()), int(input())\ntotal = 0\nfor _ in range(n):\n    _w, _l = [int(d) for d in input().split()]\n    total += _w * _l\nprint(int(total / w))\n
"},{"location":"solutions/#shopaholic","title":"Shopaholic","text":"Solution in Python Python
n = int(input())\nc = [int(d) for d in input().split()]\n\nc = sorted(c, reverse=True)\ngroups = [c[i : i + 3] if i + 3 < n else c[i:] for i in range(0, n, 3)]\n\nprint(sum(g[-1] if len(g) == 3 else 0 for g in groups))\n
"},{"location":"solutions/#shopping-list-easy","title":"Shopping List (Easy)","text":"Solution in Python Python
n, m = [int(d) for d in input().split()]\nitems = []\nfor _ in range(n):\n    items.append(set(input().split()))\n\nans = items[0]\nans = ans.intersection(*items[1:])\n\nprint(len(ans))\nprint(\"\\n\".join(sorted(list(ans))))\n
"},{"location":"solutions/#sibice","title":"Sibice","text":"Solution in Python Python
import math\n\nn, w, h = [int(d) for d in input().split()]\nfor _ in range(n):\n    line = int(input())\n    if line <= math.sqrt(w**2 + h**2):\n        print(\"DA\")\n    else:\n        print(\"NE\")\n
"},{"location":"solutions/#sideways-sorting","title":"Sideways Sorting","text":"Solution in Python Python
while True:\n    r, c = [int(d) for d in input().split()]\n    if not r and not c:\n        break\n    s = []\n    for _ in range(r):\n        s.append(input())\n    items = []\n    for i in range(c):\n        items.append(\"\".join(s[j][i] for j in range(r)))\n    items = sorted(items, key=lambda t: t.lower())\n    for i in range(r):\n        print(\"\".join(items[j][i] for j in range(c)))\n
"},{"location":"solutions/#digit-product","title":"Digit Product","text":"Solution in Python Python
def digit_product(x):\n    ans = 1\n    while x:\n        ans *= x % 10 or 1\n        x //= 10\n    return ans\n\n\nx = int(input())\nwhile True:\n    x = digit_product(x)\n    if x < 10:\n        break\nprint(x)\n
"},{"location":"solutions/#simon-says","title":"Simon Says","text":"Solution in Python Python
for _ in range(int(input())):\n    command = input()\n    start = \"simon says \"\n    if command.startswith(start):\n        print(command[len(start) :])\n    else:\n        print()\n
"},{"location":"solutions/#simone","title":"Simone","text":"Solution in Python Python
from collections import Counter\n\nn, k = [int(d) for d in input().split()]\n\ns = Counter(int(d) for d in input().split())\n\nleast = min(s.values())\nif len(s.values()) < k:\n    least = 0\nans = 0\nc = []\nfor i in range(k):\n    if s[i + 1] == least:\n        c.append(str(i + 1))\n        ans += 1\nprint(ans)\nprint(\" \".join(c))\n
"},{"location":"solutions/#simon-says_1","title":"Simon Says","text":"Solution in Python Python
for _ in range(int(input())):\n    command = input()\n    start = \"Simon says \"\n    if command.startswith(start):\n        print(command[len(start) :])\n
"},{"location":"solutions/#simple-addition","title":"Simple Addition","text":"Solution in Python Python
a, b = input(), input()\n\na = a[::-1]\nb = b[::-1]\ni = 0\nans = \"\"\ncarry = 0\nwhile i < len(a) or i < len(b):\n    if i < len(a) and i < len(b):\n        s = int(a[i]) + int(b[i]) + carry\n\n    elif i < len(a):\n        s = int(a[i]) + carry\n\n    else:\n        s = int(b[i]) + carry\n    ans += str(s % 10)\n    carry = s // 10\n    i += 1\nif carry:\n    ans += str(carry)\nprint(ans[::-1])\n\n# or simply\n# print(int(a) + int(b))\n
"},{"location":"solutions/#simple-factoring","title":"Simple Factoring","text":"Solution in Python Python
for _ in range(int(input())):\n    a, b, c = [int(d) for d in input().split()]\n    import math\n\n    if not b**2 - 4 * a * c < 0 and math.sqrt(b**2 - 4 * a * c).is_integer():\n        print(\"YES\")\n    else:\n        print(\"NO\")\n
"},{"location":"solutions/#sith","title":"Sith","text":"Solution in Python Python
_ = input()\na = int(input())\nb = int(input())\ndiff = int(input())\nif diff <= 0:\n    print(\"JEDI\")\nelif a < b:\n    print(\"SITH\")\nelse:\n    print(\"VEIT EKKI\")\n
"},{"location":"solutions/#sjecista","title":"Sjecista","text":"Solution in Python Python
n = int(input())\nprint((n - 3) * (n - 2) * (n - 1) * (n) // 24)\n
"},{"location":"solutions/#skammstofun","title":"Skammst\u00f6fun","text":"Solution in Python Python
_ = input()\nwords = input().split()\nprint(\"\".join([w[0] for w in words if w[0].isupper()]))\n
"},{"location":"solutions/#skener","title":"Skener","text":"Solution in Python Python
r, _, zr, zc = [int(d) for d in input().split()]\nmatrix = []\nfor _ in range(r):\n    matrix.append(input())\n\nans = []\n\nfor row in matrix:\n    for i in range(zr):\n        ans.append(row)\n\nfor row in ans:\n    print(\"\".join([col * zc for col in row]))\n
"},{"location":"solutions/#skocimis","title":"Skocimis","text":"Solutions in 3 languages GoLuaPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var a, b, c int\n    fmt.Scan(&a)\n    fmt.Scan(&b)\n    fmt.Scan(&c)\n    x := b - a\n    y := c - b\n    ans := x\n    if ans < y {\n        ans = y\n    }\n    ans -= 1\n    fmt.Println(ans)\n}\n
a, b, c = io.read(\"*n\", \"*n\", \"*n\")\nprint(math.max(b - a, c - b) - 1)\n
a, b, c = [int(d) for d in input().split()]\nprint(max(b - a, c - b) - 1)\n
"},{"location":"solutions/#turn-it-up","title":"Turn It Up!","text":"Solution in Python Python
volume = 7\nfor _ in range(int(input())):\n    if input() == \"Skru op!\":\n        volume = min(volume + 1, 10)\n    else:\n        volume = max(volume - 1, 0)\nprint(volume)\n
"},{"location":"solutions/#slatkisi","title":"Slatkisi","text":"Solution in Python Python
c, k = [int(d) for d in input().split()]\nd = 10**k\nc = (c // d) * d + (d if (c % d) / d >= 0.5 else 0)\nprint(c)\n
"},{"location":"solutions/#smil","title":"SMIL","text":"Solutions in 2 languages JavaPython
import java.util.Scanner;\n\nclass SMIL {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        String m = s.nextLine();\n        int size = m.length();\n        int i = 0;\n        while (i < size) {\n            if (m.charAt(i) == ':' || m.charAt(i) == ';') {\n                if (i + 1 < size && m.charAt(i + 1) == ')') {\n                    System.out.println(i);\n                    i += 2;\n                    continue;\n                }\n                if (i + 2 < size && m.charAt(i + 1) == '-' && m.charAt(i + 2) == ')') {\n                    System.out.println(i);\n                    i += 3;\n                    continue;\n                }\n            }\n            i += 1;\n        }\n    }\n}\n
s = input()\n\ni = 0\nsize = len(s)\nwhile i < size:\n    if s[i] in [\":\", \";\"]:\n        if i + 1 < size and s[i + 1] == \")\":\n            print(i)\n            i += 2\n            continue\n        if i + 2 < size and s[i + 1] == \"-\" and s[i + 2] == \")\":\n            print(i)\n            i += 3\n            continue\n\n    i += 1\n
"},{"location":"solutions/#soda-slurper","title":"Soda Slurper","text":"Solutions in 2 languages GoPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var e, f, c int\n    fmt.Scan(&e)\n    fmt.Scan(&f)\n    fmt.Scan(&c)\n    total := 0\n    s := e + f\n    for s >= c {\n        total += s / c\n        s = s%c + s/c\n    }\n    fmt.Println(total)\n}\n
e, f, c = [int(d) for d in input().split()]\ntotal = 0\ns = e + f\nwhile s >= c:\n    total += s // c\n    s = s % c + s // c\nprint(total)\n
"},{"location":"solutions/#sok","title":"Sok","text":"Solution in Python Python
a, b, c = [int(d) for d in input().split()]\ni, j, k = [int(d) for d in input().split()]\ns = min(a / i, b / j, c / k)\nprint(a - i * s, b - j * s, c - k * s)\n
"},{"location":"solutions/#some-sum","title":"Some Sum","text":"Solution in Python Python
n = int(input())\nif n == 1:\n    print(\"Either\")\nelif n == 2:\n    print(\"Odd\")\nelif n % 2 == 0:\n    print(\"Even\" if (n / 2) % 2 == 0 else \"Odd\")\nelse:\n    print(\"Either\")\n
"},{"location":"solutions/#sort","title":"Sort","text":"Solution in Python Python
from collections import Counter\n\nn, c = [int(d) for d in input().split()]\nnum = [int(d) for d in input().split()]\n\nfreq = Counter(num)\nprint(\n    \" \".join(\n        [\n            str(d)\n            for d in sorted(\n                num, key=lambda k: (freq[k], n - num.index(k)), reverse=True\n            )\n        ]\n    )\n)\n
"},{"location":"solutions/#sort-of-sorting","title":"Sort of Sorting","text":"Solution in Python Python
first = True\nwhile True:\n    n = int(input())\n    if not n:\n        break\n    else:\n        if not first:\n            print()\n    first = False\n    names = []\n    for _ in range(n):\n        names.append(input())\n    print(\"\\n\".join(sorted(names, key=lambda k: k[:2])))\n
"},{"location":"solutions/#sort-two-numbers","title":"Sort Two Numbers","text":"Solutions in 4 languages C++GoLuaPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int a = 0, b = 0;\n    cin >> a >> b;\n    if (a < b)\n    {\n        cout << a << \" \" << b;\n    }\n    else\n    {\n        cout << b << \" \" << a;\n    }\n}\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var a, b int\n    fmt.Scan(&a)\n    fmt.Scan(&b)\n    if a < b {\n        fmt.Printf(\"%d %d\\n\", a, b)\n    } else {\n        fmt.Printf(\"%d %d\\n\", b, a)\n    }\n}\n
a, b = io.read(\"*n\", \"*n\")\nif a < b then\n    print(a, b)\nelse\n    print(b, a)\nend\n
line = input()\na, b = [int(d) for d in line.split()]\nif a < b:\n    print(a, b)\nelse:\n    print(b, a)\n
"},{"location":"solutions/#sottkvi","title":"S\u00f3ttkv\u00ed","text":"Solutions in 2 languages JavaPython
import java.util.Scanner;\n\nclass Sottkvi {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int n = s.nextInt();\n        int k = s.nextInt();\n        int today = s.nextInt();\n        int ans = 0;\n        for (int i = 0; i < n; i++) {\n            int d = s.nextInt();\n            if (d + 14 - today <= k) {\n                ans += 1;\n            }\n        }\n        System.out.println(ans);\n\n    }\n}\n
n, k, today = [int(d) for d in input().split()]\nres = 0\nfor _ in range(n):\n    d = int(input())\n    if d + 14 - today <= k:\n        res += 1\nprint(res)\n
"},{"location":"solutions/#soylent","title":"Soylent","text":"Solution in Python Python
import math\n\nfor _ in range(int(input())):\n    n = int(input())\n    print(math.ceil(n / 400))\n
"},{"location":"solutions/#space-race","title":"Space Race","text":"Solution in Python Python
n = int(input())\n_ = input()\nd = {}\nfor _ in range(n):\n    entry = input().split()\n    d[entry[0]] = float(entry[-1])\n\nprint(min(d, key=lambda k: d[k]))\n
"},{"location":"solutions/#spavanac","title":"Spavanac","text":"Solutions in 3 languages C++JavaPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int h, m;\n    cin >> h >> m;\n\n    int mm = m - 45;\n    int borrow = 0;\n    if (mm < 0)\n    {\n        mm += 60;\n        borrow = 1;\n    }\n    int hh = h - borrow;\n    if (hh < 0)\n    {\n        hh += 24;\n    }\n    cout << hh << \" \" << mm << endl;\n    return 0;\n}\n
import java.util.Scanner;\n\nclass Spavanac {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int h = s.nextInt();\n        int m = s.nextInt();\n\n        int mm = m - 45;\n        int borrow = 0;\n        if (mm < 0) {\n            mm += 60;\n            borrow = 1;\n        }\n\n        int hh = h - borrow;\n        if (hh < 0) {\n            hh += 24;\n        }\n        System.out.println(hh + \" \" + mm);\n    }\n}\n
h, m = [int(d) for d in input().split()]\n\nmm = m - 45\n\nborrow = 0\nif mm < 0:\n    mm += 60\n    borrow = 1\n\nhh = h - borrow\nif hh < 0:\n    hh += 24\n\nprint(hh, mm)\n
"},{"location":"solutions/#speeding","title":"Speeding","text":"Solution in Python Python
n = int(input())\nmile, time, max_speed = 0, 0, 0\nfor _ in range(n):\n    t, s = [int(d) for d in input().split()]\n    if not t and not s:\n        continue\n    speed = int((s - mile) / (t - time))\n    if speed > max_speed:\n        max_speed = speed\n    mile, time = s, t\nprint(max_speed)\n
"},{"location":"solutions/#speed-limit","title":"Speed Limit","text":"Solution in Python Python
while True:\n    n = int(input())\n    if n == -1:\n        break\n    miles = 0\n    elapsed = 0\n    for _ in range(n):\n        s, t = [int(d) for d in input().split()]\n        miles += s * (t - elapsed)\n        elapsed = t\n    print(f\"{miles} miles\")\n
"},{"location":"solutions/#spelling-bee","title":"Spelling Bee","text":"Solution in Python Python
hexagon = input()\nc = hexagon[0]\nhexagon = set(list(hexagon))\nn = int(input())\nvalid = []\nfor _ in range(n):\n    w = input()\n    if c in w and len(w) >= 4 and set(list(w)) <= hexagon:\n        valid.append(w)\nprint(\"\\n\".join(valid))\n
"},{"location":"solutions/#spritt","title":"Spritt","text":"Solution in Python Python
n, x = [int(d) for d in input().split()]\nfor _ in range(n):\n    x -= int(input())\n    if x < 0:\n        print(\"Neibb\")\n        break\nif x >= 0:\n    print(\"Jebb\")\n
"},{"location":"solutions/#square-peg","title":"Square Peg","text":"Solution in Python Python
l, r = [int(d) for d in input().split()]\nif 2 * (l / 2) ** 2 <= r**2:\n    print(\"fits\")\nelse:\n    print(\"nope\")\n
"},{"location":"solutions/#stafur","title":"Stafur","text":"Solution in Python Python
l = input()\nif l in \"AEIOU\":\n    print(\"Jebb\")\nelif l == \"Y\":\n    print(\"Kannski\")\nelse:\n    print(\"Neibb\")\n
"},{"location":"solutions/#statistics","title":"Statistics","text":"Solution in Python Python
case_num = 0\nwhile True:\n    try:\n        line = input()\n    except:\n        break\n    case_num += 1\n    numbers = [int(d) for d in line.split()[1:]]\n    print(f\"Case {case_num}: {min(numbers)} {max(numbers)} {max(numbers)-min(numbers)}\")\n
"},{"location":"solutions/#sticky-keys","title":"Sticky Keys","text":"Solution in Python Python
message = input()\n\nl = [message[0]]\nfor i in message[1:]:\n    if i != l[-1]:\n        l.append(i)\nprint(\"\".join(l))\n
"},{"location":"solutions/#messy-lists","title":"Messy lists","text":"Solution in Python Python
n = int(input())\na = [int(d) for d in input().split()]\ns = sorted(a)\nprint(sum([i != j for i, j in zip(a, s)]))\n
"},{"location":"solutions/#stopwatch","title":"Stopwatch","text":"Solution in Python Python
n = int(input())\ntimes = []\nfor _ in range(n):\n    times.append(int(input()))\nif n % 2:\n    print(\"still running\")\nelse:\n    seconds = 0\n    for i in range(0, n, 2):\n        seconds += times[i + 1] - times[i]\n    print(seconds)\n
"},{"location":"solutions/#streets-ahead","title":"Streets Ahead","text":"Solution in Python Python
n, q = [int(d) for d in input().split()]\n\ns = {}\nfor i in range(n):\n    s[input()] = i\n\nfor _ in range(q):\n    a, b = input().split()\n    print(abs(s[a] - s[b]) - 1)\n
"},{"location":"solutions/#successful-zoom","title":"Successful Zoom","text":"Solution in Python Python
n = int(input())\nx = [int(d) for d in input().split()]\nfound = False\nfor k in range(1, n // 2 + 1):\n    v = [x[i] for i in range(k - 1, n, k)]\n    if all([v[i] < v[i + 1] for i in range(len(v) - 1)]):\n        print(k)\n        found = True\n        break\nif not found:\n    print(\"ABORT!\")\n
"},{"location":"solutions/#sum-kind-of-problem","title":"Sum Kind of Problem","text":"Solution in Python Python
for _ in range(int(input())):\n    k, n = [int(d) for d in input().split()]\n    s1 = sum(range(1, n + 1))\n    s2 = sum(range(1, 2 * n + 1, 2))\n    s3 = sum(range(2, 2 * (n + 1), 2))\n    print(k, s1, s2, s3)\n
"},{"location":"solutions/#sum-of-the-others","title":"Sum of the Others","text":"Solution in Python Python
while True:\n    try:\n        n = [int(d) for d in input().split()]\n    except:\n        break\n\n    for i in range(len(n)):\n        if n[i] == sum([n[j] for j in range(len(n)) if j != i]):\n            print(n[i])\n            break\n
"},{"location":"solutions/#sum-squared-digits-function","title":"Sum Squared Digits Function","text":"Solution in Python Python
for _ in range(int(input())):\n    k, b, n = [int(d) for d in input().split()]\n    ssd = 0\n    while n:\n        ssd += (n % b) ** 2\n        n //= b\n    print(k, ssd)\n
"},{"location":"solutions/#sun-and-moon","title":"Sun and Moon","text":"Solution in Python Python
sun_years_ago, sun_cycle = [int(v) for v in input().split()]\nmoon_years_ago, moon_cycle = [int(v) for v in input().split()]\n\nfor t in range(1, 5001):\n    if (t + sun_years_ago) % sun_cycle == 0 and (t + moon_years_ago) % moon_cycle == 0:\n        print(t)\n        break\n
"},{"location":"solutions/#symmetric-order","title":"Symmetric Order","text":"Solution in Python Python
set_num = 0\nwhile True:\n    size = int(input())\n    if size == 0:\n        break\n\n    names = []\n    for _ in range(size):\n        names.append(input())\n\n    set_num += 1\n    print(f\"SET {set_num}\")\n\n    top, bottom = [], []\n    for i in range(1, size, 2):\n        bottom.append(names[i])\n    for i in range(0, size, 2):\n        top.append(names[i])\n    names = top + bottom[::-1]\n    for name in names:\n        print(name)\n
"},{"location":"solutions/#synchronizing-lists","title":"Synchronizing Lists","text":"Solution in Python Python
while True:\n    n = int(input())\n    if not n:\n        break\n    a, b = [], []\n    for _ in range(n):\n        a.append(int(input()))\n    for _ in range(n):\n        b.append(int(input()))\n    mapping = dict(zip(sorted(a), sorted(b)))\n    for key in a:\n        print(mapping[key])\n    print()\n
"},{"location":"solutions/#t9-spelling","title":"T9 Spelling","text":"Solution in Python Python
n = int(input())\nmapping = {\n    \"2\": \"abc\",\n    \"3\": \"def\",\n    \"4\": \"ghi\",\n    \"5\": \"jkl\",\n    \"6\": \"mno\",\n    \"7\": \"pqrs\",\n    \"8\": \"tuv\",\n    \"9\": \"wxyz\",\n    \"0\": \" \",\n}\n\nfor i in range(n):\n    ans = []\n    prev = \"\"\n    for c in input():\n        for d, r in mapping.items():\n            if c in r:\n                if d == prev:\n                    ans.append(\" \")\n                ans.append(d * (r.index(c) + 1))\n                prev = d\n                break\n    print(f\"Case #{i+1}: {''.join(ans)}\")\n
"},{"location":"solutions/#tais-formula","title":"Tai's formula","text":"Solution in Python Python
n = int(input())\nt1, v1 = [float(d) for d in input().split()]\ntotal = 0\nfor _ in range(n - 1):\n    t2, v2 = [float(d) for d in input().split()]\n    total += (v1 + v2) * (t2 - t1) / 2\n    t1, v1 = t2, v2\ntotal /= 1000\nprint(total)\n
"},{"location":"solutions/#tajna","title":"Tajna","text":"Solution in Python Python
s = input()\n\nl = len(s)\nr = int(l**0.5)\nwhile l % r:\n    r -= 1\nc = l // r\n\nparts = [s[i : i + r] for i in range(0, l, r)]\n\nprint(\"\".join([\"\".join([row[i] for row in parts]) for i in range(r)]))\n
"},{"location":"solutions/#tarifa","title":"Tarifa","text":"Solutions in 2 languages LuaPython
x = io.read(\"*n\")\nn = io.read(\"*n\")\nlocal used = 0\nfor i = 1, n do\n    used = used + io.read(\"*n\")\nend\nprint(x * (n + 1) - used)\n
x = int(input())\nn = int(input())\nused = 0\nfor _ in range(n):\n    used += int(input())\nprint(x * (n + 1) - used)\n
"},{"location":"solutions/#time-travelling-temperatures","title":"Time Travelling Temperatures","text":"Solution in Python Python
x, y = [int(d) for d in input().split()]\nif y == 1:\n    print(\"ALL GOOD\" if not x else \"IMPOSSIBLE\")\nelse:\n    print(-x / (y - 1))\n
"},{"location":"solutions/#temperature-confusion","title":"Temperature Confusion","text":"Solution in Python Python
import math\n\na, b = [int(d) for d in input().split(\"/\")]\nx, y = 5 * a - 160 * b, 9 * b\ngcd = math.gcd(x, y)\nx //= gcd\ny //= gcd\n\nprint(f\"{x}/{y}\")\n
"},{"location":"solutions/#test-drive","title":"Test Drive","text":"Solution in Python Python
a, b, c = [int(d) for d in input().split()]\nx, y = b - a, c - b\nif x == y:\n    print(\"cruised\")\nelif x * y < 0:\n    print(\"turned\")\nelif abs(y) > abs(x):\n    print(\"accelerated\")\nelse:\n    print(\"braked\")\n
"},{"location":"solutions/#tetration","title":"Tetration","text":"Solution in Python Python
import math\n\nn = float(input())\nprint(f\"{math.pow(n,1/n):.6f}\")\n
"},{"location":"solutions/#thanos","title":"Thanos","text":"Solution in Python Python
for _ in range(int(input())):\n    p, r, f = [int(d) for d in input().split()]\n    y = 0\n    while p <= f:\n        p *= r\n        y += 1\n    print(y)\n
"},{"location":"solutions/#the-grand-adventure","title":"The Grand Adventure","text":"Solution in Python Python
mapping = {\"b\": \"$\", \"t\": \"|\", \"j\": \"*\"}\nfor _ in range(int(input())):\n    a = input()\n    bag = []\n    early_fail = False\n    for i in a:\n        if i in mapping.values():\n            bag.append(i)\n        elif i in mapping:\n            if not bag or bag.pop() != mapping[i]:\n                print(\"NO\")\n                early_fail = True\n                break\n    if not early_fail:\n        print(\"YES\" if not bag else \"NO\")\n
"},{"location":"solutions/#the-last-problem","title":"The Last Problem","text":"Solutions in 3 languages GoLuaPython
package main\n\nimport (\n    \"bufio\"\n    \"fmt\"\n    \"os\"\n)\n\nfunc main() {\n    scanner := bufio.NewScanner(os.Stdin)\n    scanner.Scan()\n    s := scanner.Text()\n    fmt.Println(\"Thank you,\", s+\",\", \"and farewell!\")\n}\n
print(string.format(\"Thank you, %s, and farewell!\", io.read()))\n
print(f\"Thank you, {input()}, and farewell!\")\n
"},{"location":"solutions/#the-plank","title":"The Plank","text":"Solutions in 4 languages C++GoLuaPython
#include <iostream>\n\nusing namespace std;\n\nint f(int n)\n{\n    if (n == 0)\n    {\n        return 1;\n    }\n    else if (n == 1)\n    {\n        return 1;\n    }\n    else if (n == 2)\n    {\n        return 2;\n    }\n    else\n    {\n        return f(n - 1) + f(n - 2) + f(n - 3);\n    }\n}\n\nint main()\n{\n    int n;\n    cin >> n;\n    cout << f(n) << endl;\n    return 0;\n}\n
package main\n\nimport \"fmt\"\n\nfunc f(n int) int {\n    if n == 0 {\n        return 1\n    } else if n == 1 {\n        return 1\n    } else if n == 2 {\n        return 2\n    } else {\n        return f(n-1) + f(n-2) + f(n-3)\n    }\n\n}\n\nfunc main() {\n    var n int\n    fmt.Scan(&n)\n    fmt.Println(f(n))\n}\n
function f(n)\n  if n == 0 then\n    return 1\n  elseif n == 1 then\n    return 1\n  elseif n == 2 then\n    return 2\n  else\n    return f(n - 1) + f(n - 2) + f(n - 3)\n  end\nend\n\nn = io.read(\"*n\")\nprint(f(n))\n
def f(n):\n    if n < 3:\n        return {0: 1, 1: 1, 2: 2}[n]\n    else:\n        return f(n - 1) + f(n - 2) + f(n - 3)\n\n\nprint(f(int(input())))\n
"},{"location":"solutions/#this-aint-your-grandpas-checkerboard","title":"This Ain't Your Grandpa's Checkerboard","text":"Solution in Python Python
n = int(input())\nb = []\nfor _ in range(n):\n    b.append(input())\n\n\ndef check(b, n):\n    for row in b:\n        if row.count(\"W\") != row.count(\"B\"):\n            return False\n\n        for j in range(0, n - 3):\n            if row[j] == row[j + 1] == row[j + 2]:\n                return False\n\n    for i in range(n):\n        col = [\"\".join(row[i]) for row in b]\n\n        if col.count(\"W\") != col.count(\"B\"):\n            return False\n\n        for j in range(0, n - 3):\n            if col[j] == col[j + 1] == col[j + 2]:\n                return False\n\n    return True\n\n\nvalid = check(b, n)\nprint(1 if valid else 0)\n
"},{"location":"solutions/#stuck-in-a-time-loop","title":"Stuck In A Time Loop","text":"Solutions in 2 languages C++Python
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int a;\n    cin >> a;\n    for (int i = 0; i < a; i++)\n    {\n        cout << i + 1 << \" Abracadabra\" << endl;\n    }\n}\n
n = int(input())\nfor i in range(n):\n    print(f\"{i+1} Abracadabra\")\n
"},{"location":"solutions/#title-cost","title":"Title Cost","text":"Solution in Python Python
s, c = input().split()\nc = float(c)\nprint(min(c, len(s)))\n
"},{"location":"solutions/#toflur","title":"T\u00f6flur","text":"Solution in Python Python
n = int(input())\na = sorted([int(d) for d in input().split()])\nscore = sum([(a[j] - a[j + 1]) ** 2 for j in range(n - 1)])\nprint(score)\n
"},{"location":"solutions/#toilet-seat","title":"Toilet Seat","text":"Solution in Python Python
t = input()\n\n\ndef u(pos, preference):\n    if pos == preference == \"U\":\n        return 0\n    elif pos == preference == \"D\":\n        return 1\n    elif pos == \"U\" and preference == \"D\":\n        return 2\n    else:\n        return 1\n\n\ndef l(pos, preference):\n    if pos == preference == \"U\":\n        return 1\n    elif pos == preference == \"D\":\n        return 0\n    elif pos == \"U\" and preference == \"D\":\n        return 1\n    else:\n        return 2\n\n\ndef b(pos, preference):\n    if pos == preference:\n        return 0\n    else:\n        return 1\n\n\npu = [u(pos, preference) for pos, preference in zip(t[0] + \"U\" * (len(t) - 2), t[1:])]\npl = [l(pos, preference) for pos, preference in zip(t[0] + \"D\" * (len(t) - 2), t[1:])]\npb = [b(pos, preference) for pos, preference in zip(t[0] + t[1:-1], t[1:])]\n\nprint(sum(pu))\nprint(sum(pl))\nprint(sum(pb))\n
"},{"location":"solutions/#tolower","title":"ToLower","text":"Solution in Python Python
p, t = [int(d) for d in input().split()]\nscore = 0\nfor _ in range(p):\n    solved = True\n    for _ in range(t):\n        s = input()\n        if solved:\n            s = s[0].lower() + s[1:]\n            if s.lower() == s:\n                continue\n        solved = False\n    if solved:\n        score += 1\nprint(score)\n
"},{"location":"solutions/#tolvunarfringar-telja","title":"T\u00f6lvunarfr\u00e6\u00f0ingar telja","text":"Solutions in 4 languages C++GoLuaPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int n;\n    cin >> n;\n    cout << n - 1 << endl;\n    return 0;\n}\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var n int\n    fmt.Scan(&n)\n    fmt.Println(n-1)\n}\n
n = io.read(\"*n\")\nprint(n - 1)\n
print(int(input()) - 1)\n
"},{"location":"solutions/#tower-construction","title":"Tower Construction","text":"Solution in Python Python
_ = input()\nn = 0\ntop = 0\nfor d in [int(d) for d in input().split()]:\n    if not top or d > top:\n        n += 1\n    top = d\n\nprint(n)\n
"},{"location":"solutions/#touchscreen-keyboard","title":"Touchscreen Keyboard","text":"Solution in Python Python
k = [\n    \"qwertyuiop\",\n    \"asdfghjkl\",\n    \"zxcvbnm\",\n]\n\n\ndef d(a, b):\n    for r1 in range(3):\n        if a in k[r1]:\n            c1 = k[r1].index(a)\n            break\n    for r2 in range(3):\n        if b in k[r2]:\n            c2 = k[r2].index(b)\n            break\n\n    return abs(c1 - c2) + abs(r1 - r2)\n\n\nfor _ in range(int(input())):\n    x, n = input().split()\n    n, w = int(n), []\n\n    for _ in range(n):\n        y = input()\n        dist = sum([d(a, b) for a, b in zip(list(x), list(y))])\n        w.append([y, dist])\n\n    print(\"\\n\".join([f\"{k} {v}\" for k, v in sorted(w, key=lambda k: (k[1], k[0]))]))\n
"},{"location":"solutions/#tram","title":"Tram","text":"Solutions in 2 languages LuaPython
n = io.read(\"*n\")\nd = 0\nfor i = 1, n do\n    x, y = io.read(\"*n\", \"*n\")\n    d = d + 2 * (x - y)\nend\nprint(-d / (2 * n))\n
n = int(input())\nd = 0\nfor _ in range(n):\n    x, y = [int(i) for i in input().split()]\n    d += 2 * (x - y)\nprint(-d / (2 * n))\n
"},{"location":"solutions/#transit-woes","title":"Transit Woes","text":"Solution in Python Python
s, t, n = [int(d) for d in input().split()]\nds = [int(d) for d in input().split()]\nbs = [int(d) for d in input().split()]\ncs = [int(d) for d in input().split()]\n\nfor i in range(n):\n    s += ds[i]\n    if not s % cs[i]:\n        wait_b = 0\n    else:\n        wait_b = cs[i] - s % cs[i]\n    s += wait_b + bs[i]\n\ns += ds[n]\n\nif s <= t:\n    print(\"yes\")\nelse:\n    print(\"no\")\n
"},{"location":"solutions/#tri","title":"Tri","text":"Solution in Python Python
from operator import add, sub, truediv, mul\n\na, b, c = [int(d) for d in input().split()]\nops = {\n    \"+\": add,\n    \"-\": sub,\n    \"*\": mul,\n    \"/\": truediv,\n}\n\nfor op, func in ops.items():\n    if a == func(b, c):\n        print(f\"{a}={b}{op}{c}\")\n        break\n    if func(a, b) == c:\n        print(f\"{a}{op}{b}={c}\")\n
"},{"location":"solutions/#triangle-area","title":"Triangle Area","text":"Solutions in 5 languages C++GoJavaLuaPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int h, b;\n    cin >> h >> b;\n    cout << float(h) * b / 2 << endl;\n    return 0;\n}\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var a, b int\n    fmt.Scan(&a)\n    fmt.Scan(&b)\n    fmt.Println(float32(a) * float32(b) / 2)\n}\n
import java.util.Scanner;\n\nclass TriangleArea {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        float a = s.nextFloat();\n        int b = s.nextInt();\n        System.out.println(a * b / 2);\n    }\n}\n
a, b = io.read(\"*n\", \"*n\")\nprint(a * b / 2)\n
a, b = [int(d) for d in input().split()]\nprint(a * b / 2)\n
"},{"location":"solutions/#trik","title":"Trik","text":"Solution in Python Python
moves = input()\nball = [1, 0, 0]\nfor move in moves:\n    if move == \"A\":\n        ball[0], ball[1] = ball[1], ball[0]\n    if move == \"B\":\n        ball[1], ball[2] = ball[2], ball[1]\n    if move == \"C\":\n        ball[0], ball[2] = ball[2], ball[0]\n\nif ball[0]:\n    print(1)\nelif ball[1]:\n    print(2)\nelse:\n    print(3)\n
"},{"location":"solutions/#triple-texting","title":"Triple Texting","text":"Solution in Python Python
from collections import Counter\n\ns = input()\ntimes = 3\nsize = len(s) // times\nmessages = []\nfor i in range(0, len(s), size):\n    messages.append(s[i : i + size])\n\noriginal = \"\"\nfor i in range(size):\n    chars = [m[i] for m in messages]\n    if len(set(chars)) == 1:\n        original += chars[0]\n    else:\n        c = Counter(chars)\n        original += max(c, key=lambda k: c[k])\n\nprint(original)\n
"},{"location":"solutions/#take-two-stones","title":"Take Two Stones","text":"Solutions in 6 languages GoHaskellJavaJavaScriptKotlinPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var n int\n    fmt.Scan(&n)\n    if n%2 == 1 {\n        fmt.Println(\"Alice\")\n    } else {\n        fmt.Println(\"Bob\")\n    }\n}\n
main = do\n    input <- getLine\n    let n = (read input :: Int)\n    if  n `mod` 2  ==  1\n    then putStrLn \"Alice\"\n        else putStrLn \"Bob\"\n
import java.util.Scanner;\n\nclass TakeTwoStones {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int n = s.nextInt();\n        if (n % 2 == 1) {\n            System.out.println(\"Alice\");\n        } else {\n            System.out.println(\"Bob\");\n        }\n    }\n}\n
const readline = require(\"readline\");\nconst rl = readline.createInterface(process.stdin, process.stdout);\n\nrl.question(\"\", (n) => {\n  if (parseInt(n) % 2) {\n    console.log(\"Alice\");\n  } else {\n    console.log(\"Bob\");\n  }\n});\n
fun main() {\n    if (readLine()!!.toInt() % 2 == 1) {\n        println(\"Alice\")\n    } else {\n        println(\"Bob\")\n    }\n}\n
if int(input()) % 2:\n    print(\"Alice\")\nelse:\n    print(\"Bob\")\n
"},{"location":"solutions/#two-sum","title":"Two-sum","text":"Solutions in 4 languages C++GoJavaPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int a, b;\n    cin >> a >> b;\n    cout << a + b << endl;\n    return 0;\n}\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var a, b int\n    fmt.Scan(&a)\n    fmt.Scan(&b)\n    fmt.Println(a + b)\n}\n
import java.util.Scanner;\n\nclass TwoSum {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int a = s.nextInt();\n        int b = s.nextInt();\n        System.out.println(a + b);\n    }\n}\n
line = input()\na, b = [int(d) for d in line.split()]\nprint(a + b)\n
"},{"location":"solutions/#ullen-dullen-doff","title":"\u00dallen d\u00fallen doff","text":"Solution in Python Python
n = int(input())\nnames = input().split()\nif n < 13:\n    i = 13 % n - 1\nelse:\n    i = 12\nprint(names[i])\n
"},{"location":"solutions/#ultimate-binary-watch","title":"Ultimate Binary Watch","text":"Solution in Python Python
t = [int(d) for d in input()]\nb = [f\"{d:b}\".zfill(4) for d in t]\n\nfor r in range(4):\n    row = [\".\" if b[i][r] == \"0\" else \"*\" for i in range(4)]\n    row.insert(2, \" \")\n    print(\" \".join(row))\n
"},{"location":"solutions/#umfer","title":"Umfer\u00f0","text":"Solution in Python Python
m = int(input())\nn = int(input())\ncars = 0\nfor _ in range(n):\n    cars += input().count(\".\")\nprint(cars / (m * n))\n
"},{"location":"solutions/#undead-or-alive","title":"Undead or Alive","text":"Solution in Python Python
s = input()\n\nsmiley = \":)\" in s\n\nfrowny = \":(\" in s\n\nif not frowny and smiley:\n    print(\"alive\")\n\nelif frowny and not smiley:\n    print(\"undead\")\n\nelif frowny and smiley:\n    print(\"double agent\")\n\nelse:\n    print(\"machine\")\n
"},{"location":"solutions/#unlock-pattern","title":"Unlock Pattern","text":"Solution in Python Python
import math\n\n\ndef dist(a, b):\n    return math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)\n\n\ncoords = {}\nfor i in range(3):\n    n = [int(d) for d in input().split()]\n    for j in range(3):\n        coords[n[j]] = (i, j)\n\nvalues = [coords[k] for k in sorted(coords)]\ntotal, prev = 0, 0\nfor i in range(1, 9):\n    total += dist(values[i], values[prev])\n    prev = i\nprint(total)\n
"},{"location":"solutions/#arrangement","title":"Arrangement","text":"Solution in Python Python
import math\n\nn, m = int(input()), int(input())\n\nk = math.ceil(m / n)\n\nfor _ in range(n - (n * k - m)):\n    print(\"*\" * k)\nfor _ in range(n * k - m):\n    print(\"*\" * (k - 1))\n
"},{"location":"solutions/#utf-8","title":"UTF-8","text":"Solution in Python Python
n = int(input())\ns = []\nfor _ in range(n):\n    s.append(input())\n\ni = 0\nnum = 0\nerr = False\nt = [0] * 4\nwhile i < n:\n    a = s[i]\n    if a.startswith(\"0\") and not num:\n        num = 0\n        t[0] += 1\n    elif a.startswith(\"110\") and not num:\n        t[1] += 1\n        num = 1\n    elif a.startswith(\"1110\") and not num:\n        t[2] += 1\n        num = 2\n    elif a.startswith(\"11110\") and not num:\n        t[3] += 1\n        num = 3\n    elif a.startswith(\"10\") and num:\n        num -= 1\n    else:\n        err = True\n        break\n    i += 1\n\nif err or num:\n    print(\"invalid\")\nelse:\n    print(\"\\n\".join([str(d) for d in t]))\n
"},{"location":"solutions/#vaccine-efficacy","title":"Vaccine Efficacy","text":"Solution in Python Python
participants = int(input())\n\nvaccinated = 0\ncontrol = 0\ninfected_control_a = 0\ninfected_vaccinated_a = 0\ninfected_control_b = 0\ninfected_vaccinated_b = 0\ninfected_control_c = 0\ninfected_vaccinated_c = 0\n\nfor p in range(participants):\n    record = input()\n    v, a, b, c = list(record)\n\n    if v == \"N\":\n        control += 1\n    else:\n        vaccinated += 1\n\n    if a == \"Y\":\n        if v == \"N\":\n            infected_control_a += 1\n        else:\n            infected_vaccinated_a += 1\n\n    if b == \"Y\":\n        if v == \"N\":\n            infected_control_b += 1\n        else:\n            infected_vaccinated_b += 1\n\n    if c == \"Y\":\n        if v == \"N\":\n            infected_control_c += 1\n        else:\n            infected_vaccinated_c += 1\n\n\ndef get_vaccine_efficacy(infected_vaccinated, vaccinated, infected_control, control):\n    infection_rate_vaccinated = infected_vaccinated / vaccinated\n    infection_rate_control = infected_control / control\n    return 1 - infection_rate_vaccinated / infection_rate_control\n\n\nvaccine_efficacy = [\n    get_vaccine_efficacy(\n        infected_vaccinated_a,\n        vaccinated,\n        infected_control_a,\n        control,\n    ),\n    get_vaccine_efficacy(\n        infected_vaccinated_b,\n        vaccinated,\n        infected_control_b,\n        control,\n    ),\n    get_vaccine_efficacy(\n        infected_vaccinated_c,\n        vaccinated,\n        infected_control_c,\n        control,\n    ),\n]\n\nfor value in vaccine_efficacy:\n    if value <= 0:\n        print(\"Not Effective\")\n    else:\n        print(f\"{value*100:.6f}\")\n
"},{"location":"solutions/#right-of-way","title":"Right-of-Way","text":"Solution in Python Python
d = [\"North\", \"East\", \"South\", \"West\"]\na, b, c = input().split()\nia = d.index(a)\nib = d.index(b)\nic = d.index(c)\n\nib = (ib - ia) % 4\nic = (ic - ia) % 4\nia -= ia\n\nif ib == 2:\n    print(\"Yes\" if ic == 3 else \"No\")\nelif ib == 1:\n    print(\"Yes\" if ic in [2, 3] else \"No\")\nelse:\n    print(\"No\")\n
"},{"location":"solutions/#variable-arithmetic","title":"Variable Arithmetic","text":"Solution in Python Python
context = {}\nwhile True:\n    s = input()\n    if s == \"0\":\n        break\n\n    if \"=\" in s:\n        x, y = [d.strip() for d in s.split(\"=\")]\n        context[x] = int(y)\n    else:\n        v = [d.strip() for d in s.split(\"+\")]\n        t = 0\n        n = []\n        for d in v:\n            if d.isdigit():\n                t += int(d)\n            elif d in context:\n                t += context[d]\n            else:\n                n.append(d)\n        if len(n) < len(v):\n            n = [str(t)] + n\n        print(\" + \".join(n))\n
"},{"location":"solutions/#veci","title":"Veci","text":"Solution in Python Python
from itertools import permutations\n\nx = input()\n\nvalues = sorted(set([int(\"\".join(v)) for v in permutations(x, len(x))]))\n\nindex = values.index(int(x))\nif index + 1 < len(values):\n    print(values[index + 1])\nelse:\n    print(0)\n
"},{"location":"solutions/#vector-functions","title":"Vector Functions","text":"Solution in C++ C++
#include \"vectorfunctions.h\"\n#include <algorithm>\n\nvoid backwards(std::vector<int> &vec)\n{\n    vec = std::vector<int>(vec.rbegin(), vec.rend());\n}\n\nstd::vector<int> everyOther(const std::vector<int> &vec)\n{\n    std::vector<int> ans;\n\n    for (int i = 0; i < vec.size(); i += 2)\n        ans.push_back(vec[i]);\n\n    return ans;\n}\n\nint smallest(const std::vector<int> &vec)\n{\n    return *min_element(vec.begin(), vec.end());\n}\n\nint sum(const std::vector<int> &vec)\n{\n    int ans = 0;\n\n    for (auto it = begin(vec); it != end(vec); ++it)\n    {\n        ans += *it;\n    }\n\n    return ans;\n}\n\nint veryOdd(const std::vector<int> &suchVector)\n{\n    int ans = 0;\n    for (int i = 1; i < suchVector.size(); i += 2)\n    {\n        if (suchVector[i] % 2 == 1)\n            ans++;\n    }\n\n    return ans;\n}\n
"},{"location":"solutions/#veur-lokaar-heiar","title":"Ve\u00f0ur - Loka\u00f0ar hei\u00f0ar","text":"Solution in Python Python
v = int(input())\nfor _ in range(int(input())):\n    s, k = input().split()\n    if int(k) >= v:\n        print(s, \"opin\")\n    else:\n        print(s, \"lokud\")\n
"},{"location":"solutions/#veur-vindhrai","title":"Ve\u00f0ur - Vindhra\u00f0i","text":"Solution in Python Python
k = float(input())\nif k < 0.3:\n    print(\"logn\")\nelif k < 1.6:\n    print(\"Andvari\")\nelif k < 3.4:\n    print(\"Kul\")\nelif k < 5.5:\n    print(\"Gola\")\nelif k < 8.0:\n    print(\"Stinningsgola\")\nelif k < 10.8:\n    print(\"Kaldi\")\nelif k < 13.9:\n    print(\"Stinningskaldi\")\nelif k < 17.2:\n    print(\"Allhvass vindur\")\nelif k < 20.8:\n    print(\"Hvassvidri\")\nelif k < 24.5:\n    print(\"Stormur\")\nelif k < 28.5:\n    print(\"Rok\")\n\nelif k < 32.7:\n    print(\"Ofsavedur\")\nelse:\n    print(\"Farvidri\")\n
"},{"location":"solutions/#vefjonatjon","title":"Vef\u00fej\u00f3natj\u00f3n","text":"Solution in Python Python
n = int(input())\nparts = [0, 0, 0]\nfor _ in range(n):\n    for i, value in enumerate(input().split()):\n        if value == \"J\":\n            parts[i] += 1\nprint(min(parts))\n
"},{"location":"solutions/#velkomin","title":"Velkomin!","text":"Solutions in 6 languages JavaJavaScriptKotlinLuaPythonRuby
class Velkomin {\n    public static void main(String[] args) {\n        System.out.println(\"VELKOMIN!\");\n    }\n}\n
console.log(\"VELKOMIN!\");\n
fun main() {\n    println(\"VELKOMIN!\")\n}\n
print(\"VELKOMIN!\")\n
print(\"VELKOMIN!\")\n
puts \"VELKOMIN!\"\n
"},{"location":"solutions/#who-wins","title":"Who wins?","text":"Solution in Python Python
board = []\nfor _ in range(3):\n    board.append(input().split())\n\nwinner = \"\"\nfor i in range(3):\n    if board[i][0] == board[i][1] == board[i][2] and board[i][0] != \"_\":\n        winner = board[i][0]\n        break\n    elif board[0][i] == board[1][i] == board[2][i] and board[0][i] != \"_\":\n        winner = board[0][i]\n        break\n\nif board[0][0] == board[1][1] == board[2][2] and board[1][1] != \"_\":\n    winner = board[1][1]\nelif board[0][2] == board[1][1] == board[2][0] and board[1][1] != \"_\":\n    winner = board[1][1]\n\nif not winner:\n    winner = \"ingen\"\nelif winner == \"X\":\n    winner = \"Johan\"\nelse:\n    winner = \"Abdullah\"\n\nprint(f\"{winner} har vunnit\")\n
"},{"location":"solutions/#video-speedup","title":"Video Speedup","text":"Solution in Python Python
n, p, k = [int(d) for d in input().split()]\ni = [int(d) for d in input().split()]\n\nstart, total = 0, 0\nspeed = 1\nfor ti in i:\n    total += speed * (ti - start)\n    start = ti\n    speed += p / 100\ntotal += speed * (k - start)\nprint(f\"{total:.3f}\")\n
"},{"location":"solutions/#visnuningur","title":"Vi\u00f0sn\u00faningur","text":"Solution in Python Python
print(input()[::-1])\n
"},{"location":"solutions/#popular-vote","title":"Popular Vote","text":"Solution in Python Python
for _ in range(int(input())):\n    n = int(input())\n    votes = [int(input()) for _ in range(n)]\n    largest = max(votes)\n    if votes.count(largest) > 1:\n        print(\"no winner\")\n    else:\n        total = sum(votes)\n        winner = votes.index(largest)\n        print(\n            \"majority\" if votes[winner] > total / 2 else \"minority\",\n            \"winner\",\n            winner + 1,\n        )\n
"},{"location":"solutions/#warehouse","title":"Warehouse","text":"Solution in Python Python
for _ in range(int(input())):\n    n = int(input())\n    warehouse = {}\n    for _ in range(n):\n        s = input().split()\n        name, quantity = s[0], int(s[1])\n        if name not in warehouse:\n            warehouse[name] = quantity\n        else:\n            warehouse[name] += quantity\n    print(len(warehouse))\n    names = sorted(warehouse)\n    for name in sorted(\n        warehouse, key=lambda k: (warehouse[k], -names.index(k)), reverse=True\n    ):\n        print(name, warehouse[name])\n
"},{"location":"solutions/#weak-vertices","title":"Weak Vertices","text":"Solution in Python Python
from itertools import combinations\n\nwhile True:\n    n = int(input())\n    if n == -1:\n        break\n    graph = {}\n    for i in range(n):\n        graph[str(i)] = [str(v) for v, e in zip(range(n), input().split()) if e == \"1\"]\n\n    # listing the weak vertices ordered from least to greatest\n    # I guess it means vertex number, not the weakness\n    # keys = sorted(graph, key=lambda x: len(graph[x]), reverse=True)\n\n    keys = graph.keys()\n\n    result = []\n\n    for key in keys:\n        has_triangle = False\n        for a, b in combinations(graph[key], 2):\n            if a in graph[b] and b in graph[a]:\n                has_triangle = True\n                break\n\n        if not has_triangle:\n            result.append(key)\n\n    print(\" \".join(result))\n
"},{"location":"solutions/#wertyu","title":"WERTYU","text":"Solution in Python Python
mapping = {\n    # row 1\n    \"1\": \"`\",\n    \"2\": \"1\",\n    \"3\": \"2\",\n    \"4\": \"3\",\n    \"5\": \"4\",\n    \"6\": \"5\",\n    \"7\": \"6\",\n    \"8\": \"7\",\n    \"9\": \"8\",\n    \"0\": \"9\",\n    \"-\": \"0\",\n    \"=\": \"-\",\n    # row 2\n    \"W\": \"Q\",\n    \"E\": \"W\",\n    \"R\": \"E\",\n    \"T\": \"R\",\n    \"Y\": \"T\",\n    \"U\": \"Y\",\n    \"I\": \"U\",\n    \"O\": \"I\",\n    \"P\": \"O\",\n    \"[\": \"P\",\n    \"]\": \"[\",\n    \"\\\\\": \"]\",\n    # row 3\n    \"S\": \"A\",\n    \"D\": \"S\",\n    \"F\": \"D\",\n    \"G\": \"F\",\n    \"H\": \"G\",\n    \"J\": \"H\",\n    \"K\": \"J\",\n    \"L\": \"K\",\n    \";\": \"L\",\n    \"'\": \";\",\n    # row 4\n    \"X\": \"Z\",\n    \"C\": \"X\",\n    \"V\": \"C\",\n    \"B\": \"V\",\n    \"N\": \"B\",\n    \"M\": \"N\",\n    \",\": \"M\",\n    \".\": \",\",\n    \"/\": \".\",\n    \" \": \" \",\n}\n\nwhile True:\n    try:\n        s = input()\n    except:\n        break\n    print(\"\".join([mapping[c] for c in s]))\n
"},{"location":"solutions/#what-does-the-fox-say","title":"What does the fox say?","text":"Solution in Python Python
for _ in range(int(input())):\n    words = input().split()\n    others = set()\n    while True:\n        line = input()\n        if line == \"what does the fox say?\":\n            break\n        w = line.split()[-1]\n        others.add(w)\n    print(\" \".join(w for w in words if w not in others))\n
"},{"location":"solutions/#which-is-greater","title":"Which is Greater?","text":"Solutions in 5 languages C++GoJavaJavaScriptPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int a, b;\n    cin >> a >> b;\n    int ans = (a > b) ? 1 : 0;\n    cout << ans << endl;\n    return 0;\n}\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var a, b int\n    fmt.Scan(&a)\n    fmt.Scan(&b)\n    if a > b {\n        fmt.Println(1)\n    } else {\n        fmt.Println(0)\n    }\n}\n
import java.util.Scanner;\n\nclass WhichisGreater {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int a = s.nextInt();\n        int b = s.nextInt();\n        if (a>b){\n            System.out.println(1);\n        }else{\n            System.out.println(0);\n        }\n    }\n}\n
const readline = require(\"readline\");\nconst rl = readline.createInterface(process.stdin, process.stdout);\n\nrl.question(\"\", (line) => {\n  [a, b] = line\n    .trim()\n    .split(\" \")\n    .map((e) => parseInt(e));\n  if (a > b) {\n    console.log(1);\n  } else {\n    console.log(0);\n  }\n});\n
a, b = [int(d) for d in input().split()]\nif a > b:\n    print(1)\nelse:\n    print(0)\n
"},{"location":"solutions/#wizard-of-odds","title":"Wizard of Odds","text":"Solution in Python Python
import math\n\nn, k = [int(d) for d in input().split()]\nans = math.log(n, 2) <= k\nif ans:\n    print(\"Your wish is granted!\")\nelse:\n    print(\"You will become a flying monkey!\")\n
"},{"location":"solutions/#words-for-numbers","title":"Words for Numbers","text":"Solution in Python Python
mapping = {\n    0: \"zero\",\n    1: \"one\",\n    2: \"two\",\n    3: \"three\",\n    4: \"four\",\n    5: \"five\",\n    6: \"six\",\n    7: \"seven\",\n    8: \"eight\",\n    9: \"nine\",\n    10: \"ten\",\n    11: \"eleven\",\n    12: \"twelve\",\n}\n\n\ndef f(d):\n    if d < 13:\n        return mapping[d]\n\n    ones = d % 10\n    if d < 20:\n        return {3: \"thir\", 5: \"fif\", 8: \"eigh\"}.get(ones, mapping[ones]) + \"teen\"\n\n    tens = d // 10\n    return (\n        {2: \"twen\", 3: \"thir\", 4: \"for\", 5: \"fif\", 8: \"eigh\"}.get(tens, mapping[tens])\n        + \"ty\"\n        + (\"-\" + mapping[ones] if ones else \"\")\n    )\n\n\ndef t(w):\n    if w.isdigit():\n        return f(int(w))\n    else:\n        return w\n\n\nwhile True:\n    try:\n        words = input()\n    except:\n        break\n    print(\" \".join([t(w) for w in words.split()]))\n
"},{"location":"solutions/#yin-and-yang-stones","title":"Yin and Yang Stones","text":"Solution in Python Python
s = input()\nprint(1 if s.count(\"W\") == s.count(\"B\") else 0)\n
"},{"location":"solutions/#yoda","title":"Yoda","text":"Solution in Python Python
a, b = input(), input()\nsize = max(len(a), len(b))\n\na = [int(d) for d in a.zfill(size)]\nb = [int(d) for d in b.zfill(size)]\n\nans_a = [d1 for d1, d2 in zip(a, b) if d1 >= d2]\nans_b = [d2 for d1, d2 in zip(a, b) if d2 >= d1]\n\n\ndef f(ans):\n    if not ans:\n        return \"YODA\"\n    else:\n        return int(\"\".join([str(d) for d in ans]))\n\n\nprint(f(ans_a))\nprint(f(ans_b))\n
"},{"location":"solutions/#zamka","title":"Zamka","text":"Solution in Python Python
l, d, x = input(), input(), input()\nl, d, x = int(l), int(d), int(x)\n\nfor i in range(l, d + 1):\n    if sum([int(d) for d in str(i)]) == x:\n        print(i)\n        break\n\nfor i in range(d, l - 1, -1):\n    if sum([int(d) for d in str(i)]) == x:\n        print(i)\n        break\n
"},{"location":"solutions/#stand-on-zanzibar","title":"Stand on Zanzibar","text":"Solutions in 2 languages JavaPython
import java.util.Scanner;\n\nclass StandOnZanzibar {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int t = s.nextInt();\n        for (int i = 0; i < t; i++) {\n            int total = 0;\n            int n = 0;\n            int init = 1;\n            while (true) {\n                n = s.nextInt();\n                if (n == 0) {\n                    break;\n                }\n                total += Math.max(n - 2 * init, 0);\n                init = n;\n            }\n            System.out.println(total);\n        }\n    }\n}\n
for _ in range(int(input())):\n    numbers = [int(d) for d in input().split()[:-1]]\n    total = 0\n    for i in range(1, len(numbers)):\n        total += max(numbers[i] - 2 * numbers[i - 1], 0)\n    print(total)\n
"},{"location":"solutions/#un-bear-able-zoo","title":"Un-bear-able Zoo","text":"Solution in Python Python
from collections import Counter\n\nlc = 0\nwhile True:\n    n = int(input())\n    if not n:\n        break\n    lc += 1\n    l = Counter()\n    for _ in range(n):\n        animal = input().lower().split()\n        l[animal[-1]] += 1\n    print(f\"List {lc}:\")\n    print(\"\\n\".join([f\"{k} | {l[k]}\" for k in sorted(l)]))\n
"},{"location":"solutions/#zoom","title":"Zoom","text":"Solution in Python Python
n, k = [int(d) for d in input().split()]\nx = [int(d) for d in input().split()]\nprint(\" \".join([str(x[i]) for i in range(k - 1, n, k)]))\n
"}]} \ No newline at end of file +{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Home","text":""},{"location":"#kattis","title":"Kattis","text":""},{"location":"#summary-by-difficulty","title":"Summary by Difficulty","text":"

as of 2023-11-22

{ \"data\": { \"values\": [ {\"Difficulty\": \"Easy\", \"Count\": 440}, {\"Difficulty\": \"Medium\", \"Count\": 29}, {\"Difficulty\": \"Hard\", \"Count\": 1} ] }, \"mark\": {\"type\": \"bar\", \"tooltip\": true}, \"encoding\": { \"x\": {\"field\": \"Difficulty\", \"type\": \"nominal\", \"axis\": {\"labelAngle\": 0}, \"sort\": \"-y\"}, \"y\": {\"field\": \"Count\", \"type\": \"quantitative\"}, \"color\": {\"field\": \"Difficulty\", \"legend\": null} } }

"},{"location":"#summary-by-initial","title":"Summary by Initial","text":"

{ \"data\": { \"values\": [ {\"Initial\": \"S\", \"Count\": 60}, {\"Initial\": \"C\", \"Count\": 39}, {\"Initial\": \"P\", \"Count\": 35}, {\"Initial\": \"A\", \"Count\": 35}, {\"Initial\": \"T\", \"Count\": 33}, {\"Initial\": \"B\", \"Count\": 31}, {\"Initial\": \"M\", \"Count\": 26}, {\"Initial\": \"E\", \"Count\": 21}, {\"Initial\": \"H\", \"Count\": 21}, {\"Initial\": \"F\", \"Count\": 19}, {\"Initial\": \"R\", \"Count\": 18}, {\"Initial\": \"D\", \"Count\": 18}, {\"Initial\": \"G\", \"Count\": 15}, {\"Initial\": \"L\", \"Count\": 12}, {\"Initial\": \"V\", \"Count\": 10}, {\"Initial\": \"O\", \"Count\": 10}, {\"Initial\": \"I\", \"Count\": 10}, {\"Initial\": \"W\", \"Count\": 9}, {\"Initial\": \"K\", \"Count\": 9}, {\"Initial\": \"J\", \"Count\": 9}, {\"Initial\": \"N\", \"Count\": 6}, {\"Initial\": \"U\", \"Count\": 6}, {\"Initial\": \"Q\", \"Count\": 5}, {\"Initial\": \"Z\", \"Count\": 2}, {\"Initial\": \"1\", \"Count\": 2}, {\"Initial\": \"Y\", \"Count\": 2}, {\"Initial\": \"\u00c1\", \"Count\": 1}, {\"Initial\": \"\u00d3\", \"Count\": 1}, {\"Initial\": \"3\", \"Count\": 1}, {\"Initial\": \"\u00da\", \"Count\": 1}, {\"Initial\": \"\u00d6\", \"Count\": 1}, {\"Initial\": \"4\", \"Count\": 1}, {\"Initial\": \"9\", \"Count\": 1} ] }, \"mark\": {\"type\": \"bar\", \"tooltip\": true}, \"encoding\": { \"x\": {\"field\": \"Initial\", \"type\": \"nominal\", \"axis\": {\"labelAngle\": 0}, \"sort\": \"-y\"}, \"y\": {\"field\": \"Count\", \"type\": \"quantitative\"}, \"color\": {\"field\": \"Initial\", \"legend\": null} } }

"},{"location":"#summary-by-language","title":"Summary by Language","text":"

{ \"data\": { \"values\": [ {\"Language\": \"Python\", \"Count\": 467}, {\"Language\": \"Go\", \"Count\": 42}, {\"Language\": \"Java\", \"Count\": 28}, {\"Language\": \"C++\", \"Count\": 22}, {\"Language\": \"Lua\", \"Count\": 18}, {\"Language\": \"JavaScript\", \"Count\": 10}, {\"Language\": \"Haskell\", \"Count\": 4}, {\"Language\": \"Ruby\", \"Count\": 4}, {\"Language\": \"Kotlin\", \"Count\": 4}, {\"Language\": \"Rust\", \"Count\": 3}, {\"Language\": \"Julia\", \"Count\": 2} ] }, \"mark\": {\"type\": \"bar\", \"tooltip\": true}, \"encoding\": { \"x\": {\"field\": \"Language\", \"type\": \"nominal\", \"axis\": {\"labelAngle\": 0}, \"sort\": \"-y\"}, \"y\": {\"field\": \"Count\", \"type\": \"quantitative\"}, \"color\": {\"field\": \"Language\", \"legend\": null} } }

Thanks to all 6 contributors.

"},{"location":"solutions/","title":"470 Solutions","text":""},{"location":"solutions/#10-kinds-of-people","title":"10 Kinds of People","text":"Solution in Python Python
# 22/25\n\n\nfrom copy import deepcopy\n\n\nrow, col = [int(d) for d in input().split()]\nm = []\nfor _ in range(row):\n    m.append([int(d) for d in input()])\n\ndirections = [[0, 1], [0, -1], [1, 0], [-1, 0]]\n\n\ndef reachable(m, r1, c1, r2, c2):\n    _m = deepcopy(m)\n\n    q = []\n    q.append((r1, c1))\n    kind = _m[r1][c1]\n\n    while len(q):\n        r, c = q.pop()\n        _m[r][c] = -1\n\n        if (r, c) == (r2, c2):\n            return True\n\n        for x, y in directions:\n            a = r + x\n            b = c + y\n            if a >= 0 and b >= 0 and a < row and b < col and _m[a][b] == kind:\n                q.append((a, b))\n\n    return False\n\n\nn = int(input())\nfor _ in range(n):\n    r1, c1, r2, c2 = [int(d) - 1 for d in input().split()]\n    if reachable(m, r1, c1, r2, c2):\n        print(\"decimal\" if m[r1][c1] else \"binary\")\n    else:\n        print(\"neither\")\n
"},{"location":"solutions/#1-d-frogger-easy","title":"1-D Frogger (Easy)","text":"Solutions in 2 languages C++Python
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int n, s, m, curspace, cnt = 0;\n    cin >> n >> s >> m;\n    int board[n];\n\n    for (int i = 0; i < n; i++)\n    {\n        int tmp;\n        cin >> tmp;\n        board[i] = tmp;\n    }\n    curspace = s - 1;\n\n    while (true)\n    {\n        if (curspace < 0)\n        {\n            cout << \"left\" << endl;\n            break;\n        }\n        else if (curspace > n - 1)\n        {\n            cout << \"right\" << endl;\n            break;\n        }\n        int temp = board[curspace];\n        if (temp == 999)\n        {\n            cout << \"cycle\" << endl;\n            break;\n        }\n        else if (temp == m)\n        {\n            cout << \"magic\" << endl;\n            break;\n        }\n        else\n        {\n            cnt += 1;\n            board[curspace] = 999;\n            curspace += temp;\n        }\n    }\n    cout << cnt << endl;\n}\n
n, s, m = [int(d) for d in input().split()]\nb = [int(d) for d in input().split()]\nvisited, hops = set(), 0\nwhile True:\n    if s in visited:\n        print(\"cycle\")\n        break\n    elif s < 1:\n        print(\"left\")\n        break\n    elif s > n:\n        print(\"right\")\n        break\n    elif b[s - 1] == m:\n        print(\"magic\")\n        break\n    else:\n        visited.add(s)\n        s += b[s - 1]\n        hops += 1\nprint(hops)\n
"},{"location":"solutions/#3d-printed-statues","title":"3D Printed Statues","text":"Solutions in 3 languages GoJavaPython
package main\n\nimport (\n    \"fmt\"\n    \"math\"\n)\n\nfunc main() {\n    var n int\n    fmt.Scan(&n)\n    d := 1.0\n    for math.Pow(2, d-1) < float64(n) {\n        d += 1\n    }\n    fmt.Println(d)\n}\n
import java.util.Scanner;\n\nclass ThreeDPrintedStatues {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int n = s.nextInt();\n        int d = 1;\n        while (Math.pow(2, d - 1) < n) {\n            d += 1;\n        }\n        System.out.println(d);\n    }\n}\n
n = int(input())\nd = 1\nwhile 2 ** (d - 1) < n:\n    d += 1\nprint(d)\n
"},{"location":"solutions/#4-thought","title":"4 thought","text":"Solution in Python Python
from itertools import product\n\nops = [\"+\", \"-\", \"*\", \"//\"]\n\nfor _ in range(int(input())):\n    s = int(input())\n    solved = False\n    for op1, op2, op3 in product(ops, ops, ops):\n        e = f\"4 {op1} 4 {op2} 4 {op3} 4\"\n        try:\n            ans = eval(e) == s\n        except:\n            ans = False\n        if ans:\n            print(f\"{e.replace('//','/')} = {s}\")\n            solved = True\n            break\n    if not solved:\n        print(\"no solution\")\n
"},{"location":"solutions/#99-problems","title":"99 Problems","text":"Solution in Python Python
import math\n\nn = int(input())\nceil = math.ceil(n / 100) * 100 - 1\nfloor = math.floor(n / 100) * 100 - 1\nif ceil == floor:\n    print(ceil)\nelse:\n    if abs(ceil - n) <= abs(n - floor) or floor < 0:\n        print(ceil)\n    else:\n        print(floor)\n
"},{"location":"solutions/#aaah","title":"Aaah!","text":"Solutions in 2 languages GoPython
package main\n\nimport (\n    \"fmt\"\n    \"strings\"\n)\n\nfunc main() {\n    var a, b string\n    fmt.Scan(&a)\n    fmt.Scan(&b)\n    if strings.Count(a, \"a\") >= strings.Count(b, \"a\") {\n        fmt.Println(\"go\")\n    } else {\n        fmt.Println(\"no\")\n    }\n}\n
a, b = input(), input()\nif a.count(\"a\") >= b.count(\"a\"):\n    print(\"go\")\nelse:\n    print(\"no\")\n
"},{"location":"solutions/#abc","title":"ABC","text":"Solution in Python Python
numbers = sorted([int(d) for d in input().split()])\norders = list(input())\norder_map = {\n    \"A\": 0,\n    \"B\": 1,\n    \"C\": 2,\n}\n\nprint(\" \".join([str(numbers[order_map[o]]) for o in orders]))\n
"},{"location":"solutions/#above-average","title":"Above Average","text":"Solution in Python Python
n = int(input())\nfor _ in range(n):\n    numbers = [int(d) for d in input().split()[1:]]\n    ave = sum(numbers) / len(numbers)\n    above_ave = [d > ave for d in numbers]\n    print(f\"{sum(above_ave)/len(numbers):.3%}\")\n
"},{"location":"solutions/#acm-contest-scoring","title":"ACM Contest Scoring","text":"Solution in Python Python
problems = {}\nsolved = set()\nwhile True:\n    line = input()\n    if line == \"-1\":\n        break\n    t, p, ans = line.split()\n    t = int(t)\n    if p in solved:\n        continue\n    if p not in problems:\n        problems[p] = [(t, ans)]\n    else:\n        problems[p].append((t, ans))\n    if ans == \"right\":\n        solved.add(p)\n\nscore = 0\nfor p in problems:\n    t, ans = problems[p][-1]\n    if ans == \"right\":\n        score += t + 20 * len(problems[p][:-1])\n\nprint(len(solved), score)\n
"},{"location":"solutions/#adding-trouble","title":"Adding Trouble","text":"Solution in Python Python
a, b, c = [int(v) for v in input().split()]\nif a + b == c:\n    print(\"correct!\")\nelse:\n    print(\"wrong!\")\n
"},{"location":"solutions/#adding-words","title":"Adding Words","text":"Solution in Python Python
name = {}\nvalue = {}\nop = [\"-\", \"+\"]\nwhile True:\n    try:\n        s = input().split()\n    except:\n        break\n\n    if s[0] == \"clear\":\n        name.clear()\n        value.clear()\n    elif s[0] == \"def\":\n        n, v = s[1:]\n        v = int(v)\n        if n in name:\n            value.pop(name[n])\n        name[n] = v\n        value[v] = n\n    elif s[0] == \"calc\":\n        try:\n            ans = eval(\"\".join([str(name[p]) if p not in op else p for p in s[1:-1]]))\n        except:\n            ans = \"unknown\"\n\n        ans = value.get(ans, \"unknown\")\n        print(\" \".join(s[1:] + [ans]))\n
"},{"location":"solutions/#add-two-numbers","title":"Add Two Numbers","text":"Solutions in 4 languages GoJavaJavaScriptPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var a, b int\n    fmt.Scan(&a)\n    fmt.Scan(&b)\n    fmt.Println(a + b)\n}\n
import java.util.Scanner;\n\nclass AddTwoNumbers {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int a = s.nextInt(), b = s.nextInt();\n        System.out.println(a + b);\n    }\n}\n
const readline = require(\"readline\");\nconst rl = readline.createInterface(process.stdin, process.stdout);\n\nrl.question(\"\", (line) => {\n  [a, b] = line\n    .trim()\n    .split(\" \")\n    .map((e) => parseInt(e));\n  console.log(a + b);\n});\n
line = input()\na, b = line.split()\na = int(a)\nb = int(b)\nprint(a + b)\n
"},{"location":"solutions/#akcija","title":"Akcija","text":"Solution in Python Python
n = int(input())\nc = [int(input()) for _ in range(n)]\n\nc = sorted(c, reverse=True)\ngroups = [c[i : i + 3] if i + 3 < n else c[i:] for i in range(0, n, 3)]\n\nprint(sum(sum(g if len(g) < 3 else g[:2]) for g in groups))\n
"},{"location":"solutions/#a-lei-i-bio","title":"\u00c1 lei\u00f0 \u00ed b\u00ed\u00f3","text":"Solutions in 4 languages C++GoJavaPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int a, b, c;\n    cin >> a >> b >> c;\n    cout << c - a - b << endl;\n    return 0;\n}\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var a, b, c int\n    fmt.Scan(&a)\n    fmt.Scan(&b)\n    fmt.Scan(&c)\n    fmt.Println(c - a - b)\n}\n
import java.util.Scanner;\n\nclass Aleidibio {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int a = s.nextInt();\n        int b = s.nextInt();\n        int c = s.nextInt();\n        System.out.println(c - a - b);\n    }\n}\n
a = int(input())\nb = int(input())\nc = int(input())\nprint(c - a - b)\n
"},{"location":"solutions/#alex-and-barb","title":"Alex and Barb","text":"Solution in Python Python
k, m, n = [int(d) for d in input().split()]\n\nprint(\"Barb\" if k % (m + n) < m else \"Alex\")\n
"},{"location":"solutions/#alphabet-spam","title":"Alphabet Spam","text":"Solution in Python Python
s = input()\ntotal = len(s)\nwhites = s.count(\"_\")\nlowers = len([c for c in s if ord(c) >= ord(\"a\") and ord(c) <= ord(\"z\")])\nuppers = len([c for c in s if ord(c) >= ord(\"A\") and ord(c) <= ord(\"Z\")])\nsymbols = total - whites - lowers - uppers\nprint(f\"{whites/total:.15f}\")\nprint(f\"{lowers/total:.15f}\")\nprint(f\"{uppers/total:.15f}\")\nprint(f\"{symbols/total:.15f}\")\n
"},{"location":"solutions/#ameriskur-vinnustaur","title":"Amer\u00edskur vinnusta\u00f0ur","text":"Solution in Python Python
print(int(input()) * 0.09144)\n
"},{"location":"solutions/#amsterdam-distance","title":"Amsterdam Distance","text":"Solution in Python Python
import math\n\nm, n, r = input().split()\nm = int(m)\nn = int(n)\nr = float(r)\ncoords = [int(d) for d in input().split()]\np = r / n\n\ndist1 = 0\ndist1 += p * abs(coords[1] - coords[3])\ndist1 += (\n    math.pi\n    * r\n    * ((min(coords[3], coords[1]) if coords[3] != coords[1] else coords[1]) / n)\n    * (abs(coords[0] - coords[2]) / m)\n)\n\ndist2 = p * abs(coords[1] + coords[3])\n\nprint(min(dist1, dist2))\n
"},{"location":"solutions/#a-new-alphabet","title":"A New Alphabet","text":"Solutions in 2 languages GoPython
package main\n\nimport (\n    \"bufio\"\n    \"fmt\"\n    \"os\"\n    \"strings\"\n)\n\nfunc main() {\n    mapping := map[string]string{\n        \"a\": \"@\",\n        \"b\": \"8\",\n        \"c\": \"(\",\n        \"d\": \"|)\",\n        \"e\": \"3\",\n        \"f\": \"#\",\n        \"g\": \"6\",\n        \"h\": \"[-]\",\n        \"i\": \"|\",\n        \"j\": \"_|\",\n        \"k\": \"|<\",\n        \"l\": \"1\",\n        \"m\": \"[]\\\\/[]\",\n        \"n\": \"[]\\\\[]\",\n        \"o\": \"0\",\n        \"p\": \"|D\",\n        \"q\": \"(,)\",\n        \"r\": \"|Z\",\n        \"s\": \"$\",\n        \"t\": \"']['\",\n        \"u\": \"|_|\",\n        \"v\": \"\\\\/\",\n        \"w\": \"\\\\/\\\\/\",\n        \"x\": \"}{\",\n        \"y\": \"`/\",\n        \"z\": \"2\",\n    }\n    scanner := bufio.NewScanner(os.Stdin)\n    scanner.Scan()\n    line := scanner.Text()\n    runes := []rune(strings.ToLower(line))\n    for i := 0; i < len(runes); i++ {\n        v, ok := mapping[string(runes[i])]\n        if ok {\n            fmt.Printf(v)\n        } else {\n            fmt.Printf(string(runes[i]))\n        }\n    }\n}\n
mapping = {\n    \"a\": \"@\",\n    \"b\": \"8\",\n    \"c\": \"(\",\n    \"d\": \"|)\",\n    \"e\": \"3\",\n    \"f\": \"#\",\n    \"g\": \"6\",\n    \"h\": \"[-]\",\n    \"i\": \"|\",\n    \"j\": \"_|\",\n    \"k\": \"|<\",\n    \"l\": \"1\",\n    \"m\": \"[]\\\\/[]\",\n    \"n\": \"[]\\\\[]\",\n    \"o\": \"0\",\n    \"p\": \"|D\",\n    \"q\": \"(,)\",\n    \"r\": \"|Z\",\n    \"s\": \"$\",\n    \"t\": \"']['\",\n    \"u\": \"|_|\",\n    \"v\": \"\\\\/\",\n    \"w\": \"\\\\/\\\\/\",\n    \"x\": \"}{\",\n    \"y\": \"`/\",\n    \"z\": \"2\",\n}\nprint(\"\".join([mapping.get(c, c) for c in input().lower()]))\n
"},{"location":"solutions/#another-brick-in-the-wall","title":"Another Brick in the Wall","text":"Solution in Python Python
h, w, n = [int(d) for d in input().split()]\nb = [int(d) for d in input().split()]\n\ni, tw, th, done = 0, 0, 0, False\nwhile i < n:\n    if tw + b[i] <= w:\n        tw += b[i]\n        if tw == w:\n            tw = 0\n            th += 1\n        if th == h and tw == 0:\n            done = True\n            break\n    else:\n        break\n    i += 1\n\nprint(\"YES\" if done else \"NO\")\n
"},{"location":"solutions/#another-candies","title":"Another Candies","text":"Solution in Python Python
for _ in range(int(input())):\n    _ = input()\n    n = int(input())\n    s = 0\n    for _ in range(n):\n        s += int(input())\n        if s > n:\n            s %= n\n    print(\"NO\" if s % n else \"YES\")\n
"},{"location":"solutions/#apaxiaaaaaaaaaaaans","title":"Apaxiaaaaaaaaaaaans!","text":"Solution in Python Python
name = input()\ncompact = \"\"\nfor s in name:\n    if not compact or s != compact[-1]:\n        compact += s\nprint(compact)\n
"},{"location":"solutions/#honour-thy-apaxian-parent","title":"Honour Thy (Apaxian) Parent","text":"Solution in Python Python
y, p = input().split()\nif y.endswith(\"e\"):\n    name = y + \"x\" + p\nelif y[-1] in \"aiou\":\n    name = y[:-1] + \"ex\" + p\nelif y.endswith(\"ex\"):\n    name = y + p\nelse:\n    name = y + \"ex\" + p\n\nprint(name)\n
"},{"location":"solutions/#a-real-challenge","title":"A Real Challenge","text":"Solutions in 3 languages GoJavaScriptPython
package main\n\nimport (\n    \"fmt\"\n    \"math\"\n)\n\nfunc main() {\n    var a int\n    fmt.Scan(&a)\n    fmt.Println(4 * math.Sqrt(float64(a)))\n}\n
const readline = require(\"readline\");\nconst rl = readline.createInterface(process.stdin, process.stdout);\n\nrl.question(\"\", (a) => {\n  console.log(4 * Math.sqrt(parseInt(a)));\n});\n
import math\n\ns = int(input())\nprint(4 * math.sqrt(s))\n
"},{"location":"solutions/#are-you-listening","title":"Are You Listening?","text":"Solution in Python Python
import math\n\ncx, cy, n = [int(d) for d in input().split()]\n\nd = []\nfor _ in range(n):\n    x, y, r = [int(d) for d in input().split()]\n    d.append(((x - cx) ** 2 + (y - cy) ** 2) ** 0.5 - r)\nv = sorted(d)[2]\nprint(math.floor(v) if v > 0 else 0)\n
"},{"location":"solutions/#arithmetic","title":"Arithmetic","text":"Solution in Python Python
import math\n\nmapping8 = {\n    \"0\": \"000\",\n    \"1\": \"001\",\n    \"2\": \"010\",\n    \"3\": \"011\",\n    \"4\": \"100\",\n    \"5\": \"101\",\n    \"6\": \"110\",\n    \"7\": \"111\",\n}\nmapping16 = {\n    \"0000\": \"0\",\n    \"0001\": \"1\",\n    \"0010\": \"2\",\n    \"0011\": \"3\",\n    \"0100\": \"4\",\n    \"0101\": \"5\",\n    \"0110\": \"6\",\n    \"0111\": \"7\",\n    \"1000\": \"8\",\n    \"1001\": \"9\",\n    \"1010\": \"A\",\n    \"1011\": \"B\",\n    \"1100\": \"C\",\n    \"1101\": \"D\",\n    \"1110\": \"E\",\n    \"1111\": \"F\",\n}\n\nb = \"\".join([mapping8[c] for c in input()])\nb = b.zfill(math.ceil(len(b) / 4) * 4)\nans = \"\".join([mapping16[b[i : i + 4]] for i in range(0, len(b), 4)])\nif ans != \"0\":\n    ans = ans.lstrip(\"0\")\nprint(ans)\n
"},{"location":"solutions/#arithmetic-functions","title":"Arithmetic Functions","text":"Solution in C++ C++
#include \"arithmeticfunctions.h\"\n\n// Compute x^3\nint cube(int x)\n{\n    return x * x * x;\n}\n\n// Compute the maximum of x and y\nint max(int x, int y)\n{\n    if (x > y)\n    {\n        return x;\n    }\n    else\n    {\n        return y;\n    }\n}\n\n// Compute x - y\nint difference(int x, int y)\n{\n    return x - y;\n}\n
"},{"location":"solutions/#army-strength-easy","title":"Army Strength (Easy)","text":"Solution in Python Python
t = int(input())\nfor _ in range(t):\n    input()\n    ng, nm = [int(d) for d in input().split()]\n    g = [int(d) for d in input().split()]\n    m = [int(d) for d in input().split()]\n    if max(m) > max(g):\n        print(\"MechaGodzilla\")\n    else:\n        print(\"Godzilla\")\n
"},{"location":"solutions/#army-strength-hard","title":"Army Strength (Hard)","text":"Solution in Python Python
t = int(input())\nfor _ in range(t):\n    input()\n    ng, nm = [int(d) for d in input().split()]\n    g = [int(d) for d in input().split()]\n    m = [int(d) for d in input().split()]\n    if max(m) > max(g):\n        print(\"MechaGodzilla\")\n    else:\n        print(\"Godzilla\")\n
"},{"location":"solutions/#ascii-kassi","title":"ASCII kassi","text":"Solution in Python Python
n = int(input())\nprint(f'+{\"-\"*n}+')\nfor _ in range(n):\n    print(f'|{\" \"*n}|')\nprint(f'+{\"-\"*n}+')\n
"},{"location":"solutions/#astrological-sign","title":"Astrological Sign","text":"Solution in Python Python
for _ in range(int(input())):\n    d, m = input().split()\n    d = int(d)\n    if (m == \"Mar\" and d >= 21) or (m == \"Apr\" and d <= 20):\n        print(\"Aries\")\n    elif (m == \"Apr\" and d >= 21) or (m == \"May\" and d <= 20):\n        print(\"Taurus\")\n    elif (m == \"May\" and d >= 21) or (m == \"Jun\" and d <= 21):\n        print(\"Gemini\")\n    elif (m == \"Jun\" and d >= 22) or (m == \"Jul\" and d <= 22):\n        print(\"Cancer\")\n    elif (m == \"Jul\" and d >= 23) or (m == \"Aug\" and d <= 22):\n        print(\"Leo\")\n    elif (m == \"Aug\" and d >= 23) or (m == \"Sep\" and d <= 21):\n        print(\"Virgo\")\n    elif (m == \"Sep\" and d >= 22) or (m == \"Oct\" and d <= 22):\n        print(\"Libra\")\n    elif (m == \"Oct\" and d >= 23) or (m == \"Nov\" and d <= 22):\n        print(\"Scorpio\")\n    elif (m == \"Nov\" and d >= 23) or (m == \"Dec\" and d <= 21):\n        print(\"Sagittarius\")\n    elif (m == \"Dec\" and d >= 22) or (m == \"Jan\" and d <= 20):\n        print(\"Capricorn\")\n    elif (m == \"Jan\" and d >= 21) or (m == \"Feb\" and d <= 19):\n        print(\"Aquarius\")\n    elif (m == \"Feb\" and d >= 20) or (m == \"Mar\" and d <= 20):\n        print(\"Pisces\")\n
"},{"location":"solutions/#attendance","title":"Attendance","text":"Solution in Python Python
n = int(input())\ns = []\nfor _ in range(n):\n    c = input()\n    if c == \"Present!\":\n        s.pop()\n    else:\n        s.append(c)\nif not s:\n    print(\"No Absences\")\nelse:\n    print(\"\\n\".join(s))\n
"},{"location":"solutions/#autori","title":"Autori","text":"Solution in Python Python
print(\"\".join([part[0] for part in input().split(\"-\")]))\n
"},{"location":"solutions/#average-character","title":"Average Character","text":"Solution in Python Python
s = input()\ns = [ord(c) for c in s]\ns = sum(s) // len(s)\nprint(chr(s))\n
"},{"location":"solutions/#avion","title":"Avion","text":"Solution in Python Python
ans = []\nfor i in range(5):\n    row = input()\n    if \"FBI\" in row:\n        ans.append(str(i + 1))\nif not ans:\n    print(\"HE GOT AWAY!\")\nelse:\n    print(\" \".join(ans))\n
"},{"location":"solutions/#babelfish","title":"Babelfish","text":"Solution in Python Python
d = []\nwhile True:\n    line = input()\n    if not line:\n        break\n    w, f = line.split()\n    d.append((f, w))\n\nd = dict(d)\nwhile True:\n    try:\n        line = input()\n    except:\n        break\n    print(d.get(line, \"eh\"))\n
"},{"location":"solutions/#baby-bites","title":"Baby Bites","text":"Solution in Python Python
n = int(input())\na = input().split()\nc = [str(d) for d in range(1, n + 1)]\ninplace = [i == j if i.isnumeric() and j.isnumeric() else None for i, j in zip(a, c)]\ninplace = [v for v in inplace if v is not None]\nprint(\"makes sense\" if all(inplace) else \"something is fishy\")\n
"},{"location":"solutions/#baby-panda","title":"Baby Panda","text":"Solution in Python Python
import math\n\nn, m = [int(d) for d in input().split()]\nd = 0\nwhile m:\n    c = math.floor(math.log(m, 2))\n    d += 1\n    m -= 2**c\nprint(d)\n
"},{"location":"solutions/#backspace","title":"Backspace","text":"Solution in Python Python
ans = []\nfor c in input():\n    if c != \"<\":\n        ans.append(c)\n    else:\n        ans.pop()\nprint(\"\".join(ans))\n
"},{"location":"solutions/#bacon-eggs-and-spam","title":"Bacon, Eggs, and Spam","text":"Solution in Python Python
while True:\n    n = int(input())\n    if not n:\n        break\n    record = {}\n    for _ in range(n):\n        order = input().split()\n        name = order[0]\n        items = order[1:]\n        for item in items:\n            if item not in record:\n                record[item] = [name]\n            else:\n                record[item].append(name)\n    for name in sorted(record):\n        print(name, \" \".join(sorted(record[name])))\n    print()\n
"},{"location":"solutions/#bannor","title":"Bannor\u00f0","text":"Solution in Python Python
s = set(input())\nm = input().split()\nprint(\" \".join([\"*\" * len(p) if s & set(p) else p for p in m]))\n
"},{"location":"solutions/#basketball-one-on-one","title":"Basketball One-on-One","text":"Solutions in 2 languages JavaPython
import java.util.Scanner;\n\nclass BasketballOneOnOne {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        String scores = s.nextLine();\n        System.out.println(scores.charAt(scores.length() - 2));\n    }\n}\n
scores = input()\nsize = len(scores)\na = sum([int(scores[i + 1]) for i in range(size) if scores[i] == \"A\"])\nb = sum([int(scores[i + 1]) for i in range(size) if scores[i] == \"B\"])\nif a > b:\n    print(\"A\")\nelse:\n    print(\"B\")\n
"},{"location":"solutions/#batter-up","title":"Batter Up","text":"Solution in Python Python
_ = input()\nat_bats = [int(d) for d in input().split()]\nans = [d for d in at_bats if d >= 0]\nprint(sum(ans) / len(ans))\n
"},{"location":"solutions/#beat-the-spread","title":"Beat the Spread!","text":"Solution in Python Python
for _ in range(int(input())):\n    a, b = [int(d) for d in input().split()]\n    if a < b or (a + b) % 2:\n        print(\"impossible\")\n    else:\n        print((a + b) // 2, (a - b) // 2)\n
"},{"location":"solutions/#beavergnaw","title":"Beavergnaw","text":"Solution in Python Python
import math\n\nwhile True:\n    D, V = [int(d) for d in input().split()]\n    if not D and not V:\n        break\n    # R = D / 2\n    # r = d / 2\n    # V + \u03c0 * (r**2) * (2*r) + 2 * (1/3) * \u03c0 * (R-r) * (r**2 + r*R + R**2) == \u03c0 * (R**2) * (2*R)\n    print(math.pow(D**3 - 6 * V / math.pi, 1 / 3))\n
"},{"location":"solutions/#beekeeper","title":"Beekeeper","text":"Solution in Python Python
def count(word):\n    return sum(word.count(c * 2) for c in \"aeiouy\")\n\n\nwhile True:\n    n = int(input())\n    if not n:\n        break\n    words = []\n    for _ in range(n):\n        words.append(input())\n    print(max(words, key=count))\n
"},{"location":"solutions/#bela","title":"Bela","text":"Solution in Python Python
table = {\n    \"A\": {True: 11, False: 11},\n    \"K\": {True: 4, False: 4},\n    \"Q\": {True: 3, False: 3},\n    \"J\": {True: 20, False: 2},\n    \"T\": {True: 10, False: 10},\n    \"9\": {True: 14, False: 0},\n    \"8\": {True: 0, False: 0},\n    \"7\": {True: 0, False: 0},\n}\n\nn, b = input().split()\nn = int(n)\ntotal = 0\n\nfor _ in range(4 * n):\n    card = input()\n    f, s = card[0], card[1]\n    total += table[f][s == b]\n\nprint(total)\n
"},{"location":"solutions/#betting","title":"Betting","text":"Solutions in 2 languages GoPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var a float32\n    fmt.Scan(&a)\n    fmt.Printf(\"%.10f\", 100/a)\n    fmt.Println()\n    fmt.Printf(\"%.10f\", 100/(100-a))\n}\n
a = int(input())\nprint(f\"{100/a:.10f}\")\nprint(f\"{100/(100-a):.10f}\")\n
"},{"location":"solutions/#bijele","title":"Bijele","text":"Solution in Python Python
should_contain = (1, 1, 2, 2, 2, 8)\nfound = [int(d) for d in input().split()]\nprint(\" \".join([str(a - b) for a, b in zip(should_contain, found)]))\n
"},{"location":"solutions/#black-friday","title":"Black Friday","text":"Solution in Python Python
from collections import Counter\n\nn = input()\na = [int(d) for d in input().split()]\nc = Counter(a)\nkeys = [k for k in c if c[k] == 1]\nif not keys:\n    print(\"none\")\nelse:\n    print(a.index(max(keys)) + 1)\n
"},{"location":"solutions/#blueberry-waffle","title":"Blueberry Waffle","text":"Solution in Python Python
r, f = [int(d) for d in input().split()]\n\na = f // r\nb = (f - a * r) / r >= 0.5\n\nprint(\"up\" if (a + b) % 2 == 0 else \"down\")\n
"},{"location":"solutions/#bluetooth","title":"Bluetooth","text":"Solution in Python Python
n = int(input())\ncond = {}\n\n\ndef f(t):\n    if t[0].isdigit():\n        return (f'R{\"u\" if t[1]==\"+\" else \"l\"}', t[0])\n    else:\n        return (f'L{\"u\" if t[0]==\"+\" else \"l\"}', t[1])\n\n\nfor _ in range(n):\n    t, p = input().split()\n    q, d = f(t)\n    if p == \"b\":\n        if p not in cond:\n            cond[p] = [q]\n        else:\n            cond[p].append(q)\n    elif p == \"m\":\n        if p not in cond:\n            cond[p] = [(q, d)]\n        else:\n            cond[p].append((q, d))\n\nl, r = True, True\n\nif \"R\" in [c[0] for c in cond.get(\"b\", [])]:\n    r = False\nif \"L\" in [c[0] for c in cond.get(\"b\", [])]:\n    l = False\n\nru = len([d for q, d in cond.get(\"m\", []) if q == \"Ru\"])\nrl = len([d for q, d in cond.get(\"m\", []) if q == \"Rl\"])\nlu = len([d for q, d in cond.get(\"m\", []) if q == \"Lu\"])\nll = len([d for q, d in cond.get(\"m\", []) if q == \"Ll\"])\n\nif ru == 8 or rl == 8:\n    r = False\nif lu == 8 or ll == 8:\n    l = False\n\nif not l and not r:\n    print(2)\nelif l and not r:\n    print(0)\nelif r and not l:\n    print(1)\nelse:\n    print(\"?\")\n
"},{"location":"solutions/#boat-parts","title":"Boat Parts","text":"Solution in Python Python
p, n = [int(d) for d in input().split()]\nboat = set()\nd = -1\nfor i in range(n):\n    w = input()\n    boat.add(w)\n    if len(boat) == p:\n        d = i + 1\n        break\nif d == -1:\n    print(\"paradox avoided\")\nelse:\n    print(d)\n
"},{"location":"solutions/#booking-a-room","title":"Booking a Room","text":"Solution in Python Python
r, n = [int(d) for d in input().split()]\nbooked = [int(input()) for _ in range(n)]\navailable = set(range(1, 1 + r)) - set(booked)\nprint(\"too late\" if r == n else available.pop())\n
"},{"location":"solutions/#boss-battle","title":"Boss Battle","text":"Solution in Python Python
n = int(input())\nprint(n - 2 if n // 4 else 1)\n
"},{"location":"solutions/#bottled-up-feelings","title":"Bottled-Up Feelings","text":"Solution in Python Python
s, v1, v2 = [int(d) for d in input().split()]\n\nn1 = s // v1\nif not s % v1:\n    print(n1, 0)\nelse:\n    while True:\n        if not (s - n1 * v1) % v2:\n            print(n1, (s - n1 * v1) // v2)\n            break\n        else:\n            n1 -= 1\n            if n1 < 0:\n                break\n    if n1 < 0:\n        print(\"Impossible\")\n
"},{"location":"solutions/#bounding-robots","title":"Bounding Robots","text":"Solution in Python Python
while True:\n    room_x, room_y = [int(d) for d in input().split()]\n    if not room_x and not room_y:\n        break\n\n    robot_x, robot_y = 0, 0\n    actual_x, actual_y = 0, 0\n\n    n = int(input())\n    for _ in range(n):\n        direction, step = input().split()\n        step = int(step)\n\n        if direction == \"u\":\n            robot_y += step\n            actual_y = min(room_y - 1, actual_y + step)\n        elif direction == \"d\":\n            robot_y -= step\n            actual_y = max(0, actual_y - step)\n        elif direction == \"r\":\n            robot_x += step\n            actual_x = min(room_x - 1, actual_x + step)\n        elif direction == \"l\":\n            robot_x -= step\n            actual_x = max(0, actual_x - step)\n\n    print(f\"Robot thinks {robot_x} {robot_y}\")\n    print(f\"Actually at {actual_x} {actual_y}\")\n    print()\n
"},{"location":"solutions/#bracket-matching","title":"Bracket Matching","text":"Solution in Python Python
n = int(input())\ns = input()\nstack = []\nis_valid = True\nfor i in range(n):\n    c = s[i]\n    if c in (\"(\", \"[\", \"{\"):\n        stack.append(c)\n    else:\n        if len(stack) == 0:\n            is_valid = False\n            break\n        last = stack.pop()\n        if c == \")\" and last != \"(\":\n            is_valid = False\n            break\n        if c == \"]\" and last != \"[\":\n            is_valid = False\n            break\n        if c == \"}\" and last != \"{\":\n            is_valid = False\n            break\n\nprint(\"Valid\" if is_valid and not len(stack) else \"Invalid\")\n
"},{"location":"solutions/#breaking-branches","title":"Breaking Branches","text":"Solutions in 5 languages GoHaskellJavaJavaScriptPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var n int\n    fmt.Scan(&n)\n    if n%2 == 0 {\n        fmt.Println(\"Alice\")\n        fmt.Println(1)\n    } else {\n        fmt.Println(\"Bob\")\n    }\n}\n
main = do\n    input <- getLine\n    let n = (read input :: Int)\n    if  n `mod` 2  ==  0\n    then do putStrLn \"Alice\"\n            putStrLn \"1\"\n        else putStrLn \"Bob\"\n
import java.util.Scanner;\n\nclass BreakingBranches {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int n = s.nextInt();\n        if (n % 2 == 0) {\n            System.out.println(\"Alice\");\n            System.out.println(1);\n        } else {\n            System.out.println(\"Bob\");\n        }\n    }\n}\n
const readline = require(\"readline\");\nconst rl = readline.createInterface(process.stdin, process.stdout);\n\nrl.question(\"\", (n) => {\n  if (parseInt(n) % 2) {\n    console.log(\"Bob\");\n  } else {\n    console.log(\"Alice\");\n    console.log(1);\n  }\n});\n
n = int(input())\nif n % 2:\n    print(\"Bob\")\nelse:\n    print(\"Alice\")\n    print(1)\n
"},{"location":"solutions/#broken-calculator","title":"Broken Calculator","text":"Solution in Python Python
prev = 1\nfor _ in range(int(input())):\n    a, op, b = input().split()\n    a, b = int(a), int(b)\n    if op == \"+\":\n        ans = a + b - prev\n    elif op == \"-\":\n        ans = (a - b) * prev\n    elif op == \"*\":\n        ans = (a * b) ** 2\n    elif op == \"/\":\n        ans = (a + 1) // 2 if a % 2 else a // 2\n\n    print(ans)\n    prev = ans\n
"},{"location":"solutions/#broken-swords","title":"Broken Swords","text":"Solution in Python Python
tb, lr = 0, 0\nfor _ in range(int(input())):\n    s = input()\n    tb += s[:2].count(\"0\")\n    lr += s[2:].count(\"0\")\n\nswords = min(tb, lr) // 2\ntb -= swords * 2\nlr -= swords * 2\n\nprint(f\"{swords} {tb} {lr}\")\n
"},{"location":"solutions/#buka","title":"Buka","text":"Solution in Python Python
a, op, b = input(), input(), input()\npa, pb = a.count(\"0\"), b.count(\"0\")\nif op == \"*\":\n    print(f\"1{'0'*(pa+pb)}\")\nelif op == \"+\":\n    if pa == pb:\n        ans = f\"2{'0'*pa}\"\n    else:\n        ans = f\"1{'0'*(abs(pa-pb)-1)}1{'0'*min(pa,pb)}\"\n    print(ans)\n
"},{"location":"solutions/#bus","title":"Bus","text":"Solution in Python Python
def f(n):\n    if n == 1:\n        return 1\n    else:\n        return int(2 * (f(n - 1) + 0.5))\n\n\nfor _ in range(int(input())):\n    print(f(int(input())))\n
"},{"location":"solutions/#bus-numbers","title":"Bus Numbers","text":"Solution in Python Python
n = int(input())\nnumbers = sorted([int(d) for d in input().split()])\n\nprev = numbers[0]\nans = {prev: 1}\nfor i in range(1, n):\n    if numbers[i] == prev + ans[prev]:\n        ans[prev] += 1\n    else:\n        prev = numbers[i]\n        ans[prev] = 1\n\nprint(\n    \" \".join(\n        [\n            f\"{key}-{key+value-1}\"\n            if value > 2\n            else \" \".join([str(d) for d in range(key, key + value)])\n            for key, value in ans.items()\n        ]\n    )\n)\n
"},{"location":"solutions/#calories-from-fat","title":"Calories From Fat","text":"Solution in Python Python
mapping = {\"fat\": 9, \"protein\": 4, \"sugar\": 4, \"starch\": 4, \"alcohol\": 7}\n\n\ndef c(x, category):\n    if \"g\" in x:\n        return (int(x[:-1]) * mapping[category], \"C\")\n    elif \"C\" in x:\n        return (int(x[:-1]), \"C\")\n    elif \"%\" in x:\n        return (int(x[:-1]) / 100, \"%\")\n\n\ndef solve(items):\n    fat_c, total_c = 0, 0\n    for fat, protein, sugar, starch, alcohol in items:\n        fat_c += fat\n        total_c += fat + protein + sugar + starch + alcohol\n\n    return f\"{fat_c/total_c:.0%}\"\n\n\nitems = []\nwhile True:\n    s = input()\n    if s == \"-\":\n        if not items:\n            break\n        print(solve(items))\n\n        items = []\n        continue\n\n    fat, protein, sugar, starch, alcohol = s.split()\n    mapping.keys()\n\n    total_c, total_p = 0, 0\n\n    reading = []\n    for v, k in zip(s.split(), mapping.keys()):\n        n, t = c(v, k)\n        if t == \"C\":\n            total_c += n\n        elif t == \"%\":\n            total_p += n\n        reading.append((n, t))\n\n    total_c = total_c / (1 - total_p)\n\n    item = []\n    for n, t in reading:\n        if t == \"%\":\n            item.append(n * total_c)\n        else:\n            item.append(n)\n\n    items.append(item)\n
"},{"location":"solutions/#canadians-eh","title":"Canadians, eh?","text":"Solutions in 3 languages GoJavaPython
package main\n\nimport (\n    \"bufio\"\n    \"fmt\"\n    \"os\"\n    \"strings\"\n)\n\nfunc main() {\n    scanner := bufio.NewScanner(os.Stdin)\n    scanner.Scan()\n    line := scanner.Text()\n    if strings.HasSuffix(line, \"eh?\") {\n        fmt.Println(\"Canadian!\")\n    } else {\n        fmt.Println(\"Imposter!\")\n    }\n}\n
import java.util.Scanner;\n\nclass CanadiansEh {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        String line = s.nextLine();\n        if (line.endsWith(\"eh?\")) {\n            System.out.println(\"Canadian!\");\n        } else {\n            System.out.println(\"Imposter!\");\n        }\n    }\n}\n
line = input()\nif line.endswith(\"eh?\"):\n    print(\"Canadian!\")\nelse:\n    print(\"Imposter!\")\n
"},{"location":"solutions/#careful-ascent","title":"Careful Ascent","text":"Solution in Python Python
a, b = [int(d) for d in input().split()]\nn = int(input())\nshields = []\nfor _ in range(n):\n    l, u, f = input().split()\n    l = int(l)\n    u = int(u)\n    f = float(f)\n    shields.append((l, u, f))\n\nshields.append((b,))\ns = shields[0][0]\nfor i in range(n):\n    s += (shields[i][1] - shields[i][0]) * shields[i][2]\n    s += shields[i + 1][0] - shields[i][1]\nprint(f\"{a/s:.6f}\")\n
"},{"location":"solutions/#solving-for-carrots","title":"Solving for Carrots","text":"Solution in Python Python
n, ans = [int(d) for d in input().split()]\nfor _ in range(n):\n    input()\nprint(ans)\n
"},{"location":"solutions/#catalan-numbers","title":"Catalan Numbers","text":"Solution in Python Python
# https://en.wikipedia.org/wiki/Catalan_number\np = [1]\nfor i in range(10000):\n    p.append(p[-1] * (i + 1))\n\nfor _ in range(int(input())):\n    n = int(input())\n    print(p[2 * n] // (p[n + 1] * p[n]))\n
"},{"location":"solutions/#cd","title":"CD","text":"Solution in Python Python
while True:\n    n, m = [int(d) for d in input().split()]\n    if not n and not m:\n        break\n    a = [int(input()) for _ in range(n)]\n    b = [int(input()) for _ in range(m)]\n    total, i, j = 0, 0, 0\n    while i < n and j < m:\n        if a[i] == b[j]:\n            total += 1\n            i += 1\n            j += 1\n        elif a[i] < b[j]:\n            i += 1\n        else:\n            j += 1\n    while i < n:\n        if a[i] == b[-1]:\n            total += 1\n            break\n        i += 1\n    while j < n:\n        if a[-1] == b[j]:\n            total += 1\n            break\n        j += 1\n    print(total)\n
"},{"location":"solutions/#cetiri","title":"Cetiri","text":"Solutions in 2 languages GoPython
package main\n\nimport (\n    \"fmt\"\n    \"sort\"\n)\n\nfunc main() {\n    var a, b, c int\n    fmt.Scan(&a)\n    fmt.Scan(&b)\n    fmt.Scan(&c)\n    s := []int{a, b, c}\n    sort.Ints(s)\n    a, b, c = s[0], s[1], s[2]\n    if c-b == b-a {\n        fmt.Println(c + c - b)\n    } else if c-b > b-a {\n        fmt.Println(c - b + a)\n    } else {\n        fmt.Println(a + c - b)\n    }\n}\n
a, b, c = sorted([int(d) for d in input().split()])\nif c - b == b - a:\n    print(c + c - b)\nelif c - b > b - a:\n    print(c - b + a)\nelse:\n    print(a + c - b)\n
"},{"location":"solutions/#cetvrta","title":"Cetvrta","text":"Solution in Python Python
from collections import Counter\n\nx, y = Counter(), Counter()\n\nfor _ in range(3):\n    _x, _y = [int(d) for d in input().split()]\n    x[_x] += 1\n    y[_y] += 1\n\n\nfor key in x:\n    if x[key] == 1:\n        print(key, \" \")\n        break\n\nfor key in y:\n    if y[key] == 1:\n        print(key)\n        break\n
"},{"location":"solutions/#chanukah-challenge","title":"Chanukah Challenge","text":"Solution in Python Python
for _ in range(int(input())):\n    k, n = [int(d) for d in input().split()]\n    print(k, int((1 + n) * n / 2 + n))\n
"},{"location":"solutions/#character-development","title":"Character Development","text":"Solution in Python Python
def f(m):\n    ans = 0\n    for n in range(2, m + 1):\n        a, b = 1, 1\n        for i in range(m - n + 1, m + 1):\n            a *= i\n        for i in range(1, n + 1):\n            b *= i\n        ans += a // b\n    return ans\n\n\nprint(f(int(input())))\n
"},{"location":"solutions/#chocolate-division","title":"Chocolate Division","text":"Solution in Python Python
r, c = [int(v) for v in input().split()]\n\nchocolate_bar_cuts = (r * c) - 1\n\nif chocolate_bar_cuts % 2 == 1:\n    print(\"Alf\")\nelse:\n    print(\"Beata\")\n
"},{"location":"solutions/#preludes","title":"Preludes","text":"Solution in Python Python
alternatives = [(\"A#\", \"Bb\"), (\"C#\", \"Db\"), (\"D#\", \"Eb\"), (\"F#\", \"Gb\"), (\"G#\", \"Ab\")]\n\n\nm = dict(alternatives + [(b, a) for a, b in alternatives])\n\ni = 1\nwhile True:\n    try:\n        s = input()\n    except:\n        break\n    key, tone = s.split()\n    if key in m:\n        print(f\"Case {i}: {m[key]} {tone}\")\n    else:\n        print(f\"Case {i}: UNIQUE\")\n\n    i += 1\n
"},{"location":"solutions/#cinema-crowds","title":"Cinema Crowds","text":"Solution in Python Python
n, m = [int(v) for v in input().split()]\n\nsize = [int(v) for v in input().split()]\n\ngroups_admitted = 0\n\nfor i in range(m):\n    if size[i] <= n:\n        n -= size[i]\n        groups_admitted += 1\n\nprint(m - groups_admitted)\n
"},{"location":"solutions/#cinema-crowds-2","title":"Cinema Crowds 2","text":"Solution in Python Python
n, m = [int(t) for t in input().split()]\np = [int(t) for t in input().split()]\n\nd = 0\nl = 0\nfor i in range(m):\n    if p[i] > n - d:\n        break\n    else:\n        k = p[i]\n        d += k\n        l += 1\n\nprint(m - l)\n
"},{"location":"solutions/#class-field-trip","title":"Class Field Trip","text":"Solution in Python Python
a = input()\nb = input()\n\ni, j = 0, 0\nans = []\nwhile i < len(a) and j < len(b):\n    if a[i] < b[j]:\n        ans.append(a[i])\n        i += 1\n    else:\n        ans.append(b[j])\n        j += 1\n\n\nans += a[i:] if i < len(a) else b[j:]\n\nprint(\"\".join(ans))\n
"},{"location":"solutions/#a-furious-cocktail","title":"A Furious Cocktail","text":"Solution in Python Python
n, t = [int(d) for d in input().split()]\np = [int(input()) for _ in range(n)]\np = sorted(p, reverse=True)\nending = p[0]\nable = True\nfor i in range(1, n):\n    if t * i >= ending:\n        print(\"NO\")\n        able = False\n        break\n    if t * i + p[i] < ending:\n        ending = t * i + p[i]\nif able:\n    print(\"YES\")\n
"},{"location":"solutions/#code-cleanups","title":"Code Cleanups","text":"Solution in Python Python
n = int(input())\np = [int(d) for d in input().split()]\nprev = []\nt = 0\nfor v in p:\n    if not prev:\n        prev.append(v)\n        continue\n    d = (19 + sum(prev)) // len(prev)\n    if v <= d:\n        prev.append(v)\n    else:\n        prev = [v]\n        t += 1\nif prev:\n    t += 1\nprint(t)\n
"},{"location":"solutions/#code-to-save-lives","title":"Code to Save Lives","text":"Solution in Python Python
t = int(input())\nfor _ in range(t):\n    a = int(input().replace(\" \", \"\"))\n    b = int(input().replace(\" \", \"\"))\n    print(\" \".join(str(a + b)))\n
"},{"location":"solutions/#coffee-cup-combo","title":"Coffee Cup Combo","text":"Solution in Python Python
n = int(input())\nawake = [0] * n\ns = list(input())\nfor i in range(n):\n    if s[i] == \"1\":\n        awake[i] = 1\n        if i + 1 < n:\n            awake[i + 1] = 1\n        if i + 2 < n:\n            awake[i + 2] = 1\nprint(sum(awake))\n
"},{"location":"solutions/#cold-puter-science","title":"Cold-puter Science","text":"Solution in Python Python
_ = input()\nprint(len([t for t in input().split() if \"-\" in t]))\n
"},{"location":"solutions/#competitive-arcade-basketball","title":"Competitive Arcade Basketball","text":"Solution in Python Python
from collections import Counter\n\nn, p, m = [int(d) for d in input().split()]\n\nrecords = Counter()\nwinners = []\nnames = [input() for _ in range(n)]\nfor r in range(m):\n    name, point = input().split()\n    point = int(point)\n    records[name] += point\n    if records[name] >= p and name not in winners:\n        winners.append(name)\nif not winners:\n    print(\"No winner!\")\nelse:\n    print(\"\\n\".join([f\"{n} wins!\" for n in winners]))\n
"},{"location":"solutions/#completing-the-square","title":"Completing the Square","text":"Solution in Python Python
x1, y1 = [int(d) for d in input().split()]\nx2, y2 = [int(d) for d in input().split()]\nx3, y3 = [int(d) for d in input().split()]\n\nd12 = (x1 - x2) ** 2 + (y1 - y2) ** 2\nd13 = (x1 - x3) ** 2 + (y1 - y3) ** 2\nd23 = (x2 - x3) ** 2 + (y2 - y3) ** 2\n\nif d12 == d13:\n    x, y = x2 + x3 - x1, y2 + y3 - y1\nelif d12 == d23:\n    x, y = x1 + x3 - x2, y1 + y3 - y2\nelse:\n    x, y = x1 + x2 - x3, y1 + y2 - y3\n\nprint(x, y)\n
"},{"location":"solutions/#compound-words","title":"Compound Words","text":"Solution in Python Python
from itertools import permutations\n\nl = []\nwhile True:\n    try:\n        l.extend(input().split())\n    except:\n        break\n\nw = set()\nfor i, j in permutations(l, 2):\n    w.add(f\"{i}{j}\")\n\n\nprint(\"\\n\".join(sorted(w)))\n
"},{"location":"solutions/#conformity","title":"Conformity","text":"Solution in Python Python
from collections import Counter\n\nn = int(input())\nentries = []\nfor _ in range(n):\n    entries.append(\" \".join(sorted(input().split())))\n\nsummary = Counter(entries)\npopular = max(summary.values())\n\nprint(sum([summary[e] for e in summary if summary[e] == popular]))\n
"},{"location":"solutions/#contingency-planning","title":"Contingency Planning","text":"Solution in Python Python
def permutations(n, c):\n    value = 1\n    for i in range(n - c + 1, n + 1):\n        value *= i\n    return value\n\n\nn = int(input())\nans = 0\nfor i in range(1, n + 1):\n    ans += permutations(n, i)\nif ans > 1_000_000_000:\n    print(\"JUST RUN!!\")\nelse:\n    print(ans)\n
"},{"location":"solutions/#cryptographers-conundrum","title":"Cryptographer's Conundrum","text":"Solution in Python Python
text = input()\ntotal = 0\nfor i in range(0, len(text), 3):\n    if text[i] != \"P\":\n        total += 1\n    if text[i + 1] != \"E\":\n        total += 1\n    if text[i + 2] != \"R\":\n        total += 1\nprint(total)\n
"},{"location":"solutions/#convex-polygon-area","title":"Convex Polygon Area","text":"Solution in Python Python
for _ in range(int(input())):\n    values = [int(d) for d in input().split()]\n    coords = values[1:]\n    n = values[0]\n\n    coords.append(coords[0])\n    coords.append(coords[1])\n\n    area = 0\n    for i in range(0, 2 * n, 2):\n        x1, y1 = coords[i], coords[i + 1]\n        x2, y2 = coords[i + 2], coords[i + 3]\n        area += x1 * y2 - x2 * y1\n\n    print(0.5 * abs(area))\n
"},{"location":"solutions/#cooking-water","title":"Cooking Water","text":"Solution in Python Python
n = int(input())\nlb, ub = 0, 1000\nfor _ in range(n):\n    a, b = [int(d) for d in input().split()]\n    lb = max(lb, a)\n    ub = min(ub, b)\n\nif lb > ub:\n    print(\"edward is right\")\nelse:\n    print(\"gunilla has a point\")\n
"},{"location":"solutions/#cornhusker","title":"Cornhusker","text":"Solution in Python Python
a = [int(d) for d in input().split()]\nn, kwf = [int(d) for d in input().split()]\ns = sum([a[i] * a[i + 1] for i in range(0, 10, 2)])\n\nprint(int(int(s / 5) * n / kwf))\n
"},{"location":"solutions/#cosmic-path-optimization","title":"Cosmic Path Optimization","text":"Solution in Python Python
import math\n\nm = int(input())\nt = [int(d) for d in input().split()]\nprint(f\"{math.floor(sum(t)/m)}\")\n
"},{"location":"solutions/#costume-contest","title":"Costume Contest","text":"Solution in Python Python
from collections import Counter\n\nn = int(input())\nc = Counter()\nfor _ in range(n):\n    c[input()] += 1\nprint(\"\\n\".join(sorted([k for k, v in c.items() if v == min(c.values())])))\n
"},{"location":"solutions/#count-doubles","title":"Count Doubles","text":"Solution in Python Python
n, m = [int(d) for d in input().split()]\nvalues = [int(d) for d in input().split()]\nans = 0\nfor i in range(n - m + 1):\n    if len([v for v in values[i : i + m] if not v % 2]) >= 2:\n        ans += 1\nprint(ans)\n
"},{"location":"solutions/#counting-clauses","title":"Counting Clauses","text":"Solution in Python Python
m, _ = [int(d) for d in input().split()]\nfor _ in range(m):\n    input()\nif m >= 8:\n    print(\"satisfactory\")\nelse:\n    print(\"unsatisfactory\")\n
"},{"location":"solutions/#count-the-vowels","title":"Count the Vowels","text":"Solution in Python Python
print(len([c for c in input().lower() if c in \"aeiou\"]))\n
"},{"location":"solutions/#course-scheduling","title":"Course Scheduling","text":"Solution in Python Python
from collections import Counter\n\nc = Counter()\nn = {}\n\nfor _ in range(int(input())):\n    r = input().split()\n    name, course = \" \".join(r[:2]), r[-1]\n    if course not in n:\n        n[course] = set()\n\n    if name not in n[course]:\n        c[course] += 1\n        n[course].add(name)\n\nfor k in sorted(c.keys()):\n    print(f\"{k} {c[k]}\")\n
"},{"location":"solutions/#cpr-number","title":"CPR Number","text":"Solution in Python Python
cpr = input().replace(\"-\", \"\")\nvalues = [4, 3, 2, 7, 6, 5, 4, 3, 2, 1]\ntotal = 0\nfor d, v in zip(cpr, values):\n    total += int(d) * v\nif not total % 11:\n    print(1)\nelse:\n    print(0)\n
"},{"location":"solutions/#crne","title":"Crne","text":"Solutions in 2 languages GoPython
package main\n\nimport (\n    \"fmt\"\n)\n\nfunc main() {\n    var n int\n    fmt.Scan(&n)\n    a := n / 2\n    b := n - a\n    fmt.Println((a + 1) * (b + 1))\n}\n
n = int(input())\na = n // 2\nb = n - a\nprint((a + 1) * (b + 1))\n
"},{"location":"solutions/#cudoviste","title":"Cudoviste","text":"Solution in Python Python
r, c = [int(d) for d in input().split()]\nparking = []\nfor _ in range(r):\n    parking.append(input())\n\n\ndef count_spaces(parking, squash):\n    total = 0\n    for i in range(r - 1):\n        for j in range(c - 1):\n            spaces = [\n                parking[i][j],\n                parking[i + 1][j],\n                parking[i][j + 1],\n                parking[i + 1][j + 1],\n            ]\n            if (\n                all(s in \".X\" for s in spaces)\n                and sum([s == \"X\" for s in spaces]) == squash\n            ):\n                total += 1\n    return total\n\n\nfor num in range(0, 5):\n    print(count_spaces(parking, num))\n
"},{"location":"solutions/#stacking-cups","title":"Stacking Cups","text":"Solution in Python Python
size = {}\nfor _ in range(int(input())):\n    parts = input().split()\n    if parts[0].isdigit():\n        size[parts[1]] = int(parts[0]) / 2\n    else:\n        size[parts[0]] = int(parts[1])\nfor color in sorted(size, key=lambda x: size[x]):\n    print(color)\n
"},{"location":"solutions/#cut-in-line","title":"Cut in Line","text":"Solution in Python Python
n = int(input())\nqueue = []\nfor _ in range(n):\n    queue.append(input())\n\nc = int(input())\nfor _ in range(c):\n    event = input().split()\n    if event[0] == \"leave\":\n        queue.remove(event[1])\n    elif event[0] == \"cut\":\n        queue.insert(queue.index(event[2]), event[1])\n\nfor name in queue:\n    print(name)\n
"},{"location":"solutions/#cut-the-negativity","title":"Cut the Negativity","text":"Solution in Python Python
n = int(input())\n\npositives = []\nfor i in range(n):\n    numbers = [int(d) for d in input().split()]\n    for j in range(n):\n        if numbers[j] > 0:\n            positives.append((str(i + 1), str(j + 1), str(numbers[j])))\n\nprint(len(positives))\nfor p in positives:\n    print(\" \".join(p))\n
"},{"location":"solutions/#cyanide-rivers","title":"Cyanide Rivers","text":"Solution in Python Python
import math\n\ns = input()\nt = s.split(\"1\")\nprint(max([math.ceil(len(z) / 2) for z in t]))\n
"},{"location":"solutions/#cypher-decypher","title":"Cypher Decypher","text":"Solution in Python Python
from string import ascii_uppercase\n\n\ndef f(n, m):\n    return ascii_uppercase[(n * m) % 26]\n\n\nm = input()\nfor _ in range(int(input())):\n    s = input()\n    print(\"\".join([f(ascii_uppercase.index(c), int(d)) for c, d in zip(s, m)]))\n
"},{"location":"solutions/#damaged-equation","title":"Damaged Equation","text":"Solution in Python Python
from itertools import product\n\na, b, c, d = [int(d) for d in input().split()]\nops = [\"*\", \"+\", \"-\", \"//\"]\nvalid = False\nfor op1, op2 in product(ops, ops):\n    e = f\"{a} {op1} {b} == {c} {op2} {d}\"\n    try:\n        if eval(e):\n            print(e.replace(\"==\", \"=\").replace(\"//\", \"/\"))\n            valid = True\n    except:\n        pass\nif not valid:\n    print(\"problems ahead\")\n
"},{"location":"solutions/#datum","title":"Datum","text":"Solution in Python Python
from datetime import datetime\n\nd, m = [int(d) for d in input().split()]\nprint(datetime(year=2009, month=m, day=d).strftime(\"%A\"))\n
"},{"location":"solutions/#death-knight-hero","title":"Death Knight Hero","text":"Solution in Python Python
total = 0\nfor _ in range(int(input())):\n    if \"CD\" not in input():\n        total += 1\nprint(total)\n
"},{"location":"solutions/#delimiter-soup","title":"Delimiter Soup","text":"Solution in Python Python
n = int(input())\ns = input()\n\nstack = []\n\nvalid = True\n\nfor i in range(n):\n    c = s[i]\n    if c in [\"(\", \"[\", \"{\"]:\n        stack.append(c)\n    if c in [\")\", \"]\", \"}\"]:\n        if len(stack) == 0:\n            valid = False\n            break\n\n        v = stack.pop()\n        if c == \")\" and v != \"(\":\n            valid = False\n            break\n        elif c == \"]\" and v != \"[\":\n            valid = False\n            break\n        elif c == \"}\" and v != \"{\":\n            valid = False\n            break\n\nif valid:\n    print(\"ok so far\")\nelse:\n    print(c, i)\n
"},{"location":"solutions/#detailed-differences","title":"Detailed Differences","text":"Solution in Python Python
for _ in range(int(input())):\n    s1, s2 = input(), input()\n    result = [\".\" if c1 == c2 else \"*\" for c1, c2 in zip(s1, s2)]\n    print(s1)\n    print(s2)\n    print(\"\".join(result))\n
"},{"location":"solutions/#dice-cup","title":"Dice Cup","text":"Solution in Python Python
d1, d2 = [int(d) for d in input().split()]\n\nsums = []\nfor i in range(1, d1 + 1):\n    for j in range(1, d2 + 1):\n        sums.append(i + j)\n\nfrom collections import Counter\n\nc = Counter(sums)\nmost_likely = max(c.values())\nfor key in sorted(c.keys()):\n    if c[key] == most_likely:\n        print(key)\n
"},{"location":"solutions/#dice-game","title":"Dice Game","text":"Solution in Python Python
g = [int(d) for d in input().split()]\ne = [int(d) for d in input().split()]\n\n\ndef ev(d):\n    total, count = 0, 0\n    for i in range(d[0], d[1] + 1):\n        for j in range(d[2], d[3] + 1):\n            total += i + j\n            count += 1\n    return total / count\n\n\nratio = ev(g) / ev(e)\nif ratio > 1:\n    print(\"Gunnar\")\nelif ratio < 1:\n    print(\"Emma\")\nelse:\n    print(\"Tie\")\n
"},{"location":"solutions/#a-different-problem","title":"A Different Problem","text":"Solution in Python Python
while True:\n    try:\n        line = input()\n    except:\n        break\n    a, b = [int(d) for d in line.split()]\n    print(abs(a - b))\n
"},{"location":"solutions/#different-distances","title":"Different Distances","text":"Solution in Python Python
while True:\n    line = input()\n    if line == \"0\":\n        break\n    x1, y1, x2, y2, p = [float(d) for d in line.split()]\n    print((abs(x1 - x2) ** p + abs(y1 - y2) ** p) ** (1 / p))\n
"},{"location":"solutions/#digit-swap","title":"Digit Swap","text":"Solutions in 3 languages GoJavaPython
package main\n\nimport (\n    \"fmt\"\n)\n\nfunc reverse(str string) (ans string) {\n    for _, v := range str {\n        ans = string(v) + ans\n    }\n    return\n}\nfunc main() {\n    var str string\n    fmt.Scan(&str)\n    fmt.Println(reverse(str))\n}\n
import java.util.*;\n\nclass DigitSwap {\n    public static void main(String[] argv){\n        Scanner s = new Scanner(System.in);\n        StringBuilder ans = new StringBuilder();\n        ans.append(s.nextLine());\n        ans.reverse();\n        System.out.println(ans);\n    }\n}\n
print(input()[::-1])\n
"},{"location":"solutions/#disc-district","title":"Disc District","text":"Solution in Python Python
print(1, input())\n
"},{"location":"solutions/#divvying-up","title":"Divvying Up","text":"Solution in Python Python
_ = input()\np = [int(d) for d in input().split()]\nif sum(p) % 3:\n    print(\"no\")\nelse:\n    print(\"yes\")\n
"},{"location":"solutions/#dont-fall-down-stairs","title":"Don't Fall Down Stairs","text":"Solution in Python Python
n = int(input())\na = [int(d) for d in input().split()] + [0]\nprint(sum(max(a[i] - a[i + 1] - 1, 0) for i in range(n)))\n
"},{"location":"solutions/#double-password","title":"Double Password","text":"Solutions in 2 languages JavaPython
import java.util.Scanner;\n\nclass DoublePassword {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        String a = s.nextLine();\n        String b = s.nextLine();\n        int number = 1;\n        for (int i = 0; i < a.length(); i++) {\n            if (a.charAt(i) == b.charAt(i)) {\n                number *= 1;\n            } else {\n                number *= 2;\n            }\n        }\n        System.out.println(number);\n\n    }\n}\n
a, b = input(), input()\nnumber = 1\nfor c1, c2 in zip(a, b):\n    if c1 == c2:\n        number *= 1\n    else:\n        number *= 2\nprint(number)\n
"},{"location":"solutions/#drinking-song","title":"Drinking Song","text":"Solution in Python Python
n = int(input())\nw = input()\n\nfor i in range(n):\n    a = f\"{n-i} bottle{'s' if n-i >1 else ''}\"\n    b = f\"{'no more' if n-i-1==0 else n-i-1 } bottle{'' if n-i-1==1 else 's'}\"\n    c = f\"{'one' if n-i>1 else 'it' }\"\n    d = f\"{' on the wall' if n-i-1 else ''}\"\n    print(f\"{a} of {w} on the wall, {a} of {w}.\")\n    print(f\"Take {c} down, pass it around, {b} of {w}{d}.\")\n    if n - i - 1:\n        print()\n
"},{"location":"solutions/#drivers-dilemma","title":"Driver's Dilemma","text":"Solution in Python Python
c, x, m = [float(d) for d in input().split()]\ntop = 0\nfor _ in range(6):\n    mph, mpg = [float(d) for d in input().split()]\n\n    if m / mph * x + m / mpg <= c / 2:\n        top = mph\nif top:\n    print(f\"YES {top:.0f}\")\nelse:\n    print(\"NO\")\n
"},{"location":"solutions/#drm-messages","title":"DRM Messages","text":"Solution in Python Python
l = ord(\"A\")\nr = ord(\"Z\")\n\n\ndef divide(message):\n    half = len(message) // 2\n    return message[:half], message[half:]\n\n\ndef to_ord(c, rotation):\n    new_chr = ord(c) + rotation\n    return new_chr if new_chr <= r else l + (new_chr - r - 1)\n\n\ndef rotate(half):\n    rotation = sum([ord(c) - l for c in half])\n    rotation %= 26\n    result = [to_ord(c, rotation) for c in half]\n    return \"\".join([chr(c) for c in result])\n\n\ndef merge(first, second):\n    rotations = [ord(c) - l for c in second]\n    result = [to_ord(c, rotation) for c, rotation in zip(first, rotations)]\n    return \"\".join([chr(c) for c in result])\n\n\nmessage = input()\nfirst, second = divide(message)\nprint(merge(rotate(first), rotate(second)))\n
"},{"location":"solutions/#drunk-vigenere","title":"Drunk Vigen\u00e8re","text":"Solution in Python Python
import string\n\nuppers = string.ascii_uppercase\n\n\ndef unshift(c, k, f):\n    index = uppers.index(k)\n    if f:\n        new_index = uppers.index(c) + index\n    else:\n        new_index = uppers.index(c) - index\n    return uppers[new_index % 26]\n\n\nmessage, key = input(), input()\nprint(\"\".join([unshift(c, k, i % 2) for i, (c, k) in enumerate(zip(message, key))]))\n
"},{"location":"solutions/#early-winter","title":"Early Winter","text":"Solution in Python Python
n, m = [int(_) for _ in input().split()]\nd = [int(_) for _ in input().split()]\nd = [v > m for v in d]\n\n\nfor k in range(n):\n    if not d[k]:\n        break\n\nif all(d):\n    print(\"It had never snowed this early!\")\nelse:\n    print(f\"It hadn't snowed this early in {k} years!\")\n
"},{"location":"solutions/#the-easiest-problem-is-this-one","title":"The Easiest Problem Is This One","text":"Solution in Python Python
while True:\n    n = input()\n    if n == \"0\":\n        break\n    s1 = sum([int(d) for d in n])\n\n    n = int(n)\n    p = 11\n    while True:\n        s2 = sum([int(d) for d in str(n * p)])\n        if s2 == s1:\n            break\n        p += 1\n\n    print(p)\n
"},{"location":"solutions/#echo-echo-echo","title":"Echo Echo Echo","text":"Solution in Python Python
word = input().strip()\nprint(\" \".join([word] * 3))\n
"},{"location":"solutions/#egypt","title":"Egypt","text":"Solution in Python Python
while True:\n    sides = sorted([int(d) for d in input().split()])\n    if not all(sides):\n        break\n    if sides[0] ** 2 + sides[1] ** 2 == sides[2] ** 2:\n        print(\"right\")\n    else:\n        print(\"wrong\")\n
"},{"location":"solutions/#eiginnofn","title":"Eiginn\u00f6fn","text":"Solution in Python Python
n = int(input())\nmapping = {}\nfor _ in range(n):\n    names = input().split()\n    mapping[names[0]] = names\nm = int(input())\nfor _ in range(m):\n    name = input()\n    if name not in mapping:\n        print(\"Neibb\")\n    elif name in mapping and len(mapping[name]) == 1:\n        print(\"Jebb\")\n    else:\n        print(f'Neibb en {\" \".join(mapping[name])} er heima')\n
"},{"location":"solutions/#ekki-daui-opna-inni","title":"Ekki dau\u00f0i opna inni","text":"Solution in Python Python
l = []\nwhile True:\n    try:\n        l.append(input().split(\"|\"))\n    except:\n        break\n\nl = [l[i][0] for i in range(len(l))] + [\" \"] + [l[i][1] for i in range(len(l))]\nprint(\"\".join(l))\n
"},{"location":"solutions/#election-paradox","title":"Election Paradox","text":"Solution in Python Python
n = int(input())\np = [int(d) for d in input().split()]\np = sorted(p)\nt = 0\nfor i in range(0, n // 2 + 1):\n    t += p[i] // 2\nfor i in range(n // 2 + 1, n):\n    t += p[i]\nprint(t)\n
"},{"location":"solutions/#electrical-outlets","title":"Electrical Outlets","text":"Solution in Python Python
for _ in range(int(input())):\n    print(sum([int(d) - 1 for d in input().split()[1:]]) + 1)\n
"},{"location":"solutions/#eligibility","title":"Eligibility","text":"Solution in Python Python
for _ in range(int(input())):\n    name, pss, dob, courses = input().split()\n    courses = int(courses)\n    pss = [int(d) for d in pss.split(\"/\")]\n    dob = [int(d) for d in dob.split(\"/\")]\n    if pss[0] >= 2010 or dob[0] >= 1991:\n        print(name, \"eligible\")\n    elif courses > 40:\n        print(name, \"ineligible\")\n    else:\n        print(name, \"coach petitions\")\n
"},{"location":"solutions/#encoded-message","title":"Encoded Message","text":"Solution in Python Python
import math\n\nfor _ in range(int(input())):\n    message = input()\n    size = int(math.sqrt(len(message)))\n    m = []\n    for i in range(size):\n        m.append(message[i * size : (i + 1) * size])\n\n    ans = []\n    for i in range(size - 1, -1, -1):\n        for j in range(size):\n            ans.append(m[j][i])\n    print(\"\".join(ans))\n
"},{"location":"solutions/#endurvinnsla","title":"Endurvinnsla","text":"Solution in Python Python
_ = input()\np = float(input())\nn = int(input())\nitems = [input() == \"ekki plast\" for _ in range(n)]\nprint(\"Jebb\" if sum(items) <= p * n else \"Neibb\")\n
"},{"location":"solutions/#engineering-english","title":"Engineering English","text":"Solution in Python Python
seen = set()\n\nwhile True:\n    try:\n        s = input().split()\n    except:\n        break\n    d = []\n    for t in s:\n        if t.lower() not in seen:\n            seen.add(t.lower())\n        else:\n            t = \".\"\n        d.append(t)\n    print(\" \".join(d))\n
"},{"location":"solutions/#erase-securely","title":"Erase Securely","text":"Solution in Python Python
n = int(input())\na, b = input(), input()\nif n % 2:\n    print(\n        \"Deletion\", \"failed\" if not all([i != j for i, j in zip(a, b)]) else \"succeeded\"\n    )\nelse:\n    print(\n        \"Deletion\", \"failed\" if not all([i == j for i, j in zip(a, b)]) else \"succeeded\"\n    )\n
"},{"location":"solutions/#espresso","title":"Espresso!","text":"Solution in Python Python
n, s = [int(d) for d in input().split()]\nrefill = 0\ntank = s\nfor _ in range(n):\n    o = input()\n    if \"L\" in o:\n        w = int(o[:-1]) + 1\n    else:\n        w = int(o)\n    if tank - w < 0:\n        refill += 1\n        tank = s\n\n    tank -= w\nprint(refill)\n
"},{"location":"solutions/#estimating-the-area-of-a-circle","title":"Estimating the Area of a Circle","text":"Solution in Python Python
import math\n\nwhile True:\n    r, m, c = input().split()\n    if r == \"0\" and m == \"0\" and c == \"0\":\n        break\n    r = float(r)\n    m, c = int(m), int(c)\n    print(math.pi * r * r, 4 * r * r * c / m)\n
"},{"location":"solutions/#eulers-number","title":"Euler's Number","text":"Solutions in 2 languages C++Python
#include <iomanip>\n#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int n;\n    long double e, m;\n    cin >> n;\n    e = 1;\n    m = 1;\n    for (int i = 1; i <= n; i++)\n    {\n        m *= i;\n        e += 1 / m;\n    }\n    cout << std::setprecision(13) << e << endl;\n    return 0;\n}\n
n = int(input())\ne = 1\nm = 1\nfor i in range(1, n + 1):\n    m *= i\n    e += 1 / m\nprint(e)\n
"},{"location":"solutions/#evening-out-1","title":"Evening Out 1","text":"Solutions in 2 languages C++Python
#include <algorithm>\n#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    long int a, b;\n    cin >> a >> b;\n    long int c = a % b;\n    cout << std::min(c, b - c);\n    return 0;\n}\n
a, b = [int(d) for d in input().split()]\nc = a % b\nprint(min(c, b - c))\n
"},{"location":"solutions/#event-planning","title":"Event Planning","text":"Solution in Python Python
n, b, h, w = [int(d) for d in input().split()]\n\ncosts = []\nfor _ in range(h):\n    p = int(input())\n    a = [int(d) for d in input().split()]\n    if not any([_a >= n for _a in a]):\n        costs.append(None)\n        continue\n    c = p * n\n    if c > b:\n        c = None\n    costs.append(c)\n\ncosts = [c for c in costs if c]\nif not costs:\n    print(\"stay home\")\nelse:\n    print(min(costs))\n
"},{"location":"solutions/#ive-been-everywhere-man","title":"I've Been Everywhere, Man","text":"Solution in Python Python
cities = {}\nfor i in range(int(input())):\n    cities[i] = set()\n    for _ in range(int(input())):\n        cities[i].add(input())\n\nprint(\"\\n\".join([str(len(s)) for s in cities.values()]))\n
"},{"location":"solutions/#exactly-electrical","title":"Exactly Electrical","text":"Solution in Python Python
a, b = [int(d) for d in input().split()]\nc, d = [int(d) for d in input().split()]\nt = int(input())\nm = abs(a - c) + abs(b - d)\nprint(\"Y\" if m <= t and (m - t) % 2 == 0 else \"N\")\n
"},{"location":"solutions/#exam","title":"Exam","text":"Solution in Python Python
k = int(input())\ny = input()\nf = input()\nsame, different = 0, 0\nfor a, b in zip(y, f):\n    if a == b:\n        same += 1\n    else:\n        different += 1\nprint(min(same, k) + min(different, (len(y) - k)))\n
"},{"location":"solutions/#expected-earnings","title":"Expected Earnings","text":"Solution in Python Python
n, k, p = input().split()\nn = int(n)\nk = int(k)\np = float(p)\nev = n * p - k\nif ev < 0:\n    print(\"spela\")\nelse:\n    print(\"spela inte!\")\n
"},{"location":"solutions/#eye-of-sauron","title":"Eye of Sauron","text":"Solutions in 2 languages GoPython
package main\n\nimport (\n    \"fmt\"\n    \"strings\"\n)\n\nfunc main() {\n    var drawing string\n    fmt.Scan(&drawing)\n    parts := strings.Split(drawing, \"()\")\n    left, right := parts[0], parts[1]\n    if left == right {\n        fmt.Println(\"correct\")\n    } else {\n        fmt.Println(\"fix\")\n    }\n}\n
drawing = input()\nleft, right = drawing.split(\"()\")\nif left == right:\n    print(\"correct\")\nelse:\n    print(\"fix\")\n
"},{"location":"solutions/#fading-wind","title":"Fading Wind","text":"Solution in Python Python
h, k, v, s = [int(d) for d in input().split()]\nt = 0\nwhile h > 0:\n    v += s\n    v -= max(1, v // 10)\n    if v >= k:\n        h += 1\n    elif v > 0:\n        h -= 1\n        if not h:\n            v = 0\n    else:\n        h = 0\n        v = 0\n    t += v\n    if s > 0:\n        s -= 1\nprint(t)\n
"},{"location":"solutions/#faktor","title":"Faktor","text":"Solution in Python Python
a, i = [int(d) for d in input().split()]\nprint(a * (i - 1) + 1)\n
"},{"location":"solutions/#falling-apart","title":"Falling Apart","text":"Solution in Python Python
n = int(input())\na = sorted([int(d) for d in input().split()], reverse=True)\nprint(\n    sum([a[i] for i in range(0, n, 2)]),\n    sum([a[i] for i in range(1, n, 2)]),\n)\n
"},{"location":"solutions/#false-sense-of-security","title":"False Sense of Security","text":"Solution in Python Python
encoding = {\n    \"A\": \".-\",\n    \"B\": \"-...\",\n    \"C\": \"-.-.\",\n    \"D\": \"-..\",\n    \"E\": \".\",\n    \"F\": \"..-.\",\n    \"G\": \"--.\",\n    \"H\": \"....\",\n    \"I\": \"..\",\n    \"J\": \".---\",\n    \"K\": \"-.-\",\n    \"L\": \".-..\",\n    \"M\": \"--\",\n    \"N\": \"-.\",\n    \"O\": \"---\",\n    \"P\": \".--.\",\n    \"Q\": \"--.-\",\n    \"R\": \".-.\",\n    \"S\": \"...\",\n    \"T\": \"-\",\n    \"U\": \"..-\",\n    \"V\": \"...-\",\n    \"W\": \".--\",\n    \"X\": \"-..-\",\n    \"Y\": \"-.--\",\n    \"Z\": \"--..\",\n    \"_\": \"..--\",\n    \",\": \".-.-\",\n    \".\": \"---.\",\n    \"?\": \"----\",\n}\n\ndecoding = dict([(v, k) for k, v in encoding.items()])\n\nwhile True:\n    try:\n        encoded = input()\n    except:\n        break\n    length = [len(encoding[c]) for c in encoded]\n    morse = \"\".join([encoding[c] for c in encoded])\n\n    ans, s = \"\", 0\n    for i in reversed(length):\n        ans += decoding[morse[s : s + i]]\n        s += i\n    print(ans)\n
"},{"location":"solutions/#fast-food-prizes","title":"Fast Food Prizes","text":"Solution in Python Python
for _ in range(int(input())):\n    n, m = [int(d) for d in input().split()]\n    r = []\n    for _ in range(n):\n        s = input().split()\n        p = int(s[-1])\n        k = [int(d) for d in s[1:-1]]\n        r.append((k, p))\n    s = [int(d) for d in input().split()]\n\n    ans = 0\n    for t, p in r:\n        c = min([s[d - 1] for d in t])\n        ans += p * c\n\n    print(ans)\n
"},{"location":"solutions/#fbi-universal-control-numbers","title":"FBI Universal Control Numbers","text":"Solution in Python Python
m = {\n    \"0\": 0,\n    \"1\": 1,\n    \"2\": 2,\n    \"3\": 3,\n    \"4\": 4,\n    \"5\": 5,\n    \"6\": 6,\n    \"7\": 7,\n    \"8\": 8,\n    \"9\": 9,\n    \"A\": 10,\n    \"B\": 8,\n    \"C\": 11,\n    \"D\": 12,\n    \"E\": 13,\n    \"F\": 14,\n    \"G\": 11,\n    \"H\": 15,\n    \"I\": 1,\n    \"J\": 16,\n    \"K\": 17,\n    \"L\": 18,\n    \"M\": 19,\n    \"N\": 20,\n    \"O\": 0,\n    \"P\": 21,\n    \"Q\": 0,\n    \"R\": 22,\n    \"S\": 5,\n    \"T\": 23,\n    \"U\": 24,\n    \"V\": 24,\n    \"W\": 25,\n    \"X\": 26,\n    \"Y\": 24,\n    \"Z\": 2,\n}\nw = [2, 4, 5, 7, 8, 10, 11, 13]\n\nfor _ in range(int(input())):\n    i, d = input().split()\n    t = sum([m[b] * a for a, b in zip(w, d)])\n    if t % 27 == m[d[-1]]:\n        s = sum([m[b] * 27**a for a, b in zip(range(8), d[:8][::-1])])\n        print(f\"{i} {s}\")\n    else:\n        print(f\"{i} Invalid\")\n
"},{"location":"solutions/#framtiar-fifa","title":"Framt\u00ed\u00f0ar FIFA","text":"Solution in Python Python
n = int(input())\nm = int(input())\nprint(2022 + n // m)\n
"},{"location":"solutions/#fifty-shades-of-pink","title":"Fifty Shades of Pink","text":"Solution in Python Python
total = 0\nfor _ in range(int(input())):\n    button = input().lower()\n    if \"pink\" in button or \"rose\" in button:\n        total += 1\nif not total:\n    print(\"I must watch Star Wars with my daughter\")\nelse:\n    print(total)\n
"},{"location":"solutions/#filip","title":"Filip","text":"Solution in Python Python
a, b = input().split()\na, b = a[::-1], b[::-1]\nif a > b:\n    print(a)\nelse:\n    print(b)\n
"},{"location":"solutions/#final-exam","title":"Final Exam","text":"Solution in Python Python
n = int(input())\nans, score = [], 0\nfor i in range(n):\n    ans.append(input())\n    if i == 0:\n        continue\n    if ans[i] == ans[i - 1]:\n        score += 1\nprint(score)\n
"},{"location":"solutions/#finding-an-a","title":"Finding An A","text":"Solutions in 3 languages C++GoPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    string a;\n    cin >> a;\n\n    int found = a.find_first_of(\"a\");\n\n    cout << a.substr(found);\n\n    return 0;\n}\n
package main\n\nimport (\n    \"fmt\"\n    \"strings\"\n)\n\nfunc main() {\n    var s string\n    fmt.Scan(&s)\n    index := strings.Index(s, \"a\")\n    fmt.Println(s[index:])\n}\n
word = input()\nprint(word[word.find(\"a\") :])\n
"},{"location":"solutions/#fizzbuzz","title":"FizzBuzz","text":"Solution in Python Python
x, y, n = [int(d) for d in input().split()]\nfor i in range(1, n + 1):\n    ans = \"\"\n    if not i % x:\n        ans += \"Fizz\"\n    if not i % y:\n        ans += \"Buzz\"\n    if not ans:\n        ans = i\n    print(ans)\n
"},{"location":"solutions/#flatbokuveisla","title":"Flatb\u00f6kuveisla","text":"Solutions in 2 languages LuaPython
m = io.read(\"*n\")\nn = io.read(\"*n\")\nprint(m % n)\n
n = int(input())\nm = int(input())\nprint(n - n // m * m)\n
"},{"location":"solutions/#flexible-spaces","title":"Flexible Spaces","text":"Solution in Python Python
w, p = [int(d) for d in input().split()]\nl = [int(d) for d in input().split()]\nl = [0] + l + [w]\nc = set()\nfor i in range(p + 1):\n    for j in range(i + 1, p + 2):\n        c.add(l[j] - l[i])\nprint(\" \".join([str(d) for d in sorted(c)]))\n
"},{"location":"solutions/#flytibaka","title":"Fl\u00fdtibaka","text":"Solutions in 11 languages C++GoHaskellJavaJuliaJavaScriptKotlinLuaPythonRubyRust
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    cout << \"\";\n    return 0;\n}\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n    fmt.Println(\"\")\n}\n
main = do\n    putStrLn \"\"\n
class Flytibaka {\n    public static void main(String[] args) {\n        System.out.println(\"\");\n    }\n}\n
print()\n
console.log(\"\");\n
fun main() {\n    println(\"\")\n}\n
print()\n
print()\n
puts \"\"\n
fn main() {\n    println!(\"\");\n}\n
"},{"location":"solutions/#birthday-memorization","title":"Birthday Memorization","text":"Solution in Python Python
n = int(input())\nrecords = {}\nfor _ in range(n):\n    s, c, date = input().split()\n    c = int(c)\n    date = \"\".join(date.split(\"/\")[::-1])\n    if date not in records:\n        records[date] = (s, c)\n    else:\n        _, _c = records[date]\n        if c > _c:\n            records[date] = (s, c)\nprint(len(records.keys()))\nordered_keys = sorted(records, key=lambda k: records[k][0])\nfor key in ordered_keys:\n    print(records[key][0])\n
"},{"location":"solutions/#forced-choice","title":"Forced Choice","text":"Solution in Python Python
_, p, s = input().split()\nfor _ in range(int(s)):\n    if p in input().split()[1:]:\n        print(\"KEEP\")\n    else:\n        print(\"REMOVE\")\n
"},{"location":"solutions/#free-food","title":"Free Food","text":"Solution in Python Python
n = int(input())\ndays = set()\nfor _ in range(n):\n    start, end = [int(d) for d in input().split()]\n    days.update(range(start, end + 1))\nprint(len(days))\n
"},{"location":"solutions/#from-a-to-b","title":"From A to B","text":"Solution in Python Python
a, b = [int(d) for d in input().split()]\n\nif a <= b:\n    print(b - a)\nelse:\n    total = 0\n    while a > b:\n        if a % 2:\n            a += 1\n            total += 1\n        a /= 2\n        total += 1\n    total += b - a\n    print(int(total))\n
"},{"location":"solutions/#fyi","title":"FYI","text":"Solutions in 3 languages GoPythonRuby
package main\n\nimport (\n    \"fmt\"\n    \"strings\"\n)\n\nfunc main() {\n    var s string\n    fmt.Scan(&s)\n    if strings.HasPrefix(s, \"555\") {\n        fmt.Println(1)\n    } else {\n        fmt.Println(0)\n    }\n}\n
if input().startswith(\"555\"):\n    print(1)\nelse:\n    print(0)\n
s = gets\nif s.start_with?(\"555\")\n    puts 1\nelse\n    puts 0\nend\n
"},{"location":"solutions/#gandalfs-spell","title":"Gandalf's Spell","text":"Solution in Python Python
c = list(input())\ns = input().split()\nif len(c) != len(s):\n    print(\"False\")\nelse:\n    d, valid = {}, True\n    for a, b in zip(c, s):\n        if a not in d:\n            d[a] = b\n        else:\n            if d[a] != b:\n                print(\"False\")\n                valid = False\n                break\n    if valid:\n        if len(set(d.keys())) == len(set(d.values())):\n            print(\"True\")\n        else:\n            print(\"False\")\n
"},{"location":"solutions/#gcd","title":"GCD","text":"Solution in Python Python
import math\n\na, b = [int(d) for d in input().split()]\n\nprint(math.gcd(a, b))\n
"},{"location":"solutions/#gcvwr","title":"GCVWR","text":"Solution in Python Python
g, t, n = [int(d) for d in input().split()]\ncapacity = (g - t) * 0.9\nitems = sum([int(d) for d in input().split()])\nprint(int(capacity - items))\n
"},{"location":"solutions/#gene-block","title":"Gene Block","text":"Solution in Python Python
mapping = {\n    1: 3,\n    2: 6,\n    3: 9,\n    4: 2,\n    5: 5,\n    6: 8,\n    7: 1,\n    8: 4,\n    9: 7,\n    0: 10,\n}\n\nfor _ in range(int(input())):\n    n = int(input())\n    d = n % 10\n\n    if n >= 7 * mapping[d]:\n        print(mapping[d])\n    else:\n        print(-1)\n
"},{"location":"solutions/#gerrymandering","title":"Gerrymandering","text":"Solution in Python Python
p, _ = [int(d) for d in input().split()]\nvotes = {}\nfor _ in range(p):\n    d, a, b = [int(d) for d in input().split()]\n    if d not in votes:\n        votes[d] = {\"A\": a, \"B\": b}\n    else:\n        votes[d][\"A\"] += a\n        votes[d][\"B\"] += b\n\ntotal_wa, total_wb = 0, 0\nfor d in sorted(votes):\n    total = votes[d][\"A\"] + votes[d][\"B\"]\n    t = total // 2 + 1\n    winner = \"A\" if votes[d][\"A\"] > votes[d][\"B\"] else \"B\"\n    wa = votes[d][\"A\"] - t if votes[d][\"A\"] > votes[d][\"B\"] else votes[d][\"A\"]\n    wb = votes[d][\"B\"] - t if votes[d][\"B\"] > votes[d][\"A\"] else votes[d][\"B\"]\n    print(winner, wa, wb)\n    total_wa += wa\n    total_wb += wb\nv = sum([sum(ab.values()) for ab in votes.values()])\nprint(abs(total_wa - total_wb) / v)\n
"},{"location":"solutions/#glasses-foggy-moms-spaghetti","title":"Glasses Foggy, Mom's Spaghetti","text":"Solution in Python Python
import math\n\nd, x, y, h = input().split()\nd = int(d)\nx = int(x)\ny = int(y)\nh = int(h)\n\nangle1 = (math.atan(y / x)) - (math.atan((y - h / 2) / x))\nangle2 = (math.atan((y + h / 2) / x)) - (math.atan(y / x))\n\nd1 = math.tan(angle1) * d\nd2 = math.tan(angle2) * d\n\nprint(d1 + d2)\n
"},{"location":"solutions/#goat-rope","title":"Goat Rope","text":"Solution in Python Python
x, y, x1, y1, x2, y2 = [int(d) for d in input().split()]\n\nif x >= x1 and x <= x2:\n    print(min(abs(y - y1), abs(y - y2)))\nelif y >= y1 and y <= y2:\n    print(min(abs(x - x1), abs(x - x2)))\nelse:\n    x3, y3 = x1, y2\n    x4, y4 = x2, y1\n    l = [\n        ((x - a) ** 2 + (y - b) ** 2) ** 0.5\n        for a, b in [(x1, y1), (x2, y2), (x1, y2), (x2, y1)]\n    ]\n    print(min(l))\n
"},{"location":"solutions/#goomba-stacks","title":"Goomba Stacks","text":"Solution in Python Python
n = int(input())\ntotal = 0\nresult = True\nfor _ in range(n):\n    g, b = [int(d) for d in input().split()]\n    total += g\n    if total < b:\n        result = False\nprint(\"possible\" if result else \"impossible\")\n
"},{"location":"solutions/#grading","title":"Grading","text":"Solution in Python Python
line = input()\nscore = int(input())\na, b, c, d, e = [int(d) for d in line.split()]\nif score >= a:\n    print(\"A\")\nelif score >= b:\n    print(\"B\")\nelif score >= c:\n    print(\"C\")\nelif score >= d:\n    print(\"D\")\nelif score >= e:\n    print(\"E\")\nelse:\n    print(\"F\")\n
"},{"location":"solutions/#grass-seed-inc","title":"Grass Seed Inc.","text":"Solution in Python Python
c = float(input())\ntotal = 0\nfor _ in range(int(input())):\n    w, l = [float(d) for d in input().split()]\n    total += c * w * l\nprint(f\"{total:.7f}\")\n
"},{"location":"solutions/#greedily-increasing-subsequence","title":"Greedily Increasing Subsequence","text":"Solution in Python Python
n = int(input())\na = [int(d) for d in input().split()]\n\ng = [a[0]]\nfor i in range(1, n):\n    v = a[i]\n    if v > g[-1]:\n        g.append(v)\nprint(len(g))\nprint(\" \".join([str(d) for d in g]))\n
"},{"location":"solutions/#greedy-polygons","title":"Greedy Polygons","text":"Solution in Python Python
import math\n\nfor _ in range(int(input())):\n    n, l, d, g = [int(d) for d in input().split()]\n    a = n * l * l / (4 * math.tan(math.pi / n))\n    a += n * l * d * g\n    a += math.pi * ((d * g) ** 2)\n    print(a)\n
"},{"location":"solutions/#greetings","title":"Greetings!","text":"Solution in Python Python
print(input().replace(\"e\", \"ee\"))\n
"},{"location":"solutions/#guess-the-number","title":"Guess the Number","text":"Solution in Python Python
start, end = 1, 1000\nwhile True:\n    guess = (start + end) // 2\n    print(guess)\n    resp = input()\n    if resp == \"correct\":\n        break\n    elif resp == \"higher\":\n        start = guess + 1\n    else:\n        end = guess\n
"},{"location":"solutions/#guess-who","title":"Guess Who","text":"Solution in Python Python
n, m, q = [int(d) for d in input().split()]\nM = []\nfor _ in range(n):\n    M.append(input())\nQ = []\nfor _ in range(q):\n    Q.append(input().split())\nans = [all([c[int(i) - 1] == v for i, v in Q]) for c in M]\nif sum(ans) > 1:\n    print(\"ambiguous\")\n    print(sum(ans))\nelse:\n    print(\"unique\")\n    print(ans.index(True) + 1)\n
"},{"location":"solutions/#watch-out-for-those-hailstones","title":"Watch Out For Those Hailstones!","text":"Solutions in 2 languages GoPython
package main\n\nimport (\n    \"fmt\"\n)\n\nfunc h(n int) int {\n    if n == 1 {\n        return 1\n    } else if n%2 == 0 {\n        return n + h(n/2)\n    } else {\n        return n + h(3*n+1)\n    }\n}\n\nfunc main() {\n    var n int\n    fmt.Scan(&n)\n    fmt.Println(h(n))\n}\n
def h(n):\n    if n == 1:\n        return 1\n    else:\n        return n + (h(n // 2) if n % 2 == 0 else h(3 * n + 1))\n\n\nn = int(input())\nprint(h(n))\n
"},{"location":"solutions/#hailstone-sequences","title":"Hailstone Sequences","text":"Solution in Python Python
n = int(input())\ns = [n]\nwhile True:\n    v = s[-1]\n    if v == 1:\n        break\n    elif v % 2 == 0:\n        s.append(v // 2)\n    else:\n        s.append(3 * v + 1)\nprint(len(s))\n
"},{"location":"solutions/#half-a-cookie","title":"Half a Cookie","text":"Solution in Python Python
import math\n\nwhile True:\n    try:\n        r, x, y = [float(d) for d in input().split()]\n    except:\n        break\n    if x**2 + y**2 >= r**2:\n        print(\"miss\")\n    else:\n        # https://mathworld.wolfram.com/CircularSegment.html\n        d = math.sqrt(x**2 + y**2)\n        h = r - d\n        a = math.acos((r - h) / r)\n        t = (r - h) * math.sqrt(2 * r * h - h * h)\n        p = (r**2) * a\n        s = p - t\n        print(math.pi * (r**2) - s, s)\n
"},{"location":"solutions/#hanging-out-on-the-terrace","title":"Hanging Out on the Terrace","text":"Solution in Python Python
l, x = [int(d) for d in input().split()]\no, r = 0, 0\nfor _ in range(x):\n    action, n = input().split()\n    n = int(n)\n    if action == \"leave\":\n        o -= n\n    elif action == \"enter\":\n        if o + n > l:\n            r += 1\n        else:\n            o += n\nprint(r)\n
"},{"location":"solutions/#hangman","title":"Hangman","text":"Solution in Python Python
word = set(list(input()))\nguess = input()\ntries = 0\ncorrect = 0\nfor c in guess:\n    if c in word:\n        correct += 1\n    else:\n        tries += 1\n\n    if correct == len(word):\n        break\n\nif tries >= 10:\n    print(\"LOSE\")\nelse:\n    print(\"WIN\")\n
"},{"location":"solutions/#harshad-numbers","title":"Harshad Numbers","text":"Solution in Python Python
n = int(input())\nwhile True:\n    sd = sum([int(d) for d in str(n)])\n    if not n % sd:\n        break\n    n += 1\nprint(n)\n
"},{"location":"solutions/#haughty-cuisine","title":"Haughty Cuisine","text":"Solution in Python Python
from random import randint\n\nn = int(input())\nmenu = []\nfor _ in range(n):\n    menu.append(input().split())\n\nprint(\"\\n\".join(menu[randint(0, n - 1)]))\n
"},{"location":"solutions/#head-guard","title":"Head Guard","text":"Solution in Python Python
while True:\n    try:\n        s = input()\n    except:\n        break\n    parts = []\n    prev, t = s[0], 1\n    for c in s[1:]:\n        if c != prev:\n            parts.append((prev, t))\n            t = 1\n            prev = c\n        else:\n            t += 1\n    parts.append((prev, t))\n    print(\"\".join([f\"{v}{k}\" for k, v in parts]))\n
"},{"location":"solutions/#heart-rate","title":"Heart Rate","text":"Solution in Python Python
for _ in range(int(input())):\n    b, p = [float(d) for d in input().split()]\n    min_abpm = 60 / p * (b - 1)\n    bpm = 60 * b / p\n    max_abpm = 60 / p * (b + 1)\n    print(f\"{min_abpm:.4f} {bpm:.4f} {max_abpm:.4f}\")\n
"},{"location":"solutions/#homework","title":"Homework","text":"Solution in Python Python
total = 0\nparts = input().split(\";\")\nfor part in parts:\n    ranges = part.split(\"-\")\n    if len(ranges) == 1:\n        total += 1\n    else:\n        total += len(range(int(ranges[0]), int(ranges[1]))) + 1\nprint(total)\n
"},{"location":"solutions/#heirs-dilemma","title":"Heir's Dilemma","text":"Solution in Python Python
l, h = [int(d) for d in input().split()]\ntotal = 0\nfor i in range(l, h + 1):\n    digits = set(str(i))\n    if len(digits) != 6 or \"0\" in digits:\n        continue\n    if not all([i % int(d) == 0 for d in digits]):\n        continue\n    total += 1\nprint(total)\n
"},{"location":"solutions/#heliocentric","title":"Heliocentric","text":"Solution in Python Python
def offset(d, b):\n    return (b - d % b) % b\n\n\ncc = 1\nwhile True:\n    try:\n        a, b = [int(d) for d in input().split()]\n    except:\n        break\n\n    offset_a, offset_b = offset(a, 365), offset(b, 687)\n\n    if offset_a == offset_b:\n        print(f\"Case {cc}:\", offset_a)\n    else:\n        t = offset_a\n        while True:\n            t += 365\n            if (offset(t, 687) + offset_b) % 687 == 0:\n                break\n        print(f\"Case {cc}:\", t)\n\n    cc += 1\n
"},{"location":"solutions/#hello-world","title":"Hello World!","text":"Solutions in 11 languages C++GoHaskellJavaJuliaJavaScriptKotlinLuaPythonRubyRust
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    cout << \"Hello World!\" << endl;\n\n    return 0;\n}\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n    fmt.Println(\"Hello World!\")\n}\n
main = putStrLn \"Hello World!\"\n
class HelloWorld {\n    public static void main(String[] args) {\n        System.out.println(\"Hello World!\");\n    }\n}\n
print(\"Hello World!\")\n
console.log(\"Hello World!\");\n
fun main() {\n    println(\"Hello World!\")\n}\n
print(\"Hello World!\")\n
print(\"Hello World!\")\n
puts \"Hello World!\"\n
fn main() {\n    println!(\"Hello World!\");\n}\n
"},{"location":"solutions/#help-a-phd-candidate-out","title":"Help a PhD candidate out!","text":"Solution in Python Python
n = int(input())\nfor _ in range(n):\n    line = input()\n    parts = line.split(\"+\")\n    if len(parts) == 1:\n        print(\"skipped\")\n    else:\n        print(int(parts[0]) + int(parts[1]))\n
"},{"location":"solutions/#herman","title":"Herman","text":"Solution in Python Python
import math\n\nr = int(input())\nprint(f\"{math.pi*r*r:.6f}\")\nprint(2 * r * r)\n
"},{"location":"solutions/#heroes-of-velmar","title":"Heroes of Velmar","text":"Solution in Python Python
m = {\n    \"Shadow\": 6,\n    \"Gale\": 5,\n    \"Ranger\": 4,\n    \"Anvil\": 7,\n    \"Vexia\": 3,\n    \"Guardian\": 8,\n    \"Thunderheart\": 6,\n    \"Frostwhisper\": 2,\n    \"Voidclaw\": 3,\n    \"Ironwood\": 3,\n    \"Zenith\": 4,\n    \"Seraphina\": 1,\n}\n\n\ndef calculate(heros, location):\n    boost = 0\n\n    if \"Seraphina\" in heros:\n        boost += heros.count(\"Seraphina\") * (len(heros) - 1)\n\n    if location == \"center\":\n        boost += heros.count(\"Zenith\") * 5\n\n    if len(heros) == 4:\n        boost += m[\"Thunderheart\"] * heros.count(\"Thunderheart\")\n\n    return sum([m[h] for h in heros]) + boost\n\n\nl1 = calculate(input().split()[1:], \"left\")\nl2 = calculate(input().split()[1:], \"left\")\nc1 = calculate(input().split()[1:], \"center\")\nc2 = calculate(input().split()[1:], \"center\")\nr1 = calculate(input().split()[1:], \"right\")\nr2 = calculate(input().split()[1:], \"right\")\n\ns1, s2 = 0, 0\n\nif l1 > l2:\n    s1 += 1\nelif l1 < l2:\n    s2 += 1\n\nif c1 > c2:\n    s1 += 1\nelif c1 < c2:\n    s2 += 1\n\nif r1 > r2:\n    s1 += 1\nelif r1 < r2:\n    s2 += 1\n\nif s1 > s2:\n    print(\"Player 1\")\nelif s1 < s2:\n    print(\"Player 2\")\nelse:\n    if l1 + c1 + r1 > l2 + c2 + r2:\n        print(\"Player 1\")\n    elif l1 + c1 + r1 < l2 + c2 + r2:\n        print(\"Player 2\")\n    else:\n        print(\"Tie\")\n
"},{"location":"solutions/#hissing-microphone","title":"Hissing Microphone","text":"Solutions in 3 languages C++JavaScriptPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    string a;\n    cin >> a;\n\n    if (a.find(\"ss\") == -1)\n    {\n        cout << \"no hiss\" << endl;\n    }\n    else\n    {\n        cout << \"hiss\" << endl;\n    }\n\n    return 0;\n}\n
const readline = require(\"readline\");\nconst rl = readline.createInterface(process.stdin, process.stdout);\n\nrl.question(\"\", (line) => {\n  if (line.includes(\"ss\")) {\n    console.log(\"hiss\");\n  } else {\n    console.log(\"no hiss\");\n  }\n});\n
a = input()\nif \"ss\" in a:\n    print(\"hiss\")\nelse:\n    print(\"no hiss\")\n
"},{"location":"solutions/#hitting-the-targets","title":"Hitting the Targets","text":"Solution in Python Python
def in_rectangle(x1, y1, x2, y2, x, y):\n    x1, x2 = min(x1, x2), max(x1, x2)\n    y1, y2 = min(y1, y2), max(y1, y2)\n    if x in range(x1, x2 + 1) and y in range(y1, y2 + 1):\n        return True\n    else:\n        return False\n\n\ndef in_circle(x0, y0, r, x, y):\n    return (x0 - x) ** 2 + (y0 - y) ** 2 <= r**2\n\n\nm = int(input())\nshapes = []\nfor _ in range(m):\n    values = input().split()\n    shapes.append((values[0], *[int(d) for d in values[1:]]))\n\nn = int(input())\nfor _ in range(n):\n    total = 0\n    x, y = [int(d) for d in input().split()]\n    for shape in shapes:\n        if shape[0] == \"rectangle\":\n            total += in_rectangle(*shape[1:], x, y)\n        elif shape[0] == \"circle\":\n            total += in_circle(*shape[1:], x, y)\n    print(total)\n
"},{"location":"solutions/#hot-hike","title":"Hot Hike","text":"Solution in Python Python
n = int(input())\nt = [int(d) for d in input().split()]\norder = sorted(range(n - 2), key=lambda k: max(t[k], t[k + 2]))\nd = order[0]\nv = max(t[d], t[d + 2])\nprint(d + 1, v)\n
"},{"location":"solutions/#hragreining","title":"Hra\u00f0greining","text":"Solutions in 2 languages GoPython
package main\n\nimport (\n    \"fmt\"\n    \"strings\"\n)\n\nfunc main() {\n    var s string\n    fmt.Scan(&s)\n    if strings.Contains(s, \"COV\") {\n        fmt.Println(\"Veikur!\")\n    } else {\n        fmt.Println(\"Ekki veikur!\")\n    }\n}\n
print(\"Veikur!\" if \"COV\" in input() else \"Ekki veikur!\")\n
"},{"location":"solutions/#the-amazing-human-cannonball","title":"The Amazing Human Cannonball","text":"Solution in Python Python
import math\n\nfor _ in range(int(input())):\n    v0, a, x1, h1, h2 = [float(d) for d in input().split()]\n    a = math.radians(a)\n    t = x1 / (v0 * math.cos(a))\n    y = v0 * t * math.sin(a) - 0.5 * 9.81 * (t**2)\n    if y < h1 + 1 or y > h2 - 1:\n        print(\"Not Safe\")\n    else:\n        print(\"Safe\")\n
"},{"location":"solutions/#hvert-skal-mta","title":"Hvert Skal M\u00e6ta?","text":"Solution in Python Python
mapping = {\n    \"Reykjavik\": \"Reykjavik\",\n    \"Kopavogur\": \"Reykjavik\",\n    \"Hafnarfjordur\": \"Reykjavik\",\n    \"Reykjanesbaer\": \"Reykjavik\",\n    \"Akureyri\": \"Akureyri\",\n    \"Gardabaer\": \"Reykjavik\",\n    \"Mosfellsbaer\": \"Reykjavik\",\n    \"Arborg\": \"Reykjavik\",\n    \"Akranes\": \"Reykjavik\",\n    \"Fjardabyggd\": \"Akureyri\",\n    \"Mulathing\": \"Akureyri\",\n    \"Seltjarnarnes\": \"Reykjavik\",\n}\nprint(mapping[input()])\n
"},{"location":"solutions/#icpc-awards","title":"ICPC Awards","text":"Solution in Python Python
n = int(input())\nshown = {}\nfor _ in range(n):\n    u, t = input().split()\n    if u not in shown and len(shown.keys()) < 12:\n        print(u, t)\n        shown[u] = True\n
"},{"location":"solutions/#illuminati-spotti","title":"Illuminati Spotti","text":"Solution in Python Python
n = int(input())\nm = []\nfor _ in range(n):\n    m.append(input().split())\ntotal = 0\nfor i in range(1, n - 1):\n    for j in range(i):\n        for k in range(i + 1, n):\n            if m[i][j] == m[k][j] == m[k][i] == \"1\":\n                total += 1\nprint(total)\n
"},{"location":"solutions/#inheritance","title":"Inheritance","text":"Solution in Python Python
from itertools import product\n\np = input()\nans = []\nfor i in range(len(p)):\n    for t in product(\"24\", repeat=i + 1):\n        if int(p) % int(\"\".join(t)) == 0:\n            ans.append(int(\"\".join(t)))\nprint(\"\\n\".join([str(d) for d in sorted(ans)]))\n
"},{"location":"solutions/#international-dates","title":"International Dates","text":"Solution in Python Python
aa, bb, _ = [int(d) for d in input().split(\"/\")]\n\nif aa > 12 and bb <= 12:\n    print(\"EU\")\nelif aa <= 12 and bb > 12:\n    print(\"US\")\nelse:\n    print(\"either\")\n
"},{"location":"solutions/#i-repeat-myself-i-repeat-myself-i-repeat","title":"I Repeat Myself I Repeat Myself I Repeat","text":"Solution in Python Python
import math\n\nfor _ in range(int(input())):\n    s = input()\n    for n in range(1, len(s) + 1):\n        if (s[:n] * math.ceil(len(s) / n)).startswith(s):\n            print(n)\n            break\n
"},{"location":"solutions/#is-it-even","title":"Is It Even?","text":"Solution in Python Python
n, k = [int(d) for d in input().split()]\n\nfor _ in range(n):\n    x = int(input())\n    while True:\n        if x % 2 == 0:\n            x //= 2\n            k -= 1\n        else:\n            break\n    if k <= 0:\n        break\n\nprint(0 if k > 0 else 1)\n
"},{"location":"solutions/#isithalloweencom","title":"IsItHalloween.com","text":"Solutions in 2 languages GoPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var m, d string\n    fmt.Scan(&m)\n    fmt.Scan(&d)\n    if (m == \"OCT\" && d == \"31\") || (m == \"DEC\" && d == \"25\") {\n        fmt.Println(\"yup\")\n    } else {\n        fmt.Println(\"nope\")\n    }\n}\n
m, d = input().split()\nif (m == \"OCT\" and d == \"31\") or (m == \"DEC\" and d == \"25\"):\n    print(\"yup\")\nelse:\n    print(\"nope\")\n
"},{"location":"solutions/#jabuke","title":"Jabuke","text":"Solution in Python Python
xa, ya = [int(d) for d in input().split()]\nxb, yb = [int(d) for d in input().split()]\nxc, yc = [int(d) for d in input().split()]\nn = int(input())\narea = abs(xa * (yb - yc) + xb * (yc - ya) + xc * (ya - yb)) / 2\nprint(f\"{area:.1f}\")\n\n\ndef sign(x1, y1, x2, y2, x3, y3):\n    return (x1 - x3) * (y2 - y3) - (x2 - x3) * (y1 - y3)\n\n\ndef in_triangle(x, y, x1, y1, x2, y2, x3, y3):\n    d1 = sign(x, y, x1, y1, x2, y2)\n    d2 = sign(x, y, x2, y2, x3, y3)\n    d3 = sign(x, y, x3, y3, x1, y1)\n\n    has_neg = d1 < 0 or d2 < 0 or d3 < 0\n    has_pos = d1 > 0 or d2 > 0 or d3 > 0\n\n    return not (has_neg and has_pos)\n\n\ntotal = 0\nfor _ in range(n):\n    x, y = [int(d) for d in input().split()]\n    if in_triangle(x, y, xa, ya, xb, yb, xc, yc):\n        total += 1\nprint(total)\n
"},{"location":"solutions/#jack-o-lantern-juxtaposition","title":"Jack-O'-Lantern Juxtaposition","text":"Solution in Python Python
numbers = [int(n) for n in input().split()]\nresult = 1\nfor n in numbers:\n    result *= n\nprint(result)\n
"},{"location":"solutions/#janitor-troubles","title":"Janitor Troubles","text":"Solution in Python Python
import math\n\na, b, c, d = [int(d) for d in input().split()]\ns = (a + b + c + d) / 2\nprint(math.sqrt((s - a) * (s - b) * (s - c) * (s - d)))\n
"},{"location":"solutions/#jewelry-box","title":"Jewelry Box","text":"Solution in Python Python
def f(h):\n    a = x - 2 * h\n    b = y - 2 * h\n    return a * b * h\n\n\nfor _ in range(int(input())):\n    x, y = [int(d) for d in input().split()]\n    h = (x + y - ((x + y) ** 2 - 3 * x * y) ** 0.5) / 6\n    print(f\"{f(h):.11f}\")\n
"},{"location":"solutions/#job-expenses","title":"Job Expenses","text":"Solution in Python Python
_ = input()\nprint(-sum([int(d) for d in input().split() if \"-\" in d]))\n
"},{"location":"solutions/#joint-jog-jam","title":"Joint Jog Jam","text":"Solution in Python Python
import math\n\n\ndef dist(x1, y1, x2, y2):\n    return math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)\n\n\ncoords = [int(d) for d in input().split()]\nprint(max(dist(*coords[:4]), dist(*coords[4:])))\n
"},{"location":"solutions/#judging-moose","title":"Judging Moose","text":"Solutions in 2 languages GoPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var l, r int\n    fmt.Scan(&l)\n    fmt.Scan(&r)\n    if l == 0 && r == 0 {\n        fmt.Println(\"Not a moose\")\n    } else {\n        p := 2 * l\n        if r > l {\n            p = 2 * r\n        }\n        t := \"Odd\"\n        if l == r {\n            t = \"Even\"\n        }\n        fmt.Println(t, p)\n    }\n}\n
l, r = [int(d) for d in input().split()]\nif not l and not r:\n    print(\"Not a moose\")\nelse:\n    p = 2 * max(l, r)\n    print(\"Odd\" if l != r else \"Even\", p)\n
"},{"location":"solutions/#jumbo-javelin","title":"Jumbo Javelin","text":"Solution in Python Python
n = int(input())\nlength = 0\nfor _ in range(n):\n    length += int(input())\nlength -= n - 1\nprint(length)\n
"},{"location":"solutions/#just-a-minute","title":"Just a Minute","text":"Solution in Python Python
a, b = [], []\nfor _ in range(int(input())):\n    x, y = [int(d) for d in input().split()]\n    a.append(x * 60)\n    b.append(y)\nans = sum(b) / sum(a)\nif ans <= 1:\n    ans = \"measurement error\"\nprint(ans)\n
"},{"location":"solutions/#running-race","title":"Running Race","text":"Solution in Python Python
l, k, _ = [int(d) for d in input().split()]\n\nrecord = {}\nfor _ in range(l):\n    i, t = input().split()\n    mm, ss = [int(d) for d in t.split(\".\")]\n    s = mm * 60 + ss\n    if i in record:\n        record[i].append(s)\n    else:\n        record[i] = [s]\n\ndelete = [i for i in record if len(record[i]) != k]\nfor i in delete:\n    record.pop(i)\n\nsorted_i = sorted(record, key=lambda i: (sum(record[i]), int(i)))\nprint(\"\\n\".join(sorted_i))\n
"},{"location":"solutions/#karte","title":"Karte","text":"Solution in Python Python
from collections import Counter\n\ns = input()\ncards = {\n    \"P\": Counter(),\n    \"K\": Counter(),\n    \"H\": Counter(),\n    \"T\": Counter(),\n}\nduplicated = False\nfor i in range(0, len(s), 3):\n    suit = s[i]\n    card = s[i + 1 : i + 3]\n    if cards[suit][card]:\n        duplicated = True\n        break\n    cards[suit][card] += 1\n\nif not duplicated:\n    print(\" \".join([str(13 - len(c)) for c in cards.values()]))\nelse:\n    print(\"GRESKA\")\n
"},{"location":"solutions/#kemija","title":"Kemija","text":"Solutions in 2 languages JavaScriptPython
const readline = require(\"readline\");\nconst rl = readline.createInterface(process.stdin, process.stdout);\n\nrl.question(\"\", (line) => {\n  for (let c of \"aeiou\") {\n    const regex = new RegExp(`${c}p${c}`, \"g\");\n    line = line.replace(regex, c);\n  }\n  console.log(line);\n});\n
s = input()\n\nfor c in \"aeiou\":\n    s = s.replace(f\"{c}p{c}\", c)\n\nprint(s)\n
"},{"location":"solutions/#the-key-to-cryptography","title":"The Key to Cryptography","text":"Solution in Python Python
import string\n\nuppers = string.ascii_uppercase\n\n\ndef decrypt(c, k):\n    index = (uppers.index(c) - uppers.index(k)) % 26\n    return uppers[index]\n\n\nm, w = input(), input()\n\nsize_w = len(w)\nsize_m = len(m)\no = []\nfor i in range(0, size_m, size_w):\n    if i + size_w < size_m:\n        l = zip(m[i : i + size_w], w)\n    else:\n        l = zip(m[i:], w)\n    t = \"\".join([decrypt(c, k) for c, k in l])\n    o.append(t)\n    w = t\nprint(\"\".join(o))\n
"},{"location":"solutions/#keywords","title":"Keywords","text":"Solution in Python Python
keywords = set()\nfor _ in range(int(input())):\n    keywords.add(input().lower().replace(\"-\", \" \"))\nprint(len(keywords))\n
"},{"location":"solutions/#kitten-on-a-tree","title":"Kitten on a Tree","text":"Solution in Python Python
k = input()\nb = []\nwhile True:\n    line = input()\n    if line == \"-1\":\n        break\n    b.append(line.split())\n\np = [k]\nt = k\nwhile True:\n    found = False\n    for row in b:\n        if t in row[1:]:\n            p.append(row[0])\n            found = True\n            t = row[0]\n            break\n    if not found:\n        break\n\nprint(\" \".join(p))\n
"},{"location":"solutions/#kleptography","title":"Kleptography","text":"Solution in Python Python
from string import ascii_lowercase as l\n\n\nn, m = [int(d) for d in input().split()]\np = input()\nc = input()\np = p[::-1]\nc = c[::-1]\n\nans = \"\"\nfor i in range(0, m, n):\n    if i + n < m:\n        part = c[i : i + n]\n    else:\n        part = c[i:]\n\n    ans += p\n    p = \"\".join([l[(l.index(a) - l.index(b)) % 26] for a, b in zip(part, p)])\n\nans += p\nprint(ans[::-1][n:])\n
"},{"location":"solutions/#knight-packing","title":"Knight Packing","text":"Solution in Python Python
if int(input()) % 2:\n    print(\"first\")\nelse:\n    print(\"second\")\n
"},{"location":"solutions/#knot-knowledge","title":"Knot Knowledge","text":"Solution in Python Python
input()\ntotal = set(input().split())\nknown = set(input().split())\nprint((total - known).pop())\n
"},{"location":"solutions/#kornislav","title":"Kornislav","text":"Solution in Python Python
numbers = sorted([int(d) for d in input().split()])\nprint(numbers[0] * numbers[2])\n
"},{"location":"solutions/#krizaljka","title":"Kri\u017ealjka","text":"Solution in Python Python
a, b = input().split()\nfor i in range(len(a)):\n    if a[i] in b:\n        j = b.index(a[i])\n        break\n\nrows = []\n\nfor k in range(j):\n    rows.append(\".\" * i + b[k] + \".\" * (len(a) - i - 1))\n\nrows.append(a)\n\nfor k in range(j + 1, len(b)):\n    rows.append(\".\" * i + b[k] + \".\" * (len(a) - i - 1))\n\nprint(\"\\n\".join(rows))\n
"},{"location":"solutions/#ladder","title":"Ladder","text":"Solution in Python Python
import math\n\nh, v = [int(d) for d in input().split()]\nprint(math.ceil(h / math.sin(math.radians(v))))\n
"},{"location":"solutions/#lamps","title":"Lamps","text":"Solution in Python Python
h, p = [int(d) for d in input().split()]\n\ndays = 0\ncost_bulb, cost_lamp = 5, 60\nused_bulb, used_lamp = 0, 0\n\nwhile True:\n    days += 1\n    cost_bulb += 60 * h * p / 100000\n    cost_lamp += 11 * h * p / 100000\n    used_bulb += h\n    used_lamp += h\n\n    if used_bulb > 1000:\n        cost_bulb += 5\n        used_bulb -= 1000\n\n    if used_lamp > 8000:\n        cost_lamp += 60\n        used_lamp -= 8000\n\n    if cost_bulb > cost_lamp:\n        break\n\nprint(days)\n
"},{"location":"solutions/#laptop-sticker","title":"Laptop Sticker","text":"Solutions in 3 languages C++GoPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int wc, hc, ws, hs;\n    cin >> wc >> hc >> ws >> hs;\n    if (wc - 2 >= ws && hc - 2 >= hs)\n    {\n        cout << 1 << endl;\n    }\n    else\n    {\n        cout << 0 << endl;\n    }\n    return 0;\n}\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var wc, hc, ws, hs int\n    fmt.Scan(&wc)\n    fmt.Scan(&hc)\n    fmt.Scan(&ws)\n    fmt.Scan(&hs)\n    if wc-2 >= ws && hc-2 >= hs {\n\n        fmt.Println(1)\n\n    } else {\n\n        fmt.Println(0)\n\n    }\n}\n
wc, hc, ws, hs = [int(d) for d in input().split()]\nif wc - 2 >= ws and hc - 2 >= hs:\n    print(1)\nelse:\n    print(0)\n
"},{"location":"solutions/#last-factorial-digit","title":"Last Factorial Digit","text":"Solution in Python Python
for _ in range(int(input())):\n    n = int(input())\n    number = 1\n    for i in range(1, n + 1):\n        number *= i\n    print(number % 10)\n
"},{"location":"solutions/#left-beehind","title":"Left Beehind","text":"Solutions in 3 languages GoJavaPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var x, y int\n    for true {\n        fmt.Scan(&x)\n        fmt.Scan(&y)\n        if x == 0 && y == 0 {\n            break\n        }\n        if x+y == 13 {\n            fmt.Println(\"Never speak again.\")\n        } else if x > y {\n            fmt.Println(\"To the convention.\")\n        } else if x == y {\n            fmt.Println(\"Undecided.\")\n        } else {\n            fmt.Println(\"Left beehind.\")\n        }\n    }\n}\n
import java.util.Scanner;\n\nclass LeftBeehind {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        while (true) {\n            int x = s.nextInt();\n            int y = s.nextInt();\n            if (x == 0 && y == 0) {\n                break;\n            }\n            if (x + y == 13) {\n                System.out.println(\"Never speak again.\");\n            } else if (x > y) {\n                System.out.println(\"To the convention.\");\n            } else if (x == y) {\n                System.out.println(\"Undecided.\");\n            } else {\n                System.out.println(\"Left beehind.\");\n            }\n        }\n    }\n}\n
while True:\n    x, y = [int(d) for d in input().split()]\n    if not x and not y:\n        break\n    if x + y == 13:\n        print(\"Never speak again.\")\n    elif x > y:\n        print(\"To the convention.\")\n    elif x == y:\n        print(\"Undecided.\")\n    else:\n        print(\"Left beehind.\")\n
"},{"location":"solutions/#leggja-saman","title":"Leggja saman","text":"Solutions in 2 languages GoPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var n, m int\n    fmt.Scan(&n)\n    fmt.Scan(&m)\n    fmt.Println(n + m)\n}\n
m = int(input())\nn = int(input())\nprint(m + n)\n
"},{"location":"solutions/#license-to-launch","title":"License to Launch","text":"Solution in Python Python
_ = input()\njunks = [int(d) for d in input().split()]\nprint(junks.index(min(junks)))\n
"},{"location":"solutions/#line-them-up","title":"Line Them Up","text":"Solution in Python Python
n = int(input())\nnames = []\nfor _ in range(n):\n    names.append(input())\norder = []\nfor i in range(1, n):\n    order.append(names[i] > names[i - 1])\nif all(order):\n    print(\"INCREASING\")\nelif not any(order):\n    print(\"DECREASING\")\nelse:\n    print(\"NEITHER\")\n
"},{"location":"solutions/#a-list-game","title":"A List Game","text":"Solution in Python Python
import math\n\nx = int(input())\n\np = 1\ntotal = 0\n\nwhile x % 2 == 0:\n    p = 2\n    x /= 2\n    total += 1\n\n\nfor i in range(3, math.ceil(math.sqrt(x)) + 1, 2):\n    while x % i == 0:\n        p = i\n        x /= i\n        total += 1\nif x > 1:\n    total += 1\n\n\nif p == 1:\n    total = 1\n\n\nprint(total)\n
"},{"location":"solutions/#locust-locus","title":"Locust Locus","text":"Solution in Python Python
from math import gcd\n\nn = int(input())\nl = []\nfor _ in range(n):\n    y, c1, c2 = [int(d) for d in input().split()]\n    g = gcd(c1, c2)\n    l.append(y + g * (c1 // g) * (c2 // g))\nprint(min(l))\n
"},{"location":"solutions/#logic-functions","title":"Logic Functions","text":"Solution in C++ C++
#include \"logicfunctions.h\"\n\n// Compute xor\nvoid exclusive(bool x, bool y, bool &ans)\n{\n    ans = x != y;\n}\n\n// Compute implication\nvoid implies(bool x, bool y, bool &ans)\n{\n    if (x && !y)\n    {\n        ans = false;\n    }\n    else\n    {\n        ans = true;\n    }\n}\n\n// Compute equivalence\nvoid equivalence(bool x, bool y, bool &ans)\n{\n    ans = x == y;\n}\n
"},{"location":"solutions/#lost-lineup","title":"Lost Lineup","text":"Solution in Python Python
n = int(input())\norder = [int(d) for d in input().split()]\nd = range(1, n)\norder = dict(zip(d, order))\nranges = range(1, n + 1)\nresult = [\"1\"]\nfor k in sorted(order, key=lambda x: order[x]):\n    result.append(str(ranges[k]))\nprint(\" \".join(result))\n
"},{"location":"solutions/#luhns-checksum-algorithm","title":"Luhn's Checksum Algorithm","text":"Solution in Python Python
for _ in range(int(input())):\n    n = input()[::-1]\n    checksum = 0\n    for i in range(len(n)):\n        s = int(n[i]) * (i % 2 + 1)\n        if s > 9:\n            s = sum([int(d) for d in str(s)])\n        checksum += s\n\n    print(\"FAIL\" if checksum % 10 else \"PASS\")\n
"},{"location":"solutions/#magic-trick","title":"Magic Trick","text":"Solution in Python Python
s = input()\ncounter = {}\nguess = 1\nfor c in s:\n    if c in counter:\n        guess = 0\n        break\n    else:\n        counter[c] = None\nprint(guess)\n
"},{"location":"solutions/#making-a-meowth","title":"Making A Meowth","text":"Solution in Python Python
n, p, x, y = [int(d) for d in input().split()]\nprint(p * x + p // (n - 1) * y)\n
"},{"location":"solutions/#identifying-map-tiles","title":"Identifying Map Tiles","text":"Solutions in 2 languages GoPython
package main\n\nimport (\n    \"fmt\"\n    \"math\"\n)\n\nfunc main() {\n    var s string\n    fmt.Scanln(&s)\n    zoom := len(s)\n    var x, y float64\n    for i := 0; i < zoom; i++ {\n        d := math.Pow(2, float64(zoom)-float64(i)-1)\n        if s[i] == '1' {\n            x += d\n        } else if s[i] == '2' {\n            y += d\n        } else if s[i] == '3' {\n            x += d\n            y += d\n        }\n    }\n    fmt.Printf(\"%d %d %d\", zoom, int64(x), int64(y))\n}\n
s = input()\nx, y = 0, 0\nzoom = len(s)\nfor i in range(len(s)):\n    d = 2 ** (zoom - i - 1)\n    if s[i] == \"1\":\n        x += d\n    elif s[i] == \"2\":\n        y += d\n    elif s[i] == \"3\":\n        x += d\n        y += d\nprint(f\"{zoom} {x} {y}\")\n
"},{"location":"solutions/#marko","title":"Marko","text":"Solution in Python Python
mapping = {\n    \"2\": \"abc\",\n    \"3\": \"def\",\n    \"4\": \"ghi\",\n    \"5\": \"jkl\",\n    \"6\": \"mno\",\n    \"7\": \"pqrs\",\n    \"8\": \"tuv\",\n    \"9\": \"wxyz\",\n}\nn = []\nfor _ in range(int(input())):\n    w = input()\n    t = \"\"\n    for c in w:\n        for d, r in mapping.items():\n            if c in r:\n                t += d\n                break\n    n.append(t)\n\nd = input()\nprint(sum([d == t for t in n]))\n
"},{"location":"solutions/#mars-window","title":"Mars Window","text":"Solution in Python Python
y = int(input())\nprint(\"YES\" if 26 - ((y - 2018) * 12 - 4) % 26 <= 12 else \"NO\")\n
"},{"location":"solutions/#math-homework","title":"Math Homework","text":"Solution in Python Python
b, d, c, l = [int(d) for d in input().split()]\nsolved = False\nfor i in range(l // b + 1):\n    for j in range((l - b * i) // d + 1):\n        for k in range((l - b * i - d * j) // c + 1):\n            if b * i + d * j + c * k == l:\n                print(i, j, k)\n                solved = True\nif not solved:\n    print(\"impossible\")\n
"},{"location":"solutions/#mean-words","title":"Mean Words","text":"Solution in Python Python
n = int(input())\nwords = []\nfor _ in range(n):\n    words.append(input())\nm = max([len(w) for w in words])\nans = []\nfor i in range(m):\n    values = [ord(w[i]) for w in words if len(w) > i]\n    ans.append(sum(values) // len(values))\nprint(\"\".join(chr(d) for d in ans))\n
"},{"location":"solutions/#imperial-measurement","title":"Imperial Measurement","text":"Solution in Python Python
mapping = {\n    \"th\": \"thou\",\n    \"in\": \"inch\",\n    \"ft\": \"foot\",\n    \"yd\": \"yard\",\n    \"ch\": \"chain\",\n    \"fur\": \"furlong\",\n    \"mi\": \"mile\",\n    \"lea\": \"league\",\n}\nnames = list(mapping.values())\nscale = [1, 1000, 12, 3, 22, 10, 8, 3]\n\nv, a, _, b = input().split()\nv = int(v)\nna, nb = mapping.get(a, a), mapping.get(b, b)\nia, ib = names.index(na), names.index(nb)\n\nrate = 1\nfor s in scale[min(ia, ib) + 1 : max(ia, ib) + 1]:\n    rate *= s\n\nprint(v * rate if ia > ib else v / rate)\n
"},{"location":"solutions/#metaprogramming","title":"Metaprogramming","text":"Solution in Python Python
c = {}\nwhile True:\n    try:\n        s = input()\n    except:\n        break\n    parts = s.split()\n    if parts[0] == \"define\":\n        v, n = parts[1:]\n        c[n] = int(v)\n    elif parts[0] == \"eval\":\n        x, y, z = parts[1:]\n        if x not in c or z not in c:\n            print(\"undefined\")\n        elif y == \"=\":\n            print(\"true\" if c[x] == c[z] else \"false\")\n        elif y == \">\":\n            print(\"true\" if c[x] > c[z] else \"false\")\n        elif y == \"<\":\n            print(\"true\" if c[x] < c[z] else \"false\")\n
"},{"location":"solutions/#methodic-multiplication","title":"Methodic Multiplication","text":"Solution in Python Python
a, b = input(), input()\nt = a.count(\"S\") * b.count(\"S\")\nprint(\"S(\" * t + \"0\" + \")\" * t)\n
"},{"location":"solutions/#metronome","title":"Metronome","text":"Solution in Python Python
n = int(input())\nprint(f\"{n/4:.2f}\")\n
"},{"location":"solutions/#mia","title":"Mia","text":"Solution in Python Python
def score(a, b):\n    roll = set([a, b])\n    if roll == {1, 2}:\n        return (3, None)\n    elif len(roll) == 1:\n        return (2, a)\n    else:\n        a, b = min(a, b), max(b, a)\n        return (1, 10 * b + a)\n\n\nwhile True:\n    rolls = [int(d) for d in input().split()]\n    if not any(rolls):\n        break\n    score1 = score(*rolls[:2])\n    score2 = score(*rolls[2:])\n    if score1 == score2:\n        print(\"Tie.\")\n    elif score1[0] == score2[0]:\n        print(f\"Player {1 if score1[1] > score2[1] else 2} wins.\")\n    else:\n        print(f\"Player {1 if score1[0] > score2[0] else 2} wins.\")\n
"},{"location":"solutions/#millifrsla","title":"Millif\u00e6rsla","text":"Solution in Python Python
names, fees = [\"Monnei\", \"Fjee\", \"Dolladollabilljoll\"], []\nfor _ in range(3):\n    fees.append(int(input()))\nprint(names[fees.index(min(fees))])\n
"},{"location":"solutions/#missing-numbers","title":"Missing Numbers","text":"Solution in Python Python
numbers = []\nfor _ in range(int(input())):\n    numbers.append(int(input()))\n\nis_good_job = True\nfor i in range(1, max(numbers) + 1):\n    if i not in numbers:\n        is_good_job = False\n        print(i)\n\nif is_good_job:\n    print(\"good job\")\n
"},{"location":"solutions/#mixed-fractions","title":"Mixed Fractions","text":"Solution in Python Python
while True:\n    m, n = [int(d) for d in input().split()]\n    if not m and not n:\n        break\n    a = m // n\n    b = m % n\n    print(f\"{a} {b} / {n}\")\n
"},{"location":"solutions/#mjehuric","title":"Mjehuric","text":"Solution in Python Python
f = input().split()\nwhile f != [str(d) for d in range(1, 6)]:\n    for i in range(4):\n        if f[i] > f[i + 1]:\n            f[i], f[i + 1] = f[i + 1], f[i]\n            print(\" \".join(f))\n
"},{"location":"solutions/#moderate-pace","title":"Moderate Pace","text":"Solution in Python Python
n = int(input())\ndistances = [[int(d) for d in input().split()] for _ in range(3)]\nplan = [sorted([d[i] for d in distances])[1] for i in range(n)]\nprint(\" \".join([str(d) for d in plan]))\n
"},{"location":"solutions/#modulo","title":"Modulo","text":"Solution in Python Python
n = set()\nfor _ in range(10):\n    n.add(int(input()) % 42)\nprint(len(n))\n
"},{"location":"solutions/#monopoly","title":"Monopoly","text":"Solution in Python Python
n = int(input())\na = [int(d) for d in input().split()]\nt = 0\nm = 0\nfor i in range(1, 7):\n    for j in range(1, 7):\n        t += 1\n        if i + j in a:\n            m += 1\nprint(m / t)\n
"},{"location":"solutions/#moscow-dream","title":"Moscow Dream","text":"Solution in Python Python
a, b, c, n = [int(d) for d in input().split()]\n\nif not all(d > 0 for d in [a, b, c]):\n    print(\"NO\")\nelse:\n    print(\"YES\" if a + b + c >= n and n >= 3 else \"NO\")\n
"},{"location":"solutions/#mosquito-multiplication","title":"Mosquito Multiplication","text":"Solution in Python Python
while True:\n    try:\n        m, p, l, e, r, s, n = [int(d) for d in input().split()]\n    except:\n        break\n    for _ in range(n):\n        pp = p\n        p = l // r\n        l = e * m\n        m = pp // s\n    print(m)\n
"},{"location":"solutions/#mrcodeformatgrader","title":"MrCodeFormatGrader","text":"Solution in Python Python
def f(numbers):\n    prev = numbers[0]\n    ans = {prev: 1}\n    for i in range(1, len(numbers)):\n        if numbers[i] == prev + ans[prev]:\n            ans[prev] += 1\n        else:\n            prev = numbers[i]\n            ans[prev] = 1\n\n    parts = [\n        f\"{key}-{key+value-1}\"\n        if value > 1\n        else \" \".join([str(d) for d in range(key, key + value)])\n        for key, value in ans.items()\n    ]\n\n    return \", \".join(parts[:-1]) + \" and \" + parts[-1]\n\n\nc, n = [int(d) for d in input().split()]\nerrors = [int(d) for d in input().split()]\ncorrect = [i for i in range(1, 1 + c) if i not in errors]\n\nprint(\"Errors:\", f(errors))\nprint(\"Correct:\", f(correct))\n
"},{"location":"solutions/#mult","title":"Mult!","text":"Solution in Python Python
n = int(input())\nb = None\nfor _ in range(n):\n    d = int(input())\n    if not b:\n        b = d\n        continue\n\n    if d % b == 0:\n        print(d)\n        b = None\n
"},{"location":"solutions/#mumble-rap","title":"Mumble Rap","text":"Solution in Python Python
n = int(input())\ns = input()\na = []\nd = \"\"\nimport string\n\nfor i in range(n):\n    if s[i] in string.digits:\n        d += s[i]\n\n    else:\n        if d:\n            a.append(int(d))\n            d = \"\"\nif d:\n    a.append(int(d))\n\nprint(max(a))\n
"},{"location":"solutions/#musical-scales","title":"Musical Scales","text":"Solution in Python Python
notes = [\"A\", \"A#\", \"B\", \"C\", \"C#\", \"D\", \"D#\", \"E\", \"F\", \"F#\", \"G\", \"G#\"]\noffset = [2, 2, 1, 2, 2, 2]\nmajors = {}\nfor i in range(len(notes)):\n    name = notes[i]\n    progression = [name]\n    for i in offset:\n        index = (notes.index(progression[-1]) + i) % len(notes)\n        progression.append(notes[index])\n    majors[name] = progression\n\n_ = input()\nscales = set(input().split())\nprint(\" \".join([n for n in majors if scales < set(majors[n])]) or \"none\")\n
"},{"location":"solutions/#music-your-way","title":"Music Your Way","text":"Solution in Python Python
cols = input().split()\nm = int(input())\nsongs = [input().split() for _ in range(m)]\nn = int(input())\n\nfor i in range(n):\n    col = input()\n    index = cols.index(col)\n    songs = sorted(songs, key=lambda k: k[index])\n    print(\" \".join(cols))\n    for song in songs:\n        print(\" \".join(song))\n    if i < n - 1:\n        print()\n
"},{"location":"solutions/#mylla","title":"Mylla","text":"Solution in Python Python
board = []\nfor _ in range(3):\n    board.append(list(input()))\n\nwinner = \"\"\nfor i in range(3):\n    if board[i][0] == board[i][1] == board[i][2] and board[i][0] != \"_\":\n        winner = board[i][0]\n        break\n    elif board[0][i] == board[1][i] == board[2][i] and board[0][i] != \"_\":\n        winner = board[0][i]\n        break\n\nif board[0][0] == board[1][1] == board[2][2] and board[1][1] != \"_\":\n    winner = board[1][1]\nelif board[0][2] == board[1][1] == board[2][0] and board[1][1] != \"_\":\n    winner = board[1][1]\n\nif winner == \"O\":\n    winner = \"Jebb\"\nelse:\n    winner = \"Neibb\"\n\nprint(winner)\n
"},{"location":"solutions/#nasty-hacks","title":"Nasty Hacks","text":"Solutions in 2 languages C++Python
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int n, r, e, c;\n    cin >> n;\n\n    for (int i = 0; i < n; i++)\n    {\n        cin >> r >> e >> c;\n        if ((e - c) > r)\n        {\n            cout << \"advertise\";\n        }\n        else if ((e - c) < r)\n        {\n            cout << \"do not advertise\";\n        }\n        else\n        {\n            cout << \"does not matter\";\n        }\n    }\n}\n
for _ in range(int(input())):\n    r, e, c = [int(d) for d in input().split()]\n    if e > r + c:\n        print(\"advertise\")\n    elif e < r + c:\n        print(\"do not advertise\")\n    else:\n        print(\"does not matter\")\n
"},{"location":"solutions/#no-duplicates","title":"No Duplicates","text":"Solution in Python Python
words = input().split()\n\ncounter = {}\nrepeated = False\nfor w in words:\n    if w in counter:\n        repeated = True\n        break\n    else:\n        counter[w] = None\nif repeated:\n    print(\"no\")\nelse:\n    print(\"yes\")\n
"},{"location":"solutions/#nop","title":"NOP","text":"Solution in Python Python
s = input()\ni, m, p = 0, {}, None\n\nfor c in s:\n    if c.isupper():\n        m[i] = 1\n        p = i\n        i += 1\n    else:\n        m[p] += 1\n\nprint(\n    sum(\n        4 - m[k] % 4 if m[k] % 4 else (4 if not m[k] else 0)\n        for k in list(m.keys())[:-1]\n    )\n)\n
"},{"location":"solutions/#no-thanks","title":"No Thanks!","text":"Solution in Python Python
n = int(input())\nv = sorted([int(d) for d in input().split()])\n\nprev = v[0]\nans = {prev: 1}\nfor i in range(1, n):\n    if v[i] == prev + ans[prev]:\n        ans[prev] += 1\n    else:\n        prev = v[i]\n        ans[prev] = 1\n\nprint(sum(ans.keys()))\n
"},{"location":"solutions/#n-sum","title":"N-sum","text":"Solutions in 2 languages JavaPython
import java.util.Scanner;\n\nclass NSum {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int n = s.nextInt();\n        int ans = 0;\n        for (int i = 0; i < n; i++) {\n            ans += s.nextInt();\n        }\n        System.out.println(ans);\n    }\n}\n
_ = int(input())\nnumbers = []\nfor d in input().split():\n    numbers.append(int(d))\nprint(sum(numbers))\n
"},{"location":"solutions/#number-fun","title":"Number Fun","text":"Solution in Python Python
for _ in range(int(input())):\n    a, b, c = [int(d) for d in input().split()]\n    if a + b == c or a * b == c or a - b == c or b - a == c or a / b == c or b / a == c:\n        print(\"Possible\")\n    else:\n        print(\"Impossible\")\n
"},{"location":"solutions/#odd-echo","title":"Odd Echo","text":"Solution in Python Python
n = int(input())\nwords = []\nfor _ in range(n):\n    words.append(input())\nfor i in range(0, n, 2):\n    print(words[i])\n
"},{"location":"solutions/#odd-gnome","title":"Odd Gnome","text":"Solution in Python Python
n = int(input())\nfor _ in range(n):\n    g = [int(d) for d in input().split()][1:]\n    prev = g[0]\n    for i in range(1, len(g)):\n        if g[i] != prev + 1:\n            break\n        prev = g[i]\n    print(i + 1)\n
"},{"location":"solutions/#oddities","title":"Oddities","text":"Solution in Python Python
n = int(input())\nfor _ in range(n):\n    x = int(input())\n    if x % 2:\n        res = \"odd\"\n    else:\n        res = \"even\"\n    print(f\"{x} is {res}\")\n
"},{"location":"solutions/#odd-man-out","title":"Odd Man Out","text":"Solution in Python Python
from collections import Counter\n\nn = int(input())\nfor i in range(n):\n    _ = input()\n    c = Counter(input().split())\n    print(f\"Case #{i+1}: {' '.join(v for v in c if c[v]==1)}\")\n
"},{"location":"solutions/#off-world-records","title":"Off-World Records","text":"Solutions in 2 languages JavaPython
import java.util.Scanner;\n\nclass OffWorldRecords {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int n = s.nextInt();\n        int c = s.nextInt();\n        int p = s.nextInt();\n        int ans = 0;\n\n        for (int i = 0; i < n; i++) {\n            int h = s.nextInt();\n            if (h > c + p) {\n                ans += 1;\n                p = c;\n                c = h;\n            }\n        }\n        System.out.println(ans);\n    }\n}\n
n, c, p = [int(d) for d in input().split()]\nans = 0\nfor _ in range(n):\n    h = int(input())\n    if h > c + p:\n        ans += 1\n        c, p = h, c\nprint(ans)\n
"},{"location":"solutions/#reverse","title":"Reverse","text":"Solution in Python Python
n = int(input())\nnumbers = []\nfor _ in range(n):\n    numbers.append(int(input()))\nfor d in numbers[::-1]:\n    print(d)\n
"},{"location":"solutions/#oktalni","title":"Oktalni","text":"Solution in Python Python
import math\n\nmapping = {\n    \"000\": \"0\",\n    \"001\": \"1\",\n    \"010\": \"2\",\n    \"011\": \"3\",\n    \"100\": \"4\",\n    \"101\": \"5\",\n    \"110\": \"6\",\n    \"111\": \"7\",\n}\nb = input()\nlength = 3 * math.ceil(len(b) / 3)\nb = b.zfill(length)\n\nprint(\"\".join([mapping[b[i : i + 3]] for i in range(0, length, 3)]))\n
"},{"location":"solutions/#one-chicken-per-person","title":"One Chicken Per Person!","text":"Solution in Python Python
n, m = [int(d) for d in input().split()]\n\ndiff = n - m\nif diff > 0:\n    print(f\"Dr. Chaz needs {diff} more piece{'s' if diff >1 else ''} of chicken!\")\nelse:\n    diff = abs(diff)\n    print(\n        f\"Dr. Chaz will have {diff} piece{'s' if diff >1 else ''} of chicken left over!\"\n    )\n
"},{"location":"solutions/#ordinals","title":"Ordinals","text":"Solution in Python Python
def f(n):\n    if n == 0:\n        return \"{}\"\n    else:\n        ans = \",\".join([f(i) for i in range(n)])\n        return \"{\" + ans + \"}\"\n\n\nprint(f(int(input())))\n
"},{"location":"solutions/#ornaments","title":"Ornaments","text":"Solution in Python Python
import math\n\nwhile True:\n    r, h, s = [int(d) for d in input().split()]\n    if not r and not h and not s:\n        break\n    l = math.sqrt(h**2 - r**2) * 2\n    a = math.pi - math.acos(r / h)\n    l += 2 * math.pi * r * (a / math.pi)\n    l *= 1 + s / 100\n    print(f\"{l:.2f}\")\n
"},{"location":"solutions/#ostgotska","title":"\u00d6stg\u00f6tska","text":"Solution in Python Python
sentence = input()\nwords = sentence.split()\nif len([w for w in words if \"ae\" in w]) / len(words) >= 0.4:\n    print(\"dae ae ju traeligt va\")\nelse:\n    print(\"haer talar vi rikssvenska\")\n
"},{"location":"solutions/#overdraft","title":"Overdraft","text":"Solution in Python Python
n = int(input())\ns = 0\nb = 0\nfor _ in range(n):\n    t = int(input())\n    if t > 0:\n        b += t\n    elif b + t < 0:\n        s -= b + t\n        b = 0\n    else:\n        b += t\nprint(s)\n
"},{"location":"solutions/#ovissa","title":"\u00d3vissa","text":"Solutions in 3 languages GoLuaPython
package main\n\nimport (\n    \"fmt\"\n    \"strings\"\n)\n\nfunc main() {\n    var s string\n    fmt.Scan(&s)\n    fmt.Println(strings.Count(s, \"u\"))\n}\n
s = io.read()\n_, count = string.gsub(s, \"u\", \"\")\nprint(count)\n
print(input().count(\"u\"))\n
"},{"location":"solutions/#the-owl-and-the-fox","title":"The Owl and the Fox","text":"Solution in Python Python
def sd(n):\n    return sum([int(d) for d in str(n)])\n\n\nfor _ in range(int(input())):\n    n = int(input())\n    s = sd(n) - 1\n    d = n - 1\n    while True:\n        if sd(d) == s:\n            break\n        d -= 1\n    print(d)\n
"},{"location":"solutions/#pachyderm-peanut-packing","title":"Pachyderm Peanut Packing","text":"Solution in Python Python
def inbox(coords, x, y):\n    if x >= coords[0] and x <= coords[2] and y >= coords[1] and y <= coords[3]:\n        return True\n    return False\n\n\nwhile True:\n    n = int(input())\n    if not n:\n        break\n    box = {}\n    for i in range(n):\n        desc = input().split()\n        size = desc[-1]\n        coords = [float(d) for d in desc[:-1]]\n        box[i] = (coords, size)\n    m = int(input())\n    for _ in range(m):\n        desc = input().split()\n        size = desc[-1]\n        x, y = [float(d) for d in desc[:-1]]\n        floor = True\n        for i in range(n):\n            coords, box_size = box[i]\n            if inbox(coords, x, y):\n                floor = False\n                break\n        if floor:\n            status = \"floor\"\n        else:\n            status = \"correct\" if box_size == size else box_size\n        print(size, status)\n    print()\n
"},{"location":"solutions/#parent-gap","title":"Parent Gap","text":"Solution in Python Python
from datetime import datetime\n\nyear = int(input())\n\nmother = datetime(year, 5, 1).isoweekday()\nfather = datetime(year, 6, 1).isoweekday()\n\nx = 7 - mother\ny = 7 - father\ndaymother = 1 + x + 7\ndayfather = 1 + y + 14\n\ndaymother = datetime(year, 5, daymother)\ndayfather = datetime(year, 6, dayfather)\n\nprint(((dayfather - daymother).days) // 7, \"weeks\")\n
"},{"location":"solutions/#parket","title":"Parket","text":"Solution in Python Python
import math\n\nr, b = [int(d) for d in input().split()]\nw = math.floor((r + b) ** 0.5)\nwhile w:\n    if (r + b) / w == (r + 4) / 2 - w:\n        print((r + 4) // 2 - w, w)\n        break\n    w -= 1\n
"},{"location":"solutions/#parking","title":"Parking","text":"Solution in Python Python
a, b, c = [int(d) for d in input().split()]\nt = [0] * 100\nfor _ in range(3):\n    start, end = [int(d) - 1 for d in input().split()]\n    for i in range(start, end):\n        t[i] += 1\n\ntotal = 0\nmapping = {\n    3: c,\n    2: b,\n    1: a,\n}\nfor s in t:\n    total += mapping.get(s, 0) * s\nprint(total)\n
"},{"location":"solutions/#parking_1","title":"Parking","text":"Solution in Python Python
for _ in range(int(input())):\n    _ = input()\n    positions = [int(d) for d in input().split()]\n    print(2 * (max(positions) - min(positions)))\n
"},{"location":"solutions/#patuljci","title":"Patuljci","text":"Solution in Python Python
d = [int(input()) for _ in range(9)]\ndiff = sum(d) - 100\nend = False\nfor i in range(8):\n    for j in range(i + 1, 9):\n        if d[i] + d[j] == diff:\n            end = True\n            break\n    if end:\n        break\nprint(\"\\n\".join([str(d[k]) for k in range(9) if k not in [i, j]]))\n
"},{"location":"solutions/#paul-eigon","title":"Paul Eigon","text":"Solutions in 2 languages GoPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var n, p, q int\n    fmt.Scan(&n)\n    fmt.Scan(&p)\n    fmt.Scan(&q)\n    if ((p+q)/n)%2 == 0 {\n        fmt.Println(\"paul\")\n    } else {\n        fmt.Println(\"opponent\")\n    }\n}\n
n, p, q = [int(d) for d in input().split()]\n\nif ((p + q) // n) % 2 == 0:\n    print(\"paul\")\nelse:\n    print(\"opponent\")\n
"},{"location":"solutions/#peach-powder-polygon","title":"Peach Powder Polygon","text":"Solution in Python Python
n = int(input())\nprint(\"Yes\" if n % 4 else \"No\")\n
"},{"location":"solutions/#pea-soup-and-pancakes","title":"Pea Soup and Pancakes","text":"Solution in Python Python
found = False\nfor _ in range(int(input())):\n    k = int(input())\n\n    name = input()\n    items = [input() for _ in range(k)]\n    if \"pea soup\" in items and \"pancakes\" in items:\n        found = True\n        print(name)\n        break\n\nif not found:\n    print(\"Anywhere is fine I guess\")\n
"},{"location":"solutions/#peragrams","title":"Peragrams","text":"Solution in Python Python
from collections import Counter\n\ns = Counter(input())\nv = [d for d in s.values() if d % 2]\nv = sorted(v)[:-1]\n\nprint(len(v))\n
"},{"location":"solutions/#perket","title":"Perket","text":"Solution in Python Python
from itertools import combinations\n\nn = int(input())\nl = [[int(d) for d in input().split()] for _ in range(n)]\n\nc = []\nfor i in range(1, n + 1):\n    c.extend(list(combinations(l, i)))\n\nd = []\nfor i in c:\n    s, b = 1, 0\n    for x, y in i:\n        s *= x\n        b += y\n    d.append(abs(s - b))\n\nprint(min(d))\n
"},{"location":"solutions/#permuted-arithmetic-sequence","title":"Permuted Arithmetic Sequence","text":"Solution in Python Python
def arithmetic(n):\n    d = [n[i] - n[i + 1] for i in range(len(n) - 1)]\n    return True if len(set(d)) == 1 else False\n\n\nfor _ in range(int(input())):\n    s = input().split()\n    n = [int(d) for d in s[1:]]\n    if arithmetic(n):\n        print(\"arithmetic\")\n    elif arithmetic(sorted(n)):\n        print(\"permuted arithmetic\")\n    else:\n        print(\"non-arithmetic\")\n
"},{"location":"solutions/#pervasive-heart-monitor","title":"Pervasive Heart Monitor","text":"Solution in Python Python
while True:\n    try:\n        line = input().split()\n    except:\n        break\n\n    name, rate = [], []\n    for p in line:\n        if p.isalpha():\n            name.append(p)\n        else:\n            rate.append(float(p))\n    name = \" \".join(name)\n    rate = sum(rate) / len(rate)\n    print(f\"{rate:.6f} {name}\")\n
"},{"location":"solutions/#pet","title":"Pet","text":"Solution in Python Python
winner, max_score = 0, 0\nfor i in range(5):\n    score = sum([int(d) for d in input().split()])\n    if score > max_score:\n        max_score = score\n        winner = i + 1\n\nprint(winner, max_score)\n
"},{"location":"solutions/#piece-of-cake","title":"Piece of Cake!","text":"Solution in Python Python
n, h, v = [int(d) for d in input().split()]\nprint(4 * max(h * v, (n - h) * (n - v), h * (n - v), v * (n - h)))\n
"},{"location":"solutions/#pig-latin","title":"Pig Latin","text":"Solution in Python Python
def translate(w):\n    if w[0] in \"aeiouy\":\n        return w + \"yay\"\n    else:\n        i = 1\n        while i < len(w):\n            if w[i] in \"aeiouy\":\n                break\n            i += 1\n        return w[i:] + w[:i] + \"ay\"\n\n\nwhile True:\n    try:\n        text = input()\n        print(\" \".join([translate(w) for w in text.split()]))\n    except:\n        break\n
"},{"location":"solutions/#a-vicious-pikeman-easy","title":"A Vicious Pikeman (Easy)","text":"Solution in Python Python
def f(n, time, l):\n    total_time, penalty = 0, 0\n    for i, t in enumerate(sorted(l)):\n        if total_time + t > time:\n            return i, penalty\n        total_time += t\n        penalty = (penalty + total_time) % 1_000_000_007\n    return n, penalty\n\n\nn, t = [int(d) for d in input().split()]\na, b, c, t0 = [int(d) for d in input().split()]\nl = [t0]\nfor _ in range(n - 1):\n    l.append(((a * l[-1] + b) % c) + 1)\n\n\nn, penalty = f(n, t, l)\nprint(n, penalty)\n
"},{"location":"solutions/#pizza-crust","title":"Pizza Crust","text":"Solution in Python Python
r, c = [int(d) for d in input().split()]\nprint(f\"{(r-c)**2 / r**2 * 100:.6f}\")\n
"},{"location":"solutions/#pizzubestun","title":"Pizzubestun","text":"Solution in Python Python
n = int(input())\nprices = [int(input().split()[-1]) for _ in range(n)]\nif n % 2:\n    prices.append(0)\nprices = sorted(prices, reverse=True)\nprint(sum(prices[i] for i in range(0, len(prices), 2)))\n
"},{"location":"solutions/#planetaris","title":"Planetaris","text":"Solution in Python Python
_, a = [int(d) for d in input().split()]\ne = sorted([int(d) + 1 for d in input().split()])\n\nt = 0\nfor s in e:\n    if a >= s:\n        t += 1\n        a -= s\n    else:\n        break\nprint(t)\n
"},{"location":"solutions/#planina","title":"Planina","text":"Solution in Python Python
def p(n):\n    if n == 1:\n        return 3\n    else:\n        return p(n - 1) * 2 - 1\n\n\nn = int(input())\nprint(p(n) ** 2)\n
"},{"location":"solutions/#planting-trees","title":"Planting Trees","text":"Solution in Python Python
n = int(input())\nt = [int(d) for d in input().split()]\n\ndays = [v + d for v, d in zip(sorted(t, reverse=True), range(1, n + 1))]\nprint(max(days) + 1)\n
"},{"location":"solutions/#pokechat","title":"Pokechat","text":"Solution in Python Python
chars = input()\nids = input()\nids = [int(ids[i : i + 3]) - 1 for i in range(0, len(ids), 3)]\nprint(\"\".join([chars[i] for i in ids]))\n
"},{"location":"solutions/#poker-hand","title":"Poker Hand","text":"Solution in Python Python
from collections import Counter\n\nhands = [h[0] for h in input().split()]\nprint(max(Counter(hands).values()))\n
"},{"location":"solutions/#polynomial-multiplication-1","title":"Polynomial Multiplication 1","text":"Solution in Python Python
from collections import Counter\n\nfor _ in range(int(input())):\n    n = int(input())\n    a = [int(d) for d in input().split()]\n    m = int(input())\n    b = [int(d) for d in input().split()]\n    p = Counter()\n    for i in range(n + 1):\n        for j in range(m + 1):\n            p[i + j] += a[i] * b[j]\n    keys = max([k for k in p.keys() if p[k] != 0])\n    print(keys)\n    print(\" \".join([str(p[k]) for k in range(keys + 1)]))\n
"},{"location":"solutions/#popularity-contest","title":"Popularity Contest","text":"Solution in Python Python
n, m = [int(d) for d in input().split()]\np = [0] * n\nfor _ in range(m):\n    a, b = [int(d) - 1 for d in input().split()]\n    p[a] += 1\n    p[b] += 1\nprint(\" \".join([str(a - b) for a, b in zip(p, range(1, 1 + n))]))\n
"},{"location":"solutions/#pot","title":"Pot","text":"Solution in Python Python
n = int(input())\ntotal = 0\nfor _ in range(n):\n    line = input()\n    n, p = int(line[:-1]), int(line[-1])\n    total += n**p\nprint(total)\n
"},{"location":"solutions/#saving-princess-peach","title":"Saving Princess Peach","text":"Solution in Python Python
n, y = [int(d) for d in input().split()]\nfound = []\nfor _ in range(y):\n    found.append(int(input()))\nfound = set(found)\nfor i in range(n):\n    if i not in found:\n        print(i)\nprint(f\"Mario got {len(found)} of the dangerous obstacles.\")\n
"},{"location":"solutions/#printing-costs","title":"Printing Costs","text":"Solution in Python Python
t = \"\"\"\n    0        !   9        \"   6        #  24        $  29        %  22\n&  24        '   3        (  12        )  12        *  17        +  13\n,   7        -   7        .   4        /  10        0  22        1  19\n2  22        3  23        4  21        5  27        6  26        7  16\n8  23        9  26        :   8        ;  11        <  10        =  14\n>  10        ?  15        @  32        A  24        B  29        C  20\nD  26        E  26        F  20        G  25        H  25        I  18\nJ  18        K  21        L  16        M  28        N  25        O  26\nP  23        Q  31        R  28        S  25        T  16        U  23\nV  19        W  26        X  18        Y  14        Z  22        [  18\n\\  10        ]  18        ^   7        _   8        `   3        a  23\nb  25        c  17        d  25        e  23        f  18        g  30\nh  21        i  15        j  20        k  21        l  16        m  22\nn  18        o  20        p  25        q  25        r  13        s  21\nt  17        u  17        v  13        w  19        x  13        y  24\nz  19        {  18        |  12        }  18        ~   9\n\"\"\"\n\nm = []\nfor row in t.splitlines():\n    if not row:\n        continue\n    values = row.split()\n    if len(values) % 2:\n        values.insert(0, \" \")\n\n    for i in range(0, len(values), 2):\n        m.append((values[i], int(values[i + 1])))\nm = dict(m)\n\nwhile True:\n    try:\n        s = input()\n    except:\n        break\n    print(sum([m[c] for c in s]))\n
"},{"location":"solutions/#prjonamynstur","title":"Prj\u00f3namynstur","text":"Solution in Python Python
mapping = {\n    \".\": 20,\n    \"O\": 10,\n    \"\\\\\": 25,\n    \"/\": 25,\n    \"A\": 35,\n    \"^\": 5,\n    \"v\": 22,\n}\nn, _ = input().split()\ncost = 0\nfor _ in range(int(n)):\n    for c in input():\n        cost += mapping[c]\nprint(cost)\n
"},{"location":"solutions/#provinces-and-gold","title":"Provinces and Gold","text":"Solution in Python Python
g, s, c = [int(d) for d in input().split()]\n\nbuying = 3 * g + 2 * s + 1 * c\nresult = []\n\nif buying >= 8:\n    result.append(\"Province\")\nelif buying >= 5:\n    result.append(\"Duchy\")\nelif buying >= 2:\n    result.append(\"Estate\")\n\nif buying >= 6:\n    result.append(\"Gold\")\nelif buying >= 3:\n    result.append(\"Silver\")\nelse:\n    result.append(\"Copper\")\n\nprint(\" or \".join(result))\n
"},{"location":"solutions/#prsteni","title":"Prsteni","text":"Solution in Python Python
import math\n\n_ = input()\nnumbers = [int(d) for d in input().split()]\n\nbase = numbers.pop(0)\n\ngcd = [math.gcd(base, n) for n in numbers]\n\nfor g, n in zip(gcd, numbers):\n    print(f\"{int(base/g)}/{int(n/g)}\")\n
"},{"location":"solutions/#prva","title":"Prva","text":"Solution in Python Python
r, c = [int(d) for d in input().split()]\npuzzle = []\nfor _ in range(r):\n    puzzle.append(input())\n\nwords = set()\nfor row in puzzle:\n    words.update([w for w in row.split(\"#\") if len(w) > 1])\nfor i in range(c):\n    col = \"\".join([row[i] for row in puzzle])\n    words.update([w for w in col.split(\"#\") if len(w) > 1])\n\nprint(sorted(words)[0])\n
"},{"location":"solutions/#ptice","title":"Ptice","text":"Solution in Python Python
def adrian(n):\n    if n == 0:\n        return \"\"\n    elif n == 1:\n        return \"A\"\n    elif n == 2:\n        return \"AB\"\n    elif n == 3:\n        return \"ABC\"\n    else:\n        duplicate = n // 3\n        return adrian(3) * duplicate + adrian(n % 3)\n\n\ndef bruno(n):\n    if n == 0:\n        return \"\"\n    elif n == 1:\n        return \"B\"\n    elif n == 2:\n        return \"BA\"\n    elif n == 3:\n        return \"BAB\"\n    elif n == 4:\n        return \"BABC\"\n    else:\n        duplicate = n // 4\n        return bruno(4) * duplicate + bruno(n % 4)\n\n\ndef goran(n):\n    if n == 0:\n        return \"\"\n    elif n in [1, 2]:\n        return \"C\" * n\n    elif n in [3, 4]:\n        return \"CC\" + \"A\" * (n - 2)\n    elif n in [5, 6]:\n        return \"CCAA\" + \"B\" * (n - 4)\n    else:\n        duplicate = n // 6\n        return goran(6) * duplicate + goran(n % 6)\n\n\ndef get_score(ans, guess):\n    return sum([a == g for a, g in zip(ans, guess)])\n\n\nn = int(input())\nans = input()\n\nresult = {}\nresult[\"Adrian\"] = get_score(ans, adrian(n))\nresult[\"Bruno\"] = get_score(ans, bruno(n))\nresult[\"Goran\"] = get_score(ans, goran(n))\n\nbest = max(result.values())\nprint(best)\n\nfor name, score in result.items():\n    if score == best:\n        print(name)\n
"},{"location":"solutions/#plants-vs-bad-guys","title":"Plants vs Bad Guys","text":"Solutions in 2 languages LuaPython
n = io.read(\"*n\")\nlocal min = math.huge\nfor i = 1, n do\n    value = io.read(\"*n\")\n    min   = min < value and min or value\nend\nprint(1 + min)\n
_ = input()\nprint(1 + min(int(d) for d in input().split()))\n
"},{"location":"solutions/#building-pyramids","title":"Building Pyramids","text":"Solution in Python Python
n = int(input())\n\nheight = 0\nwhile True:\n    height += 1\n    blocks = (2 * height - 1) ** 2\n    if blocks > n:\n        height -= 1\n        break\n    n -= blocks\n\nprint(height)\n
"},{"location":"solutions/#quality-adjusted-life-year","title":"Quality-Adjusted Life-Year","text":"Solution in Python Python
qaly = 0\nfor _ in range(int(input())):\n    q, y = input().split()\n    q, y = float(q), float(y)\n    qaly += q * y\nprint(qaly)\n
"},{"location":"solutions/#quadrant-selection","title":"Quadrant Selection","text":"Solutions in 4 languages GoJavaPythonRust
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var x, y int\n    fmt.Scan(&x)\n    fmt.Scan(&y)\n    if x > 0 {\n        if y > 0 {\n            fmt.Println(1)\n        } else {\n            fmt.Println(4)\n        }\n    } else {\n        if y > 0 {\n            fmt.Println(2)\n        } else {\n            fmt.Println(3)\n        }\n    }\n}\n
import java.util.Scanner;\n\nclass QuadrantSelection {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int x = s.nextInt();\n        int y = s.nextInt();\n\n        if (x > 0) {\n            if (y > 0) {\n                System.out.println(1);\n            } else {\n                System.out.println(4);\n            }\n        } else {\n            if (y > 0) {\n                System.out.println(2);\n            } else {\n                System.out.println(3);\n            }\n        }\n\n    }\n}\n
x = int(input())\ny = int(input())\nif x > 0:\n    if y > 0:\n        print(1)\n    else:\n        print(4)\nelse:\n    if y > 0:\n        print(2)\n    else:\n        print(3)\n
fn main() {\n    let mut line1 = String::new();\n    std::io::stdin().read_line(&mut line1).unwrap();\n    let x: i32 = line1.trim().parse().unwrap();\n\n    let mut line2 = String::new();\n    std::io::stdin().read_line(&mut line2).unwrap();\n    let y: i32 = line2.trim().parse().unwrap();\n\n    if x > 0 {\n        if y > 0 {\n            println!(\"1\");\n        } else {\n            println!(\"4\");\n        }\n    } else {\n        if y > 0 {\n            println!(\"2\");\n        } else {\n            println!(\"3\");\n        }\n    }\n}\n
"},{"location":"solutions/#quick-brown-fox","title":"Quick Brown Fox","text":"Solution in Python Python
import string\n\nfor _ in range(int(input())):\n    p = set([c for c in input().lower() if c.isalpha()])\n    if len(p) == 26:\n        print(\"pangram\")\n    else:\n        print(\n            f\"missing {''.join([c for c in string.ascii_lowercase[:26] if c not in p])}\"\n        )\n
"},{"location":"solutions/#quick-estimates","title":"Quick Estimates","text":"Solutions in 2 languages JavaPython
import java.util.Scanner;\n\nclass QuickEstimates {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int n = s.nextInt();\n        for (int i = 0; i < n; i++) {\n            String cost = s.next();\n            System.out.println(cost.length());\n        }\n    }\n}\n
for _ in range(int(input())):\n    print(len(input()))\n
"},{"location":"solutions/#quite-a-problem","title":"Quite a Problem","text":"Solution in Python Python
while True:\n    try:\n        line = input()\n    except:\n        break\n\n    if \"problem\" in line.lower():\n        print(\"yes\")\n    else:\n        print(\"no\")\n
"},{"location":"solutions/#r2","title":"R2","text":"Solutions in 5 languages C++GoJavaLuaPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int r1, s;\n    cin >> r1 >> s;\n    cout << 2 * s - r1 << endl;\n    return 0;\n}\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var r1, s int\n    fmt.Scan(&r1)\n    fmt.Scan(&s)\n    fmt.Println(2*s - r1)\n}\n
import java.util.Scanner;\n\nclass R2 {\n    public static void main(String[] args) {\n        Scanner scanner = new Scanner(System.in);\n        int r1 = scanner.nextInt();\n        int s = scanner.nextInt();\n        System.out.println(2 * s - r1);\n    }\n}\n
r1 = io.read(\"*n\")\ns = io.read(\"*n\")\nr2 = 2 * s - r1\nprint(r2)\n
r1, s = [int(d) for d in input().split()]\nr2 = 2 * s - r1\nprint(r2)\n
"},{"location":"solutions/#racing-around-the-alphabet","title":"Racing Around the Alphabet","text":"Solution in Python Python
import math\n\ntokens = dict([(chr(c), c - ord(\"A\") + 1) for c in range(ord(\"A\"), ord(\"Z\") + 1)])\ntokens[\" \"] = 27\ntokens[\"'\"] = 28\nt = math.pi * 60 / (28 * 15)\nfor _ in range(int(input())):\n    m = input()\n    total = 1\n    prev = m[0]\n    for c in m[1:]:\n        dist = abs(tokens[prev] - tokens[c])\n        total += 1 + t * min(dist, 28 - dist)\n        prev = c\n    print(total)\n
"},{"location":"solutions/#ragged-right","title":"Ragged Right","text":"Solution in Python Python
l = []\nwhile True:\n    try:\n        s = input()\n    except:\n        break\n    l.append(len(s))\nm = max(l)\nprint(sum([(n - m) ** 2 for n in l[:-1]]))\n
"},{"location":"solutions/#railroad","title":"Railroad","text":"Solutions in 4 languages GoJavaLuaPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var x, y int\n    fmt.Scan(&x)\n    fmt.Scan(&y)\n    if y%2 == 1 {\n        fmt.Println(\"impossible\")\n    } else {\n        fmt.Println(\"possible\")\n    }\n}\n
import java.util.Scanner;\n\nclass Railroad {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int x = s.nextInt();\n        int y = s.nextInt();\n        if (y % 2 == 1) {\n            System.out.println(\"impossible\");\n        } else {\n            System.out.println(\"possible\");\n        }\n    }\n}\n
x = io.read(\"*n\")\ny = io.read(\"*n\")\nif y % 2 == 1 then\n    print(\"impossible\")\nelse\n    print(\"possible\")\nend\n
_, y = [int(d) for d in input().split()]\nif y % 2:\n    print(\"impossible\")\nelse:\n    print(\"possible\")\n
"},{"location":"solutions/#a-rank-problem","title":"A Rank Problem","text":"Solution in Python Python
n, m = [int(d) for d in input().split()]\nranking = [f\"T{i}\" for i in range(1, 1 + n)]\nfor _ in range(m):\n    i, j = input().split()\n    if ranking.index(i) < ranking.index(j):\n        continue\n    ranking.remove(j)\n    ranking.insert(ranking.index(i) + 1, j)\nprint(\" \".join(ranking))\n
"},{"location":"solutions/#rating-problems","title":"Rating Problems","text":"Solutions in 2 languages JavaPython
import java.util.Scanner;\n\nclass RatingProblems {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int n = s.nextInt();\n        int k = s.nextInt();\n        int score = 0;\n        for (int i = 0; i < k; i++) {\n            score += s.nextInt();\n        }\n        float min = (score - 3 * (n - k)) / (float) n;\n        float max = (score + 3 * (n - k)) / (float) n;\n        System.out.println(min + \" \" + max);\n    }\n}\n
n, k = [int(d) for d in input().split()]\nscore = 0\nfor _ in range(k):\n    score += int(input())\n\nprint((score - 3 * (n - k)) / n, (score + 3 * (n - k)) / n)\n
"},{"location":"solutions/#a-rational-sequence-2","title":"A Rational Sequence 2","text":"Solution in Python Python
def f(l, r):\n    if l == r:\n        return 1\n    elif l > r:\n        return 2 * f(l - r, r) + 1\n    else:\n        return 2 * f(l, r - l)\n\n\nfor _ in range(int(input())):\n    k, v = input().split()\n    l, r = [int(d) for d in v.split(\"/\")]\n    print(f\"{k} {f(l,r)}\")\n
"},{"location":"solutions/#scaling-recipes","title":"Scaling Recipes","text":"Solution in Python Python
for i in range(int(input())):\n    r, p, d = [int(d) for d in input().split()]\n    recipe = {}\n    main = None\n    for _ in range(r):\n        name, weight, percent = input().split()\n        weight = float(weight)\n        percent = float(percent)\n        if percent == 100.0:\n            main = name\n        recipe[name] = (weight, percent)\n    scale = d / p\n    print(f\"Recipe # {i+1}\")\n    dw = recipe[main][0] * scale\n    for k in recipe:\n        print(k, f\"{recipe[k][1] * dw / 100:.1f}\")\n    print(\"-\" * 40)\n
"},{"location":"solutions/#recount","title":"Recount","text":"Solution in Python Python
from collections import Counter\n\nc = Counter()\nwhile True:\n    try:\n        name = input()\n    except:\n        break\n    c[name] += 1\n\nhighest = max(c.values())\nnames = [k for k in c if c[k] == highest]\nprint(\"Runoff!\" if len(names) > 1 else names.pop())\n
"},{"location":"solutions/#rectangle-area","title":"Rectangle Area","text":"Solution in Python Python
x1, y1, x2, y2 = [float(d) for d in input().split()]\n\nprint(abs((x1 - x2) * (y1 - y2)))\n
"},{"location":"solutions/#reduced-id-numbers","title":"Reduced ID Numbers","text":"Solution in Python Python
g = int(input())\nids = []\nfor _ in range(g):\n    ids.append(int(input()))\n\nm = 1\nwhile True:\n    v = [d % m for d in ids]\n    if g == len(set(v)):\n        break\n    m += 1\n\nprint(m)\n
"},{"location":"solutions/#relocation","title":"Relocation","text":"Solution in Python Python
n, q = [int(d) for d in input().split()]\nx = [int(d) for d in input().split()]\nfor _ in range(q):\n    req = [int(d) for d in input().split()]\n    if req[0] == 1:\n        x[req[1] - 1] = req[2]\n    elif req[0] == 2:\n        print(abs(x[req[1] - 1] - x[req[2] - 1]))\n
"},{"location":"solutions/#restaurant-opening","title":"Restaurant Opening","text":"Solution in Python Python
from itertools import product\n\nn, m = [int(d) for d in input().split()]\n\ng = []\nfor _ in range(n):\n    g.append([int(d) for d in input().split()])\n\nl = list(product(range(n), range(m)))\n\nc = []\nfor i, j in l:\n    s = 0\n    for a, b in l:\n        s += g[a][b] * (abs(i - a) + abs(j - b))\n    c.append(s)\n\nprint(min(c))\n
"},{"location":"solutions/#reversed-binary-numbers","title":"Reversed Binary Numbers","text":"Solution in Python Python
n = int(input())\n\nb = []\nwhile n:\n    b.append(n % 2)\n    n //= 2\n\nprint(sum([d * (2**p) for d, p in zip(b, reversed(range(len(b))))]))\n
"},{"location":"solutions/#reverse-rot","title":"Reverse Rot","text":"Solution in Python Python
import string\n\nrotations = string.ascii_uppercase + \"_.\"\n\n\ndef rotate(c, n):\n    index = (rotations.index(c) + n) % 28\n    return rotations[index]\n\n\nwhile True:\n    line = input()\n    if line == \"0\":\n        break\n    n, m = line.split()\n    n = int(n)\n    print(\"\".join([rotate(c, n) for c in m[::-1]]))\n
"},{"location":"solutions/#rijeci","title":"Rije\u010di","text":"Solutions in 4 languages GoJavaLuaPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var n int\n    fmt.Scan(&n)\n    a := 1\n    b := 0\n    for i := 0; i < n; i++ {\n        a, b = b, b+a\n    }\n    fmt.Println(a, b)\n}\n
import java.util.Scanner;\n\nclass Rijeci {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int k = s.nextInt();\n        int a = 1;\n        int b = 0;\n        for (int i = 0; i < k; i++) {\n            int t = b;\n            b = a + b;\n            a = t;\n\n        }\n\n        System.out.println(a + \" \" + b);\n    }\n}\n
k = io.read(\"*n\")\nlocal a, b = 1, 0\nfor i = 1, k do\n    a, b = b, b + a\nend\nprint(a, b)\n
k = int(input())\na, b = 1, 0\nfor _ in range(k):\n    a, b = b, b + a\n\nprint(a, b)\n
"},{"location":"solutions/#roaming-romans","title":"Roaming Romans","text":"Solutions in 3 languages GoLuaPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var x float64\n    fmt.Scan(&x)\n    fmt.Println(int(x*1000*5280/4854 + 0.5))\n}\n
x = io.read(\"*n\")\nprint(math.floor(x * 1000 * 5280 / 4854 + .5))\n
x = float(input())\nprint(int(x * 1000 * 5280 / 4854 + 0.5))\n
"},{"location":"solutions/#run-length-encoding-run","title":"Run-Length Encoding, Run!","text":"Solution in Python Python
action, s = input().split()\nif action == \"D\":\n    print(\"\".join([s[i] * int(s[i + 1]) for i in range(0, len(s), 2)]))\nelif action == \"E\":\n    parts = []\n    prev, t = s[0], 1\n    for c in s[1:]:\n        if c != prev:\n            parts.append((prev, t))\n            t = 1\n            prev = c\n        else:\n            t += 1\n    parts.append((prev, t))\n\n    print(\"\".join([f\"{k}{v}\" for k, v in parts]))\n
"},{"location":"solutions/#same-digits-easy","title":"Same Digits (Easy)","text":"Solution in Python Python
a, b = [int(d) for d in input().split()]\npairs = []\nfor x in range(a, b + 1):\n    for y in range(x, b + 1):\n        xy = x * y\n        if sorted(str(xy)) == sorted(str(x) + str(y)):\n            pairs.append((x, y, xy))\nprint(f\"{len(pairs)} digit-preserving pair(s)\")\nfor x, y, xy in pairs:\n    print(f\"x = {x}, y = {y}, xy = {xy}\")\n
"},{"location":"solutions/#same-digits-hard","title":"Same Digits (Hard)","text":"Solution in Python Python
a, b = [int(d) for d in input().split()]\npairs = []\nfor x in range(a, b + 1):\n    for y in range(x, b + 1):\n        xy = x * y\n        if x * y > b:\n            break\n        if sorted(str(xy)) == sorted(str(x) + str(y)):\n            pairs.append((x, y, xy))\n    if x * x > b:\n        break\n\nprint(f\"{len(pairs)} digit-preserving pair(s)\")\nfor x, y, xy in pairs:\n    print(f\"x = {x}, y = {y}, xy = {xy}\")\n
"},{"location":"solutions/#saving-daylight","title":"Saving Daylight","text":"Solution in Python Python
while True:\n    try:\n        s = input().split()\n    except:\n        break\n\n    t1, t2 = s[-2:]\n\n    h1, m1 = [int(d) for d in t1.split(\":\")]\n    h2, m2 = [int(d) for d in t2.split(\":\")]\n\n    mins = (h2 - h1) * 60 + (m2 - m1)\n    h = mins // 60\n    m = mins % 60\n\n    ans = s[:-2]\n    ans.extend([str(h), \"hours\", str(m), \"minutes\"])\n\n    print(\" \".join(ans))\n
"},{"location":"solutions/#saving-for-retirement","title":"Saving For Retirement","text":"Solution in Python Python
import math\n\nB, Br, Bs, A, As = [int(d) for d in input().split()]\nrate = Bs * (Br - B) / As\nAr = math.ceil(rate) + A\nif rate.is_integer():\n    Ar += 1\nprint(Ar)\n
"},{"location":"solutions/#scaling-recipe","title":"Scaling Recipe","text":"Solution in Python Python
import math\n\nn, x, y = [int(d) for d in input().split()]\ni = [int(input()) for _ in range(n)]\n\n# for python 3.9+ (https://docs.python.org/3.9/library/math.html#math.gcd)\n# s = math.gcd(x, *i)\n\ns = math.gcd(x, i[0])\nfor k in range(1, n):\n    s = math.gcd(s, i[k])\n\nx /= s\ni = [v / s for v in i]\n\nscale = y / x\nfor v in i:\n    print(int(scale * v))\n
"},{"location":"solutions/#school-spirit","title":"School Spirit","text":"Solution in Python Python
n = int(input())\ns = []\nfor _ in range(n):\n    s.append(int(input()))\n\n\ndef group_score(s):\n    gs = 0\n    for i in range(len(s)):\n        gs += s[i] * (0.8**i)\n    return 0.2 * gs\n\n\nprint(group_score(s))\nnew_gs = []\nfor i in range(n):\n    new_gs.append(group_score([s[j] for j in range(n) if j != i]))\nprint(sum(new_gs) / len(new_gs))\n
"},{"location":"solutions/#secret-message","title":"Secret Message","text":"Solution in Python Python
import math\n\nfor _ in range(int(input())):\n    m = input()\n    k = math.ceil(len(m) ** 0.5)\n\n    m += \"*\" * (k * k - len(m))\n    rows = [m[i : i + k] for i in range(0, len(m), k)]\n\n    s = []\n    for i in range(k):\n        s.append(\"\".join([row[i] for row in rows if row[i] != \"*\"][::-1]))\n    print(\"\".join(s))\n
"},{"location":"solutions/#secure-doors","title":"Secure Doors","text":"Solution in Python Python
pool = set()\nfor _ in range(int(input())):\n    action, name = input().split()\n    if action == \"entry\":\n        print(name, \"entered\", \"(ANOMALY)\" if name in pool else \"\")\n        pool.add(name)\n    elif action == \"exit\":\n        print(name, \"exited\", \"(ANOMALY)\" if name not in pool else \"\")\n        pool.discard(name)\n
"},{"location":"solutions/#server","title":"Server","text":"Solution in Python Python
_, t = [int(d) for d in input().split()]\ntotal, used = 0, 0\nfor v in [int(d) for d in input().split()]:\n    if used + v <= t:\n        total += 1\n        used += v\n    else:\n        break\nprint(total)\n
"},{"location":"solutions/#seven-wonders","title":"Seven Wonders","text":"Solution in Python Python
from collections import Counter\n\nc = Counter(input())\nscore = 0\nfor value in c.values():\n    score += value**2\nif len(c.values()) == 3:\n    score += 7 * min(c.values())\nprint(score)\n
"},{"location":"solutions/#shattered-cake","title":"Shattered Cake","text":"Solution in Python Python
w, n = int(input()), int(input())\ntotal = 0\nfor _ in range(n):\n    _w, _l = [int(d) for d in input().split()]\n    total += _w * _l\nprint(int(total / w))\n
"},{"location":"solutions/#shopaholic","title":"Shopaholic","text":"Solution in Python Python
n = int(input())\nc = [int(d) for d in input().split()]\n\nc = sorted(c, reverse=True)\ngroups = [c[i : i + 3] if i + 3 < n else c[i:] for i in range(0, n, 3)]\n\nprint(sum(g[-1] if len(g) == 3 else 0 for g in groups))\n
"},{"location":"solutions/#shopping-list-easy","title":"Shopping List (Easy)","text":"Solution in Python Python
n, m = [int(d) for d in input().split()]\nitems = []\nfor _ in range(n):\n    items.append(set(input().split()))\n\nans = items[0]\nans = ans.intersection(*items[1:])\n\nprint(len(ans))\nprint(\"\\n\".join(sorted(list(ans))))\n
"},{"location":"solutions/#sibice","title":"Sibice","text":"Solution in Python Python
import math\n\nn, w, h = [int(d) for d in input().split()]\nfor _ in range(n):\n    line = int(input())\n    if line <= math.sqrt(w**2 + h**2):\n        print(\"DA\")\n    else:\n        print(\"NE\")\n
"},{"location":"solutions/#sideways-sorting","title":"Sideways Sorting","text":"Solution in Python Python
while True:\n    r, c = [int(d) for d in input().split()]\n    if not r and not c:\n        break\n    s = []\n    for _ in range(r):\n        s.append(input())\n    items = []\n    for i in range(c):\n        items.append(\"\".join(s[j][i] for j in range(r)))\n    items = sorted(items, key=lambda t: t.lower())\n    for i in range(r):\n        print(\"\".join(items[j][i] for j in range(c)))\n
"},{"location":"solutions/#digit-product","title":"Digit Product","text":"Solution in Python Python
def digit_product(x):\n    ans = 1\n    while x:\n        ans *= x % 10 or 1\n        x //= 10\n    return ans\n\n\nx = int(input())\nwhile True:\n    x = digit_product(x)\n    if x < 10:\n        break\nprint(x)\n
"},{"location":"solutions/#simon-says","title":"Simon Says","text":"Solution in Python Python
for _ in range(int(input())):\n    command = input()\n    start = \"simon says \"\n    if command.startswith(start):\n        print(command[len(start) :])\n    else:\n        print()\n
"},{"location":"solutions/#simone","title":"Simone","text":"Solution in Python Python
from collections import Counter\n\nn, k = [int(d) for d in input().split()]\n\ns = Counter(int(d) for d in input().split())\n\nleast = min(s.values())\nif len(s.values()) < k:\n    least = 0\nans = 0\nc = []\nfor i in range(k):\n    if s[i + 1] == least:\n        c.append(str(i + 1))\n        ans += 1\nprint(ans)\nprint(\" \".join(c))\n
"},{"location":"solutions/#simon-says_1","title":"Simon Says","text":"Solution in Python Python
for _ in range(int(input())):\n    command = input()\n    start = \"Simon says \"\n    if command.startswith(start):\n        print(command[len(start) :])\n
"},{"location":"solutions/#simple-addition","title":"Simple Addition","text":"Solution in Python Python
a, b = input(), input()\n\na = a[::-1]\nb = b[::-1]\ni = 0\nans = \"\"\ncarry = 0\nwhile i < len(a) or i < len(b):\n    if i < len(a) and i < len(b):\n        s = int(a[i]) + int(b[i]) + carry\n\n    elif i < len(a):\n        s = int(a[i]) + carry\n\n    else:\n        s = int(b[i]) + carry\n    ans += str(s % 10)\n    carry = s // 10\n    i += 1\nif carry:\n    ans += str(carry)\nprint(ans[::-1])\n\n# or simply\n# print(int(a) + int(b))\n
"},{"location":"solutions/#simple-factoring","title":"Simple Factoring","text":"Solution in Python Python
for _ in range(int(input())):\n    a, b, c = [int(d) for d in input().split()]\n    import math\n\n    if not b**2 - 4 * a * c < 0 and math.sqrt(b**2 - 4 * a * c).is_integer():\n        print(\"YES\")\n    else:\n        print(\"NO\")\n
"},{"location":"solutions/#sith","title":"Sith","text":"Solution in Python Python
_ = input()\na = int(input())\nb = int(input())\ndiff = int(input())\nif diff <= 0:\n    print(\"JEDI\")\nelif a < b:\n    print(\"SITH\")\nelse:\n    print(\"VEIT EKKI\")\n
"},{"location":"solutions/#sjecista","title":"Sjecista","text":"Solution in Python Python
n = int(input())\nprint((n - 3) * (n - 2) * (n - 1) * (n) // 24)\n
"},{"location":"solutions/#skammstofun","title":"Skammst\u00f6fun","text":"Solution in Python Python
_ = input()\nwords = input().split()\nprint(\"\".join([w[0] for w in words if w[0].isupper()]))\n
"},{"location":"solutions/#skener","title":"Skener","text":"Solution in Python Python
r, _, zr, zc = [int(d) for d in input().split()]\nmatrix = []\nfor _ in range(r):\n    matrix.append(input())\n\nans = []\n\nfor row in matrix:\n    for i in range(zr):\n        ans.append(row)\n\nfor row in ans:\n    print(\"\".join([col * zc for col in row]))\n
"},{"location":"solutions/#skocimis","title":"Skocimis","text":"Solutions in 3 languages GoLuaPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var a, b, c int\n    fmt.Scan(&a)\n    fmt.Scan(&b)\n    fmt.Scan(&c)\n    x := b - a\n    y := c - b\n    ans := x\n    if ans < y {\n        ans = y\n    }\n    ans -= 1\n    fmt.Println(ans)\n}\n
a, b, c = io.read(\"*n\", \"*n\", \"*n\")\nprint(math.max(b - a, c - b) - 1)\n
a, b, c = [int(d) for d in input().split()]\nprint(max(b - a, c - b) - 1)\n
"},{"location":"solutions/#turn-it-up","title":"Turn It Up!","text":"Solution in Python Python
volume = 7\nfor _ in range(int(input())):\n    if input() == \"Skru op!\":\n        volume = min(volume + 1, 10)\n    else:\n        volume = max(volume - 1, 0)\nprint(volume)\n
"},{"location":"solutions/#slatkisi","title":"Slatkisi","text":"Solution in Python Python
c, k = [int(d) for d in input().split()]\nd = 10**k\nc = (c // d) * d + (d if (c % d) / d >= 0.5 else 0)\nprint(c)\n
"},{"location":"solutions/#smil","title":"SMIL","text":"Solutions in 2 languages JavaPython
import java.util.Scanner;\n\nclass SMIL {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        String m = s.nextLine();\n        int size = m.length();\n        int i = 0;\n        while (i < size) {\n            if (m.charAt(i) == ':' || m.charAt(i) == ';') {\n                if (i + 1 < size && m.charAt(i + 1) == ')') {\n                    System.out.println(i);\n                    i += 2;\n                    continue;\n                }\n                if (i + 2 < size && m.charAt(i + 1) == '-' && m.charAt(i + 2) == ')') {\n                    System.out.println(i);\n                    i += 3;\n                    continue;\n                }\n            }\n            i += 1;\n        }\n    }\n}\n
s = input()\n\ni = 0\nsize = len(s)\nwhile i < size:\n    if s[i] in [\":\", \";\"]:\n        if i + 1 < size and s[i + 1] == \")\":\n            print(i)\n            i += 2\n            continue\n        if i + 2 < size and s[i + 1] == \"-\" and s[i + 2] == \")\":\n            print(i)\n            i += 3\n            continue\n\n    i += 1\n
"},{"location":"solutions/#soda-slurper","title":"Soda Slurper","text":"Solutions in 2 languages GoPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var e, f, c int\n    fmt.Scan(&e)\n    fmt.Scan(&f)\n    fmt.Scan(&c)\n    total := 0\n    s := e + f\n    for s >= c {\n        total += s / c\n        s = s%c + s/c\n    }\n    fmt.Println(total)\n}\n
e, f, c = [int(d) for d in input().split()]\ntotal = 0\ns = e + f\nwhile s >= c:\n    total += s // c\n    s = s % c + s // c\nprint(total)\n
"},{"location":"solutions/#sok","title":"Sok","text":"Solution in Python Python
a, b, c = [int(d) for d in input().split()]\ni, j, k = [int(d) for d in input().split()]\ns = min(a / i, b / j, c / k)\nprint(a - i * s, b - j * s, c - k * s)\n
"},{"location":"solutions/#some-sum","title":"Some Sum","text":"Solution in Python Python
n = int(input())\nif n == 1:\n    print(\"Either\")\nelif n == 2:\n    print(\"Odd\")\nelif n % 2 == 0:\n    print(\"Even\" if (n / 2) % 2 == 0 else \"Odd\")\nelse:\n    print(\"Either\")\n
"},{"location":"solutions/#sort","title":"Sort","text":"Solution in Python Python
from collections import Counter\n\nn, c = [int(d) for d in input().split()]\nnum = [int(d) for d in input().split()]\n\nfreq = Counter(num)\nprint(\n    \" \".join(\n        [\n            str(d)\n            for d in sorted(\n                num, key=lambda k: (freq[k], n - num.index(k)), reverse=True\n            )\n        ]\n    )\n)\n
"},{"location":"solutions/#sort-of-sorting","title":"Sort of Sorting","text":"Solution in Python Python
first = True\nwhile True:\n    n = int(input())\n    if not n:\n        break\n    else:\n        if not first:\n            print()\n    first = False\n    names = []\n    for _ in range(n):\n        names.append(input())\n    print(\"\\n\".join(sorted(names, key=lambda k: k[:2])))\n
"},{"location":"solutions/#sort-two-numbers","title":"Sort Two Numbers","text":"Solutions in 4 languages C++GoLuaPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int a = 0, b = 0;\n    cin >> a >> b;\n    if (a < b)\n    {\n        cout << a << \" \" << b;\n    }\n    else\n    {\n        cout << b << \" \" << a;\n    }\n}\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var a, b int\n    fmt.Scan(&a)\n    fmt.Scan(&b)\n    if a < b {\n        fmt.Printf(\"%d %d\\n\", a, b)\n    } else {\n        fmt.Printf(\"%d %d\\n\", b, a)\n    }\n}\n
a, b = io.read(\"*n\", \"*n\")\nif a < b then\n    print(a, b)\nelse\n    print(b, a)\nend\n
line = input()\na, b = [int(d) for d in line.split()]\nif a < b:\n    print(a, b)\nelse:\n    print(b, a)\n
"},{"location":"solutions/#sottkvi","title":"S\u00f3ttkv\u00ed","text":"Solutions in 2 languages JavaPython
import java.util.Scanner;\n\nclass Sottkvi {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int n = s.nextInt();\n        int k = s.nextInt();\n        int today = s.nextInt();\n        int ans = 0;\n        for (int i = 0; i < n; i++) {\n            int d = s.nextInt();\n            if (d + 14 - today <= k) {\n                ans += 1;\n            }\n        }\n        System.out.println(ans);\n\n    }\n}\n
n, k, today = [int(d) for d in input().split()]\nres = 0\nfor _ in range(n):\n    d = int(input())\n    if d + 14 - today <= k:\n        res += 1\nprint(res)\n
"},{"location":"solutions/#soylent","title":"Soylent","text":"Solution in Python Python
import math\n\nfor _ in range(int(input())):\n    n = int(input())\n    print(math.ceil(n / 400))\n
"},{"location":"solutions/#space-race","title":"Space Race","text":"Solution in Python Python
n = int(input())\n_ = input()\nd = {}\nfor _ in range(n):\n    entry = input().split()\n    d[entry[0]] = float(entry[-1])\n\nprint(min(d, key=lambda k: d[k]))\n
"},{"location":"solutions/#spavanac","title":"Spavanac","text":"Solutions in 3 languages C++JavaPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int h, m;\n    cin >> h >> m;\n\n    int mm = m - 45;\n    int borrow = 0;\n    if (mm < 0)\n    {\n        mm += 60;\n        borrow = 1;\n    }\n    int hh = h - borrow;\n    if (hh < 0)\n    {\n        hh += 24;\n    }\n    cout << hh << \" \" << mm << endl;\n    return 0;\n}\n
import java.util.Scanner;\n\nclass Spavanac {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int h = s.nextInt();\n        int m = s.nextInt();\n\n        int mm = m - 45;\n        int borrow = 0;\n        if (mm < 0) {\n            mm += 60;\n            borrow = 1;\n        }\n\n        int hh = h - borrow;\n        if (hh < 0) {\n            hh += 24;\n        }\n        System.out.println(hh + \" \" + mm);\n    }\n}\n
h, m = [int(d) for d in input().split()]\n\nmm = m - 45\n\nborrow = 0\nif mm < 0:\n    mm += 60\n    borrow = 1\n\nhh = h - borrow\nif hh < 0:\n    hh += 24\n\nprint(hh, mm)\n
"},{"location":"solutions/#speeding","title":"Speeding","text":"Solution in Python Python
n = int(input())\nmile, time, max_speed = 0, 0, 0\nfor _ in range(n):\n    t, s = [int(d) for d in input().split()]\n    if not t and not s:\n        continue\n    speed = int((s - mile) / (t - time))\n    if speed > max_speed:\n        max_speed = speed\n    mile, time = s, t\nprint(max_speed)\n
"},{"location":"solutions/#speed-limit","title":"Speed Limit","text":"Solution in Python Python
while True:\n    n = int(input())\n    if n == -1:\n        break\n    miles = 0\n    elapsed = 0\n    for _ in range(n):\n        s, t = [int(d) for d in input().split()]\n        miles += s * (t - elapsed)\n        elapsed = t\n    print(f\"{miles} miles\")\n
"},{"location":"solutions/#spelling-bee","title":"Spelling Bee","text":"Solution in Python Python
hexagon = input()\nc = hexagon[0]\nhexagon = set(list(hexagon))\nn = int(input())\nvalid = []\nfor _ in range(n):\n    w = input()\n    if c in w and len(w) >= 4 and set(list(w)) <= hexagon:\n        valid.append(w)\nprint(\"\\n\".join(valid))\n
"},{"location":"solutions/#spritt","title":"Spritt","text":"Solution in Python Python
n, x = [int(d) for d in input().split()]\nfor _ in range(n):\n    x -= int(input())\n    if x < 0:\n        print(\"Neibb\")\n        break\nif x >= 0:\n    print(\"Jebb\")\n
"},{"location":"solutions/#square-peg","title":"Square Peg","text":"Solution in Python Python
l, r = [int(d) for d in input().split()]\nif 2 * (l / 2) ** 2 <= r**2:\n    print(\"fits\")\nelse:\n    print(\"nope\")\n
"},{"location":"solutions/#stafur","title":"Stafur","text":"Solution in Python Python
l = input()\nif l in \"AEIOU\":\n    print(\"Jebb\")\nelif l == \"Y\":\n    print(\"Kannski\")\nelse:\n    print(\"Neibb\")\n
"},{"location":"solutions/#statistics","title":"Statistics","text":"Solution in Python Python
case_num = 0\nwhile True:\n    try:\n        line = input()\n    except:\n        break\n    case_num += 1\n    numbers = [int(d) for d in line.split()[1:]]\n    print(f\"Case {case_num}: {min(numbers)} {max(numbers)} {max(numbers)-min(numbers)}\")\n
"},{"location":"solutions/#sticky-keys","title":"Sticky Keys","text":"Solution in Python Python
message = input()\n\nl = [message[0]]\nfor i in message[1:]:\n    if i != l[-1]:\n        l.append(i)\nprint(\"\".join(l))\n
"},{"location":"solutions/#messy-lists","title":"Messy lists","text":"Solution in Python Python
n = int(input())\na = [int(d) for d in input().split()]\ns = sorted(a)\nprint(sum([i != j for i, j in zip(a, s)]))\n
"},{"location":"solutions/#stopwatch","title":"Stopwatch","text":"Solution in Python Python
n = int(input())\ntimes = []\nfor _ in range(n):\n    times.append(int(input()))\nif n % 2:\n    print(\"still running\")\nelse:\n    seconds = 0\n    for i in range(0, n, 2):\n        seconds += times[i + 1] - times[i]\n    print(seconds)\n
"},{"location":"solutions/#streets-ahead","title":"Streets Ahead","text":"Solution in Python Python
n, q = [int(d) for d in input().split()]\n\ns = {}\nfor i in range(n):\n    s[input()] = i\n\nfor _ in range(q):\n    a, b = input().split()\n    print(abs(s[a] - s[b]) - 1)\n
"},{"location":"solutions/#successful-zoom","title":"Successful Zoom","text":"Solution in Python Python
n = int(input())\nx = [int(d) for d in input().split()]\nfound = False\nfor k in range(1, n // 2 + 1):\n    v = [x[i] for i in range(k - 1, n, k)]\n    if all([v[i] < v[i + 1] for i in range(len(v) - 1)]):\n        print(k)\n        found = True\n        break\nif not found:\n    print(\"ABORT!\")\n
"},{"location":"solutions/#sum-kind-of-problem","title":"Sum Kind of Problem","text":"Solution in Python Python
for _ in range(int(input())):\n    k, n = [int(d) for d in input().split()]\n    s1 = sum(range(1, n + 1))\n    s2 = sum(range(1, 2 * n + 1, 2))\n    s3 = sum(range(2, 2 * (n + 1), 2))\n    print(k, s1, s2, s3)\n
"},{"location":"solutions/#sum-of-the-others","title":"Sum of the Others","text":"Solution in Python Python
while True:\n    try:\n        n = [int(d) for d in input().split()]\n    except:\n        break\n\n    for i in range(len(n)):\n        if n[i] == sum([n[j] for j in range(len(n)) if j != i]):\n            print(n[i])\n            break\n
"},{"location":"solutions/#sum-squared-digits-function","title":"Sum Squared Digits Function","text":"Solution in Python Python
for _ in range(int(input())):\n    k, b, n = [int(d) for d in input().split()]\n    ssd = 0\n    while n:\n        ssd += (n % b) ** 2\n        n //= b\n    print(k, ssd)\n
"},{"location":"solutions/#sun-and-moon","title":"Sun and Moon","text":"Solution in Python Python
sun_years_ago, sun_cycle = [int(v) for v in input().split()]\nmoon_years_ago, moon_cycle = [int(v) for v in input().split()]\n\nfor t in range(1, 5001):\n    if (t + sun_years_ago) % sun_cycle == 0 and (t + moon_years_ago) % moon_cycle == 0:\n        print(t)\n        break\n
"},{"location":"solutions/#symmetric-order","title":"Symmetric Order","text":"Solution in Python Python
set_num = 0\nwhile True:\n    size = int(input())\n    if size == 0:\n        break\n\n    names = []\n    for _ in range(size):\n        names.append(input())\n\n    set_num += 1\n    print(f\"SET {set_num}\")\n\n    top, bottom = [], []\n    for i in range(1, size, 2):\n        bottom.append(names[i])\n    for i in range(0, size, 2):\n        top.append(names[i])\n    names = top + bottom[::-1]\n    for name in names:\n        print(name)\n
"},{"location":"solutions/#synchronizing-lists","title":"Synchronizing Lists","text":"Solution in Python Python
while True:\n    n = int(input())\n    if not n:\n        break\n    a, b = [], []\n    for _ in range(n):\n        a.append(int(input()))\n    for _ in range(n):\n        b.append(int(input()))\n    mapping = dict(zip(sorted(a), sorted(b)))\n    for key in a:\n        print(mapping[key])\n    print()\n
"},{"location":"solutions/#t9-spelling","title":"T9 Spelling","text":"Solution in Python Python
n = int(input())\nmapping = {\n    \"2\": \"abc\",\n    \"3\": \"def\",\n    \"4\": \"ghi\",\n    \"5\": \"jkl\",\n    \"6\": \"mno\",\n    \"7\": \"pqrs\",\n    \"8\": \"tuv\",\n    \"9\": \"wxyz\",\n    \"0\": \" \",\n}\n\nfor i in range(n):\n    ans = []\n    prev = \"\"\n    for c in input():\n        for d, r in mapping.items():\n            if c in r:\n                if d == prev:\n                    ans.append(\" \")\n                ans.append(d * (r.index(c) + 1))\n                prev = d\n                break\n    print(f\"Case #{i+1}: {''.join(ans)}\")\n
"},{"location":"solutions/#tais-formula","title":"Tai's formula","text":"Solution in Python Python
n = int(input())\nt1, v1 = [float(d) for d in input().split()]\ntotal = 0\nfor _ in range(n - 1):\n    t2, v2 = [float(d) for d in input().split()]\n    total += (v1 + v2) * (t2 - t1) / 2\n    t1, v1 = t2, v2\ntotal /= 1000\nprint(total)\n
"},{"location":"solutions/#tajna","title":"Tajna","text":"Solution in Python Python
s = input()\n\nl = len(s)\nr = int(l**0.5)\nwhile l % r:\n    r -= 1\nc = l // r\n\nparts = [s[i : i + r] for i in range(0, l, r)]\n\nprint(\"\".join([\"\".join([row[i] for row in parts]) for i in range(r)]))\n
"},{"location":"solutions/#tarifa","title":"Tarifa","text":"Solutions in 2 languages LuaPython
x = io.read(\"*n\")\nn = io.read(\"*n\")\nlocal used = 0\nfor i = 1, n do\n    used = used + io.read(\"*n\")\nend\nprint(x * (n + 1) - used)\n
x = int(input())\nn = int(input())\nused = 0\nfor _ in range(n):\n    used += int(input())\nprint(x * (n + 1) - used)\n
"},{"location":"solutions/#time-travelling-temperatures","title":"Time Travelling Temperatures","text":"Solution in Python Python
x, y = [int(d) for d in input().split()]\nif y == 1:\n    print(\"ALL GOOD\" if not x else \"IMPOSSIBLE\")\nelse:\n    print(-x / (y - 1))\n
"},{"location":"solutions/#temperature-confusion","title":"Temperature Confusion","text":"Solution in Python Python
import math\n\na, b = [int(d) for d in input().split(\"/\")]\nx, y = 5 * a - 160 * b, 9 * b\ngcd = math.gcd(x, y)\nx //= gcd\ny //= gcd\n\nprint(f\"{x}/{y}\")\n
"},{"location":"solutions/#test-drive","title":"Test Drive","text":"Solution in Python Python
a, b, c = [int(d) for d in input().split()]\nx, y = b - a, c - b\nif x == y:\n    print(\"cruised\")\nelif x * y < 0:\n    print(\"turned\")\nelif abs(y) > abs(x):\n    print(\"accelerated\")\nelse:\n    print(\"braked\")\n
"},{"location":"solutions/#tetration","title":"Tetration","text":"Solution in Python Python
import math\n\nn = float(input())\nprint(f\"{math.pow(n,1/n):.6f}\")\n
"},{"location":"solutions/#thanos","title":"Thanos","text":"Solution in Python Python
for _ in range(int(input())):\n    p, r, f = [int(d) for d in input().split()]\n    y = 0\n    while p <= f:\n        p *= r\n        y += 1\n    print(y)\n
"},{"location":"solutions/#the-grand-adventure","title":"The Grand Adventure","text":"Solution in Python Python
mapping = {\"b\": \"$\", \"t\": \"|\", \"j\": \"*\"}\nfor _ in range(int(input())):\n    a = input()\n    bag = []\n    early_fail = False\n    for i in a:\n        if i in mapping.values():\n            bag.append(i)\n        elif i in mapping:\n            if not bag or bag.pop() != mapping[i]:\n                print(\"NO\")\n                early_fail = True\n                break\n    if not early_fail:\n        print(\"YES\" if not bag else \"NO\")\n
"},{"location":"solutions/#the-last-problem","title":"The Last Problem","text":"Solutions in 3 languages GoLuaPython
package main\n\nimport (\n    \"bufio\"\n    \"fmt\"\n    \"os\"\n)\n\nfunc main() {\n    scanner := bufio.NewScanner(os.Stdin)\n    scanner.Scan()\n    s := scanner.Text()\n    fmt.Println(\"Thank you,\", s+\",\", \"and farewell!\")\n}\n
print(string.format(\"Thank you, %s, and farewell!\", io.read()))\n
print(f\"Thank you, {input()}, and farewell!\")\n
"},{"location":"solutions/#the-plank","title":"The Plank","text":"Solutions in 4 languages C++GoLuaPython
#include <iostream>\n\nusing namespace std;\n\nint f(int n)\n{\n    if (n == 0)\n    {\n        return 1;\n    }\n    else if (n == 1)\n    {\n        return 1;\n    }\n    else if (n == 2)\n    {\n        return 2;\n    }\n    else\n    {\n        return f(n - 1) + f(n - 2) + f(n - 3);\n    }\n}\n\nint main()\n{\n    int n;\n    cin >> n;\n    cout << f(n) << endl;\n    return 0;\n}\n
package main\n\nimport \"fmt\"\n\nfunc f(n int) int {\n    if n == 0 {\n        return 1\n    } else if n == 1 {\n        return 1\n    } else if n == 2 {\n        return 2\n    } else {\n        return f(n-1) + f(n-2) + f(n-3)\n    }\n\n}\n\nfunc main() {\n    var n int\n    fmt.Scan(&n)\n    fmt.Println(f(n))\n}\n
function f(n)\n  if n == 0 then\n    return 1\n  elseif n == 1 then\n    return 1\n  elseif n == 2 then\n    return 2\n  else\n    return f(n - 1) + f(n - 2) + f(n - 3)\n  end\nend\n\nn = io.read(\"*n\")\nprint(f(n))\n
def f(n):\n    if n < 3:\n        return {0: 1, 1: 1, 2: 2}[n]\n    else:\n        return f(n - 1) + f(n - 2) + f(n - 3)\n\n\nprint(f(int(input())))\n
"},{"location":"solutions/#this-aint-your-grandpas-checkerboard","title":"This Ain't Your Grandpa's Checkerboard","text":"Solution in Python Python
n = int(input())\nb = []\nfor _ in range(n):\n    b.append(input())\n\n\ndef check(b, n):\n    for row in b:\n        if row.count(\"W\") != row.count(\"B\"):\n            return False\n\n        for j in range(0, n - 3):\n            if row[j] == row[j + 1] == row[j + 2]:\n                return False\n\n    for i in range(n):\n        col = [\"\".join(row[i]) for row in b]\n\n        if col.count(\"W\") != col.count(\"B\"):\n            return False\n\n        for j in range(0, n - 3):\n            if col[j] == col[j + 1] == col[j + 2]:\n                return False\n\n    return True\n\n\nvalid = check(b, n)\nprint(1 if valid else 0)\n
"},{"location":"solutions/#stuck-in-a-time-loop","title":"Stuck In A Time Loop","text":"Solutions in 2 languages C++Python
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int a;\n    cin >> a;\n    for (int i = 0; i < a; i++)\n    {\n        cout << i + 1 << \" Abracadabra\" << endl;\n    }\n}\n
n = int(input())\nfor i in range(n):\n    print(f\"{i+1} Abracadabra\")\n
"},{"location":"solutions/#title-cost","title":"Title Cost","text":"Solution in Python Python
s, c = input().split()\nc = float(c)\nprint(min(c, len(s)))\n
"},{"location":"solutions/#toflur","title":"T\u00f6flur","text":"Solution in Python Python
n = int(input())\na = sorted([int(d) for d in input().split()])\nscore = sum([(a[j] - a[j + 1]) ** 2 for j in range(n - 1)])\nprint(score)\n
"},{"location":"solutions/#toilet-seat","title":"Toilet Seat","text":"Solution in Python Python
t = input()\n\n\ndef u(pos, preference):\n    if pos == preference == \"U\":\n        return 0\n    elif pos == preference == \"D\":\n        return 1\n    elif pos == \"U\" and preference == \"D\":\n        return 2\n    else:\n        return 1\n\n\ndef l(pos, preference):\n    if pos == preference == \"U\":\n        return 1\n    elif pos == preference == \"D\":\n        return 0\n    elif pos == \"U\" and preference == \"D\":\n        return 1\n    else:\n        return 2\n\n\ndef b(pos, preference):\n    if pos == preference:\n        return 0\n    else:\n        return 1\n\n\npu = [u(pos, preference) for pos, preference in zip(t[0] + \"U\" * (len(t) - 2), t[1:])]\npl = [l(pos, preference) for pos, preference in zip(t[0] + \"D\" * (len(t) - 2), t[1:])]\npb = [b(pos, preference) for pos, preference in zip(t[0] + t[1:-1], t[1:])]\n\nprint(sum(pu))\nprint(sum(pl))\nprint(sum(pb))\n
"},{"location":"solutions/#tolower","title":"ToLower","text":"Solution in Python Python
p, t = [int(d) for d in input().split()]\nscore = 0\nfor _ in range(p):\n    solved = True\n    for _ in range(t):\n        s = input()\n        if solved:\n            s = s[0].lower() + s[1:]\n            if s.lower() == s:\n                continue\n        solved = False\n    if solved:\n        score += 1\nprint(score)\n
"},{"location":"solutions/#tolvunarfringar-telja","title":"T\u00f6lvunarfr\u00e6\u00f0ingar telja","text":"Solutions in 4 languages C++GoLuaPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int n;\n    cin >> n;\n    cout << n - 1 << endl;\n    return 0;\n}\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var n int\n    fmt.Scan(&n)\n    fmt.Println(n-1)\n}\n
n = io.read(\"*n\")\nprint(n - 1)\n
print(int(input()) - 1)\n
"},{"location":"solutions/#tower-construction","title":"Tower Construction","text":"Solution in Python Python
_ = input()\nn = 0\ntop = 0\nfor d in [int(d) for d in input().split()]:\n    if not top or d > top:\n        n += 1\n    top = d\n\nprint(n)\n
"},{"location":"solutions/#touchscreen-keyboard","title":"Touchscreen Keyboard","text":"Solution in Python Python
k = [\n    \"qwertyuiop\",\n    \"asdfghjkl\",\n    \"zxcvbnm\",\n]\n\n\ndef d(a, b):\n    for r1 in range(3):\n        if a in k[r1]:\n            c1 = k[r1].index(a)\n            break\n    for r2 in range(3):\n        if b in k[r2]:\n            c2 = k[r2].index(b)\n            break\n\n    return abs(c1 - c2) + abs(r1 - r2)\n\n\nfor _ in range(int(input())):\n    x, n = input().split()\n    n, w = int(n), []\n\n    for _ in range(n):\n        y = input()\n        dist = sum([d(a, b) for a, b in zip(list(x), list(y))])\n        w.append([y, dist])\n\n    print(\"\\n\".join([f\"{k} {v}\" for k, v in sorted(w, key=lambda k: (k[1], k[0]))]))\n
"},{"location":"solutions/#tram","title":"Tram","text":"Solutions in 2 languages LuaPython
n = io.read(\"*n\")\nd = 0\nfor i = 1, n do\n    x, y = io.read(\"*n\", \"*n\")\n    d = d + 2 * (x - y)\nend\nprint(-d / (2 * n))\n
n = int(input())\nd = 0\nfor _ in range(n):\n    x, y = [int(i) for i in input().split()]\n    d += 2 * (x - y)\nprint(-d / (2 * n))\n
"},{"location":"solutions/#transit-woes","title":"Transit Woes","text":"Solution in Python Python
s, t, n = [int(d) for d in input().split()]\nds = [int(d) for d in input().split()]\nbs = [int(d) for d in input().split()]\ncs = [int(d) for d in input().split()]\n\nfor i in range(n):\n    s += ds[i]\n    if not s % cs[i]:\n        wait_b = 0\n    else:\n        wait_b = cs[i] - s % cs[i]\n    s += wait_b + bs[i]\n\ns += ds[n]\n\nif s <= t:\n    print(\"yes\")\nelse:\n    print(\"no\")\n
"},{"location":"solutions/#tri","title":"Tri","text":"Solution in Python Python
from operator import add, sub, truediv, mul\n\na, b, c = [int(d) for d in input().split()]\nops = {\n    \"+\": add,\n    \"-\": sub,\n    \"*\": mul,\n    \"/\": truediv,\n}\n\nfor op, func in ops.items():\n    if a == func(b, c):\n        print(f\"{a}={b}{op}{c}\")\n        break\n    if func(a, b) == c:\n        print(f\"{a}{op}{b}={c}\")\n
"},{"location":"solutions/#triangle-area","title":"Triangle Area","text":"Solutions in 5 languages C++GoJavaLuaPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int h, b;\n    cin >> h >> b;\n    cout << float(h) * b / 2 << endl;\n    return 0;\n}\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var a, b int\n    fmt.Scan(&a)\n    fmt.Scan(&b)\n    fmt.Println(float32(a) * float32(b) / 2)\n}\n
import java.util.Scanner;\n\nclass TriangleArea {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        float a = s.nextFloat();\n        int b = s.nextInt();\n        System.out.println(a * b / 2);\n    }\n}\n
a, b = io.read(\"*n\", \"*n\")\nprint(a * b / 2)\n
a, b = [int(d) for d in input().split()]\nprint(a * b / 2)\n
"},{"location":"solutions/#trik","title":"Trik","text":"Solution in Python Python
moves = input()\nball = [1, 0, 0]\nfor move in moves:\n    if move == \"A\":\n        ball[0], ball[1] = ball[1], ball[0]\n    if move == \"B\":\n        ball[1], ball[2] = ball[2], ball[1]\n    if move == \"C\":\n        ball[0], ball[2] = ball[2], ball[0]\n\nif ball[0]:\n    print(1)\nelif ball[1]:\n    print(2)\nelse:\n    print(3)\n
"},{"location":"solutions/#triple-texting","title":"Triple Texting","text":"Solution in Python Python
from collections import Counter\n\ns = input()\ntimes = 3\nsize = len(s) // times\nmessages = []\nfor i in range(0, len(s), size):\n    messages.append(s[i : i + size])\n\noriginal = \"\"\nfor i in range(size):\n    chars = [m[i] for m in messages]\n    if len(set(chars)) == 1:\n        original += chars[0]\n    else:\n        c = Counter(chars)\n        original += max(c, key=lambda k: c[k])\n\nprint(original)\n
"},{"location":"solutions/#take-two-stones","title":"Take Two Stones","text":"Solutions in 6 languages GoHaskellJavaJavaScriptKotlinPython
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var n int\n    fmt.Scan(&n)\n    if n%2 == 1 {\n        fmt.Println(\"Alice\")\n    } else {\n        fmt.Println(\"Bob\")\n    }\n}\n
main = do\n    input <- getLine\n    let n = (read input :: Int)\n    if  n `mod` 2  ==  1\n    then putStrLn \"Alice\"\n        else putStrLn \"Bob\"\n
import java.util.Scanner;\n\nclass TakeTwoStones {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int n = s.nextInt();\n        if (n % 2 == 1) {\n            System.out.println(\"Alice\");\n        } else {\n            System.out.println(\"Bob\");\n        }\n    }\n}\n
const readline = require(\"readline\");\nconst rl = readline.createInterface(process.stdin, process.stdout);\n\nrl.question(\"\", (n) => {\n  if (parseInt(n) % 2) {\n    console.log(\"Alice\");\n  } else {\n    console.log(\"Bob\");\n  }\n});\n
fun main() {\n    if (readLine()!!.toInt() % 2 == 1) {\n        println(\"Alice\")\n    } else {\n        println(\"Bob\")\n    }\n}\n
if int(input()) % 2:\n    print(\"Alice\")\nelse:\n    print(\"Bob\")\n
"},{"location":"solutions/#two-sum","title":"Two-sum","text":"Solutions in 4 languages C++GoJavaPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int a, b;\n    cin >> a >> b;\n    cout << a + b << endl;\n    return 0;\n}\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var a, b int\n    fmt.Scan(&a)\n    fmt.Scan(&b)\n    fmt.Println(a + b)\n}\n
import java.util.Scanner;\n\nclass TwoSum {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int a = s.nextInt();\n        int b = s.nextInt();\n        System.out.println(a + b);\n    }\n}\n
line = input()\na, b = [int(d) for d in line.split()]\nprint(a + b)\n
"},{"location":"solutions/#ullen-dullen-doff","title":"\u00dallen d\u00fallen doff","text":"Solution in Python Python
n = int(input())\nnames = input().split()\nif n < 13:\n    i = 13 % n - 1\nelse:\n    i = 12\nprint(names[i])\n
"},{"location":"solutions/#ultimate-binary-watch","title":"Ultimate Binary Watch","text":"Solution in Python Python
t = [int(d) for d in input()]\nb = [f\"{d:b}\".zfill(4) for d in t]\n\nfor r in range(4):\n    row = [\".\" if b[i][r] == \"0\" else \"*\" for i in range(4)]\n    row.insert(2, \" \")\n    print(\" \".join(row))\n
"},{"location":"solutions/#umfer","title":"Umfer\u00f0","text":"Solution in Python Python
m = int(input())\nn = int(input())\ncars = 0\nfor _ in range(n):\n    cars += input().count(\".\")\nprint(cars / (m * n))\n
"},{"location":"solutions/#undead-or-alive","title":"Undead or Alive","text":"Solution in Python Python
s = input()\n\nsmiley = \":)\" in s\n\nfrowny = \":(\" in s\n\nif not frowny and smiley:\n    print(\"alive\")\n\nelif frowny and not smiley:\n    print(\"undead\")\n\nelif frowny and smiley:\n    print(\"double agent\")\n\nelse:\n    print(\"machine\")\n
"},{"location":"solutions/#unlock-pattern","title":"Unlock Pattern","text":"Solution in Python Python
import math\n\n\ndef dist(a, b):\n    return math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)\n\n\ncoords = {}\nfor i in range(3):\n    n = [int(d) for d in input().split()]\n    for j in range(3):\n        coords[n[j]] = (i, j)\n\nvalues = [coords[k] for k in sorted(coords)]\ntotal, prev = 0, 0\nfor i in range(1, 9):\n    total += dist(values[i], values[prev])\n    prev = i\nprint(total)\n
"},{"location":"solutions/#arrangement","title":"Arrangement","text":"Solution in Python Python
import math\n\nn, m = int(input()), int(input())\n\nk = math.ceil(m / n)\n\nfor _ in range(n - (n * k - m)):\n    print(\"*\" * k)\nfor _ in range(n * k - m):\n    print(\"*\" * (k - 1))\n
"},{"location":"solutions/#utf-8","title":"UTF-8","text":"Solution in Python Python
n = int(input())\ns = []\nfor _ in range(n):\n    s.append(input())\n\ni = 0\nnum = 0\nerr = False\nt = [0] * 4\nwhile i < n:\n    a = s[i]\n    if a.startswith(\"0\") and not num:\n        num = 0\n        t[0] += 1\n    elif a.startswith(\"110\") and not num:\n        t[1] += 1\n        num = 1\n    elif a.startswith(\"1110\") and not num:\n        t[2] += 1\n        num = 2\n    elif a.startswith(\"11110\") and not num:\n        t[3] += 1\n        num = 3\n    elif a.startswith(\"10\") and num:\n        num -= 1\n    else:\n        err = True\n        break\n    i += 1\n\nif err or num:\n    print(\"invalid\")\nelse:\n    print(\"\\n\".join([str(d) for d in t]))\n
"},{"location":"solutions/#vaccine-efficacy","title":"Vaccine Efficacy","text":"Solution in Python Python
participants = int(input())\n\nvaccinated = 0\ncontrol = 0\ninfected_control_a = 0\ninfected_vaccinated_a = 0\ninfected_control_b = 0\ninfected_vaccinated_b = 0\ninfected_control_c = 0\ninfected_vaccinated_c = 0\n\nfor p in range(participants):\n    record = input()\n    v, a, b, c = list(record)\n\n    if v == \"N\":\n        control += 1\n    else:\n        vaccinated += 1\n\n    if a == \"Y\":\n        if v == \"N\":\n            infected_control_a += 1\n        else:\n            infected_vaccinated_a += 1\n\n    if b == \"Y\":\n        if v == \"N\":\n            infected_control_b += 1\n        else:\n            infected_vaccinated_b += 1\n\n    if c == \"Y\":\n        if v == \"N\":\n            infected_control_c += 1\n        else:\n            infected_vaccinated_c += 1\n\n\ndef get_vaccine_efficacy(infected_vaccinated, vaccinated, infected_control, control):\n    infection_rate_vaccinated = infected_vaccinated / vaccinated\n    infection_rate_control = infected_control / control\n    return 1 - infection_rate_vaccinated / infection_rate_control\n\n\nvaccine_efficacy = [\n    get_vaccine_efficacy(\n        infected_vaccinated_a,\n        vaccinated,\n        infected_control_a,\n        control,\n    ),\n    get_vaccine_efficacy(\n        infected_vaccinated_b,\n        vaccinated,\n        infected_control_b,\n        control,\n    ),\n    get_vaccine_efficacy(\n        infected_vaccinated_c,\n        vaccinated,\n        infected_control_c,\n        control,\n    ),\n]\n\nfor value in vaccine_efficacy:\n    if value <= 0:\n        print(\"Not Effective\")\n    else:\n        print(f\"{value*100:.6f}\")\n
"},{"location":"solutions/#right-of-way","title":"Right-of-Way","text":"Solution in Python Python
d = [\"North\", \"East\", \"South\", \"West\"]\na, b, c = input().split()\nia = d.index(a)\nib = d.index(b)\nic = d.index(c)\n\nib = (ib - ia) % 4\nic = (ic - ia) % 4\nia -= ia\n\nif ib == 2:\n    print(\"Yes\" if ic == 3 else \"No\")\nelif ib == 1:\n    print(\"Yes\" if ic in [2, 3] else \"No\")\nelse:\n    print(\"No\")\n
"},{"location":"solutions/#variable-arithmetic","title":"Variable Arithmetic","text":"Solution in Python Python
context = {}\nwhile True:\n    s = input()\n    if s == \"0\":\n        break\n\n    if \"=\" in s:\n        x, y = [d.strip() for d in s.split(\"=\")]\n        context[x] = int(y)\n    else:\n        v = [d.strip() for d in s.split(\"+\")]\n        t = 0\n        n = []\n        for d in v:\n            if d.isdigit():\n                t += int(d)\n            elif d in context:\n                t += context[d]\n            else:\n                n.append(d)\n        if len(n) < len(v):\n            n = [str(t)] + n\n        print(\" + \".join(n))\n
"},{"location":"solutions/#veci","title":"Veci","text":"Solution in Python Python
from itertools import permutations\n\nx = input()\n\nvalues = sorted(set([int(\"\".join(v)) for v in permutations(x, len(x))]))\n\nindex = values.index(int(x))\nif index + 1 < len(values):\n    print(values[index + 1])\nelse:\n    print(0)\n
"},{"location":"solutions/#vector-functions","title":"Vector Functions","text":"Solution in C++ C++
#include \"vectorfunctions.h\"\n#include <algorithm>\n\nvoid backwards(std::vector<int> &vec)\n{\n    vec = std::vector<int>(vec.rbegin(), vec.rend());\n}\n\nstd::vector<int> everyOther(const std::vector<int> &vec)\n{\n    std::vector<int> ans;\n\n    for (int i = 0; i < vec.size(); i += 2)\n        ans.push_back(vec[i]);\n\n    return ans;\n}\n\nint smallest(const std::vector<int> &vec)\n{\n    return *min_element(vec.begin(), vec.end());\n}\n\nint sum(const std::vector<int> &vec)\n{\n    int ans = 0;\n\n    for (auto it = begin(vec); it != end(vec); ++it)\n    {\n        ans += *it;\n    }\n\n    return ans;\n}\n\nint veryOdd(const std::vector<int> &suchVector)\n{\n    int ans = 0;\n    for (int i = 1; i < suchVector.size(); i += 2)\n    {\n        if (suchVector[i] % 2 == 1)\n            ans++;\n    }\n\n    return ans;\n}\n
"},{"location":"solutions/#veur-lokaar-heiar","title":"Ve\u00f0ur - Loka\u00f0ar hei\u00f0ar","text":"Solution in Python Python
v = int(input())\nfor _ in range(int(input())):\n    s, k = input().split()\n    if int(k) >= v:\n        print(s, \"opin\")\n    else:\n        print(s, \"lokud\")\n
"},{"location":"solutions/#veur-vindhrai","title":"Ve\u00f0ur - Vindhra\u00f0i","text":"Solution in Python Python
k = float(input())\nif k < 0.3:\n    print(\"logn\")\nelif k < 1.6:\n    print(\"Andvari\")\nelif k < 3.4:\n    print(\"Kul\")\nelif k < 5.5:\n    print(\"Gola\")\nelif k < 8.0:\n    print(\"Stinningsgola\")\nelif k < 10.8:\n    print(\"Kaldi\")\nelif k < 13.9:\n    print(\"Stinningskaldi\")\nelif k < 17.2:\n    print(\"Allhvass vindur\")\nelif k < 20.8:\n    print(\"Hvassvidri\")\nelif k < 24.5:\n    print(\"Stormur\")\nelif k < 28.5:\n    print(\"Rok\")\n\nelif k < 32.7:\n    print(\"Ofsavedur\")\nelse:\n    print(\"Farvidri\")\n
"},{"location":"solutions/#vefjonatjon","title":"Vef\u00fej\u00f3natj\u00f3n","text":"Solution in Python Python
n = int(input())\nparts = [0, 0, 0]\nfor _ in range(n):\n    for i, value in enumerate(input().split()):\n        if value == \"J\":\n            parts[i] += 1\nprint(min(parts))\n
"},{"location":"solutions/#velkomin","title":"Velkomin!","text":"Solutions in 6 languages JavaJavaScriptKotlinLuaPythonRuby
class Velkomin {\n    public static void main(String[] args) {\n        System.out.println(\"VELKOMIN!\");\n    }\n}\n
console.log(\"VELKOMIN!\");\n
fun main() {\n    println(\"VELKOMIN!\")\n}\n
print(\"VELKOMIN!\")\n
print(\"VELKOMIN!\")\n
puts \"VELKOMIN!\"\n
"},{"location":"solutions/#who-wins","title":"Who wins?","text":"Solution in Python Python
board = []\nfor _ in range(3):\n    board.append(input().split())\n\nwinner = \"\"\nfor i in range(3):\n    if board[i][0] == board[i][1] == board[i][2] and board[i][0] != \"_\":\n        winner = board[i][0]\n        break\n    elif board[0][i] == board[1][i] == board[2][i] and board[0][i] != \"_\":\n        winner = board[0][i]\n        break\n\nif board[0][0] == board[1][1] == board[2][2] and board[1][1] != \"_\":\n    winner = board[1][1]\nelif board[0][2] == board[1][1] == board[2][0] and board[1][1] != \"_\":\n    winner = board[1][1]\n\nif not winner:\n    winner = \"ingen\"\nelif winner == \"X\":\n    winner = \"Johan\"\nelse:\n    winner = \"Abdullah\"\n\nprint(f\"{winner} har vunnit\")\n
"},{"location":"solutions/#video-speedup","title":"Video Speedup","text":"Solution in Python Python
n, p, k = [int(d) for d in input().split()]\ni = [int(d) for d in input().split()]\n\nstart, total = 0, 0\nspeed = 1\nfor ti in i:\n    total += speed * (ti - start)\n    start = ti\n    speed += p / 100\ntotal += speed * (k - start)\nprint(f\"{total:.3f}\")\n
"},{"location":"solutions/#visnuningur","title":"Vi\u00f0sn\u00faningur","text":"Solution in Python Python
print(input()[::-1])\n
"},{"location":"solutions/#popular-vote","title":"Popular Vote","text":"Solution in Python Python
for _ in range(int(input())):\n    n = int(input())\n    votes = [int(input()) for _ in range(n)]\n    largest = max(votes)\n    if votes.count(largest) > 1:\n        print(\"no winner\")\n    else:\n        total = sum(votes)\n        winner = votes.index(largest)\n        print(\n            \"majority\" if votes[winner] > total / 2 else \"minority\",\n            \"winner\",\n            winner + 1,\n        )\n
"},{"location":"solutions/#warehouse","title":"Warehouse","text":"Solution in Python Python
for _ in range(int(input())):\n    n = int(input())\n    warehouse = {}\n    for _ in range(n):\n        s = input().split()\n        name, quantity = s[0], int(s[1])\n        if name not in warehouse:\n            warehouse[name] = quantity\n        else:\n            warehouse[name] += quantity\n    print(len(warehouse))\n    names = sorted(warehouse)\n    for name in sorted(\n        warehouse, key=lambda k: (warehouse[k], -names.index(k)), reverse=True\n    ):\n        print(name, warehouse[name])\n
"},{"location":"solutions/#weak-vertices","title":"Weak Vertices","text":"Solution in Python Python
from itertools import combinations\n\nwhile True:\n    n = int(input())\n    if n == -1:\n        break\n    graph = {}\n    for i in range(n):\n        graph[str(i)] = [str(v) for v, e in zip(range(n), input().split()) if e == \"1\"]\n\n    # listing the weak vertices ordered from least to greatest\n    # I guess it means vertex number, not the weakness\n    # keys = sorted(graph, key=lambda x: len(graph[x]), reverse=True)\n\n    keys = graph.keys()\n\n    result = []\n\n    for key in keys:\n        has_triangle = False\n        for a, b in combinations(graph[key], 2):\n            if a in graph[b] and b in graph[a]:\n                has_triangle = True\n                break\n\n        if not has_triangle:\n            result.append(key)\n\n    print(\" \".join(result))\n
"},{"location":"solutions/#wertyu","title":"WERTYU","text":"Solution in Python Python
mapping = {\n    # row 1\n    \"1\": \"`\",\n    \"2\": \"1\",\n    \"3\": \"2\",\n    \"4\": \"3\",\n    \"5\": \"4\",\n    \"6\": \"5\",\n    \"7\": \"6\",\n    \"8\": \"7\",\n    \"9\": \"8\",\n    \"0\": \"9\",\n    \"-\": \"0\",\n    \"=\": \"-\",\n    # row 2\n    \"W\": \"Q\",\n    \"E\": \"W\",\n    \"R\": \"E\",\n    \"T\": \"R\",\n    \"Y\": \"T\",\n    \"U\": \"Y\",\n    \"I\": \"U\",\n    \"O\": \"I\",\n    \"P\": \"O\",\n    \"[\": \"P\",\n    \"]\": \"[\",\n    \"\\\\\": \"]\",\n    # row 3\n    \"S\": \"A\",\n    \"D\": \"S\",\n    \"F\": \"D\",\n    \"G\": \"F\",\n    \"H\": \"G\",\n    \"J\": \"H\",\n    \"K\": \"J\",\n    \"L\": \"K\",\n    \";\": \"L\",\n    \"'\": \";\",\n    # row 4\n    \"X\": \"Z\",\n    \"C\": \"X\",\n    \"V\": \"C\",\n    \"B\": \"V\",\n    \"N\": \"B\",\n    \"M\": \"N\",\n    \",\": \"M\",\n    \".\": \",\",\n    \"/\": \".\",\n    \" \": \" \",\n}\n\nwhile True:\n    try:\n        s = input()\n    except:\n        break\n    print(\"\".join([mapping[c] for c in s]))\n
"},{"location":"solutions/#what-does-the-fox-say","title":"What does the fox say?","text":"Solution in Python Python
for _ in range(int(input())):\n    words = input().split()\n    others = set()\n    while True:\n        line = input()\n        if line == \"what does the fox say?\":\n            break\n        w = line.split()[-1]\n        others.add(w)\n    print(\" \".join(w for w in words if w not in others))\n
"},{"location":"solutions/#which-is-greater","title":"Which is Greater?","text":"Solutions in 5 languages C++GoJavaJavaScriptPython
#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n    int a, b;\n    cin >> a >> b;\n    int ans = (a > b) ? 1 : 0;\n    cout << ans << endl;\n    return 0;\n}\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n    var a, b int\n    fmt.Scan(&a)\n    fmt.Scan(&b)\n    if a > b {\n        fmt.Println(1)\n    } else {\n        fmt.Println(0)\n    }\n}\n
import java.util.Scanner;\n\nclass WhichisGreater {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int a = s.nextInt();\n        int b = s.nextInt();\n        if (a>b){\n            System.out.println(1);\n        }else{\n            System.out.println(0);\n        }\n    }\n}\n
const readline = require(\"readline\");\nconst rl = readline.createInterface(process.stdin, process.stdout);\n\nrl.question(\"\", (line) => {\n  [a, b] = line\n    .trim()\n    .split(\" \")\n    .map((e) => parseInt(e));\n  if (a > b) {\n    console.log(1);\n  } else {\n    console.log(0);\n  }\n});\n
a, b = [int(d) for d in input().split()]\nif a > b:\n    print(1)\nelse:\n    print(0)\n
"},{"location":"solutions/#wizard-of-odds","title":"Wizard of Odds","text":"Solution in Python Python
import math\n\nn, k = [int(d) for d in input().split()]\nans = math.log(n, 2) <= k\nif ans:\n    print(\"Your wish is granted!\")\nelse:\n    print(\"You will become a flying monkey!\")\n
"},{"location":"solutions/#words-for-numbers","title":"Words for Numbers","text":"Solution in Python Python
mapping = {\n    0: \"zero\",\n    1: \"one\",\n    2: \"two\",\n    3: \"three\",\n    4: \"four\",\n    5: \"five\",\n    6: \"six\",\n    7: \"seven\",\n    8: \"eight\",\n    9: \"nine\",\n    10: \"ten\",\n    11: \"eleven\",\n    12: \"twelve\",\n}\n\n\ndef f(d):\n    if d < 13:\n        return mapping[d]\n\n    ones = d % 10\n    if d < 20:\n        return {3: \"thir\", 5: \"fif\", 8: \"eigh\"}.get(ones, mapping[ones]) + \"teen\"\n\n    tens = d // 10\n    return (\n        {2: \"twen\", 3: \"thir\", 4: \"for\", 5: \"fif\", 8: \"eigh\"}.get(tens, mapping[tens])\n        + \"ty\"\n        + (\"-\" + mapping[ones] if ones else \"\")\n    )\n\n\ndef t(w):\n    if w.isdigit():\n        return f(int(w))\n    else:\n        return w\n\n\nwhile True:\n    try:\n        words = input()\n    except:\n        break\n    print(\" \".join([t(w) for w in words.split()]))\n
"},{"location":"solutions/#yin-and-yang-stones","title":"Yin and Yang Stones","text":"Solution in Python Python
s = input()\nprint(1 if s.count(\"W\") == s.count(\"B\") else 0)\n
"},{"location":"solutions/#yoda","title":"Yoda","text":"Solution in Python Python
a, b = input(), input()\nsize = max(len(a), len(b))\n\na = [int(d) for d in a.zfill(size)]\nb = [int(d) for d in b.zfill(size)]\n\nans_a = [d1 for d1, d2 in zip(a, b) if d1 >= d2]\nans_b = [d2 for d1, d2 in zip(a, b) if d2 >= d1]\n\n\ndef f(ans):\n    if not ans:\n        return \"YODA\"\n    else:\n        return int(\"\".join([str(d) for d in ans]))\n\n\nprint(f(ans_a))\nprint(f(ans_b))\n
"},{"location":"solutions/#zamka","title":"Zamka","text":"Solution in Python Python
l, d, x = input(), input(), input()\nl, d, x = int(l), int(d), int(x)\n\nfor i in range(l, d + 1):\n    if sum([int(d) for d in str(i)]) == x:\n        print(i)\n        break\n\nfor i in range(d, l - 1, -1):\n    if sum([int(d) for d in str(i)]) == x:\n        print(i)\n        break\n
"},{"location":"solutions/#stand-on-zanzibar","title":"Stand on Zanzibar","text":"Solutions in 2 languages JavaPython
import java.util.Scanner;\n\nclass StandOnZanzibar {\n    public static void main(String[] args) {\n        Scanner s = new Scanner(System.in);\n        int t = s.nextInt();\n        for (int i = 0; i < t; i++) {\n            int total = 0;\n            int n = 0;\n            int init = 1;\n            while (true) {\n                n = s.nextInt();\n                if (n == 0) {\n                    break;\n                }\n                total += Math.max(n - 2 * init, 0);\n                init = n;\n            }\n            System.out.println(total);\n        }\n    }\n}\n
for _ in range(int(input())):\n    numbers = [int(d) for d in input().split()[:-1]]\n    total = 0\n    for i in range(1, len(numbers)):\n        total += max(numbers[i] - 2 * numbers[i - 1], 0)\n    print(total)\n
"},{"location":"solutions/#un-bear-able-zoo","title":"Un-bear-able Zoo","text":"Solution in Python Python
from collections import Counter\n\nlc = 0\nwhile True:\n    n = int(input())\n    if not n:\n        break\n    lc += 1\n    l = Counter()\n    for _ in range(n):\n        animal = input().lower().split()\n        l[animal[-1]] += 1\n    print(f\"List {lc}:\")\n    print(\"\\n\".join([f\"{k} | {l[k]}\" for k in sorted(l)]))\n
"},{"location":"solutions/#zoom","title":"Zoom","text":"Solution in Python Python
n, k = [int(d) for d in input().split()]\nx = [int(d) for d in input().split()]\nprint(\" \".join([str(x[i]) for i in range(k - 1, n, k)]))\n
"}]} \ No newline at end of file diff --git a/sitemap.xml.gz b/sitemap.xml.gz index 3d2fc1f..81e7f75 100644 Binary files a/sitemap.xml.gz and b/sitemap.xml.gz differ