From 56f01cdcc73bb213d6aa17bc217a217ba1c1f5e3 Mon Sep 17 00:00:00 2001 From: <> Date: Tue, 7 Nov 2023 23:21:33 +0000 Subject: [PATCH] Deployed ba45002 with MkDocs version: 1.5.3 --- index.html | 2 +- search/search_index.json | 2 +- sitemap.xml.gz | Bin 127 -> 127 bytes solutions/index.html | 12984 +++++++++++++++++++------------------ 4 files changed, 6512 insertions(+), 6476 deletions(-) diff --git a/index.html b/index.html index ef00462..3254a5a 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-06

{ "data": { "values": [ {"Difficulty": "Easy", "Count": 423}, {"Difficulty": "Medium", "Count": 29} ] }, "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": 59}, {"Initial": "C", "Count": 39}, {"Initial": "A", "Count": 34}, {"Initial": "P", "Count": 33}, {"Initial": "B", "Count": 31}, {"Initial": "T", "Count": 29}, {"Initial": "M", "Count": 25}, {"Initial": "H", "Count": 20}, {"Initial": "E", "Count": 19}, {"Initial": "D", "Count": 18}, {"Initial": "R", "Count": 18}, {"Initial": "F", "Count": 17}, {"Initial": "G", "Count": 14}, {"Initial": "L", "Count": 12}, {"Initial": "I", "Count": 10}, {"Initial": "O", "Count": 10}, {"Initial": "V", "Count": 10}, {"Initial": "W", "Count": 9}, {"Initial": "J", "Count": 9}, {"Initial": "K", "Count": 9}, {"Initial": "N", "Count": 5}, {"Initial": "Q", "Count": 5}, {"Initial": "U", "Count": 5}, {"Initial": "1", "Count": 2}, {"Initial": "Y", "Count": 2}, {"Initial": "Z", "Count": 2}, {"Initial": "3", "Count": 1}, {"Initial": "4", "Count": 1}, {"Initial": "9", "Count": 1}, {"Initial": "Ö", "Count": 1}, {"Initial": "Ó", "Count": 1}, {"Initial": "Ú", "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": 449}, {"Language": "Go", "Count": 36}, {"Language": "Java", "Count": 25}, {"Language": "C++", "Count": 16}, {"Language": "JavaScript", "Count": 8}, {"Language": "Haskell", "Count": 3}, {"Language": "Kotlin", "Count": 2}, {"Language": "Rust", "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-06
Created: 2022-12-05
Skip to content

Logo

Kattis

Summary by Difficulty

as of 2023-11-07

{ "data": { "values": [ {"Difficulty": "Easy", "Count": 427}, {"Difficulty": "Medium", "Count": 27} ] }, "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": 59}, {"Initial": "C", "Count": 39}, {"Initial": "A", "Count": 34}, {"Initial": "P", "Count": 33}, {"Initial": "B", "Count": 31}, {"Initial": "T", "Count": 30}, {"Initial": "M", "Count": 25}, {"Initial": "H", "Count": 20}, {"Initial": "E", "Count": 19}, {"Initial": "D", "Count": 18}, {"Initial": "R", "Count": 18}, {"Initial": "F", "Count": 17}, {"Initial": "G", "Count": 15}, {"Initial": "L", "Count": 12}, {"Initial": "I", "Count": 10}, {"Initial": "O", "Count": 10}, {"Initial": "V", "Count": 10}, {"Initial": "W", "Count": 9}, {"Initial": "J", "Count": 9}, {"Initial": "K", "Count": 9}, {"Initial": "N", "Count": 5}, {"Initial": "Q", "Count": 5}, {"Initial": "U", "Count": 5}, {"Initial": "1", "Count": 2}, {"Initial": "Y", "Count": 2}, {"Initial": "Z", "Count": 2}, {"Initial": "3", "Count": 1}, {"Initial": "4", "Count": 1}, {"Initial": "9", "Count": 1}, {"Initial": "Ö", "Count": 1}, {"Initial": "Ó", "Count": 1}, {"Initial": "Ú", "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": 451}, {"Language": "Go", "Count": 36}, {"Language": "Java", "Count": 25}, {"Language": "C++", "Count": 16}, {"Language": "JavaScript", "Count": 8}, {"Language": "Haskell", "Count": 3}, {"Language": "Kotlin", "Count": 2}, {"Language": "Rust", "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-07
Created: 2022-12-05
\ No newline at end of file diff --git a/search/search_index.json b/search/search_index.json index 9059c6d..a99870f 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-06

{ \"data\": { \"values\": [ {\"Difficulty\": \"Easy\", \"Count\": 423}, {\"Difficulty\": \"Medium\", \"Count\": 29} ] }, \"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\": 59}, {\"Initial\": \"C\", \"Count\": 39}, {\"Initial\": \"A\", \"Count\": 34}, {\"Initial\": \"P\", \"Count\": 33}, {\"Initial\": \"B\", \"Count\": 31}, {\"Initial\": \"T\", \"Count\": 29}, {\"Initial\": \"M\", \"Count\": 25}, {\"Initial\": \"H\", \"Count\": 20}, {\"Initial\": \"E\", \"Count\": 19}, {\"Initial\": \"D\", \"Count\": 18}, {\"Initial\": \"R\", \"Count\": 18}, {\"Initial\": \"F\", \"Count\": 17}, {\"Initial\": \"G\", \"Count\": 14}, {\"Initial\": \"L\", \"Count\": 12}, {\"Initial\": \"I\", \"Count\": 10}, {\"Initial\": \"O\", \"Count\": 10}, {\"Initial\": \"V\", \"Count\": 10}, {\"Initial\": \"W\", \"Count\": 9}, {\"Initial\": \"J\", \"Count\": 9}, {\"Initial\": \"K\", \"Count\": 9}, {\"Initial\": \"N\", \"Count\": 5}, {\"Initial\": \"Q\", \"Count\": 5}, {\"Initial\": \"U\", \"Count\": 5}, {\"Initial\": \"1\", \"Count\": 2}, {\"Initial\": \"Y\", \"Count\": 2}, {\"Initial\": \"Z\", \"Count\": 2}, {\"Initial\": \"3\", \"Count\": 1}, {\"Initial\": \"4\", \"Count\": 1}, {\"Initial\": \"9\", \"Count\": 1}, {\"Initial\": \"\u00d6\", \"Count\": 1}, {\"Initial\": \"\u00d3\", \"Count\": 1}, {\"Initial\": \"\u00da\", \"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\": 449}, {\"Language\": \"Go\", \"Count\": 36}, {\"Language\": \"Java\", \"Count\": 25}, {\"Language\": \"C++\", \"Count\": 16}, {\"Language\": \"JavaScript\", \"Count\": 8}, {\"Language\": \"Haskell\", \"Count\": 3}, {\"Language\": \"Kotlin\", \"Count\": 2}, {\"Language\": \"Rust\", \"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":"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/#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/#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/#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/#evening-out-1","title":"Evening Out 1","text":"Solution in Python Python
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/#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/#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 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.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
"},{"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/#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 8 languages C++GoHaskellJavaJavaScriptKotlinPythonRust
#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
console.log(\"Hello World!\");\n
fun main() {\n    println(\"Hello World!\")\n}\n
print(\"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/#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":"Solution in Python Python
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/#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/#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":"Solution in Python Python
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/#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/#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 4 languages C++GoJavaPython
#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, 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 3 languages GoJavaPython
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
_, 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 3 languages GoJavaPython
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 = 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 2 languages GoPython
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 = 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/#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 2 languages GoPython
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 = [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 3 languages C++GoPython
#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
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":"Solution in Python Python
x = int(input())\nn = int(input())\nused = 0\nfor _ in range(n):\n    used += int(input())\nprint(x * (n + 1) - used)\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 2 languages GoPython
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(f\"Thank you, {input()}, and farewell!\")\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/#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/#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 4 languages C++GoJavaPython
#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 = [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/#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":"Solution in Python Python
print(\"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-07

{ \"data\": { \"values\": [ {\"Difficulty\": \"Easy\", \"Count\": 427}, {\"Difficulty\": \"Medium\", \"Count\": 27} ] }, \"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\": 59}, {\"Initial\": \"C\", \"Count\": 39}, {\"Initial\": \"A\", \"Count\": 34}, {\"Initial\": \"P\", \"Count\": 33}, {\"Initial\": \"B\", \"Count\": 31}, {\"Initial\": \"T\", \"Count\": 30}, {\"Initial\": \"M\", \"Count\": 25}, {\"Initial\": \"H\", \"Count\": 20}, {\"Initial\": \"E\", \"Count\": 19}, {\"Initial\": \"D\", \"Count\": 18}, {\"Initial\": \"R\", \"Count\": 18}, {\"Initial\": \"F\", \"Count\": 17}, {\"Initial\": \"G\", \"Count\": 15}, {\"Initial\": \"L\", \"Count\": 12}, {\"Initial\": \"I\", \"Count\": 10}, {\"Initial\": \"O\", \"Count\": 10}, {\"Initial\": \"V\", \"Count\": 10}, {\"Initial\": \"W\", \"Count\": 9}, {\"Initial\": \"J\", \"Count\": 9}, {\"Initial\": \"K\", \"Count\": 9}, {\"Initial\": \"N\", \"Count\": 5}, {\"Initial\": \"Q\", \"Count\": 5}, {\"Initial\": \"U\", \"Count\": 5}, {\"Initial\": \"1\", \"Count\": 2}, {\"Initial\": \"Y\", \"Count\": 2}, {\"Initial\": \"Z\", \"Count\": 2}, {\"Initial\": \"3\", \"Count\": 1}, {\"Initial\": \"4\", \"Count\": 1}, {\"Initial\": \"9\", \"Count\": 1}, {\"Initial\": \"\u00d6\", \"Count\": 1}, {\"Initial\": \"\u00d3\", \"Count\": 1}, {\"Initial\": \"\u00da\", \"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\": 451}, {\"Language\": \"Go\", \"Count\": 36}, {\"Language\": \"Java\", \"Count\": 25}, {\"Language\": \"C++\", \"Count\": 16}, {\"Language\": \"JavaScript\", \"Count\": 8}, {\"Language\": \"Haskell\", \"Count\": 3}, {\"Language\": \"Kotlin\", \"Count\": 2}, {\"Language\": \"Rust\", \"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":"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/#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/#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/#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/#evening-out-1","title":"Evening Out 1","text":"Solution in Python Python
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/#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/#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 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.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
"},{"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 8 languages C++GoHaskellJavaJavaScriptKotlinPythonRust
#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
console.log(\"Hello World!\");\n
fun main() {\n    println(\"Hello World!\")\n}\n
print(\"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/#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":"Solution in Python Python
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/#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/#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":"Solution in Python Python
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/#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/#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 4 languages C++GoJavaPython
#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, 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 3 languages GoJavaPython
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
_, 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 3 languages GoJavaPython
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 = 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 2 languages GoPython
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 = 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/#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 2 languages GoPython
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 = [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 3 languages C++GoPython
#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
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":"Solution in Python Python
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 2 languages GoPython
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(f\"Thank you, {input()}, and farewell!\")\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/#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/#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 4 languages C++GoJavaPython
#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 = [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/#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":"Solution in Python Python
print(\"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 44141ec0a495c15ab1d86bf566c53ab14e69f1f4..dea5b7089eb1c663a01284170bd0d0a233aeee6c 100644 GIT binary patch delta 13 Ucmb=gXP58h;HW(2HIcmn03BxpSpWb4 delta 13 Ucmb=gXP58h;9yGjoXB1Q02rzRegFUf diff --git a/solutions/index.html b/solutions/index.html index cbf30c5..e6b0df3 100644 --- a/solutions/index.html +++ b/solutions/index.html @@ -9,7 +9,7 @@ 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

Solutions

🟡 10 Kinds of People

Solution in Python
 1
+                   

Solutions

🟡 10 Kinds of People

Solution in Python
 1
  2
  3
  4
@@ -338,7 +338,7 @@
             break
     if not solved:
         print("no solution")
-

🟡 99 Problems

Solution in Python
 1
+

🟢 99 Problems

Solution in Python
 1
  2
  3
  4
@@ -3006,7 +3006,7 @@
     print(1)
 else:
     print(0)
-

🟢 Crne

Solutions in 2 languages
 1
+

🟡 Crne

Solutions in 2 languages
 1
  2
  3
  4
@@ -4894,7 +4894,7 @@
         start = guess + 1
     else:
         end = guess
-

🟢 Watch Out For Those Hailstones!

Solutions in 2 languages
 1
+

🟢 Guess Who

Solution in Python
 1
  2
  3
  4
@@ -4907,73 +4907,79 @@
 11
 12
 13
-14
-15
-16
-17
-18
-19
-20
-21
package main
-
-import (
-    "fmt"
-)
-
-func h(n int) int {
-    if n == 1 {
-        return 1
-    } else if n%2 == 0 {
-        return n + h(n/2)
-    } else {
-        return n + h(3*n+1)
-    }
-}
-
-func main() {
-    var n int
-    fmt.Scan(&n)
-    fmt.Println(h(n))
-}
-
1
-2
-3
-4
-5
-6
-7
-8
-9
def h(n):
-    if n == 1:
-        return 1
-    else:
-        return n + (h(n // 2) if n % 2 == 0 else h(3 * n + 1))
+14
n, m, q = [int(d) for d in input().split()]
+M = []
+for _ in range(n):
+    M.append(input())
+Q = []
+for _ in range(q):
+    Q.append(input().split())
+ans = [all([c[int(i) - 1] == v for i, v in Q]) for c in M]
+if sum(ans) > 1:
+    print("ambiguous")
+    print(sum(ans))
+else:
+    print("unique")
+    print(ans.index(True) + 1)
+

🟢 Watch Out For Those Hailstones!

Solutions in 2 languages
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
package main
+
+import (
+    "fmt"
+)
 
-
-n = int(input())
-print(h(n))
-

🟢 Hailstone Sequences

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
n = int(input())
-s = [n]
-while True:
-    v = s[-1]
-    if v == 1:
-        break
-    elif v % 2 == 0:
-        s.append(v // 2)
-    else:
-        s.append(3 * v + 1)
-print(len(s))
-
Solution in Python
 1
+func h(n int) int {
+    if n == 1 {
+        return 1
+    } else if n%2 == 0 {
+        return n + h(n/2)
+    } else {
+        return n + h(3*n+1)
+    }
+}
+
+func main() {
+    var n int
+    fmt.Scan(&n)
+    fmt.Println(h(n))
+}
+
1
+2
+3
+4
+5
+6
+7
+8
+9
def h(n):
+    if n == 1:
+        return 1
+    else:
+        return n + (h(n // 2) if n % 2 == 0 else h(3 * n + 1))
+
+
+n = int(input())
+print(h(n))
+

🟢 Hailstone Sequences

Solution in Python
 1
  2
  3
  4
@@ -4983,32 +4989,18 @@
  8
  9
 10
-11
-12
-13
-14
-15
-16
-17
-18
import math
-
+11
n = int(input())
+s = [n]
 while True:
-    try:
-        r, x, y = [float(d) for d in input().split()]
-    except:
-        break
-    if x**2 + y**2 >= r**2:
-        print("miss")
-    else:
-        # https://mathworld.wolfram.com/CircularSegment.html
-        d = math.sqrt(x**2 + y**2)
-        h = r - d
-        a = math.acos((r - h) / r)
-        t = (r - h) * math.sqrt(2 * r * h - h * h)
-        p = (r**2) * a
-        s = p - t
-        print(math.pi * (r**2) - s, s)
-

🟢 Hanging Out on the Terrace

Solution in Python
 1
+    v = s[-1]
+    if v == 1:
+        break
+    elif v % 2 == 0:
+        s.append(v // 2)
+    else:
+        s.append(3 * v + 1)
+print(len(s))
+
Solution in Python
 1
  2
  3
  4
@@ -5020,20 +5012,30 @@
 10
 11
 12
-13
l, x = [int(d) for d in input().split()]
-o, r = 0, 0
-for _ in range(x):
-    action, n = input().split()
-    n = int(n)
-    if action == "leave":
-        o -= n
-    elif action == "enter":
-        if o + n > l:
-            r += 1
-        else:
-            o += n
-print(r)
-

🟢 Hangman

Solution in Python
 1
+13
+14
+15
+16
+17
+18
import math
+
+while True:
+    try:
+        r, x, y = [float(d) for d in input().split()]
+    except:
+        break
+    if x**2 + y**2 >= r**2:
+        print("miss")
+    else:
+        # https://mathworld.wolfram.com/CircularSegment.html
+        d = math.sqrt(x**2 + y**2)
+        h = r - d
+        a = math.acos((r - h) / r)
+        t = (r - h) * math.sqrt(2 * r * h - h * h)
+        p = (r**2) * a
+        s = p - t
+        print(math.pi * (r**2) - s, s)
+

🟢 Hanging Out on the Terrace

Solution in Python
 1
  2
  3
  4
@@ -5045,134 +5047,140 @@
 10
 11
 12
-13
-14
-15
-16
-17
word = set(list(input()))
-guess = input()
-tries = 0
-correct = 0
-for c in guess:
-    if c in word:
-        correct += 1
-    else:
-        tries += 1
-
-    if correct == len(word):
-        break
-
-if tries >= 10:
-    print("LOSE")
-else:
-    print("WIN")
-

🟢 Harshad Numbers

Solution in Python
1
-2
-3
-4
-5
-6
-7
n = int(input())
-while True:
-    sd = sum([int(d) for d in str(n)])
-    if not n % sd:
-        break
-    n += 1
-print(n)
-

🟢 Haughty Cuisine

Solution in Python
1
+13
l, x = [int(d) for d in input().split()]
+o, r = 0, 0
+for _ in range(x):
+    action, n = input().split()
+    n = int(n)
+    if action == "leave":
+        o -= n
+    elif action == "enter":
+        if o + n > l:
+            r += 1
+        else:
+            o += n
+print(r)
+

🟢 Hangman

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
word = set(list(input()))
+guess = input()
+tries = 0
+correct = 0
+for c in guess:
+    if c in word:
+        correct += 1
+    else:
+        tries += 1
+
+    if correct == len(word):
+        break
+
+if tries >= 10:
+    print("LOSE")
+else:
+    print("WIN")
+

🟢 Harshad Numbers

Solution in Python
1
 2
 3
 4
 5
 6
-7
-8
from random import randint
-
-n = int(input())
-menu = []
-for _ in range(n):
-    menu.append(input().split())
-
-print("\n".join(menu[randint(0, n - 1)]))
-

🟢 Head Guard

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
while True:
-    try:
-        s = input()
-    except:
-        break
-    parts = []
-    prev, t = s[0], 1
-    for c in s[1:]:
-        if c != prev:
-            parts.append((prev, t))
-            t = 1
-            prev = c
-        else:
-            t += 1
-    parts.append((prev, t))
-    print("".join([f"{v}{k}" for k, v in parts]))
-

🟢 Heart Rate

Solution in Python
1
-2
-3
-4
-5
-6
for _ in range(int(input())):
-    b, p = [float(d) for d in input().split()]
-    min_abpm = 60 / p * (b - 1)
-    bpm = 60 * b / p
-    max_abpm = 60 / p * (b + 1)
-    print(f"{min_abpm:.4f} {bpm:.4f} {max_abpm:.4f}")
-

🟢 Homework

Solution in Python
1
+7
n = int(input())
+while True:
+    sd = sum([int(d) for d in str(n)])
+    if not n % sd:
+        break
+    n += 1
+print(n)
+

🟢 Haughty Cuisine

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
from random import randint
+
+n = int(input())
+menu = []
+for _ in range(n):
+    menu.append(input().split())
+
+print("\n".join(menu[randint(0, n - 1)]))
+

🟢 Head Guard

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
while True:
+    try:
+        s = input()
+    except:
+        break
+    parts = []
+    prev, t = s[0], 1
+    for c in s[1:]:
+        if c != prev:
+            parts.append((prev, t))
+            t = 1
+            prev = c
+        else:
+            t += 1
+    parts.append((prev, t))
+    print("".join([f"{v}{k}" for k, v in parts]))
+

🟢 Heart Rate

Solution in Python
1
 2
 3
 4
 5
-6
-7
-8
-9
total = 0
-parts = input().split(";")
-for part in parts:
-    ranges = part.split("-")
-    if len(ranges) == 1:
-        total += 1
-    else:
-        total += len(range(int(ranges[0]), int(ranges[1]))) + 1
-print(total)
-

🟢 Heir's Dilemma

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
l, h = [int(d) for d in input().split()]
-total = 0
-for i in range(l, h + 1):
-    digits = set(str(i))
-    if len(digits) != 6 or "0" in digits:
-        continue
-    if not all([i % int(d) == 0 for d in digits]):
-        continue
-    total += 1
-print(total)
-

🟢 Heliocentric

Solution in Python
 1
+6
for _ in range(int(input())):
+    b, p = [float(d) for d in input().split()]
+    min_abpm = 60 / p * (b - 1)
+    bpm = 60 * b / p
+    max_abpm = 60 / p * (b + 1)
+    print(f"{min_abpm:.4f} {bpm:.4f} {max_abpm:.4f}")
+

🟢 Homework

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
+9
total = 0
+parts = input().split(";")
+for part in parts:
+    ranges = part.split("-")
+    if len(ranges) == 1:
+        total += 1
+    else:
+        total += len(range(int(ranges[0]), int(ranges[1]))) + 1
+print(total)
+

🟢 Heir's Dilemma

Solution in Python
 1
  2
  3
  4
@@ -5181,45 +5189,17 @@
  7
  8
  9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
def offset(d, b):
-    return (b - d % b) % b
-
-
-cc = 1
-while True:
-    try:
-        a, b = [int(d) for d in input().split()]
-    except:
-        break
-
-    offset_a, offset_b = offset(a, 365), offset(b, 687)
-
-    if offset_a == offset_b:
-        print(f"Case {cc}:", offset_a)
-    else:
-        t = offset_a
-        while True:
-            t += 365
-            if (offset(t, 687) + offset_b) % 687 == 0:
-                break
-        print(f"Case {cc}:", t)
-
-    cc += 1
-

🟢 Hello World!

Solutions in 8 languages
l, h = [int(d) for d in input().split()]
+total = 0
+for i in range(l, h + 1):
+    digits = set(str(i))
+    if len(digits) != 6 or "0" in digits:
+        continue
+    if not all([i % int(d) == 0 for d in digits]):
+        continue
+    total += 1
+print(total)
+

🟢 Heliocentric

Solution in Python
 1
  2
  3
  4
@@ -5228,115 +5208,123 @@
  7
  8
  9
-10
#include <iostream>
-
-using namespace std;
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
def offset(d, b):
+    return (b - d % b) % b
+
 
-int main()
-{
-    cout << "Hello World!" << endl;
-
-    return 0;
-}
-
1
-2
-3
-4
-5
-6
-7
package main
+cc = 1
+while True:
+    try:
+        a, b = [int(d) for d in input().split()]
+    except:
+        break
+
+    offset_a, offset_b = offset(a, 365), offset(b, 687)
+
+    if offset_a == offset_b:
+        print(f"Case {cc}:", offset_a)
+    else:
+        t = offset_a
+        while True:
+            t += 365
+            if (offset(t, 687) + offset_b) % 687 == 0:
+                break
+        print(f"Case {cc}:", t)
+
+    cc += 1
+

🟢 Hello World!

Solutions in 8 languages
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
#include <iostream>
 
-import "fmt"
+using namespace std;
 
-func main() {
-    fmt.Println("Hello World!")
-}
-
main = putStrLn "Hello World!"
-
1
-2
-3
-4
-5
class HelloWorld {
-    public static void main(String[] args) {
-        System.out.println("Hello World!");
-    }
-}
-
console.log("Hello World!");
-
1
-2
-3
fun main() {
-    println("Hello World!")
-}
-
print("Hello World!")
-
1
-2
-3
fn main() {
-    println!("Hello World!");
-}
-

🟢 Help a PhD candidate out!

Solution in Python
1
+int main()
+{
+    cout << "Hello World!" << endl;
+
+    return 0;
+}
+
1
+2
+3
+4
+5
+6
+7
package main
+
+import "fmt"
+
+func main() {
+    fmt.Println("Hello World!")
+}
+
main = putStrLn "Hello World!"
+
1
+2
+3
+4
+5
class HelloWorld {
+    public static void main(String[] args) {
+        System.out.println("Hello World!");
+    }
+}
+
console.log("Hello World!");
+
1
+2
+3
fun main() {
+    println("Hello World!")
+}
+
print("Hello World!")
+
1
 2
-3
-4
-5
-6
-7
-8
n = int(input())
-for _ in range(n):
-    line = input()
-    parts = line.split("+")
-    if len(parts) == 1:
-        print("skipped")
-    else:
-        print(int(parts[0]) + int(parts[1]))
-

🟢 Herman

Solution in Python
1
+3
fn main() {
+    println!("Hello World!");
+}
+

🟢 Help a PhD candidate out!

Solution in Python
1
 2
 3
 4
-5
import math
-
-r = int(input())
-print(f"{math.pi*r*r:.6f}")
-print(2 * r * r)
-

🟢 Hissing Microphone

Solutions in 3 languages
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
#include <iostream>
+5
+6
+7
+8
n = int(input())
+for _ in range(n):
+    line = input()
+    parts = line.split("+")
+    if len(parts) == 1:
+        print("skipped")
+    else:
+        print(int(parts[0]) + int(parts[1]))
+

🟢 Herman

Solution in Python
1
+2
+3
+4
+5
import math
 
-using namespace std;
-
-int main()
-{
-    string a;
-    cin >> a;
-
-    if (a.find("ss") == -1)
-    {
-        cout << "no hiss" << endl;
-    }
-    else
-    {
-        cout << "hiss" << endl;
-    }
-
-    return 0;
-}
-
 1
+r = int(input())
+print(f"{math.pi*r*r:.6f}")
+print(2 * r * r)
+

🟢 Hissing Microphone

Solutions in 3 languages
 1
  2
  3
  4
@@ -5345,147 +5333,165 @@
  7
  8
  9
-10
const readline = require("readline");
-const rl = readline.createInterface(process.stdin, process.stdout);
-
-rl.question("", (line) => {
-  if (line.includes("ss")) {
-    console.log("hiss");
-  } else {
-    console.log("no hiss");
-  }
-});
-
1
-2
-3
-4
-5
a = input()
-if "ss" in a:
-    print("hiss")
-else:
-    print("no hiss")
-

🟢 Hitting the Targets

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
def in_rectangle(x1, y1, x2, y2, x, y):
-    x1, x2 = min(x1, x2), max(x1, x2)
-    y1, y2 = min(y1, y2), max(y1, y2)
-    if x in range(x1, x2 + 1) and y in range(y1, y2 + 1):
-        return True
-    else:
-        return False
-
-
-def in_circle(x0, y0, r, x, y):
-    return (x0 - x) ** 2 + (y0 - y) ** 2 <= r**2
-
-
-m = int(input())
-shapes = []
-for _ in range(m):
-    values = input().split()
-    shapes.append((values[0], *[int(d) for d in values[1:]]))
-
-n = int(input())
-for _ in range(n):
-    total = 0
-    x, y = [int(d) for d in input().split()]
-    for shape in shapes:
-        if shape[0] == "rectangle":
-            total += in_rectangle(*shape[1:], x, y)
-        elif shape[0] == "circle":
-            total += in_circle(*shape[1:], x, y)
-    print(total)
-

🟢 Hot Hike

Solution in Python
1
-2
-3
-4
-5
-6
n = int(input())
-t = [int(d) for d in input().split()]
-order = sorted(range(n - 2), key=lambda k: max(t[k], t[k + 2]))
-d = order[0]
-v = max(t[d], t[d + 2])
-print(d + 1, v)
-

🟢 Hraðgreining

Solutions in 2 languages
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
package main
-
-import (
-    "fmt"
-    "strings"
-)
-
-func main() {
-    var s string
-    fmt.Scan(&s)
-    if strings.Contains(s, "COV") {
-        fmt.Println("Veikur!")
-    } else {
-        fmt.Println("Ekki veikur!")
-    }
-}
-
print("Veikur!" if "COV" in input() else "Ekki veikur!")
-

🟢 The Amazing Human Cannonball

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
import math
-
-for _ in range(int(input())):
-    v0, a, x1, h1, h2 = [float(d) for d in input().split()]
-    a = math.radians(a)
-    t = x1 / (v0 * math.cos(a))
-    y = v0 * t * math.sin(a) - 0.5 * 9.81 * (t**2)
-    if y < h1 + 1 or y > h2 - 1:
-        print("Not Safe")
-    else:
-        print("Safe")
-

🟢 Hvert Skal Mæta?

Solution in Python
 1
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
#include <iostream>
+
+using namespace std;
+
+int main()
+{
+    string a;
+    cin >> a;
+
+    if (a.find("ss") == -1)
+    {
+        cout << "no hiss" << endl;
+    }
+    else
+    {
+        cout << "hiss" << endl;
+    }
+
+    return 0;
+}
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
const readline = require("readline");
+const rl = readline.createInterface(process.stdin, process.stdout);
+
+rl.question("", (line) => {
+  if (line.includes("ss")) {
+    console.log("hiss");
+  } else {
+    console.log("no hiss");
+  }
+});
+
1
+2
+3
+4
+5
a = input()
+if "ss" in a:
+    print("hiss")
+else:
+    print("no hiss")
+

🟢 Hitting the Targets

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
def in_rectangle(x1, y1, x2, y2, x, y):
+    x1, x2 = min(x1, x2), max(x1, x2)
+    y1, y2 = min(y1, y2), max(y1, y2)
+    if x in range(x1, x2 + 1) and y in range(y1, y2 + 1):
+        return True
+    else:
+        return False
+
+
+def in_circle(x0, y0, r, x, y):
+    return (x0 - x) ** 2 + (y0 - y) ** 2 <= r**2
+
+
+m = int(input())
+shapes = []
+for _ in range(m):
+    values = input().split()
+    shapes.append((values[0], *[int(d) for d in values[1:]]))
+
+n = int(input())
+for _ in range(n):
+    total = 0
+    x, y = [int(d) for d in input().split()]
+    for shape in shapes:
+        if shape[0] == "rectangle":
+            total += in_rectangle(*shape[1:], x, y)
+        elif shape[0] == "circle":
+            total += in_circle(*shape[1:], x, y)
+    print(total)
+

🟢 Hot Hike

Solution in Python
1
+2
+3
+4
+5
+6
n = int(input())
+t = [int(d) for d in input().split()]
+order = sorted(range(n - 2), key=lambda k: max(t[k], t[k + 2]))
+d = order[0]
+v = max(t[d], t[d + 2])
+print(d + 1, v)
+

🟢 Hraðgreining

Solutions in 2 languages
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
package main
+
+import (
+    "fmt"
+    "strings"
+)
+
+func main() {
+    var s string
+    fmt.Scan(&s)
+    if strings.Contains(s, "COV") {
+        fmt.Println("Veikur!")
+    } else {
+        fmt.Println("Ekki veikur!")
+    }
+}
+
print("Veikur!" if "COV" in input() else "Ekki veikur!")
+

🟢 The Amazing Human Cannonball

Solution in Python
 1
  2
  3
  4
@@ -5495,134 +5501,128 @@
  8
  9
 10
-11
-12
-13
-14
-15
mapping = {
-    "Reykjavik": "Reykjavik",
-    "Kopavogur": "Reykjavik",
-    "Hafnarfjordur": "Reykjavik",
-    "Reykjanesbaer": "Reykjavik",
-    "Akureyri": "Akureyri",
-    "Gardabaer": "Reykjavik",
-    "Mosfellsbaer": "Reykjavik",
-    "Arborg": "Reykjavik",
-    "Akranes": "Reykjavik",
-    "Fjardabyggd": "Akureyri",
-    "Mulathing": "Akureyri",
-    "Seltjarnarnes": "Reykjavik",
-}
-print(mapping[input()])
-

🟢 ICPC Awards

Solution in Python
1
-2
-3
-4
-5
-6
-7
n = int(input())
-shown = {}
-for _ in range(n):
-    u, t = input().split()
-    if u not in shown and len(shown.keys()) < 12:
-        print(u, t)
-        shown[u] = True
-

🟢 Illuminati Spotti

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
n = int(input())
-m = []
+11
import math
+
+for _ in range(int(input())):
+    v0, a, x1, h1, h2 = [float(d) for d in input().split()]
+    a = math.radians(a)
+    t = x1 / (v0 * math.cos(a))
+    y = v0 * t * math.sin(a) - 0.5 * 9.81 * (t**2)
+    if y < h1 + 1 or y > h2 - 1:
+        print("Not Safe")
+    else:
+        print("Safe")
+

🟢 Hvert Skal Mæta?

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
mapping = {
+    "Reykjavik": "Reykjavik",
+    "Kopavogur": "Reykjavik",
+    "Hafnarfjordur": "Reykjavik",
+    "Reykjanesbaer": "Reykjavik",
+    "Akureyri": "Akureyri",
+    "Gardabaer": "Reykjavik",
+    "Mosfellsbaer": "Reykjavik",
+    "Arborg": "Reykjavik",
+    "Akranes": "Reykjavik",
+    "Fjardabyggd": "Akureyri",
+    "Mulathing": "Akureyri",
+    "Seltjarnarnes": "Reykjavik",
+}
+print(mapping[input()])
+

🟢 ICPC Awards

Solution in Python
1
+2
+3
+4
+5
+6
+7
n = int(input())
+shown = {}
 for _ in range(n):
-    m.append(input().split())
-total = 0
-for i in range(1, n - 1):
-    for j in range(i):
-        for k in range(i + 1, n):
-            if m[i][j] == m[k][j] == m[k][i] == "1":
-                total += 1
-print(total)
-

🟡 Inheritance

Solution in Python
1
-2
-3
-4
-5
-6
-7
-8
-9
from itertools import product
-
-p = input()
-ans = []
-for i in range(len(p)):
-    for t in product("24", repeat=i + 1):
-        if int(p) % int("".join(t)) == 0:
-            ans.append(int("".join(t)))
-print("\n".join([str(d) for d in sorted(ans)]))
-

🟢 International Dates

Solution in Python
1
+    u, t = input().split()
+    if u not in shown and len(shown.keys()) < 12:
+        print(u, t)
+        shown[u] = True
+

🟢 Illuminati Spotti

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
n = int(input())
+m = []
+for _ in range(n):
+    m.append(input().split())
+total = 0
+for i in range(1, n - 1):
+    for j in range(i):
+        for k in range(i + 1, n):
+            if m[i][j] == m[k][j] == m[k][i] == "1":
+                total += 1
+print(total)
+

🟡 Inheritance

Solution in Python
1
 2
 3
 4
 5
 6
 7
-8
aa, bb, _ = [int(d) for d in input().split("/")]
+8
+9
from itertools import product
 
-if aa > 12 and bb <= 12:
-    print("EU")
-elif aa <= 12 and bb > 12:
-    print("US")
-else:
-    print("either")
-

🟢 I Repeat Myself I Repeat Myself I Repeat

Solution in Python
1
+p = input()
+ans = []
+for i in range(len(p)):
+    for t in product("24", repeat=i + 1):
+        if int(p) % int("".join(t)) == 0:
+            ans.append(int("".join(t)))
+print("\n".join([str(d) for d in sorted(ans)]))
+

🟢 International Dates

Solution in Python
1
 2
 3
 4
 5
 6
 7
-8
import math
+8
aa, bb, _ = [int(d) for d in input().split("/")]
 
-for _ in range(int(input())):
-    s = input()
-    for n in range(1, len(s) + 1):
-        if (s[:n] * math.ceil(len(s) / n)).startswith(s):
-            print(n)
-            break
-

🟡 Is It Even?

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
n, k = [int(d) for d in input().split()]
+if aa > 12 and bb <= 12:
+    print("EU")
+elif aa <= 12 and bb > 12:
+    print("US")
+else:
+    print("either")
+

🟢 I Repeat Myself I Repeat Myself I Repeat

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
import math
 
-for _ in range(n):
-    x = int(input())
-    while True:
-        if x % 2 == 0:
-            x //= 2
-            k -= 1
-        else:
-            break
-    if k <= 0:
-        break
-
-print(0 if k > 0 else 1)
-

🟢 IsItHalloween.com

Solutions in 2 languages
 1
+for _ in range(int(input())):
+    s = input()
+    for n in range(1, len(s) + 1):
+        if (s[:n] * math.ceil(len(s) / n)).startswith(s):
+            print(n)
+            break
+

🟡 Is It Even?

Solution in Python
 1
  2
  3
  4
@@ -5635,261 +5635,253 @@
 11
 12
 13
-14
package main
+14
n, k = [int(d) for d in input().split()]
 
-import "fmt"
-
-func main() {
-    var m, d string
-    fmt.Scan(&m)
-    fmt.Scan(&d)
-    if (m == "OCT" && d == "31") || (m == "DEC" && d == "25") {
-        fmt.Println("yup")
-    } else {
-        fmt.Println("nope")
-    }
-}
-
1
-2
-3
-4
-5
m, d = input().split()
-if (m == "OCT" and d == "31") or (m == "DEC" and d == "25"):
-    print("yup")
-else:
-    print("nope")
-

🟢 Jabuke

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
xa, ya = [int(d) for d in input().split()]
-xb, yb = [int(d) for d in input().split()]
-xc, yc = [int(d) for d in input().split()]
-n = int(input())
-area = abs(xa * (yb - yc) + xb * (yc - ya) + xc * (ya - yb)) / 2
-print(f"{area:.1f}")
-
-
-def sign(x1, y1, x2, y2, x3, y3):
-    return (x1 - x3) * (y2 - y3) - (x2 - x3) * (y1 - y3)
-
-
-def in_triangle(x, y, x1, y1, x2, y2, x3, y3):
-    d1 = sign(x, y, x1, y1, x2, y2)
-    d2 = sign(x, y, x2, y2, x3, y3)
-    d3 = sign(x, y, x3, y3, x1, y1)
-
-    has_neg = d1 < 0 or d2 < 0 or d3 < 0
-    has_pos = d1 > 0 or d2 > 0 or d3 > 0
-
-    return not (has_neg and has_pos)
-
-
-total = 0
-for _ in range(n):
-    x, y = [int(d) for d in input().split()]
-    if in_triangle(x, y, xa, ya, xb, yb, xc, yc):
-        total += 1
-print(total)
-

🟢 Jack-O'-Lantern Juxtaposition

Solution in Python
1
-2
-3
-4
-5
numbers = [int(n) for n in input().split()]
-result = 1
-for n in numbers:
-    result *= n
-print(result)
-

🟢 Janitor Troubles

Solution in Python
1
+for _ in range(n):
+    x = int(input())
+    while True:
+        if x % 2 == 0:
+            x //= 2
+            k -= 1
+        else:
+            break
+    if k <= 0:
+        break
+
+print(0 if k > 0 else 1)
+

🟢 IsItHalloween.com

Solutions in 2 languages
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
package main
+
+import "fmt"
+
+func main() {
+    var m, d string
+    fmt.Scan(&m)
+    fmt.Scan(&d)
+    if (m == "OCT" && d == "31") || (m == "DEC" && d == "25") {
+        fmt.Println("yup")
+    } else {
+        fmt.Println("nope")
+    }
+}
+
1
+2
+3
+4
+5
m, d = input().split()
+if (m == "OCT" and d == "31") or (m == "DEC" and d == "25"):
+    print("yup")
+else:
+    print("nope")
+

🟢 Jabuke

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
xa, ya = [int(d) for d in input().split()]
+xb, yb = [int(d) for d in input().split()]
+xc, yc = [int(d) for d in input().split()]
+n = int(input())
+area = abs(xa * (yb - yc) + xb * (yc - ya) + xc * (ya - yb)) / 2
+print(f"{area:.1f}")
+
+
+def sign(x1, y1, x2, y2, x3, y3):
+    return (x1 - x3) * (y2 - y3) - (x2 - x3) * (y1 - y3)
+
+
+def in_triangle(x, y, x1, y1, x2, y2, x3, y3):
+    d1 = sign(x, y, x1, y1, x2, y2)
+    d2 = sign(x, y, x2, y2, x3, y3)
+    d3 = sign(x, y, x3, y3, x1, y1)
+
+    has_neg = d1 < 0 or d2 < 0 or d3 < 0
+    has_pos = d1 > 0 or d2 > 0 or d3 > 0
+
+    return not (has_neg and has_pos)
+
+
+total = 0
+for _ in range(n):
+    x, y = [int(d) for d in input().split()]
+    if in_triangle(x, y, xa, ya, xb, yb, xc, yc):
+        total += 1
+print(total)
+

🟢 Jack-O'-Lantern Juxtaposition

Solution in Python
1
 2
 3
 4
-5
import math
-
-a, b, c, d = [int(d) for d in input().split()]
-s = (a + b + c + d) / 2
-print(math.sqrt((s - a) * (s - b) * (s - c) * (s - d)))
-

🟢 Jewelry Box

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
def f(h):
-    a = x - 2 * h
-    b = y - 2 * h
-    return a * b * h
-
-
-for _ in range(int(input())):
-    x, y = [int(d) for d in input().split()]
-    h = (x + y - ((x + y) ** 2 - 3 * x * y) ** 0.5) / 6
-    print(f"{f(h):.11f}")
-

🟢 Job Expenses

Solution in Python
1
-2
_ = input()
-print(-sum([int(d) for d in input().split() if "-" in d]))
-

🟢 Joint Jog Jam

Solution in Python
1
-2
-3
-4
-5
-6
-7
-8
-9
import math
-
-
-def dist(x1, y1, x2, y2):
-    return math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
-
-
-coords = [int(d) for d in input().split()]
-print(max(dist(*coords[:4]), dist(*coords[4:])))
-

🟢 Judging Moose

Solutions in 2 languages
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
package main
+5
numbers = [int(n) for n in input().split()]
+result = 1
+for n in numbers:
+    result *= n
+print(result)
+

🟢 Janitor Troubles

Solution in Python
1
+2
+3
+4
+5
import math
+
+a, b, c, d = [int(d) for d in input().split()]
+s = (a + b + c + d) / 2
+print(math.sqrt((s - a) * (s - b) * (s - c) * (s - d)))
+

🟢 Jewelry Box

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
def f(h):
+    a = x - 2 * h
+    b = y - 2 * h
+    return a * b * h
+
+
+for _ in range(int(input())):
+    x, y = [int(d) for d in input().split()]
+    h = (x + y - ((x + y) ** 2 - 3 * x * y) ** 0.5) / 6
+    print(f"{f(h):.11f}")
+

🟢 Job Expenses

Solution in Python
1
+2
_ = input()
+print(-sum([int(d) for d in input().split() if "-" in d]))
+

🟢 Joint Jog Jam

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
+9
import math
 
-import "fmt"
-
-func main() {
-    var l, r int
-    fmt.Scan(&l)
-    fmt.Scan(&r)
-    if l == 0 && r == 0 {
-        fmt.Println("Not a moose")
-    } else {
-        p := 2 * l
-        if r > l {
-            p = 2 * r
-        }
-        t := "Odd"
-        if l == r {
-            t = "Even"
-        }
-        fmt.Println(t, p)
-    }
-}
-
1
-2
-3
-4
-5
-6
l, r = [int(d) for d in input().split()]
-if not l and not r:
-    print("Not a moose")
-else:
-    p = 2 * max(l, r)
-    print("Odd" if l != r else "Even", p)
-

🟢 Jumbo Javelin

Solution in Python
1
+
+def dist(x1, y1, x2, y2):
+    return math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
+
+
+coords = [int(d) for d in input().split()]
+print(max(dist(*coords[:4]), dist(*coords[4:])))
+

🟢 Judging Moose

Solutions in 2 languages
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
package main
+
+import "fmt"
+
+func main() {
+    var l, r int
+    fmt.Scan(&l)
+    fmt.Scan(&r)
+    if l == 0 && r == 0 {
+        fmt.Println("Not a moose")
+    } else {
+        p := 2 * l
+        if r > l {
+            p = 2 * r
+        }
+        t := "Odd"
+        if l == r {
+            t = "Even"
+        }
+        fmt.Println(t, p)
+    }
+}
+
1
 2
 3
 4
 5
-6
n = int(input())
-length = 0
-for _ in range(n):
-    length += int(input())
-length -= n - 1
-print(length)
-

🟢 Just a Minute

Solution in Python
1
+6
l, r = [int(d) for d in input().split()]
+if not l and not r:
+    print("Not a moose")
+else:
+    p = 2 * max(l, r)
+    print("Odd" if l != r else "Even", p)
+

🟢 Jumbo Javelin

Solution in Python
1
 2
 3
 4
 5
-6
-7
-8
-9
a, b = [], []
-for _ in range(int(input())):
-    x, y = [int(d) for d in input().split()]
-    a.append(x * 60)
-    b.append(y)
-ans = sum(b) / sum(a)
-if ans <= 1:
-    ans = "measurement error"
-print(ans)
-

🟢 Running Race

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
l, k, _ = [int(d) for d in input().split()]
-
-record = {}
-for _ in range(l):
-    i, t = input().split()
-    mm, ss = [int(d) for d in t.split(".")]
-    s = mm * 60 + ss
-    if i in record:
-        record[i].append(s)
-    else:
-        record[i] = [s]
-
-delete = [i for i in record if len(record[i]) != k]
-for i in delete:
-    record.pop(i)
-
-sorted_i = sorted(record, key=lambda i: (sum(record[i]), int(i)))
-print("\n".join(sorted_i))
-

🟢 Karte

Solution in Python
 1
+6
n = int(input())
+length = 0
+for _ in range(n):
+    length += int(input())
+length -= n - 1
+print(length)
+

🟢 Just a Minute

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
+9
a, b = [], []
+for _ in range(int(input())):
+    x, y = [int(d) for d in input().split()]
+    a.append(x * 60)
+    b.append(y)
+ans = sum(b) / sum(a)
+if ans <= 1:
+    ans = "measurement error"
+print(ans)
+

🟢 Running Race

Solution in Python
 1
  2
  3
  4
@@ -5906,33 +5898,25 @@
 15
 16
 17
-18
-19
-20
-21
-22
from collections import Counter
+18
l, k, _ = [int(d) for d in input().split()]
 
-s = input()
-cards = {
-    "P": Counter(),
-    "K": Counter(),
-    "H": Counter(),
-    "T": Counter(),
-}
-duplicated = False
-for i in range(0, len(s), 3):
-    suit = s[i]
-    card = s[i + 1 : i + 3]
-    if cards[suit][card]:
-        duplicated = True
-        break
-    cards[suit][card] += 1
-
-if not duplicated:
-    print(" ".join([str(13 - len(c)) for c in cards.values()]))
-else:
-    print("GRESKA")
-

🟢 Kemija

Solutions in 2 languages
 1
+record = {}
+for _ in range(l):
+    i, t = input().split()
+    mm, ss = [int(d) for d in t.split(".")]
+    s = mm * 60 + ss
+    if i in record:
+        record[i].append(s)
+    else:
+        record[i] = [s]
+
+delete = [i for i in record if len(record[i]) != k]
+for i in delete:
+    record.pop(i)
+
+sorted_i = sorted(record, key=lambda i: (sum(record[i]), int(i)))
+print("\n".join(sorted_i))
+

🟢 Karte

Solution in Python
 1
  2
  3
  4
@@ -5941,125 +5925,125 @@
  7
  8
  9
-10
const readline = require("readline");
-const rl = readline.createInterface(process.stdin, process.stdout);
-
-rl.question("", (line) => {
-  for (let c of "aeiou") {
-    const regex = new RegExp(`${c}p${c}`, "g");
-    line = line.replace(regex, c);
-  }
-  console.log(line);
-});
-
1
-2
-3
-4
-5
-6
s = input()
-
-for c in "aeiou":
-    s = s.replace(f"{c}p{c}", c)
-
-print(s)
-

🟢 The Key to Cryptography

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
import string
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
from collections import Counter
+
+s = input()
+cards = {
+    "P": Counter(),
+    "K": Counter(),
+    "H": Counter(),
+    "T": Counter(),
+}
+duplicated = False
+for i in range(0, len(s), 3):
+    suit = s[i]
+    card = s[i + 1 : i + 3]
+    if cards[suit][card]:
+        duplicated = True
+        break
+    cards[suit][card] += 1
+
+if not duplicated:
+    print(" ".join([str(13 - len(c)) for c in cards.values()]))
+else:
+    print("GRESKA")
+

🟢 Kemija

Solutions in 2 languages
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
const readline = require("readline");
+const rl = readline.createInterface(process.stdin, process.stdout);
+
+rl.question("", (line) => {
+  for (let c of "aeiou") {
+    const regex = new RegExp(`${c}p${c}`, "g");
+    line = line.replace(regex, c);
+  }
+  console.log(line);
+});
+
1
+2
+3
+4
+5
+6
s = input()
 
-uppers = string.ascii_uppercase
-
+for c in "aeiou":
+    s = s.replace(f"{c}p{c}", c)
 
-def decrypt(c, k):
-    index = (uppers.index(c) - uppers.index(k)) % 26
-    return uppers[index]
-
-
-m, w = input(), input()
-
-size_w = len(w)
-size_m = len(m)
-o = []
-for i in range(0, size_m, size_w):
-    if i + size_w < size_m:
-        l = zip(m[i : i + size_w], w)
-    else:
-        l = zip(m[i:], w)
-    t = "".join([decrypt(c, k) for c, k in l])
-    o.append(t)
-    w = t
-print("".join(o))
-

🟢 Keywords

Solution in Python
1
-2
-3
-4
keywords = set()
-for _ in range(int(input())):
-    keywords.add(input().lower().replace("-", " "))
-print(len(keywords))
-

🟢 Kitten on a Tree

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
k = input()
-b = []
-while True:
-    line = input()
-    if line == "-1":
-        break
-    b.append(line.split())
-
-p = [k]
-t = k
-while True:
-    found = False
-    for row in b:
-        if t in row[1:]:
-            p.append(row[0])
-            found = True
-            t = row[0]
-            break
-    if not found:
-        break
-
-print(" ".join(p))
-

🟢 Kleptography

Solution in Python
 1
+print(s)
+

🟢 The Key to Cryptography

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
import string
+
+uppers = string.ascii_uppercase
+
+
+def decrypt(c, k):
+    index = (uppers.index(c) - uppers.index(k)) % 26
+    return uppers[index]
+
+
+m, w = input(), input()
+
+size_w = len(w)
+size_m = len(m)
+o = []
+for i in range(0, size_m, size_w):
+    if i + size_w < size_m:
+        l = zip(m[i : i + size_w], w)
+    else:
+        l = zip(m[i:], w)
+    t = "".join([decrypt(c, k) for c, k in l])
+    o.append(t)
+    w = t
+print("".join(o))
+

🟢 Keywords

Solution in Python
1
+2
+3
+4
keywords = set()
+for _ in range(int(input())):
+    keywords.add(input().lower().replace("-", " "))
+print(len(keywords))
+

🟢 Kitten on a Tree

Solution in Python
 1
  2
  3
  4
@@ -6079,134 +6063,128 @@
 18
 19
 20
-21
from string import ascii_lowercase as l
-
-
-n, m = [int(d) for d in input().split()]
-p = input()
-c = input()
-p = p[::-1]
-c = c[::-1]
-
-ans = ""
-for i in range(0, m, n):
-    if i + n < m:
-        part = c[i : i + n]
-    else:
-        part = c[i:]
-
-    ans += p
-    p = "".join([l[(l.index(a) - l.index(b)) % 26] for a, b in zip(part, p)])
-
-ans += p
-print(ans[::-1][n:])
-

🟢 Knight Packing

Solution in Python
1
-2
-3
-4
if int(input()) % 2:
-    print("first")
-else:
-    print("second")
-

🟢 Knot Knowledge

Solution in Python
1
+21
+22
k = input()
+b = []
+while True:
+    line = input()
+    if line == "-1":
+        break
+    b.append(line.split())
+
+p = [k]
+t = k
+while True:
+    found = False
+    for row in b:
+        if t in row[1:]:
+            p.append(row[0])
+            found = True
+            t = row[0]
+            break
+    if not found:
+        break
+
+print(" ".join(p))
+

🟢 Kleptography

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
from string import ascii_lowercase as l
+
+
+n, m = [int(d) for d in input().split()]
+p = input()
+c = input()
+p = p[::-1]
+c = c[::-1]
+
+ans = ""
+for i in range(0, m, n):
+    if i + n < m:
+        part = c[i : i + n]
+    else:
+        part = c[i:]
+
+    ans += p
+    p = "".join([l[(l.index(a) - l.index(b)) % 26] for a, b in zip(part, p)])
+
+ans += p
+print(ans[::-1][n:])
+

🟢 Knight Packing

Solution in Python
1
 2
 3
-4
input()
-total = set(input().split())
-known = set(input().split())
-print((total - known).pop())
-

🟢 Kornislav

Solution in Python
1
-2
numbers = sorted([int(d) for d in input().split()])
-print(numbers[0] * numbers[2])
-

🟢 Križaljka

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
a, b = input().split()
-for i in range(len(a)):
-    if a[i] in b:
-        j = b.index(a[i])
-        break
-
-rows = []
-
-for k in range(j):
-    rows.append("." * i + b[k] + "." * (len(a) - i - 1))
-
-rows.append(a)
-
-for k in range(j + 1, len(b)):
-    rows.append("." * i + b[k] + "." * (len(a) - i - 1))
-
-print("\n".join(rows))
-

🟢 Ladder

Solution in Python
1
-2
-3
-4
import math
-
-h, v = [int(d) for d in input().split()]
-print(math.ceil(h / math.sin(math.radians(v))))
-

🟡 Lamps

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
h, p = [int(d) for d in input().split()]
+4
if int(input()) % 2:
+    print("first")
+else:
+    print("second")
+

🟢 Knot Knowledge

Solution in Python
1
+2
+3
+4
input()
+total = set(input().split())
+known = set(input().split())
+print((total - known).pop())
+

🟢 Kornislav

Solution in Python
1
+2
numbers = sorted([int(d) for d in input().split()])
+print(numbers[0] * numbers[2])
+

🟢 Križaljka

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
a, b = input().split()
+for i in range(len(a)):
+    if a[i] in b:
+        j = b.index(a[i])
+        break
+
+rows = []
+
+for k in range(j):
+    rows.append("." * i + b[k] + "." * (len(a) - i - 1))
+
+rows.append(a)
+
+for k in range(j + 1, len(b)):
+    rows.append("." * i + b[k] + "." * (len(a) - i - 1))
+
+print("\n".join(rows))
+

🟢 Ladder

Solution in Python
1
+2
+3
+4
import math
 
-days = 0
-cost_bulb, cost_lamp = 5, 60
-used_bulb, used_lamp = 0, 0
-
-while True:
-    days += 1
-    cost_bulb += 60 * h * p / 100000
-    cost_lamp += 11 * h * p / 100000
-    used_bulb += h
-    used_lamp += h
-
-    if used_bulb > 1000:
-        cost_bulb += 5
-        used_bulb -= 1000
-
-    if used_lamp > 8000:
-        cost_lamp += 60
-        used_lamp -= 8000
-
-    if cost_bulb > cost_lamp:
-        break
-
-print(days)
-

🟢 Laptop Sticker

Solutions in 3 languages
 1
+h, v = [int(d) for d in input().split()]
+print(math.ceil(h / math.sin(math.radians(v))))
+

🟢 Lamps

Solution in Python
 1
  2
  3
  4
@@ -6223,25 +6201,39 @@
 15
 16
 17
-18
#include <iostream>
+18
+19
+20
+21
+22
+23
+24
+25
h, p = [int(d) for d in input().split()]
 
-using namespace std;
-
-int main()
-{
-    int wc, hc, ws, hs;
-    cin >> wc >> hc >> ws >> hs;
-    if (wc - 2 >= ws && hc - 2 >= hs)
-    {
-        cout << 1 << endl;
-    }
-    else
-    {
-        cout << 0 << endl;
-    }
-    return 0;
-}
-
 1
+days = 0
+cost_bulb, cost_lamp = 5, 60
+used_bulb, used_lamp = 0, 0
+
+while True:
+    days += 1
+    cost_bulb += 60 * h * p / 100000
+    cost_lamp += 11 * h * p / 100000
+    used_bulb += h
+    used_lamp += h
+
+    if used_bulb > 1000:
+        cost_bulb += 5
+        used_bulb -= 1000
+
+    if used_lamp > 8000:
+        cost_lamp += 60
+        used_lamp -= 8000
+
+    if cost_bulb > cost_lamp:
+        break
+
+print(days)
+

🟢 Laptop Sticker

Solutions in 3 languages
 1
  2
  3
  4
@@ -6258,94 +6250,84 @@
 15
 16
 17
-18
-19
-20
package main
+18
#include <iostream>
 
-import "fmt"
+using namespace std;
 
-func main() {
-    var wc, hc, ws, hs int
-    fmt.Scan(&wc)
-    fmt.Scan(&hc)
-    fmt.Scan(&ws)
-    fmt.Scan(&hs)
-    if wc-2 >= ws && hc-2 >= hs {
-
-        fmt.Println(1)
-
-    } else {
-
-        fmt.Println(0)
-
-    }
-}
-
1
-2
-3
-4
-5
wc, hc, ws, hs = [int(d) for d in input().split()]
-if wc - 2 >= ws and hc - 2 >= hs:
-    print(1)
-else:
-    print(0)
-

🟢 Last Factorial Digit

Solution in Python
1
+int main()
+{
+    int wc, hc, ws, hs;
+    cin >> wc >> hc >> ws >> hs;
+    if (wc - 2 >= ws && hc - 2 >= hs)
+    {
+        cout << 1 << endl;
+    }
+    else
+    {
+        cout << 0 << endl;
+    }
+    return 0;
+}
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
package main
+
+import "fmt"
+
+func main() {
+    var wc, hc, ws, hs int
+    fmt.Scan(&wc)
+    fmt.Scan(&hc)
+    fmt.Scan(&ws)
+    fmt.Scan(&hs)
+    if wc-2 >= ws && hc-2 >= hs {
+
+        fmt.Println(1)
+
+    } else {
+
+        fmt.Println(0)
+
+    }
+}
+
1
 2
 3
 4
-5
-6
for _ in range(int(input())):
-    n = int(input())
-    number = 1
-    for i in range(1, n + 1):
-        number *= i
-    print(number % 10)
-

🟢 Left Beehind

Solutions in 3 languages
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
package main
-
-import "fmt"
-
-func main() {
-    var x, y int
-    for true {
-        fmt.Scan(&x)
-        fmt.Scan(&y)
-        if x == 0 && y == 0 {
-            break
-        }
-        if x+y == 13 {
-            fmt.Println("Never speak again.")
-        } else if x > y {
-            fmt.Println("To the convention.")
-        } else if x == y {
-            fmt.Println("Undecided.")
-        } else {
-            fmt.Println("Left beehind.")
-        }
-    }
-}
-
 1
+5
wc, hc, ws, hs = [int(d) for d in input().split()]
+if wc - 2 >= ws and hc - 2 >= hs:
+    print(1)
+else:
+    print(0)
+

🟢 Last Factorial Digit

Solution in Python
1
+2
+3
+4
+5
+6
for _ in range(int(input())):
+    n = int(input())
+    number = 1
+    for i in range(1, n + 1):
+        number *= i
+    print(number % 10)
+

🟢 Left Beehind

Solutions in 3 languages
 1
  2
  3
  4
@@ -6367,26 +6349,26 @@
 20
 21
 22
-23
import java.util.Scanner;
+23
package main
 
-class LeftBeehind {
-    public static void main(String[] args) {
-        Scanner s = new Scanner(System.in);
-        while (true) {
-            int x = s.nextInt();
-            int y = s.nextInt();
-            if (x == 0 && y == 0) {
-                break;
-            }
-            if (x + y == 13) {
-                System.out.println("Never speak again.");
-            } else if (x > y) {
-                System.out.println("To the convention.");
-            } else if (x == y) {
-                System.out.println("Undecided.");
-            } else {
-                System.out.println("Left beehind.");
-            }
+import "fmt"
+
+func main() {
+    var x, y int
+    for true {
+        fmt.Scan(&x)
+        fmt.Scan(&y)
+        if x == 0 && y == 0 {
+            break
+        }
+        if x+y == 13 {
+            fmt.Println("Never speak again.")
+        } else if x > y {
+            fmt.Println("To the convention.")
+        } else if x == y {
+            fmt.Println("Undecided.")
+        } else {
+            fmt.Println("Left beehind.")
         }
     }
 }
@@ -6401,54 +6383,74 @@
  9
 10
 11
-12
while True:
-    x, y = [int(d) for d in input().split()]
-    if not x and not y:
-        break
-    if x + y == 13:
-        print("Never speak again.")
-    elif x > y:
-        print("To the convention.")
-    elif x == y:
-        print("Undecided.")
-    else:
-        print("Left beehind.")
-

🟢 Leggja saman

Solution in Python
1
-2
-3
m = int(input())
-n = int(input())
-print(m + n)
-

🟢 License to Launch

Solution in Python
1
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
import java.util.Scanner;
+
+class LeftBeehind {
+    public static void main(String[] args) {
+        Scanner s = new Scanner(System.in);
+        while (true) {
+            int x = s.nextInt();
+            int y = s.nextInt();
+            if (x == 0 && y == 0) {
+                break;
+            }
+            if (x + y == 13) {
+                System.out.println("Never speak again.");
+            } else if (x > y) {
+                System.out.println("To the convention.");
+            } else if (x == y) {
+                System.out.println("Undecided.");
+            } else {
+                System.out.println("Left beehind.");
+            }
+        }
+    }
+}
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
while True:
+    x, y = [int(d) for d in input().split()]
+    if not x and not y:
+        break
+    if x + y == 13:
+        print("Never speak again.")
+    elif x > y:
+        print("To the convention.")
+    elif x == y:
+        print("Undecided.")
+    else:
+        print("Left beehind.")
+

🟢 Leggja saman

Solution in Python
1
 2
-3
_ = input()
-junks = [int(d) for d in input().split()]
-print(junks.index(min(junks)))
-

🟢 Line Them Up

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
n = int(input())
-names = []
-for _ in range(n):
-    names.append(input())
-order = []
-for i in range(1, n):
-    order.append(names[i] > names[i - 1])
-if all(order):
-    print("INCREASING")
-elif not any(order):
-    print("DECREASING")
-else:
-    print("NEITHER")
-

🟡 A List Game

Solution in Python
 1
+3
m = int(input())
+n = int(input())
+print(m + n)
+

🟢 License to Launch

Solution in Python
1
+2
+3
_ = input()
+junks = [int(d) for d in input().split()]
+print(junks.index(min(junks)))
+

🟢 Line Them Up

Solution in Python
 1
  2
  3
  4
@@ -6460,152 +6462,158 @@
 10
 11
 12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
import math
-
-x = int(input())
-
-p = 1
-total = 0
-
-while x % 2 == 0:
-    p = 2
-    x /= 2
-    total += 1
-
-
-for i in range(3, math.ceil(math.sqrt(x)) + 1, 2):
-    while x % i == 0:
-        p = i
-        x /= i
-        total += 1
-if x > 1:
-    total += 1
-
-
-if p == 1:
-    total = 1
-
-
-print(total)
-

🟢 Locust Locus

Solution in Python
1
-2
-3
-4
-5
-6
-7
-8
-9
from math import gcd
+13
n = int(input())
+names = []
+for _ in range(n):
+    names.append(input())
+order = []
+for i in range(1, n):
+    order.append(names[i] > names[i - 1])
+if all(order):
+    print("INCREASING")
+elif not any(order):
+    print("DECREASING")
+else:
+    print("NEITHER")
+

🟡 A List Game

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
import math
 
-n = int(input())
-l = []
-for _ in range(n):
-    y, c1, c2 = [int(d) for d in input().split()]
-    g = gcd(c1, c2)
-    l.append(y + g * (c1 // g) * (c2 // g))
-print(min(l))
-

🟢 Logic Functions

Solution in C++
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
#include "logicfunctions.h"
+x = int(input())
+
+p = 1
+total = 0
+
+while x % 2 == 0:
+    p = 2
+    x /= 2
+    total += 1
+
+
+for i in range(3, math.ceil(math.sqrt(x)) + 1, 2):
+    while x % i == 0:
+        p = i
+        x /= i
+        total += 1
+if x > 1:
+    total += 1
+
+
+if p == 1:
+    total = 1
+
+
+print(total)
+

🟢 Locust Locus

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
+9
from math import gcd
 
-// Compute xor
-void exclusive(bool x, bool y, bool &ans)
-{
-    ans = x != y;
-}
-
-// Compute implication
-void implies(bool x, bool y, bool &ans)
-{
-    if (x && !y)
-    {
-        ans = false;
-    }
-    else
-    {
-        ans = true;
-    }
-}
-
-// Compute equivalence
-void equivalence(bool x, bool y, bool &ans)
-{
-    ans = x == y;
-}
-

🟢 Lost Lineup

Solution in Python
1
-2
-3
-4
-5
-6
-7
-8
-9
n = int(input())
-order = [int(d) for d in input().split()]
-d = range(1, n)
-order = dict(zip(d, order))
-ranges = range(1, n + 1)
-result = ["1"]
-for k in sorted(order, key=lambda x: order[x]):
-    result.append(str(ranges[k]))
-print(" ".join(result))
-

🟢 Luhn's Checksum Algorithm

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
for _ in range(int(input())):
-    n = input()[::-1]
-    checksum = 0
-    for i in range(len(n)):
-        s = int(n[i]) * (i % 2 + 1)
-        if s > 9:
-            s = sum([int(d) for d in str(s)])
-        checksum += s
-
-    print("FAIL" if checksum % 10 else "PASS")
-

🟢 Magic Trick

Solution in Python
 1
+n = int(input())
+l = []
+for _ in range(n):
+    y, c1, c2 = [int(d) for d in input().split()]
+    g = gcd(c1, c2)
+    l.append(y + g * (c1 // g) * (c2 // g))
+print(min(l))
+

🟢 Logic Functions

Solution in C++
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
#include "logicfunctions.h"
+
+// Compute xor
+void exclusive(bool x, bool y, bool &ans)
+{
+    ans = x != y;
+}
+
+// Compute implication
+void implies(bool x, bool y, bool &ans)
+{
+    if (x && !y)
+    {
+        ans = false;
+    }
+    else
+    {
+        ans = true;
+    }
+}
+
+// Compute equivalence
+void equivalence(bool x, bool y, bool &ans)
+{
+    ans = x == y;
+}
+

🟢 Lost Lineup

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
+9
n = int(input())
+order = [int(d) for d in input().split()]
+d = range(1, n)
+order = dict(zip(d, order))
+ranges = range(1, n + 1)
+result = ["1"]
+for k in sorted(order, key=lambda x: order[x]):
+    result.append(str(ranges[k]))
+print(" ".join(result))
+

🟢 Luhn's Checksum Algorithm

Solution in Python
 1
  2
  3
  4
@@ -6614,69 +6622,39 @@
  7
  8
  9
-10
s = input()
-counter = {}
-guess = 1
-for c in s:
-    if c in counter:
-        guess = 0
-        break
-    else:
-        counter[c] = None
-print(guess)
-

🟢 Making A Meowth

Solution in Python
1
-2
n, p, x, y = [int(d) for d in input().split()]
-print(p * x + p // (n - 1) * y)
-

🟢 Identifying Map Tiles

Solutions in 2 languages
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
package main
-
-import (
-    "fmt"
-    "math"
-)
-
-func main() {
-    var s string
-    fmt.Scanln(&s)
-    zoom := len(s)
-    var x, y float64
-    for i := 0; i < zoom; i++ {
-        d := math.Pow(2, float64(zoom)-float64(i)-1)
-        if s[i] == '1' {
-            x += d
-        } else if s[i] == '2' {
-            y += d
-        } else if s[i] == '3' {
-            x += d
-            y += d
-        }
-    }
-    fmt.Printf("%d %d %d", zoom, int64(x), int64(y))
-}
-
for _ in range(int(input())):
+    n = input()[::-1]
+    checksum = 0
+    for i in range(len(n)):
+        s = int(n[i]) * (i % 2 + 1)
+        if s > 9:
+            s = sum([int(d) for d in str(s)])
+        checksum += s
+
+    print("FAIL" if checksum % 10 else "PASS")
+

🟢 Magic Trick

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
s = input()
+counter = {}
+guess = 1
+for c in s:
+    if c in counter:
+        guess = 0
+        break
+    else:
+        counter[c] = None
+print(guess)
+

🟢 Making A Meowth

Solution in Python
1
+2
n, p, x, y = [int(d) for d in input().split()]
+print(p * x + p // (n - 1) * y)
+

🟢 Identifying Map Tiles

Solutions in 2 languages
 1
  2
  3
  4
@@ -6688,20 +6666,44 @@
 10
 11
 12
-13
s = input()
-x, y = 0, 0
-zoom = len(s)
-for i in range(len(s)):
-    d = 2 ** (zoom - i - 1)
-    if s[i] == "1":
-        x += d
-    elif s[i] == "2":
-        y += d
-    elif s[i] == "3":
-        x += d
-        y += d
-print(f"{zoom} {x} {y}")
-

🟢 Marko

Solution in Python
 1
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
package main
+
+import (
+    "fmt"
+    "math"
+)
+
+func main() {
+    var s string
+    fmt.Scanln(&s)
+    zoom := len(s)
+    var x, y float64
+    for i := 0; i < zoom; i++ {
+        d := math.Pow(2, float64(zoom)-float64(i)-1)
+        if s[i] == '1' {
+            x += d
+        } else if s[i] == '2' {
+            y += d
+        } else if s[i] == '3' {
+            x += d
+            y += d
+        }
+    }
+    fmt.Printf("%d %d %d", zoom, int64(x), int64(y))
+}
+
 1
  2
  3
  4
@@ -6713,62 +6715,68 @@
 10
 11
 12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
mapping = {
-    "2": "abc",
-    "3": "def",
-    "4": "ghi",
-    "5": "jkl",
-    "6": "mno",
-    "7": "pqrs",
-    "8": "tuv",
-    "9": "wxyz",
-}
-n = []
-for _ in range(int(input())):
-    w = input()
-    t = ""
-    for c in w:
-        for d, r in mapping.items():
-            if c in r:
-                t += d
-                break
-    n.append(t)
-
-d = input()
-print(sum([d == t for t in n]))
-

🟢 Mars Window

Solution in Python
1
-2
y = int(input())
-print("YES" if 26 - ((y - 2018) * 12 - 4) % 26 <= 12 else "NO")
-

🟢 Math Homework

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
b, d, c, l = [int(d) for d in input().split()]
-solved = False
-for i in range(l // b + 1):
-    for j in range((l - b * i) // d + 1):
-        for k in range((l - b * i - d * j) // c + 1):
-            if b * i + d * j + c * k == l:
-                print(i, j, k)
-                solved = True
-if not solved:
-    print("impossible")
-

🟢 Mean Words

Solution in Python
s = input()
+x, y = 0, 0
+zoom = len(s)
+for i in range(len(s)):
+    d = 2 ** (zoom - i - 1)
+    if s[i] == "1":
+        x += d
+    elif s[i] == "2":
+        y += d
+    elif s[i] == "3":
+        x += d
+        y += d
+print(f"{zoom} {x} {y}")
+

🟢 Marko

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
mapping = {
+    "2": "abc",
+    "3": "def",
+    "4": "ghi",
+    "5": "jkl",
+    "6": "mno",
+    "7": "pqrs",
+    "8": "tuv",
+    "9": "wxyz",
+}
+n = []
+for _ in range(int(input())):
+    w = input()
+    t = ""
+    for c in w:
+        for d, r in mapping.items():
+            if c in r:
+                t += d
+                break
+    n.append(t)
+
+d = input()
+print(sum([d == t for t in n]))
+

🟢 Mars Window

Solution in Python
1
+2
y = int(input())
+print("YES" if 26 - ((y - 2018) * 12 - 4) % 26 <= 12 else "NO")
+

🟢 Math Homework

Solution in Python
 1
  2
  3
  4
@@ -6777,17 +6785,17 @@
  7
  8
  9
-10
n = int(input())
-words = []
-for _ in range(n):
-    words.append(input())
-m = max([len(w) for w in words])
-ans = []
-for i in range(m):
-    values = [ord(w[i]) for w in words if len(w) > i]
-    ans.append(sum(values) // len(values))
-print("".join(chr(d) for d in ans))
-

🟢 Imperial Measurement

Solution in Python
b, d, c, l = [int(d) for d in input().split()]
+solved = False
+for i in range(l // b + 1):
+    for j in range((l - b * i) // d + 1):
+        for k in range((l - b * i - d * j) // c + 1):
+            if b * i + d * j + c * k == l:
+                print(i, j, k)
+                solved = True
+if not solved:
+    print("impossible")
+

🟢 Mean Words

Solution in Python
 1
  2
  3
  4
@@ -6796,43 +6804,17 @@
  7
  8
  9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
mapping = {
-    "th": "thou",
-    "in": "inch",
-    "ft": "foot",
-    "yd": "yard",
-    "ch": "chain",
-    "fur": "furlong",
-    "mi": "mile",
-    "lea": "league",
-}
-names = list(mapping.values())
-scale = [1, 1000, 12, 3, 22, 10, 8, 3]
-
-v, a, _, b = input().split()
-v = int(v)
-na, nb = mapping.get(a, a), mapping.get(b, b)
-ia, ib = names.index(na), names.index(nb)
-
-rate = 1
-for s in scale[min(ia, ib) + 1 : max(ia, ib) + 1]:
-    rate *= s
-
-print(v * rate if ia > ib else v / rate)
-

🟢 Metaprogramming

Solution in Python
n = int(input())
+words = []
+for _ in range(n):
+    words.append(input())
+m = max([len(w) for w in words])
+ans = []
+for i in range(m):
+    values = [ord(w[i]) for w in words if len(w) > i]
+    ans.append(sum(values) // len(values))
+print("".join(chr(d) for d in ans))
+

🟢 Imperial Measurement

Solution in Python
 1
  2
  3
  4
@@ -6851,80 +6833,80 @@
 17
 18
 19
-20
c = {}
-while True:
-    try:
-        s = input()
-    except:
-        break
-    parts = s.split()
-    if parts[0] == "define":
-        v, n = parts[1:]
-        c[n] = int(v)
-    elif parts[0] == "eval":
-        x, y, z = parts[1:]
-        if x not in c or z not in c:
-            print("undefined")
-        elif y == "=":
-            print("true" if c[x] == c[z] else "false")
-        elif y == ">":
-            print("true" if c[x] > c[z] else "false")
-        elif y == "<":
-            print("true" if c[x] < c[z] else "false")
-

🟢 Methodic Multiplication

Solution in Python
1
-2
-3
a, b = input(), input()
-t = a.count("S") * b.count("S")
-print("S(" * t + "0" + ")" * t)
-

🟢 Metronome

Solution in Python
1
-2
n = int(input())
-print(f"{n/4:.2f}")
-

🟢 Mia

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
def score(a, b):
-    roll = set([a, b])
-    if roll == {1, 2}:
-        return (3, None)
-    elif len(roll) == 1:
-        return (2, a)
-    else:
-        a, b = min(a, b), max(b, a)
-        return (1, 10 * b + a)
-
-
-while True:
-    rolls = [int(d) for d in input().split()]
-    if not any(rolls):
-        break
-    score1 = score(*rolls[:2])
-    score2 = score(*rolls[2:])
-    if score1 == score2:
-        print("Tie.")
-    elif score1[0] == score2[0]:
-        print(f"Player {1 if score1[1] > score2[1] else 2} wins.")
-    else:
-        print(f"Player {1 if score1[0] > score2[0] else 2} wins.")
-

🟢 Missing Numbers

Solution in Python
 1
+20
+21
+22
+23
mapping = {
+    "th": "thou",
+    "in": "inch",
+    "ft": "foot",
+    "yd": "yard",
+    "ch": "chain",
+    "fur": "furlong",
+    "mi": "mile",
+    "lea": "league",
+}
+names = list(mapping.values())
+scale = [1, 1000, 12, 3, 22, 10, 8, 3]
+
+v, a, _, b = input().split()
+v = int(v)
+na, nb = mapping.get(a, a), mapping.get(b, b)
+ia, ib = names.index(na), names.index(nb)
+
+rate = 1
+for s in scale[min(ia, ib) + 1 : max(ia, ib) + 1]:
+    rate *= s
+
+print(v * rate if ia > ib else v / rate)
+

🟢 Metaprogramming

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
c = {}
+while True:
+    try:
+        s = input()
+    except:
+        break
+    parts = s.split()
+    if parts[0] == "define":
+        v, n = parts[1:]
+        c[n] = int(v)
+    elif parts[0] == "eval":
+        x, y, z = parts[1:]
+        if x not in c or z not in c:
+            print("undefined")
+        elif y == "=":
+            print("true" if c[x] == c[z] else "false")
+        elif y == ">":
+            print("true" if c[x] > c[z] else "false")
+        elif y == "<":
+            print("true" if c[x] < c[z] else "false")
+

🟢 Methodic Multiplication

Solution in Python
1
+2
+3
a, b = input(), input()
+t = a.count("S") * b.count("S")
+print("S(" * t + "0" + ")" * t)
+

🟢 Metronome

Solution in Python
1
+2
n = int(input())
+print(f"{n/4:.2f}")
+

🟢 Mia

Solution in Python
 1
  2
  3
  4
@@ -6935,108 +6917,132 @@
  9
 10
 11
-12
numbers = []
-for _ in range(int(input())):
-    numbers.append(int(input()))
-
-is_good_job = True
-for i in range(1, max(numbers) + 1):
-    if i not in numbers:
-        is_good_job = False
-        print(i)
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
def score(a, b):
+    roll = set([a, b])
+    if roll == {1, 2}:
+        return (3, None)
+    elif len(roll) == 1:
+        return (2, a)
+    else:
+        a, b = min(a, b), max(b, a)
+        return (1, 10 * b + a)
 
-if is_good_job:
-    print("good job")
-

🟢 Mixed Fractions

Solution in Python
1
-2
-3
-4
-5
-6
-7
while True:
-    m, n = [int(d) for d in input().split()]
-    if not m and not n:
-        break
-    a = m // n
-    b = m % n
-    print(f"{a} {b} / {n}")
-

🟢 Mjehuric

Solution in Python
1
+
+while True:
+    rolls = [int(d) for d in input().split()]
+    if not any(rolls):
+        break
+    score1 = score(*rolls[:2])
+    score2 = score(*rolls[2:])
+    if score1 == score2:
+        print("Tie.")
+    elif score1[0] == score2[0]:
+        print(f"Player {1 if score1[1] > score2[1] else 2} wins.")
+    else:
+        print(f"Player {1 if score1[0] > score2[0] else 2} wins.")
+

🟢 Missing Numbers

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
numbers = []
+for _ in range(int(input())):
+    numbers.append(int(input()))
+
+is_good_job = True
+for i in range(1, max(numbers) + 1):
+    if i not in numbers:
+        is_good_job = False
+        print(i)
+
+if is_good_job:
+    print("good job")
+

🟢 Mixed Fractions

Solution in Python
1
 2
 3
 4
 5
-6
f = input().split()
-while f != [str(d) for d in range(1, 6)]:
-    for i in range(4):
-        if f[i] > f[i + 1]:
-            f[i], f[i + 1] = f[i + 1], f[i]
-            print(" ".join(f))
-

🟢 Moderate Pace

Solution in Python
1
+6
+7
while True:
+    m, n = [int(d) for d in input().split()]
+    if not m and not n:
+        break
+    a = m // n
+    b = m % n
+    print(f"{a} {b} / {n}")
+

🟢 Mjehuric

Solution in Python
1
 2
 3
-4
n = int(input())
-distances = [[int(d) for d in input().split()] for _ in range(3)]
-plan = [sorted([d[i] for d in distances])[1] for i in range(n)]
-print(" ".join([str(d) for d in plan]))
-

🟢 Modulo

Solution in Python
1
+4
+5
+6
f = input().split()
+while f != [str(d) for d in range(1, 6)]:
+    for i in range(4):
+        if f[i] > f[i + 1]:
+            f[i], f[i + 1] = f[i + 1], f[i]
+            print(" ".join(f))
+

🟢 Moderate Pace

Solution in Python
1
 2
 3
-4
n = set()
-for _ in range(10):
-    n.add(int(input()) % 42)
-print(len(n))
-

🟢 Monopoly

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
n = int(input())
-a = [int(d) for d in input().split()]
-t = 0
-m = 0
-for i in range(1, 7):
-    for j in range(1, 7):
-        t += 1
-        if i + j in a:
-            m += 1
-print(m / t)
-

🟢 Moscow Dream

Solution in Python
1
-2
-3
-4
-5
-6
a, b, c, n = [int(d) for d in input().split()]
-
-if not all(d > 0 for d in [a, b, c]):
-    print("NO")
-else:
-    print("YES" if a + b + c >= n and n >= 3 else "NO")
-

🟢 Mosquito Multiplication

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
while True:
-    try:
-        m, p, l, e, r, s, n = [int(d) for d in input().split()]
-    except:
-        break
-    for _ in range(n):
-        pp = p
-        p = l // r
-        l = e * m
-        m = pp // s
-    print(m)
-

🟢 MrCodeFormatGrader

Solution in Python
 1
+4
n = int(input())
+distances = [[int(d) for d in input().split()] for _ in range(3)]
+plan = [sorted([d[i] for d in distances])[1] for i in range(n)]
+print(" ".join([str(d) for d in plan]))
+

🟢 Modulo

Solution in Python
1
+2
+3
+4
n = set()
+for _ in range(10):
+    n.add(int(input()) % 42)
+print(len(n))
+

🟢 Monopoly

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
n = int(input())
+a = [int(d) for d in input().split()]
+t = 0
+m = 0
+for i in range(1, 7):
+    for j in range(1, 7):
+        t += 1
+        if i + j in a:
+            m += 1
+print(m / t)
+

🟢 Moscow Dream

Solution in Python
1
+2
+3
+4
+5
+6
a, b, c, n = [int(d) for d in input().split()]
+
+if not all(d > 0 for d in [a, b, c]):
+    print("NO")
+else:
+    print("YES" if a + b + c >= n and n >= 3 else "NO")
+

🟢 Mosquito Multiplication

Solution in Python
 1
  2
  3
  4
@@ -7046,48 +7052,18 @@
  8
  9
 10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
def f(numbers):
-    prev = numbers[0]
-    ans = {prev: 1}
-    for i in range(1, len(numbers)):
-        if numbers[i] == prev + ans[prev]:
-            ans[prev] += 1
-        else:
-            prev = numbers[i]
-            ans[prev] = 1
-
-    parts = [
-        f"{key}-{key+value-1}"
-        if value > 1
-        else " ".join([str(d) for d in range(key, key + value)])
-        for key, value in ans.items()
-    ]
-
-    return ", ".join(parts[:-1]) + " and " + parts[-1]
-
-
-c, n = [int(d) for d in input().split()]
-errors = [int(d) for d in input().split()]
-correct = [i for i in range(1, 1 + c) if i not in errors]
-
-print("Errors:", f(errors))
-print("Correct:", f(correct))
-

🟢 Mult!

Solution in Python
while True:
+    try:
+        m, p, l, e, r, s, n = [int(d) for d in input().split()]
+    except:
+        break
+    for _ in range(n):
+        pp = p
+        p = l // r
+        l = e * m
+        m = pp // s
+    print(m)
+

🟢 MrCodeFormatGrader

Solution in Python
 1
  2
  3
  4
@@ -7097,18 +7073,48 @@
  8
  9
 10
-11
n = int(input())
-b = None
-for _ in range(n):
-    d = int(input())
-    if not b:
-        b = d
-        continue
-
-    if d % b == 0:
-        print(d)
-        b = None
-

🟢 Mumble Rap

Solution in Python
 1
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
def f(numbers):
+    prev = numbers[0]
+    ans = {prev: 1}
+    for i in range(1, len(numbers)):
+        if numbers[i] == prev + ans[prev]:
+            ans[prev] += 1
+        else:
+            prev = numbers[i]
+            ans[prev] = 1
+
+    parts = [
+        f"{key}-{key+value-1}"
+        if value > 1
+        else " ".join([str(d) for d in range(key, key + value)])
+        for key, value in ans.items()
+    ]
+
+    return ", ".join(parts[:-1]) + " and " + parts[-1]
+
+
+c, n = [int(d) for d in input().split()]
+errors = [int(d) for d in input().split()]
+correct = [i for i in range(1, 1 + c) if i not in errors]
+
+print("Errors:", f(errors))
+print("Correct:", f(correct))
+

🟢 Mult!

Solution in Python
 1
  2
  3
  4
@@ -7118,32 +7124,18 @@
  8
  9
 10
-11
-12
-13
-14
-15
-16
-17
-18
n = int(input())
-s = input()
-a = []
-d = ""
-import string
-
-for i in range(n):
-    if s[i] in string.digits:
-        d += s[i]
-
-    else:
-        if d:
-            a.append(int(d))
-            d = ""
-if d:
-    a.append(int(d))
-
-print(max(a))
-

🟢 Musical Scales

Solution in Python
n = int(input())
+b = None
+for _ in range(n):
+    d = int(input())
+    if not b:
+        b = d
+        continue
+
+    if d % b == 0:
+        print(d)
+        b = None
+

🟢 Mumble Rap

Solution in Python
 1
  2
  3
  4
@@ -7156,21 +7148,29 @@
 11
 12
 13
-14
notes = ["A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"]
-offset = [2, 2, 1, 2, 2, 2]
-majors = {}
-for i in range(len(notes)):
-    name = notes[i]
-    progression = [name]
-    for i in offset:
-        index = (notes.index(progression[-1]) + i) % len(notes)
-        progression.append(notes[index])
-    majors[name] = progression
-
-_ = input()
-scales = set(input().split())
-print(" ".join([n for n in majors if scales < set(majors[n])]) or "none")
-

🟢 Music Your Way

Solution in Python
 1
+14
+15
+16
+17
+18
n = int(input())
+s = input()
+a = []
+d = ""
+import string
+
+for i in range(n):
+    if s[i] in string.digits:
+        d += s[i]
+
+    else:
+        if d:
+            a.append(int(d))
+            d = ""
+if d:
+    a.append(int(d))
+
+print(max(a))
+

🟢 Musical Scales

Solution in Python
 1
  2
  3
  4
@@ -7183,21 +7183,21 @@
 11
 12
 13
-14
cols = input().split()
-m = int(input())
-songs = [input().split() for _ in range(m)]
-n = int(input())
-
-for i in range(n):
-    col = input()
-    index = cols.index(col)
-    songs = sorted(songs, key=lambda k: k[index])
-    print(" ".join(cols))
-    for song in songs:
-        print(" ".join(song))
-    if i < n - 1:
-        print()
-

🟢 Mylla

Solution in Python
notes = ["A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"]
+offset = [2, 2, 1, 2, 2, 2]
+majors = {}
+for i in range(len(notes)):
+    name = notes[i]
+    progression = [name]
+    for i in offset:
+        index = (notes.index(progression[-1]) + i) % len(notes)
+        progression.append(notes[index])
+    majors[name] = progression
+
+_ = input()
+scales = set(input().split())
+print(" ".join([n for n in majors if scales < set(majors[n])]) or "none")
+

🟢 Music Your Way

Solution in Python
 1
  2
  3
  4
@@ -7210,41 +7210,21 @@
 11
 12
 13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
board = []
-for _ in range(3):
-    board.append(list(input()))
-
-winner = ""
-for i in range(3):
-    if board[i][0] == board[i][1] == board[i][2] and board[i][0] != "_":
-        winner = board[i][0]
-        break
-    elif board[0][i] == board[1][i] == board[2][i] and board[0][i] != "_":
-        winner = board[0][i]
-        break
-
-if board[0][0] == board[1][1] == board[2][2] and board[1][1] != "_":
-    winner = board[1][1]
-elif board[0][2] == board[1][1] == board[2][0] and board[1][1] != "_":
-    winner = board[1][1]
-
-if winner == "O":
-    winner = "Jebb"
-else:
-    winner = "Neibb"
-
-print(winner)
-

🟢 Nasty Hacks

Solutions in 2 languages
cols = input().split()
+m = int(input())
+songs = [input().split() for _ in range(m)]
+n = int(input())
+
+for i in range(n):
+    col = input()
+    index = cols.index(col)
+    songs = sorted(songs, key=lambda k: k[index])
+    print(" ".join(cols))
+    for song in songs:
+        print(" ".join(song))
+    if i < n - 1:
+        print()
+

🟢 Mylla

Solution in Python
 1
  2
  3
  4
@@ -7267,77 +7247,97 @@
 21
 22
 23
-24
-25
-26
#include <iostream>
-
-using namespace std;
+24
board = []
+for _ in range(3):
+    board.append(list(input()))
 
-int main()
-{
-    int n, r, e, c;
-    cin >> n;
-
-    for (int i = 0; i < n; i++)
-    {
-        cin >> r >> e >> c;
-        if ((e - c) > r)
-        {
-            cout << "advertise";
-        }
-        else if ((e - c) < r)
-        {
-            cout << "do not advertise";
-        }
-        else
-        {
-            cout << "does not matter";
-        }
-    }
-}
-
1
-2
-3
-4
-5
-6
-7
-8
for _ in range(int(input())):
-    r, e, c = [int(d) for d in input().split()]
-    if e > r + c:
-        print("advertise")
-    elif e < r + c:
-        print("do not advertise")
-    else:
-        print("does not matter")
-

🟢 No Duplicates

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
words = input().split()
-
-counter = {}
-repeated = False
-for w in words:
-    if w in counter:
-        repeated = True
-        break
-    else:
-        counter[w] = None
-if repeated:
-    print("no")
-else:
-    print("yes")
-

🟢 No Thanks!

Solution in Python
 1
+winner = ""
+for i in range(3):
+    if board[i][0] == board[i][1] == board[i][2] and board[i][0] != "_":
+        winner = board[i][0]
+        break
+    elif board[0][i] == board[1][i] == board[2][i] and board[0][i] != "_":
+        winner = board[0][i]
+        break
+
+if board[0][0] == board[1][1] == board[2][2] and board[1][1] != "_":
+    winner = board[1][1]
+elif board[0][2] == board[1][1] == board[2][0] and board[1][1] != "_":
+    winner = board[1][1]
+
+if winner == "O":
+    winner = "Jebb"
+else:
+    winner = "Neibb"
+
+print(winner)
+

🟢 Nasty Hacks

Solutions in 2 languages
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
#include <iostream>
+
+using namespace std;
+
+int main()
+{
+    int n, r, e, c;
+    cin >> n;
+
+    for (int i = 0; i < n; i++)
+    {
+        cin >> r >> e >> c;
+        if ((e - c) > r)
+        {
+            cout << "advertise";
+        }
+        else if ((e - c) < r)
+        {
+            cout << "do not advertise";
+        }
+        else
+        {
+            cout << "does not matter";
+        }
+    }
+}
+
1
+2
+3
+4
+5
+6
+7
+8
for _ in range(int(input())):
+    r, e, c = [int(d) for d in input().split()]
+    if e > r + c:
+        print("advertise")
+    elif e < r + c:
+        print("do not advertise")
+    else:
+        print("does not matter")
+

🟢 No Duplicates

Solution in Python
 1
  2
  3
  4
@@ -7349,20 +7349,22 @@
 10
 11
 12
-13
n = int(input())
-v = sorted([int(d) for d in input().split()])
-
-prev = v[0]
-ans = {prev: 1}
-for i in range(1, n):
-    if v[i] == prev + ans[prev]:
-        ans[prev] += 1
+13
+14
words = input().split()
+
+counter = {}
+repeated = False
+for w in words:
+    if w in counter:
+        repeated = True
+        break
     else:
-        prev = v[i]
-        ans[prev] = 1
-
-print(sum(ans.keys()))
-

🟢 N-sum

Solutions in 2 languages
 1
+        counter[w] = None
+if repeated:
+    print("no")
+else:
+    print("yes")
+

🟢 No Thanks!

Solution in Python
 1
  2
  3
  4
@@ -7374,196 +7376,188 @@
 10
 11
 12
-13
import java.util.Scanner;
-
-class NSum {
-    public static void main(String[] args) {
-        Scanner s = new Scanner(System.in);
-        int n = s.nextInt();
-        int ans = 0;
-        for (int i = 0; i < n; i++) {
-            ans += s.nextInt();
-        }
-        System.out.println(ans);
-    }
-}
-
1
-2
-3
-4
-5
_ = int(input())
-numbers = []
-for d in input().split():
-    numbers.append(int(d))
-print(sum(numbers))
-

🟢 Number Fun

Solution in Python
1
+13
n = int(input())
+v = sorted([int(d) for d in input().split()])
+
+prev = v[0]
+ans = {prev: 1}
+for i in range(1, n):
+    if v[i] == prev + ans[prev]:
+        ans[prev] += 1
+    else:
+        prev = v[i]
+        ans[prev] = 1
+
+print(sum(ans.keys()))
+

🟢 N-sum

Solutions in 2 languages
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
import java.util.Scanner;
+
+class NSum {
+    public static void main(String[] args) {
+        Scanner s = new Scanner(System.in);
+        int n = s.nextInt();
+        int ans = 0;
+        for (int i = 0; i < n; i++) {
+            ans += s.nextInt();
+        }
+        System.out.println(ans);
+    }
+}
+
1
 2
 3
 4
-5
-6
for _ in range(int(input())):
-    a, b, c = [int(d) for d in input().split()]
-    if a + b == c or a * b == c or a - b == c or b - a == c or a / b == c or b / a == c:
-        print("Possible")
-    else:
-        print("Impossible")
-

🟢 Odd Echo

Solution in Python
1
+5
_ = int(input())
+numbers = []
+for d in input().split():
+    numbers.append(int(d))
+print(sum(numbers))
+

🟢 Number Fun

Solution in Python
1
 2
 3
 4
 5
-6
n = int(input())
-words = []
-for _ in range(n):
-    words.append(input())
-for i in range(0, n, 2):
-    print(words[i])
-

🟢 Odd Gnome

Solution in Python
1
+6
for _ in range(int(input())):
+    a, b, c = [int(d) for d in input().split()]
+    if a + b == c or a * b == c or a - b == c or b - a == c or a / b == c or b / a == c:
+        print("Possible")
+    else:
+        print("Impossible")
+

🟢 Odd Echo

Solution in Python
1
 2
 3
 4
 5
-6
-7
-8
-9
n = int(input())
-for _ in range(n):
-    g = [int(d) for d in input().split()][1:]
-    prev = g[0]
-    for i in range(1, len(g)):
-        if g[i] != prev + 1:
-            break
-        prev = g[i]
-    print(i + 1)
-

🟢 Oddities

Solution in Python
1
+6
n = int(input())
+words = []
+for _ in range(n):
+    words.append(input())
+for i in range(0, n, 2):
+    print(words[i])
+

🟢 Odd Gnome

Solution in Python
1
 2
 3
 4
 5
 6
 7
-8
n = int(input())
+8
+9
n = int(input())
 for _ in range(n):
-    x = int(input())
-    if x % 2:
-        res = "odd"
-    else:
-        res = "even"
-    print(f"{x} is {res}")
-

🟢 Odd Man Out

Solution in Python
1
+    g = [int(d) for d in input().split()][1:]
+    prev = g[0]
+    for i in range(1, len(g)):
+        if g[i] != prev + 1:
+            break
+        prev = g[i]
+    print(i + 1)
+

🟢 Oddities

Solution in Python
1
 2
 3
 4
 5
 6
-7
from collections import Counter
-
-n = int(input())
-for i in range(n):
-    _ = input()
-    c = Counter(input().split())
-    print(f"Case #{i+1}: {' '.join(v for v in c if c[v]==1)}")
-

🟢 Off-World Records

Solutions in 2 languages
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
import java.util.Scanner;
+7
+8
n = int(input())
+for _ in range(n):
+    x = int(input())
+    if x % 2:
+        res = "odd"
+    else:
+        res = "even"
+    print(f"{x} is {res}")
+

🟢 Odd Man Out

Solution in Python
1
+2
+3
+4
+5
+6
+7
from collections import Counter
 
-class OffWorldRecords {
-    public static void main(String[] args) {
-        Scanner s = new Scanner(System.in);
-        int n = s.nextInt();
-        int c = s.nextInt();
-        int p = s.nextInt();
-        int ans = 0;
-
-        for (int i = 0; i < n; i++) {
-            int h = s.nextInt();
-            if (h > c + p) {
-                ans += 1;
-                p = c;
-                c = h;
-            }
-        }
-        System.out.println(ans);
-    }
-}
-
1
-2
-3
-4
-5
-6
-7
-8
n, c, p = [int(d) for d in input().split()]
-ans = 0
-for _ in range(n):
-    h = int(input())
-    if h > c + p:
-        ans += 1
-        c, p = h, c
-print(ans)
-

🟢 Reverse

Solution in Python
1
+n = int(input())
+for i in range(n):
+    _ = input()
+    c = Counter(input().split())
+    print(f"Case #{i+1}: {' '.join(v for v in c if c[v]==1)}")
+

🟢 Off-World Records

Solutions in 2 languages
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
import java.util.Scanner;
+
+class OffWorldRecords {
+    public static void main(String[] args) {
+        Scanner s = new Scanner(System.in);
+        int n = s.nextInt();
+        int c = s.nextInt();
+        int p = s.nextInt();
+        int ans = 0;
+
+        for (int i = 0; i < n; i++) {
+            int h = s.nextInt();
+            if (h > c + p) {
+                ans += 1;
+                p = c;
+                c = h;
+            }
+        }
+        System.out.println(ans);
+    }
+}
+
1
 2
 3
 4
 5
-6
n = int(input())
-numbers = []
+6
+7
+8
n, c, p = [int(d) for d in input().split()]
+ans = 0
 for _ in range(n):
-    numbers.append(int(input()))
-for d in numbers[::-1]:
-    print(d)
-

🟢 Oktalni

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
import math
-
-mapping = {
-    "000": "0",
-    "001": "1",
-    "010": "2",
-    "011": "3",
-    "100": "4",
-    "101": "5",
-    "110": "6",
-    "111": "7",
-}
-b = input()
-length = 3 * math.ceil(len(b) / 3)
-b = b.zfill(length)
-
-print("".join([mapping[b[i : i + 3]] for i in range(0, length, 3)]))
-

🟢 One Chicken Per Person!

Solution in Python
 1
+    h = int(input())
+    if h > c + p:
+        ans += 1
+        c, p = h, c
+print(ans)
+

🟢 Reverse

Solution in Python
1
+2
+3
+4
+5
+6
n = int(input())
+numbers = []
+for _ in range(n):
+    numbers.append(int(input()))
+for d in numbers[::-1]:
+    print(d)
+

🟢 Oktalni

Solution in Python
 1
  2
  3
  4
@@ -7572,117 +7566,125 @@
  7
  8
  9
-10
n, m = [int(d) for d in input().split()]
+10
+11
+12
+13
+14
+15
+16
+17
import math
 
-diff = n - m
-if diff > 0:
-    print(f"Dr. Chaz needs {diff} more piece{'s' if diff >1 else ''} of chicken!")
-else:
-    diff = abs(diff)
-    print(
-        f"Dr. Chaz will have {diff} piece{'s' if diff >1 else ''} of chicken left over!"
-    )
-

🟢 Ordinals

Solution in Python
1
-2
-3
-4
-5
-6
-7
-8
-9
def f(n):
-    if n == 0:
-        return "{}"
-    else:
-        ans = ",".join([f(i) for i in range(n)])
-        return "{" + ans + "}"
-
-
-print(f(int(input())))
-

🟢 Ornaments

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
import math
-
-while True:
-    r, h, s = [int(d) for d in input().split()]
-    if not r and not h and not s:
-        break
-    l = math.sqrt(h**2 - r**2) * 2
-    a = math.pi - math.acos(r / h)
-    l += 2 * math.pi * r * (a / math.pi)
-    l *= 1 + s / 100
-    print(f"{l:.2f}")
-

🟢 Östgötska

Solution in Python
1
-2
-3
-4
-5
-6
sentence = input()
-words = sentence.split()
-if len([w for w in words if "ae" in w]) / len(words) >= 0.4:
-    print("dae ae ju traeligt va")
-else:
-    print("haer talar vi rikssvenska")
-

🟢 Overdraft

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
n = int(input())
-s = 0
-b = 0
-for _ in range(n):
-    t = int(input())
-    if t > 0:
-        b += t
-    elif b + t < 0:
-        s -= b + t
-        b = 0
-    else:
-        b += t
-print(s)
-

🟢 Óvissa

Solution in Python
print(input().count("u"))
-

🟢 The Owl and the Fox

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
def sd(n):
-    return sum([int(d) for d in str(n)])
-
-
-for _ in range(int(input())):
-    n = int(input())
-    s = sd(n) - 1
-    d = n - 1
-    while True:
-        if sd(d) == s:
-            break
-        d -= 1
-    print(d)
-

🟢 Pachyderm Peanut Packing

Solution in Python
 1
+mapping = {
+    "000": "0",
+    "001": "1",
+    "010": "2",
+    "011": "3",
+    "100": "4",
+    "101": "5",
+    "110": "6",
+    "111": "7",
+}
+b = input()
+length = 3 * math.ceil(len(b) / 3)
+b = b.zfill(length)
+
+print("".join([mapping[b[i : i + 3]] for i in range(0, length, 3)]))
+

🟢 One Chicken Per Person!

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
n, m = [int(d) for d in input().split()]
+
+diff = n - m
+if diff > 0:
+    print(f"Dr. Chaz needs {diff} more piece{'s' if diff >1 else ''} of chicken!")
+else:
+    diff = abs(diff)
+    print(
+        f"Dr. Chaz will have {diff} piece{'s' if diff >1 else ''} of chicken left over!"
+    )
+

🟢 Ordinals

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
+9
def f(n):
+    if n == 0:
+        return "{}"
+    else:
+        ans = ",".join([f(i) for i in range(n)])
+        return "{" + ans + "}"
+
+
+print(f(int(input())))
+

🟢 Ornaments

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
import math
+
+while True:
+    r, h, s = [int(d) for d in input().split()]
+    if not r and not h and not s:
+        break
+    l = math.sqrt(h**2 - r**2) * 2
+    a = math.pi - math.acos(r / h)
+    l += 2 * math.pi * r * (a / math.pi)
+    l *= 1 + s / 100
+    print(f"{l:.2f}")
+

🟢 Östgötska

Solution in Python
1
+2
+3
+4
+5
+6
sentence = input()
+words = sentence.split()
+if len([w for w in words if "ae" in w]) / len(words) >= 0.4:
+    print("dae ae ju traeligt va")
+else:
+    print("haer talar vi rikssvenska")
+

🟢 Overdraft

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
n = int(input())
+s = 0
+b = 0
+for _ in range(n):
+    t = int(input())
+    if t > 0:
+        b += t
+    elif b + t < 0:
+        s -= b + t
+        b = 0
+    else:
+        b += t
+print(s)
+

🟢 Óvissa

Solution in Python
print(input().count("u"))
+

🟢 The Owl and the Fox

Solution in Python
 1
  2
  3
  4
@@ -7694,60 +7696,20 @@
 10
 11
 12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
def inbox(coords, x, y):
-    if x >= coords[0] and x <= coords[2] and y >= coords[1] and y <= coords[3]:
-        return True
-    return False
-
-
-while True:
-    n = int(input())
-    if not n:
-        break
-    box = {}
-    for i in range(n):
-        desc = input().split()
-        size = desc[-1]
-        coords = [float(d) for d in desc[:-1]]
-        box[i] = (coords, size)
-    m = int(input())
-    for _ in range(m):
-        desc = input().split()
-        size = desc[-1]
-        x, y = [float(d) for d in desc[:-1]]
-        floor = True
-        for i in range(n):
-            coords, box_size = box[i]
-            if inbox(coords, x, y):
-                floor = False
-                break
-        if floor:
-            status = "floor"
-        else:
-            status = "correct" if box_size == size else box_size
-        print(size, status)
-    print()
-

🟢 Parent Gap

Solution in Python
def sd(n):
+    return sum([int(d) for d in str(n)])
+
+
+for _ in range(int(input())):
+    n = int(input())
+    s = sd(n) - 1
+    d = n - 1
+    while True:
+        if sd(d) == s:
+            break
+        d -= 1
+    print(d)
+

🟢 Pachyderm Peanut Packing

Solution in Python
 1
  2
  3
  4
@@ -7762,99 +7724,143 @@
 13
 14
 15
-16
from datetime import datetime
-
-year = int(input())
-
-mother = datetime(year, 5, 1).isoweekday()
-father = datetime(year, 6, 1).isoweekday()
-
-x = 7 - mother
-y = 7 - father
-daymother = 1 + x + 7
-dayfather = 1 + y + 14
-
-daymother = datetime(year, 5, daymother)
-dayfather = datetime(year, 6, dayfather)
-
-print(((dayfather - daymother).days) // 7, "weeks")
-

🟢 Parket

Solution in Python
1
-2
-3
-4
-5
-6
-7
-8
-9
import math
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
def inbox(coords, x, y):
+    if x >= coords[0] and x <= coords[2] and y >= coords[1] and y <= coords[3]:
+        return True
+    return False
+
+
+while True:
+    n = int(input())
+    if not n:
+        break
+    box = {}
+    for i in range(n):
+        desc = input().split()
+        size = desc[-1]
+        coords = [float(d) for d in desc[:-1]]
+        box[i] = (coords, size)
+    m = int(input())
+    for _ in range(m):
+        desc = input().split()
+        size = desc[-1]
+        x, y = [float(d) for d in desc[:-1]]
+        floor = True
+        for i in range(n):
+            coords, box_size = box[i]
+            if inbox(coords, x, y):
+                floor = False
+                break
+        if floor:
+            status = "floor"
+        else:
+            status = "correct" if box_size == size else box_size
+        print(size, status)
+    print()
+

🟢 Parent Gap

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
from datetime import datetime
 
-r, b = [int(d) for d in input().split()]
-w = math.floor((r + b) ** 0.5)
-while w:
-    if (r + b) / w == (r + 4) / 2 - w:
-        print((r + 4) // 2 - w, w)
-        break
-    w -= 1
-

🟢 Parking

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
a, b, c = [int(d) for d in input().split()]
-t = [0] * 100
-for _ in range(3):
-    start, end = [int(d) - 1 for d in input().split()]
-    for i in range(start, end):
-        t[i] += 1
-
-total = 0
-mapping = {
-    3: c,
-    2: b,
-    1: a,
-}
-for s in t:
-    total += mapping.get(s, 0) * s
-print(total)
-

🟢 Parking

Solution in Python
1
-2
-3
-4
for _ in range(int(input())):
-    _ = input()
-    positions = [int(d) for d in input().split()]
-    print(2 * (max(positions) - min(positions)))
-

🟢 Patuljci

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
d = [int(input()) for _ in range(9)]
-diff = sum(d) - 100
-end = False
-for i in range(8):
-    for j in range(i + 1, 9):
-        if d[i] + d[j] == diff:
-            end = True
-            break
-    if end:
-        break
-print("\n".join([str(d[k]) for k in range(9) if k not in [i, j]]))
-

🟢 Paul Eigon

Solutions in 2 languages
 1
+year = int(input())
+
+mother = datetime(year, 5, 1).isoweekday()
+father = datetime(year, 6, 1).isoweekday()
+
+x = 7 - mother
+y = 7 - father
+daymother = 1 + x + 7
+dayfather = 1 + y + 14
+
+daymother = datetime(year, 5, daymother)
+dayfather = datetime(year, 6, dayfather)
+
+print(((dayfather - daymother).days) // 7, "weeks")
+

🟢 Parket

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
+9
import math
+
+r, b = [int(d) for d in input().split()]
+w = math.floor((r + b) ** 0.5)
+while w:
+    if (r + b) / w == (r + 4) / 2 - w:
+        print((r + 4) // 2 - w, w)
+        break
+    w -= 1
+

🟢 Parking

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
a, b, c = [int(d) for d in input().split()]
+t = [0] * 100
+for _ in range(3):
+    start, end = [int(d) - 1 for d in input().split()]
+    for i in range(start, end):
+        t[i] += 1
+
+total = 0
+mapping = {
+    3: c,
+    2: b,
+    1: a,
+}
+for s in t:
+    total += mapping.get(s, 0) * s
+print(total)
+

🟢 Parking

Solution in Python
1
+2
+3
+4
for _ in range(int(input())):
+    _ = input()
+    positions = [int(d) for d in input().split()]
+    print(2 * (max(positions) - min(positions)))
+

🟢 Patuljci

Solution in Python
 1
  2
  3
  4
@@ -7864,113 +7870,99 @@
  8
  9
 10
-11
-12
-13
-14
-15
package main
-
-import "fmt"
-
-func main() {
-    var n, p, q int
-    fmt.Scan(&n)
-    fmt.Scan(&p)
-    fmt.Scan(&q)
-    if ((p+q)/n)%2 == 0 {
-        fmt.Println("paul")
-    } else {
-        fmt.Println("opponent")
-    }
-}
-
1
-2
-3
-4
-5
-6
n, p, q = [int(d) for d in input().split()]
+11
d = [int(input()) for _ in range(9)]
+diff = sum(d) - 100
+end = False
+for i in range(8):
+    for j in range(i + 1, 9):
+        if d[i] + d[j] == diff:
+            end = True
+            break
+    if end:
+        break
+print("\n".join([str(d[k]) for k in range(9) if k not in [i, j]]))
+

🟢 Paul Eigon

Solutions in 2 languages
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
package main
 
-if ((p + q) // n) % 2 == 0:
-    print("paul")
-else:
-    print("opponent")
-

🟢 Peach Powder Polygon

Solution in Python
1
-2
n = int(input())
-print("Yes" if n % 4 else "No")
-

🟢 Pea Soup and Pancakes

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
found = False
-for _ in range(int(input())):
-    k = int(input())
-
-    name = input()
-    items = [input() for _ in range(k)]
-    if "pea soup" in items and "pancakes" in items:
-        found = True
-        print(name)
-        break
-
-if not found:
-    print("Anywhere is fine I guess")
-

🟢 Peragrams

Solution in Python
1
-2
-3
-4
-5
-6
-7
from collections import Counter
-
-s = Counter(input())
-v = [d for d in s.values() if d % 2]
-v = sorted(v)[:-1]
-
-print(len(v))
-

🟢 Perket

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
from itertools import combinations
+import "fmt"
+
+func main() {
+    var n, p, q int
+    fmt.Scan(&n)
+    fmt.Scan(&p)
+    fmt.Scan(&q)
+    if ((p+q)/n)%2 == 0 {
+        fmt.Println("paul")
+    } else {
+        fmt.Println("opponent")
+    }
+}
+
1
+2
+3
+4
+5
+6
n, p, q = [int(d) for d in input().split()]
+
+if ((p + q) // n) % 2 == 0:
+    print("paul")
+else:
+    print("opponent")
+

🟢 Peach Powder Polygon

Solution in Python
1
+2
n = int(input())
+print("Yes" if n % 4 else "No")
+

🟢 Pea Soup and Pancakes

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
found = False
+for _ in range(int(input())):
+    k = int(input())
+
+    name = input()
+    items = [input() for _ in range(k)]
+    if "pea soup" in items and "pancakes" in items:
+        found = True
+        print(name)
+        break
+
+if not found:
+    print("Anywhere is fine I guess")
+

🟢 Peragrams

Solution in Python
1
+2
+3
+4
+5
+6
+7
from collections import Counter
 
-n = int(input())
-l = [[int(d) for d in input().split()] for _ in range(n)]
-
-c = []
-for i in range(1, n + 1):
-    c.extend(list(combinations(l, i)))
-
-d = []
-for i in c:
-    s, b = 1, 0
-    for x, y in i:
-        s *= x
-        b += y
-    d.append(abs(s - b))
-
-print(min(d))
-

🟢 Permuted Arithmetic Sequence

Solution in Python
 1
+s = Counter(input())
+v = [d for d in s.values() if d % 2]
+v = sorted(v)[:-1]
+
+print(len(v))
+

🟢 Perket

Solution in Python
 1
  2
  3
  4
@@ -7983,21 +7975,29 @@
 11
 12
 13
-14
def arithmetic(n):
-    d = [n[i] - n[i + 1] for i in range(len(n) - 1)]
-    return True if len(set(d)) == 1 else False
-
+14
+15
+16
+17
+18
from itertools import combinations
+
+n = int(input())
+l = [[int(d) for d in input().split()] for _ in range(n)]
 
-for _ in range(int(input())):
-    s = input().split()
-    n = [int(d) for d in s[1:]]
-    if arithmetic(n):
-        print("arithmetic")
-    elif arithmetic(sorted(n)):
-        print("permuted arithmetic")
-    else:
-        print("non-arithmetic")
-

🟢 Pervasive Heart Monitor

Solution in Python
 1
+c = []
+for i in range(1, n + 1):
+    c.extend(list(combinations(l, i)))
+
+d = []
+for i in c:
+    s, b = 1, 0
+    for x, y in i:
+        s *= x
+        b += y
+    d.append(abs(s - b))
+
+print(min(d))
+

🟢 Permuted Arithmetic Sequence

Solution in Python
 1
  2
  3
  4
@@ -8010,76 +8010,68 @@
 11
 12
 13
-14
-15
while True:
-    try:
-        line = input().split()
-    except:
-        break
-
-    name, rate = [], []
-    for p in line:
-        if p.isalpha():
-            name.append(p)
-        else:
-            rate.append(float(p))
-    name = " ".join(name)
-    rate = sum(rate) / len(rate)
-    print(f"{rate:.6f} {name}")
-

🟢 Pet

Solution in Python
1
-2
-3
-4
-5
-6
-7
-8
winner, max_score = 0, 0
-for i in range(5):
-    score = sum([int(d) for d in input().split()])
-    if score > max_score:
-        max_score = score
-        winner = i + 1
-
-print(winner, max_score)
-

🟢 Piece of Cake!

Solution in Python
1
-2
n, h, v = [int(d) for d in input().split()]
-print(4 * max(h * v, (n - h) * (n - v), h * (n - v), v * (n - h)))
-

🟢 Pig Latin

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
def translate(w):
-    if w[0] in "aeiouy":
-        return w + "yay"
-    else:
-        i = 1
-        while i < len(w):
-            if w[i] in "aeiouy":
-                break
-            i += 1
-        return w[i:] + w[:i] + "ay"
-
-
-while True:
-    try:
-        text = input()
-        print(" ".join([translate(w) for w in text.split()]))
-    except:
-        break
-

🟡 A Vicious Pikeman (Easy)

Solution in Python
def arithmetic(n):
+    d = [n[i] - n[i + 1] for i in range(len(n) - 1)]
+    return True if len(set(d)) == 1 else False
+
+
+for _ in range(int(input())):
+    s = input().split()
+    n = [int(d) for d in s[1:]]
+    if arithmetic(n):
+        print("arithmetic")
+    elif arithmetic(sorted(n)):
+        print("permuted arithmetic")
+    else:
+        print("non-arithmetic")
+

🟢 Pervasive Heart Monitor

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
while True:
+    try:
+        line = input().split()
+    except:
+        break
+
+    name, rate = [], []
+    for p in line:
+        if p.isalpha():
+            name.append(p)
+        else:
+            rate.append(float(p))
+    name = " ".join(name)
+    rate = sum(rate) / len(rate)
+    print(f"{rate:.6f} {name}")
+

🟢 Pet

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
winner, max_score = 0, 0
+for i in range(5):
+    score = sum([int(d) for d in input().split()])
+    if score > max_score:
+        max_score = score
+        winner = i + 1
+
+print(winner, max_score)
+

🟢 Piece of Cake!

Solution in Python
1
+2
n, h, v = [int(d) for d in input().split()]
+print(4 * max(h * v, (n - h) * (n - v), h * (n - v), v * (n - h)))
+

🟢 Pig Latin

Solution in Python
 1
  2
  3
  4
@@ -8096,245 +8088,207 @@
 15
 16
 17
-18
-19
def f(n, time, l):
-    total_time, penalty = 0, 0
-    for i, t in enumerate(sorted(l)):
-        if total_time + t > time:
-            return i, penalty
-        total_time += t
-        penalty = (penalty + total_time) % 1_000_000_007
-    return n, penalty
-
-
-n, t = [int(d) for d in input().split()]
-a, b, c, t0 = [int(d) for d in input().split()]
-l = [t0]
-for _ in range(n - 1):
-    l.append(((a * l[-1] + b) % c) + 1)
-
-
-n, penalty = f(n, t, l)
-print(n, penalty)
-

🟢 Pizza Crust

Solution in Python
1
-2
r, c = [int(d) for d in input().split()]
-print(f"{(r-c)**2 / r**2 * 100:.6f}")
-

🟢 Pizzubestun

Solution in Python
1
-2
-3
-4
-5
-6
n = int(input())
-prices = [int(input().split()[-1]) for _ in range(n)]
-if n % 2:
-    prices.append(0)
-prices = sorted(prices, reverse=True)
-print(sum(prices[i] for i in range(0, len(prices), 2)))
-

🟢 Planetaris

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
_, a = [int(d) for d in input().split()]
-e = sorted([int(d) + 1 for d in input().split()])
-
-t = 0
-for s in e:
-    if a >= s:
-        t += 1
-        a -= s
-    else:
-        break
-print(t)
-

🟢 Planina

Solution in Python
1
-2
-3
-4
-5
-6
-7
-8
-9
def p(n):
-    if n == 1:
-        return 3
-    else:
-        return p(n - 1) * 2 - 1
-
-
-n = int(input())
-print(p(n) ** 2)
-

🟢 Planting Trees

Solution in Python
1
+18
def translate(w):
+    if w[0] in "aeiouy":
+        return w + "yay"
+    else:
+        i = 1
+        while i < len(w):
+            if w[i] in "aeiouy":
+                break
+            i += 1
+        return w[i:] + w[:i] + "ay"
+
+
+while True:
+    try:
+        text = input()
+        print(" ".join([translate(w) for w in text.split()]))
+    except:
+        break
+

🟡 A Vicious Pikeman (Easy)

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
def f(n, time, l):
+    total_time, penalty = 0, 0
+    for i, t in enumerate(sorted(l)):
+        if total_time + t > time:
+            return i, penalty
+        total_time += t
+        penalty = (penalty + total_time) % 1_000_000_007
+    return n, penalty
+
+
+n, t = [int(d) for d in input().split()]
+a, b, c, t0 = [int(d) for d in input().split()]
+l = [t0]
+for _ in range(n - 1):
+    l.append(((a * l[-1] + b) % c) + 1)
+
+
+n, penalty = f(n, t, l)
+print(n, penalty)
+

🟢 Pizza Crust

Solution in Python
1
+2
r, c = [int(d) for d in input().split()]
+print(f"{(r-c)**2 / r**2 * 100:.6f}")
+

🟢 Pizzubestun

Solution in Python
1
+2
+3
+4
+5
+6
n = int(input())
+prices = [int(input().split()[-1]) for _ in range(n)]
+if n % 2:
+    prices.append(0)
+prices = sorted(prices, reverse=True)
+print(sum(prices[i] for i in range(0, len(prices), 2)))
+

🟢 Planetaris

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
_, a = [int(d) for d in input().split()]
+e = sorted([int(d) + 1 for d in input().split()])
+
+t = 0
+for s in e:
+    if a >= s:
+        t += 1
+        a -= s
+    else:
+        break
+print(t)
+

🟢 Planina

Solution in Python
1
 2
 3
 4
-5
n = int(input())
-t = [int(d) for d in input().split()]
-
-days = [v + d for v, d in zip(sorted(t, reverse=True), range(1, n + 1))]
-print(max(days) + 1)
-

🟢 Pokechat

Solution in Python
1
+5
+6
+7
+8
+9
def p(n):
+    if n == 1:
+        return 3
+    else:
+        return p(n - 1) * 2 - 1
+
+
+n = int(input())
+print(p(n) ** 2)
+

🟢 Planting Trees

Solution in Python
1
 2
 3
-4
chars = input()
-ids = input()
-ids = [int(ids[i : i + 3]) - 1 for i in range(0, len(ids), 3)]
-print("".join([chars[i] for i in ids]))
-

🟢 Poker Hand

Solution in Python
1
+4
+5
n = int(input())
+t = [int(d) for d in input().split()]
+
+days = [v + d for v, d in zip(sorted(t, reverse=True), range(1, n + 1))]
+print(max(days) + 1)
+

🟢 Pokechat

Solution in Python
1
 2
 3
-4
from collections import Counter
-
-hands = [h[0] for h in input().split()]
-print(max(Counter(hands).values()))
-

🟢 Polynomial Multiplication 1

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
from collections import Counter
+4
chars = input()
+ids = input()
+ids = [int(ids[i : i + 3]) - 1 for i in range(0, len(ids), 3)]
+print("".join([chars[i] for i in ids]))
+

🟢 Poker Hand

Solution in Python
1
+2
+3
+4
from collections import Counter
 
-for _ in range(int(input())):
-    n = int(input())
-    a = [int(d) for d in input().split()]
-    m = int(input())
-    b = [int(d) for d in input().split()]
-    p = Counter()
-    for i in range(n + 1):
-        for j in range(m + 1):
-            p[i + j] += a[i] * b[j]
-    keys = max([k for k in p.keys() if p[k] != 0])
-    print(keys)
-    print(" ".join([str(p[k]) for k in range(keys + 1)]))
-

🟢 Popularity Contest

Solution in Python
1
-2
-3
-4
-5
-6
-7
n, m = [int(d) for d in input().split()]
-p = [0] * n
-for _ in range(m):
-    a, b = [int(d) - 1 for d in input().split()]
-    p[a] += 1
-    p[b] += 1
-print(" ".join([str(a - b) for a, b in zip(p, range(1, 1 + n))]))
-

🟢 Pot

Solution in Python
1
+hands = [h[0] for h in input().split()]
+print(max(Counter(hands).values()))
+

🟢 Polynomial Multiplication 1

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
from collections import Counter
+
+for _ in range(int(input())):
+    n = int(input())
+    a = [int(d) for d in input().split()]
+    m = int(input())
+    b = [int(d) for d in input().split()]
+    p = Counter()
+    for i in range(n + 1):
+        for j in range(m + 1):
+            p[i + j] += a[i] * b[j]
+    keys = max([k for k in p.keys() if p[k] != 0])
+    print(keys)
+    print(" ".join([str(p[k]) for k in range(keys + 1)]))
+

🟢 Popularity Contest

Solution in Python
1
 2
 3
 4
 5
 6
-7
n = int(input())
-total = 0
-for _ in range(n):
-    line = input()
-    n, p = int(line[:-1]), int(line[-1])
-    total += n**p
-print(total)
-

🟢 Saving Princess Peach

Solution in Python
1
+7
n, m = [int(d) for d in input().split()]
+p = [0] * n
+for _ in range(m):
+    a, b = [int(d) - 1 for d in input().split()]
+    p[a] += 1
+    p[b] += 1
+print(" ".join([str(a - b) for a, b in zip(p, range(1, 1 + n))]))
+

🟢 Pot

Solution in Python
1
 2
 3
 4
 5
 6
-7
-8
-9
n, y = [int(d) for d in input().split()]
-found = []
-for _ in range(y):
-    found.append(int(input()))
-found = set(found)
-for i in range(n):
-    if i not in found:
-        print(i)
-print(f"Mario got {len(found)} of the dangerous obstacles.")
-

🟢 Printing Costs

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
t = """
-    0        !   9        "   6        #  24        $  29        %  22
-&  24        '   3        (  12        )  12        *  17        +  13
-,   7        -   7        .   4        /  10        0  22        1  19
-2  22        3  23        4  21        5  27        6  26        7  16
-8  23        9  26        :   8        ;  11        <  10        =  14
->  10        ?  15        @  32        A  24        B  29        C  20
-D  26        E  26        F  20        G  25        H  25        I  18
-J  18        K  21        L  16        M  28        N  25        O  26
-P  23        Q  31        R  28        S  25        T  16        U  23
-V  19        W  26        X  18        Y  14        Z  22        [  18
-\  10        ]  18        ^   7        _   8        `   3        a  23
-b  25        c  17        d  25        e  23        f  18        g  30
-h  21        i  15        j  20        k  21        l  16        m  22
-n  18        o  20        p  25        q  25        r  13        s  21
-t  17        u  17        v  13        w  19        x  13        y  24
-z  19        {  18        |  12        }  18        ~   9
-"""
-
-m = []
-for row in t.splitlines():
-    if not row:
-        continue
-    values = row.split()
-    if len(values) % 2:
-        values.insert(0, " ")
-
-    for i in range(0, len(values), 2):
-        m.append((values[i], int(values[i + 1])))
-m = dict(m)
-
-while True:
-    try:
-        s = input()
-    except:
-        break
-    print(sum([m[c] for c in s]))
-

🟢 Provinces and Gold

Solution in Python
 1
+7
n = int(input())
+total = 0
+for _ in range(n):
+    line = input()
+    n, p = int(line[:-1]), int(line[-1])
+    total += n**p
+print(total)
+

🟢 Saving Princess Peach

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
+9
n, y = [int(d) for d in input().split()]
+found = []
+for _ in range(y):
+    found.append(int(input()))
+found = set(found)
+for i in range(n):
+    if i not in found:
+        print(i)
+print(f"Mario got {len(found)} of the dangerous obstacles.")
+

🟢 Printing Costs

Solution in Python
 1
  2
  3
  4
@@ -8353,27 +8307,61 @@
 17
 18
 19
-20
g, s, c = [int(d) for d in input().split()]
-
-buying = 3 * g + 2 * s + 1 * c
-result = []
-
-if buying >= 8:
-    result.append("Province")
-elif buying >= 5:
-    result.append("Duchy")
-elif buying >= 2:
-    result.append("Estate")
-
-if buying >= 6:
-    result.append("Gold")
-elif buying >= 3:
-    result.append("Silver")
-else:
-    result.append("Copper")
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
t = """
+    0        !   9        "   6        #  24        $  29        %  22
+&  24        '   3        (  12        )  12        *  17        +  13
+,   7        -   7        .   4        /  10        0  22        1  19
+2  22        3  23        4  21        5  27        6  26        7  16
+8  23        9  26        :   8        ;  11        <  10        =  14
+>  10        ?  15        @  32        A  24        B  29        C  20
+D  26        E  26        F  20        G  25        H  25        I  18
+J  18        K  21        L  16        M  28        N  25        O  26
+P  23        Q  31        R  28        S  25        T  16        U  23
+V  19        W  26        X  18        Y  14        Z  22        [  18
+\  10        ]  18        ^   7        _   8        `   3        a  23
+b  25        c  17        d  25        e  23        f  18        g  30
+h  21        i  15        j  20        k  21        l  16        m  22
+n  18        o  20        p  25        q  25        r  13        s  21
+t  17        u  17        v  13        w  19        x  13        y  24
+z  19        {  18        |  12        }  18        ~   9
+"""
 
-print(" or ".join(result))
-

🟢 Prsteni

Solution in Python
 1
+m = []
+for row in t.splitlines():
+    if not row:
+        continue
+    values = row.split()
+    if len(values) % 2:
+        values.insert(0, " ")
+
+    for i in range(0, len(values), 2):
+        m.append((values[i], int(values[i + 1])))
+m = dict(m)
+
+while True:
+    try:
+        s = input()
+    except:
+        break
+    print(sum([m[c] for c in s]))
+

🟢 Provinces and Gold

Solution in Python
 1
  2
  3
  4
@@ -8383,18 +8371,36 @@
  8
  9
 10
-11
import math
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
g, s, c = [int(d) for d in input().split()]
 
-_ = input()
-numbers = [int(d) for d in input().split()]
+buying = 3 * g + 2 * s + 1 * c
+result = []
 
-base = numbers.pop(0)
-
-gcd = [math.gcd(base, n) for n in numbers]
-
-for g, n in zip(gcd, numbers):
-    print(f"{int(base/g)}/{int(n/g)}")
-

🟢 Prva

Solution in Python
 1
+if buying >= 8:
+    result.append("Province")
+elif buying >= 5:
+    result.append("Duchy")
+elif buying >= 2:
+    result.append("Estate")
+
+if buying >= 6:
+    result.append("Gold")
+elif buying >= 3:
+    result.append("Silver")
+else:
+    result.append("Copper")
+
+print(" or ".join(result))
+

🟢 Prsteni

Solution in Python
 1
  2
  3
  4
@@ -8404,22 +8410,18 @@
  8
  9
 10
-11
-12
-13
r, c = [int(d) for d in input().split()]
-puzzle = []
-for _ in range(r):
-    puzzle.append(input())
+11
import math
+
+_ = input()
+numbers = [int(d) for d in input().split()]
 
-words = set()
-for row in puzzle:
-    words.update([w for w in row.split("#") if len(w) > 1])
-for i in range(c):
-    col = "".join([row[i] for row in puzzle])
-    words.update([w for w in col.split("#") if len(w) > 1])
-
-print(sorted(words)[0])
-

🟢 Ptice

Solution in Python
 1
+base = numbers.pop(0)
+
+gcd = [math.gcd(base, n) for n in numbers]
+
+for g, n in zip(gcd, numbers):
+    print(f"{int(base/g)}/{int(n/g)}")
+

🟢 Prva

Solution in Python
 1
  2
  3
  4
@@ -8431,118 +8433,20 @@
 10
 11
 12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
def adrian(n):
-    if n == 0:
-        return ""
-    elif n == 1:
-        return "A"
-    elif n == 2:
-        return "AB"
-    elif n == 3:
-        return "ABC"
-    else:
-        duplicate = n // 3
-        return adrian(3) * duplicate + adrian(n % 3)
-
-
-def bruno(n):
-    if n == 0:
-        return ""
-    elif n == 1:
-        return "B"
-    elif n == 2:
-        return "BA"
-    elif n == 3:
-        return "BAB"
-    elif n == 4:
-        return "BABC"
-    else:
-        duplicate = n // 4
-        return bruno(4) * duplicate + bruno(n % 4)
-
-
-def goran(n):
-    if n == 0:
-        return ""
-    elif n in [1, 2]:
-        return "C" * n
-    elif n in [3, 4]:
-        return "CC" + "A" * (n - 2)
-    elif n in [5, 6]:
-        return "CCAA" + "B" * (n - 4)
-    else:
-        duplicate = n // 6
-        return goran(6) * duplicate + goran(n % 6)
-
-
-def get_score(ans, guess):
-    return sum([a == g for a, g in zip(ans, guess)])
-
-
-n = int(input())
-ans = input()
-
-result = {}
-result["Adrian"] = get_score(ans, adrian(n))
-result["Bruno"] = get_score(ans, bruno(n))
-result["Goran"] = get_score(ans, goran(n))
-
-best = max(result.values())
-print(best)
-
-for name, score in result.items():
-    if score == best:
-        print(name)
-

🟢 Building Pyramids

Solution in Python
r, c = [int(d) for d in input().split()]
+puzzle = []
+for _ in range(r):
+    puzzle.append(input())
+
+words = set()
+for row in puzzle:
+    words.update([w for w in row.split("#") if len(w) > 1])
+for i in range(c):
+    col = "".join([row[i] for row in puzzle])
+    words.update([w for w in col.split("#") if len(w) > 1])
+
+print(sorted(words)[0])
+

🟢 Ptice

Solution in Python
 1
  2
  3
  4
@@ -8553,73 +8457,153 @@
  9
 10
 11
-12
n = int(input())
-
-height = 0
-while True:
-    height += 1
-    blocks = (2 * height - 1) ** 2
-    if blocks > n:
-        height -= 1
-        break
-    n -= blocks
-
-print(height)
-

🟢 Quality-Adjusted Life-Year

Solution in Python
1
-2
-3
-4
-5
-6
qaly = 0
-for _ in range(int(input())):
-    q, y = input().split()
-    q, y = float(q), float(y)
-    qaly += q * y
-print(qaly)
-

🟢 Quadrant Selection

Solutions in 4 languages
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
package main
-
-import "fmt"
-
-func main() {
-    var x, y int
-    fmt.Scan(&x)
-    fmt.Scan(&y)
-    if x > 0 {
-        if y > 0 {
-            fmt.Println(1)
-        } else {
-            fmt.Println(4)
-        }
-    } else {
-        if y > 0 {
-            fmt.Println(2)
-        } else {
-            fmt.Println(3)
-        }
-    }
-}
-
 1
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
def adrian(n):
+    if n == 0:
+        return ""
+    elif n == 1:
+        return "A"
+    elif n == 2:
+        return "AB"
+    elif n == 3:
+        return "ABC"
+    else:
+        duplicate = n // 3
+        return adrian(3) * duplicate + adrian(n % 3)
+
+
+def bruno(n):
+    if n == 0:
+        return ""
+    elif n == 1:
+        return "B"
+    elif n == 2:
+        return "BA"
+    elif n == 3:
+        return "BAB"
+    elif n == 4:
+        return "BABC"
+    else:
+        duplicate = n // 4
+        return bruno(4) * duplicate + bruno(n % 4)
+
+
+def goran(n):
+    if n == 0:
+        return ""
+    elif n in [1, 2]:
+        return "C" * n
+    elif n in [3, 4]:
+        return "CC" + "A" * (n - 2)
+    elif n in [5, 6]:
+        return "CCAA" + "B" * (n - 4)
+    else:
+        duplicate = n // 6
+        return goran(6) * duplicate + goran(n % 6)
+
+
+def get_score(ans, guess):
+    return sum([a == g for a, g in zip(ans, guess)])
+
+
+n = int(input())
+ans = input()
+
+result = {}
+result["Adrian"] = get_score(ans, adrian(n))
+result["Bruno"] = get_score(ans, bruno(n))
+result["Goran"] = get_score(ans, goran(n))
+
+best = max(result.values())
+print(best)
+
+for name, score in result.items():
+    if score == best:
+        print(name)
+

🟢 Building Pyramids

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
n = int(input())
+
+height = 0
+while True:
+    height += 1
+    blocks = (2 * height - 1) ** 2
+    if blocks > n:
+        height -= 1
+        break
+    n -= blocks
+
+print(height)
+

🟢 Quality-Adjusted Life-Year

Solution in Python
1
+2
+3
+4
+5
+6
qaly = 0
+for _ in range(int(input())):
+    q, y = input().split()
+    q, y = float(q), float(y)
+    qaly += q * y
+print(qaly)
+

🟢 Quadrant Selection

Solutions in 4 languages
 1
  2
  3
  4
@@ -8640,32 +8624,28 @@
 19
 20
 21
-22
-23
-24
import java.util.Scanner;
+22
package main
 
-class QuadrantSelection {
-    public static void main(String[] args) {
-        Scanner s = new Scanner(System.in);
-        int x = s.nextInt();
-        int y = s.nextInt();
-
-        if (x > 0) {
-            if (y > 0) {
-                System.out.println(1);
-            } else {
-                System.out.println(4);
-            }
-        } else {
-            if (y > 0) {
-                System.out.println(2);
-            } else {
-                System.out.println(3);
-            }
-        }
-
-    }
-}
+import "fmt"
+
+func main() {
+    var x, y int
+    fmt.Scan(&x)
+    fmt.Scan(&y)
+    if x > 0 {
+        if y > 0 {
+            fmt.Println(1)
+        } else {
+            fmt.Println(4)
+        }
+    } else {
+        if y > 0 {
+            fmt.Println(2)
+        } else {
+            fmt.Println(3)
+        }
+    }
+}
 
 1
  2
  3
@@ -8677,18 +8657,42 @@
  9
 10
 11
-12
x = int(input())
-y = int(input())
-if x > 0:
-    if y > 0:
-        print(1)
-    else:
-        print(4)
-else:
-    if y > 0:
-        print(2)
-    else:
-        print(3)
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
import java.util.Scanner;
+
+class QuadrantSelection {
+    public static void main(String[] args) {
+        Scanner s = new Scanner(System.in);
+        int x = s.nextInt();
+        int y = s.nextInt();
+
+        if (x > 0) {
+            if (y > 0) {
+                System.out.println(1);
+            } else {
+                System.out.println(4);
+            }
+        } else {
+            if (y > 0) {
+                System.out.println(2);
+            } else {
+                System.out.println(3);
+            }
+        }
+
+    }
+}
 
 1
  2
  3
@@ -8700,41 +8704,19 @@
  9
 10
 11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
fn main() {
-    let mut line1 = String::new();
-    std::io::stdin().read_line(&mut line1).unwrap();
-    let x: i32 = line1.trim().parse().unwrap();
-
-    let mut line2 = String::new();
-    std::io::stdin().read_line(&mut line2).unwrap();
-    let y: i32 = line2.trim().parse().unwrap();
-
-    if x > 0 {
-        if y > 0 {
-            println!("1");
-        } else {
-            println!("4");
-        }
-    } else {
-        if y > 0 {
-            println!("2");
-        } else {
-            println!("3");
-        }
-    }
-}
-

🟢 Quick Brown Fox

Solution in Python
x = int(input())
+y = int(input())
+if x > 0:
+    if y > 0:
+        print(1)
+    else:
+        print(4)
+else:
+    if y > 0:
+        print(2)
+    else:
+        print(3)
+
 1
  2
  3
  4
@@ -8743,17 +8725,43 @@
  7
  8
  9
-10
import string
-
-for _ in range(int(input())):
-    p = set([c for c in input().lower() if c.isalpha()])
-    if len(p) == 26:
-        print("pangram")
-    else:
-        print(
-            f"missing {''.join([c for c in string.ascii_lowercase[:26] if c not in p])}"
-        )
-

🟢 Quick Estimates

Solutions in 2 languages
 1
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
fn main() {
+    let mut line1 = String::new();
+    std::io::stdin().read_line(&mut line1).unwrap();
+    let x: i32 = line1.trim().parse().unwrap();
+
+    let mut line2 = String::new();
+    std::io::stdin().read_line(&mut line2).unwrap();
+    let y: i32 = line2.trim().parse().unwrap();
+
+    if x > 0 {
+        if y > 0 {
+            println!("1");
+        } else {
+            println!("4");
+        }
+    } else {
+        if y > 0 {
+            println!("2");
+        } else {
+            println!("3");
+        }
+    }
+}
+

🟢 Quick Brown Fox

Solution in Python
 1
  2
  3
  4
@@ -8762,43 +8770,43 @@
  7
  8
  9
-10
-11
-12
import java.util.Scanner;
+10
import string
 
-class QuickEstimates {
-    public static void main(String[] args) {
-        Scanner s = new Scanner(System.in);
-        int n = s.nextInt();
-        for (int i = 0; i < n; i++) {
-            String cost = s.next();
-            System.out.println(cost.length());
-        }
-    }
-}
-
1
-2
for _ in range(int(input())):
-    print(len(input()))
-

🟢 Quite a Problem

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
while True:
-    try:
-        line = input()
-    except:
-        break
-
-    if "problem" in line.lower():
-        print("yes")
-    else:
-        print("no")
-

🟢 R2

Solutions in 4 languages
 1
+for _ in range(int(input())):
+    p = set([c for c in input().lower() if c.isalpha()])
+    if len(p) == 26:
+        print("pangram")
+    else:
+        print(
+            f"missing {''.join([c for c in string.ascii_lowercase[:26] if c not in p])}"
+        )
+

🟢 Quick Estimates

Solutions in 2 languages
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
import java.util.Scanner;
+
+class QuickEstimates {
+    public static void main(String[] args) {
+        Scanner s = new Scanner(System.in);
+        int n = s.nextInt();
+        for (int i = 0; i < n; i++) {
+            String cost = s.next();
+            System.out.println(cost.length());
+        }
+    }
+}
+
1
+2
for _ in range(int(input())):
+    print(len(input()))
+

🟢 Quite a Problem

Solution in Python
 1
  2
  3
  4
@@ -8807,19 +8815,17 @@
  7
  8
  9
-10
-11
#include <iostream>
-
-using namespace std;
-
-int main()
-{
-    int r1, s;
-    cin >> r1 >> s;
-    cout << 2 * s - r1 << endl;
-    return 0;
-}
-
while True:
+    try:
+        line = input()
+    except:
+        break
+
+    if "problem" in line.lower():
+        print("yes")
+    else:
+        print("no")
+

🟢 R2

Solutions in 4 languages
 1
  2
  3
  4
@@ -8828,16 +8834,18 @@
  7
  8
  9
-10
package main
+10
+11
#include <iostream>
 
-import "fmt"
+using namespace std;
 
-func main() {
-    var r1, s int
-    fmt.Scan(&r1)
-    fmt.Scan(&s)
-    fmt.Println(2*s - r1)
-}
+int main()
+{
+    int r1, s;
+    cin >> r1 >> s;
+    cout << 2 * s - r1 << endl;
+    return 0;
+}
 
 1
  2
  3
@@ -8847,95 +8855,87 @@
  7
  8
  9
-10
import java.util.Scanner;
+10
package main
 
-class R2 {
-    public static void main(String[] args) {
-        Scanner scanner = new Scanner(System.in);
-        int r1 = scanner.nextInt();
-        int s = scanner.nextInt();
-        System.out.println(2 * s - r1);
-    }
+import "fmt"
+
+func main() {
+    var r1, s int
+    fmt.Scan(&r1)
+    fmt.Scan(&s)
+    fmt.Println(2*s - r1)
 }
-
1
-2
-3
r1, s = [int(d) for d in input().split()]
-r2 = 2 * s - r1
-print(r2)
-

🟢 Racing Around the Alphabet

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
import math
-
-tokens = dict([(chr(c), c - ord("A") + 1) for c in range(ord("A"), ord("Z") + 1)])
-tokens[" "] = 27
-tokens["'"] = 28
-t = math.pi * 60 / (28 * 15)
-for _ in range(int(input())):
-    m = input()
-    total = 1
-    prev = m[0]
-    for c in m[1:]:
-        dist = abs(tokens[prev] - tokens[c])
-        total += 1 + t * min(dist, 28 - dist)
-        prev = c
-    print(total)
-

🟢 Ragged Right

Solution in Python
1
-2
-3
-4
-5
-6
-7
-8
-9
l = []
-while True:
-    try:
-        s = input()
-    except:
-        break
-    l.append(len(s))
-m = max(l)
-print(sum([(n - m) ** 2 for n in l[:-1]]))
-

🟢 Railroad

Solutions in 3 languages
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
package main
-
-import "fmt"
-
-func main() {
-    var x, y int
-    fmt.Scan(&x)
-    fmt.Scan(&y)
-    if y%2 == 1 {
-        fmt.Println("impossible")
-    } else {
-        fmt.Println("possible")
-    }
-}
-
 1
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
import java.util.Scanner;
+
+class R2 {
+    public static void main(String[] args) {
+        Scanner scanner = new Scanner(System.in);
+        int r1 = scanner.nextInt();
+        int s = scanner.nextInt();
+        System.out.println(2 * s - r1);
+    }
+}
+
1
+2
+3
r1, s = [int(d) for d in input().split()]
+r2 = 2 * s - r1
+print(r2)
+

🟢 Racing Around the Alphabet

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
import math
+
+tokens = dict([(chr(c), c - ord("A") + 1) for c in range(ord("A"), ord("Z") + 1)])
+tokens[" "] = 27
+tokens["'"] = 28
+t = math.pi * 60 / (28 * 15)
+for _ in range(int(input())):
+    m = input()
+    total = 1
+    prev = m[0]
+    for c in m[1:]:
+        dist = abs(tokens[prev] - tokens[c])
+        total += 1 + t * min(dist, 28 - dist)
+        prev = c
+    print(total)
+

🟢 Ragged Right

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
+9
l = []
+while True:
+    try:
+        s = input()
+    except:
+        break
+    l.append(len(s))
+m = max(l)
+print(sum([(n - m) ** 2 for n in l[:-1]]))
+

🟢 Railroad

Solutions in 3 languages
 1
  2
  3
  4
@@ -8948,114 +8948,116 @@
 11
 12
 13
-14
import java.util.Scanner;
+14
package main
 
-class Railroad {
-    public static void main(String[] args) {
-        Scanner s = new Scanner(System.in);
-        int x = s.nextInt();
-        int y = s.nextInt();
-        if (y % 2 == 1) {
-            System.out.println("impossible");
-        } else {
-            System.out.println("possible");
-        }
+import "fmt"
+
+func main() {
+    var x, y int
+    fmt.Scan(&x)
+    fmt.Scan(&y)
+    if y%2 == 1 {
+        fmt.Println("impossible")
+    } else {
+        fmt.Println("possible")
     }
 }
-
1
-2
-3
-4
-5
_, y = [int(d) for d in input().split()]
-if y % 2:
-    print("impossible")
-else:
-    print("possible")
-

🟢 A Rank Problem

Solution in Python
1
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
import java.util.Scanner;
+
+class Railroad {
+    public static void main(String[] args) {
+        Scanner s = new Scanner(System.in);
+        int x = s.nextInt();
+        int y = s.nextInt();
+        if (y % 2 == 1) {
+            System.out.println("impossible");
+        } else {
+            System.out.println("possible");
+        }
+    }
+}
+
1
 2
 3
 4
-5
-6
-7
-8
-9
n, m = [int(d) for d in input().split()]
-ranking = [f"T{i}" for i in range(1, 1 + n)]
-for _ in range(m):
-    i, j = input().split()
-    if ranking.index(i) < ranking.index(j):
-        continue
-    ranking.remove(j)
-    ranking.insert(ranking.index(i) + 1, j)
-print(" ".join(ranking))
-

🟢 Rating Problems

Solutions in 2 languages
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
import java.util.Scanner;
-
-class RatingProblems {
-    public static void main(String[] args) {
-        Scanner s = new Scanner(System.in);
-        int n = s.nextInt();
-        int k = s.nextInt();
-        int score = 0;
-        for (int i = 0; i < k; i++) {
-            score += s.nextInt();
-        }
-        float min = (score - 3 * (n - k)) / (float) n;
-        float max = (score + 3 * (n - k)) / (float) n;
-        System.out.println(min + " " + max);
-    }
-}
-
1
-2
-3
-4
-5
-6
n, k = [int(d) for d in input().split()]
-score = 0
-for _ in range(k):
-    score += int(input())
-
-print((score - 3 * (n - k)) / n, (score + 3 * (n - k)) / n)
-

🟢 A Rational Sequence 2

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
def f(l, r):
-    if l == r:
-        return 1
-    elif l > r:
-        return 2 * f(l - r, r) + 1
-    else:
-        return 2 * f(l, r - l)
-
-
-for _ in range(int(input())):
-    k, v = input().split()
-    l, r = [int(d) for d in v.split("/")]
-    print(f"{k} {f(l,r)}")
-

🟢 Scaling Recipes

Solution in Python
 1
+5
_, y = [int(d) for d in input().split()]
+if y % 2:
+    print("impossible")
+else:
+    print("possible")
+

🟢 A Rank Problem

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
+9
n, m = [int(d) for d in input().split()]
+ranking = [f"T{i}" for i in range(1, 1 + n)]
+for _ in range(m):
+    i, j = input().split()
+    if ranking.index(i) < ranking.index(j):
+        continue
+    ranking.remove(j)
+    ranking.insert(ranking.index(i) + 1, j)
+print(" ".join(ranking))
+

🟢 Rating Problems

Solutions in 2 languages
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
import java.util.Scanner;
+
+class RatingProblems {
+    public static void main(String[] args) {
+        Scanner s = new Scanner(System.in);
+        int n = s.nextInt();
+        int k = s.nextInt();
+        int score = 0;
+        for (int i = 0; i < k; i++) {
+            score += s.nextInt();
+        }
+        float min = (score - 3 * (n - k)) / (float) n;
+        float max = (score + 3 * (n - k)) / (float) n;
+        System.out.println(min + " " + max);
+    }
+}
+
1
+2
+3
+4
+5
+6
n, k = [int(d) for d in input().split()]
+score = 0
+for _ in range(k):
+    score += int(input())
+
+print((score - 3 * (n - k)) / n, (score + 3 * (n - k)) / n)
+

🟢 A Rational Sequence 2

Solution in Python
 1
  2
  3
  4
@@ -9067,28 +9069,20 @@
 10
 11
 12
-13
-14
-15
-16
-17
for i in range(int(input())):
-    r, p, d = [int(d) for d in input().split()]
-    recipe = {}
-    main = None
-    for _ in range(r):
-        name, weight, percent = input().split()
-        weight = float(weight)
-        percent = float(percent)
-        if percent == 100.0:
-            main = name
-        recipe[name] = (weight, percent)
-    scale = d / p
-    print(f"Recipe # {i+1}")
-    dw = recipe[main][0] * scale
-    for k in recipe:
-        print(k, f"{recipe[k][1] * dw / 100:.1f}")
-    print("-" * 40)
-

🟢 Recount

Solution in Python
def f(l, r):
+    if l == r:
+        return 1
+    elif l > r:
+        return 2 * f(l - r, r) + 1
+    else:
+        return 2 * f(l, r - l)
+
+
+for _ in range(int(input())):
+    k, v = input().split()
+    l, r = [int(d) for d in v.split("/")]
+    print(f"{k} {f(l,r)}")
+

🟢 Scaling Recipes

Solution in Python
 1
  2
  3
  4
@@ -9100,148 +9094,148 @@
 10
 11
 12
-13
from collections import Counter
-
-c = Counter()
-while True:
-    try:
-        name = input()
-    except:
-        break
-    c[name] += 1
-
-highest = max(c.values())
-names = [k for k in c if c[k] == highest]
-print("Runoff!" if len(names) > 1 else names.pop())
-

🟢 Rectangle Area

Solution in Python
1
-2
-3
x1, y1, x2, y2 = [float(d) for d in input().split()]
+13
+14
+15
+16
+17
for i in range(int(input())):
+    r, p, d = [int(d) for d in input().split()]
+    recipe = {}
+    main = None
+    for _ in range(r):
+        name, weight, percent = input().split()
+        weight = float(weight)
+        percent = float(percent)
+        if percent == 100.0:
+            main = name
+        recipe[name] = (weight, percent)
+    scale = d / p
+    print(f"Recipe # {i+1}")
+    dw = recipe[main][0] * scale
+    for k in recipe:
+        print(k, f"{recipe[k][1] * dw / 100:.1f}")
+    print("-" * 40)
+

🟢 Recount

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
from collections import Counter
 
-print(abs((x1 - x2) * (y1 - y2)))
-

🟢 Reduced ID Numbers

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
g = int(input())
-ids = []
-for _ in range(g):
-    ids.append(int(input()))
-
-m = 1
-while True:
-    v = [d % m for d in ids]
-    if g == len(set(v)):
-        break
-    m += 1
-
-print(m)
-

🟢 Relocation

Solution in Python
1
-2
-3
-4
-5
-6
-7
-8
n, q = [int(d) for d in input().split()]
-x = [int(d) for d in input().split()]
-for _ in range(q):
-    req = [int(d) for d in input().split()]
-    if req[0] == 1:
-        x[req[1] - 1] = req[2]
-    elif req[0] == 2:
-        print(abs(x[req[1] - 1] - x[req[2] - 1]))
-

🟢 Restaurant Opening

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
from itertools import product
-
-n, m = [int(d) for d in input().split()]
-
-g = []
-for _ in range(n):
-    g.append([int(d) for d in input().split()])
-
-l = list(product(range(n), range(m)))
-
-c = []
-for i, j in l:
-    s = 0
-    for a, b in l:
-        s += g[a][b] * (abs(i - a) + abs(j - b))
-    c.append(s)
-
-print(min(c))
-

🟢 Reversed Binary Numbers

Solution in Python
1
-2
-3
-4
-5
-6
-7
-8
n = int(input())
+c = Counter()
+while True:
+    try:
+        name = input()
+    except:
+        break
+    c[name] += 1
+
+highest = max(c.values())
+names = [k for k in c if c[k] == highest]
+print("Runoff!" if len(names) > 1 else names.pop())
+

🟢 Rectangle Area

Solution in Python
1
+2
+3
x1, y1, x2, y2 = [float(d) for d in input().split()]
+
+print(abs((x1 - x2) * (y1 - y2)))
+

🟢 Reduced ID Numbers

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
g = int(input())
+ids = []
+for _ in range(g):
+    ids.append(int(input()))
+
+m = 1
+while True:
+    v = [d % m for d in ids]
+    if g == len(set(v)):
+        break
+    m += 1
+
+print(m)
+

🟢 Relocation

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
n, q = [int(d) for d in input().split()]
+x = [int(d) for d in input().split()]
+for _ in range(q):
+    req = [int(d) for d in input().split()]
+    if req[0] == 1:
+        x[req[1] - 1] = req[2]
+    elif req[0] == 2:
+        print(abs(x[req[1] - 1] - x[req[2] - 1]))
+

🟢 Restaurant Opening

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
from itertools import product
 
-b = []
-while n:
-    b.append(n % 2)
-    n //= 2
-
-print(sum([d * (2**p) for d, p in zip(b, reversed(range(len(b))))]))
-

🟢 Reverse Rot

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
import string
+n, m = [int(d) for d in input().split()]
+
+g = []
+for _ in range(n):
+    g.append([int(d) for d in input().split()])
+
+l = list(product(range(n), range(m)))
+
+c = []
+for i, j in l:
+    s = 0
+    for a, b in l:
+        s += g[a][b] * (abs(i - a) + abs(j - b))
+    c.append(s)
+
+print(min(c))
+

🟢 Reversed Binary Numbers

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
n = int(input())
 
-rotations = string.ascii_uppercase + "_."
-
-
-def rotate(c, n):
-    index = (rotations.index(c) + n) % 28
-    return rotations[index]
-
-
-while True:
-    line = input()
-    if line == "0":
-        break
-    n, m = line.split()
-    n = int(n)
-    print("".join([rotate(c, n) for c in m[::-1]]))
-

🟢 Riječi

Solutions in 3 languages
 1
+b = []
+while n:
+    b.append(n % 2)
+    n //= 2
+
+print(sum([d * (2**p) for d, p in zip(b, reversed(range(len(b))))]))
+

🟢 Reverse Rot

Solution in Python
 1
  2
  3
  4
@@ -9254,21 +9248,27 @@
 11
 12
 13
-14
package main
+14
+15
+16
+17
import string
 
-import "fmt"
+rotations = string.ascii_uppercase + "_."
 
-func main() {
-    var n int
-    fmt.Scan(&n)
-    a := 1
-    b := 0
-    for i := 0; i < n; i++ {
-        a, b = b, b+a
-    }
-    fmt.Println(a, b)
-}
-
 1
+
+def rotate(c, n):
+    index = (rotations.index(c) + n) % 28
+    return rotations[index]
+
+
+while True:
+    line = input()
+    if line == "0":
+        break
+    n, m = line.split()
+    n = int(n)
+    print("".join([rotate(c, n) for c in m[::-1]]))
+

🟢 Riječi

Solutions in 3 languages
 1
  2
  3
  4
@@ -9281,91 +9281,87 @@
 11
 12
 13
-14
-15
-16
-17
-18
import java.util.Scanner;
+14
package main
 
-class Rijeci {
-    public static void main(String[] args) {
-        Scanner s = new Scanner(System.in);
-        int k = s.nextInt();
-        int a = 1;
-        int b = 0;
-        for (int i = 0; i < k; i++) {
-            int t = b;
-            b = a + b;
-            a = t;
-
-        }
-
-        System.out.println(a + " " + b);
-    }
-}
-
1
-2
-3
-4
-5
-6
k = int(input())
-a, b = 1, 0
-for _ in range(k):
-    a, b = b, b + a
-
-print(a, b)
-

🟢 Roaming Romans

Solutions in 2 languages
1
+import "fmt"
+
+func main() {
+    var n int
+    fmt.Scan(&n)
+    a := 1
+    b := 0
+    for i := 0; i < n; i++ {
+        a, b = b, b+a
+    }
+    fmt.Println(a, b)
+}
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
import java.util.Scanner;
+
+class Rijeci {
+    public static void main(String[] args) {
+        Scanner s = new Scanner(System.in);
+        int k = s.nextInt();
+        int a = 1;
+        int b = 0;
+        for (int i = 0; i < k; i++) {
+            int t = b;
+            b = a + b;
+            a = t;
+
+        }
+
+        System.out.println(a + " " + b);
+    }
+}
+
1
 2
 3
 4
 5
-6
-7
-8
-9
package main
-
-import "fmt"
-
-func main() {
-    var x float64
-    fmt.Scan(&x)
-    fmt.Println(int(x*1000*5280/4854 + 0.5))
-}
-
1
-2
x = float(input())
-print(int(x * 1000 * 5280 / 4854 + 0.5))
-

🟢 Run-Length Encoding, Run!

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
action, s = input().split()
-if action == "D":
-    print("".join([s[i] * int(s[i + 1]) for i in range(0, len(s), 2)]))
-elif action == "E":
-    parts = []
-    prev, t = s[0], 1
-    for c in s[1:]:
-        if c != prev:
-            parts.append((prev, t))
-            t = 1
-            prev = c
-        else:
-            t += 1
-    parts.append((prev, t))
-
-    print("".join([f"{k}{v}" for k, v in parts]))
-

🟢 Same Digits (Easy)

Solution in Python
 1
+6
k = int(input())
+a, b = 1, 0
+for _ in range(k):
+    a, b = b, b + a
+
+print(a, b)
+

🟢 Roaming Romans

Solutions in 2 languages
1
+2
+3
+4
+5
+6
+7
+8
+9
package main
+
+import "fmt"
+
+func main() {
+    var x float64
+    fmt.Scan(&x)
+    fmt.Println(int(x*1000*5280/4854 + 0.5))
+}
+
1
+2
x = float(input())
+print(int(x * 1000 * 5280 / 4854 + 0.5))
+

🟢 Run-Length Encoding, Run!

Solution in Python
 1
  2
  3
  4
@@ -9374,17 +9370,29 @@
  7
  8
  9
-10
a, b = [int(d) for d in input().split()]
-pairs = []
-for x in range(a, b + 1):
-    for y in range(x, b + 1):
-        xy = x * y
-        if sorted(str(xy)) == sorted(str(x) + str(y)):
-            pairs.append((x, y, xy))
-print(f"{len(pairs)} digit-preserving pair(s)")
-for x, y, xy in pairs:
-    print(f"x = {x}, y = {y}, xy = {xy}")
-

🟡 Same Digits (Hard)

Solution in Python
 1
+10
+11
+12
+13
+14
+15
+16
action, s = input().split()
+if action == "D":
+    print("".join([s[i] * int(s[i + 1]) for i in range(0, len(s), 2)]))
+elif action == "E":
+    parts = []
+    prev, t = s[0], 1
+    for c in s[1:]:
+        if c != prev:
+            parts.append((prev, t))
+            t = 1
+            prev = c
+        else:
+            t += 1
+    parts.append((prev, t))
+
+    print("".join([f"{k}{v}" for k, v in parts]))
+

🟢 Same Digits (Easy)

Solution in Python
 1
  2
  3
  4
@@ -9393,27 +9401,17 @@
  7
  8
  9
-10
-11
-12
-13
-14
-15
a, b = [int(d) for d in input().split()]
+10
a, b = [int(d) for d in input().split()]
 pairs = []
 for x in range(a, b + 1):
     for y in range(x, b + 1):
         xy = x * y
-        if x * y > b:
-            break
-        if sorted(str(xy)) == sorted(str(x) + str(y)):
-            pairs.append((x, y, xy))
-    if x * x > b:
-        break
-
-print(f"{len(pairs)} digit-preserving pair(s)")
-for x, y, xy in pairs:
-    print(f"x = {x}, y = {y}, xy = {xy}")
-

🟢 Saving Daylight

Solution in Python
 1
+        if sorted(str(xy)) == sorted(str(x) + str(y)):
+            pairs.append((x, y, xy))
+print(f"{len(pairs)} digit-preserving pair(s)")
+for x, y, xy in pairs:
+    print(f"x = {x}, y = {y}, xy = {xy}")
+

🟢 Same Digits (Hard)

Solution in Python
 1
  2
  3
  4
@@ -9427,80 +9425,74 @@
 12
 13
 14
-15
-16
-17
-18
-19
while True:
-    try:
-        s = input().split()
-    except:
-        break
-
-    t1, t2 = s[-2:]
-
-    h1, m1 = [int(d) for d in t1.split(":")]
-    h2, m2 = [int(d) for d in t2.split(":")]
-
-    mins = (h2 - h1) * 60 + (m2 - m1)
-    h = mins // 60
-    m = mins % 60
-
-    ans = s[:-2]
-    ans.extend([str(h), "hours", str(m), "minutes"])
-
-    print(" ".join(ans))
-

🟢 Saving For Retirement

Solution in Python
1
-2
-3
-4
-5
-6
-7
-8
import math
-
-B, Br, Bs, A, As = [int(d) for d in input().split()]
-rate = Bs * (Br - B) / As
-Ar = math.ceil(rate) + A
-if rate.is_integer():
-    Ar += 1
-print(Ar)
-

🟢 Scaling Recipe

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
import math
+15
a, b = [int(d) for d in input().split()]
+pairs = []
+for x in range(a, b + 1):
+    for y in range(x, b + 1):
+        xy = x * y
+        if x * y > b:
+            break
+        if sorted(str(xy)) == sorted(str(x) + str(y)):
+            pairs.append((x, y, xy))
+    if x * x > b:
+        break
+
+print(f"{len(pairs)} digit-preserving pair(s)")
+for x, y, xy in pairs:
+    print(f"x = {x}, y = {y}, xy = {xy}")
+

🟢 Saving Daylight

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
while True:
+    try:
+        s = input().split()
+    except:
+        break
+
+    t1, t2 = s[-2:]
+
+    h1, m1 = [int(d) for d in t1.split(":")]
+    h2, m2 = [int(d) for d in t2.split(":")]
+
+    mins = (h2 - h1) * 60 + (m2 - m1)
+    h = mins // 60
+    m = mins % 60
+
+    ans = s[:-2]
+    ans.extend([str(h), "hours", str(m), "minutes"])
+
+    print(" ".join(ans))
+

🟢 Saving For Retirement

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
import math
 
-n, x, y = [int(d) for d in input().split()]
-i = [int(input()) for _ in range(n)]
-
-# for python 3.9+ (https://docs.python.org/3.9/library/math.html#math.gcd)
-# s = math.gcd(x, *i)
-
-s = math.gcd(x, i[0])
-for k in range(1, n):
-    s = math.gcd(s, i[k])
-
-x /= s
-i = [v / s for v in i]
-
-scale = y / x
-for v in i:
-    print(int(scale * v))
-

🟢 School Spirit

Solution in Python
 1
+B, Br, Bs, A, As = [int(d) for d in input().split()]
+rate = Bs * (Br - B) / As
+Ar = math.ceil(rate) + A
+if rate.is_integer():
+    Ar += 1
+print(Ar)
+

🟢 Scaling Recipe

Solution in Python
 1
  2
  3
  4
@@ -9517,25 +9509,25 @@
 15
 16
 17
-18
n = int(input())
-s = []
-for _ in range(n):
-    s.append(int(input()))
+18
import math
+
+n, x, y = [int(d) for d in input().split()]
+i = [int(input()) for _ in range(n)]
 
-
-def group_score(s):
-    gs = 0
-    for i in range(len(s)):
-        gs += s[i] * (0.8**i)
-    return 0.2 * gs
+# for python 3.9+ (https://docs.python.org/3.9/library/math.html#math.gcd)
+# s = math.gcd(x, *i)
+
+s = math.gcd(x, i[0])
+for k in range(1, n):
+    s = math.gcd(s, i[k])
 
-
-print(group_score(s))
-new_gs = []
-for i in range(n):
-    new_gs.append(group_score([s[j] for j in range(n) if j != i]))
-print(sum(new_gs) / len(new_gs))
-

🟢 Secret Message

Solution in Python
 1
+x /= s
+i = [v / s for v in i]
+
+scale = y / x
+for v in i:
+    print(int(scale * v))
+

🟢 School Spirit

Solution in Python
 1
  2
  3
  4
@@ -9547,37 +9539,55 @@
 10
 11
 12
-13
import math
-
-for _ in range(int(input())):
-    m = input()
-    k = math.ceil(len(m) ** 0.5)
+13
+14
+15
+16
+17
+18
n = int(input())
+s = []
+for _ in range(n):
+    s.append(int(input()))
+
 
-    m += "*" * (k * k - len(m))
-    rows = [m[i : i + k] for i in range(0, len(m), k)]
-
-    s = []
-    for i in range(k):
-        s.append("".join([row[i] for row in rows if row[i] != "*"][::-1]))
-    print("".join(s))
-

🟢 Secure Doors

Solution in Python
1
-2
-3
-4
-5
-6
-7
-8
-9
pool = set()
-for _ in range(int(input())):
-    action, name = input().split()
-    if action == "entry":
-        print(name, "entered", "(ANOMALY)" if name in pool else "")
-        pool.add(name)
-    elif action == "exit":
-        print(name, "exited", "(ANOMALY)" if name not in pool else "")
-        pool.discard(name)
-

🟢 Server

Solution in Python
1
+def group_score(s):
+    gs = 0
+    for i in range(len(s)):
+        gs += s[i] * (0.8**i)
+    return 0.2 * gs
+
+
+print(group_score(s))
+new_gs = []
+for i in range(n):
+    new_gs.append(group_score([s[j] for j in range(n) if j != i]))
+print(sum(new_gs) / len(new_gs))
+

🟢 Secret Message

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
import math
+
+for _ in range(int(input())):
+    m = input()
+    k = math.ceil(len(m) ** 0.5)
+
+    m += "*" * (k * k - len(m))
+    rows = [m[i : i + k] for i in range(0, len(m), k)]
+
+    s = []
+    for i in range(k):
+        s.append("".join([row[i] for row in rows if row[i] != "*"][::-1]))
+    print("".join(s))
+

🟢 Secure Doors

Solution in Python
1
 2
 3
 4
@@ -9585,16 +9595,16 @@
 6
 7
 8
-9
_, t = [int(d) for d in input().split()]
-total, used = 0, 0
-for v in [int(d) for d in input().split()]:
-    if used + v <= t:
-        total += 1
-        used += v
-    else:
-        break
-print(total)
-

🟢 Seven Wonders

Solution in Python
1
+9
pool = set()
+for _ in range(int(input())):
+    action, name = input().split()
+    if action == "entry":
+        print(name, "entered", "(ANOMALY)" if name in pool else "")
+        pool.add(name)
+    elif action == "exit":
+        print(name, "exited", "(ANOMALY)" if name not in pool else "")
+        pool.discard(name)
+

🟢 Server

Solution in Python
1
 2
 3
 4
@@ -9602,101 +9612,93 @@
 6
 7
 8
-9
from collections import Counter
-
-c = Counter(input())
-score = 0
-for value in c.values():
-    score += value**2
-if len(c.values()) == 3:
-    score += 7 * min(c.values())
-print(score)
-

🟢 Shattered Cake

Solution in Python
1
+9
_, t = [int(d) for d in input().split()]
+total, used = 0, 0
+for v in [int(d) for d in input().split()]:
+    if used + v <= t:
+        total += 1
+        used += v
+    else:
+        break
+print(total)
+

🟢 Seven Wonders

Solution in Python
1
 2
 3
 4
 5
-6
w, n = int(input()), int(input())
-total = 0
-for _ in range(n):
-    _w, _l = [int(d) for d in input().split()]
-    total += _w * _l
-print(int(total / w))
-

🟢 Shopaholic

Solution in Python
1
+6
+7
+8
+9
from collections import Counter
+
+c = Counter(input())
+score = 0
+for value in c.values():
+    score += value**2
+if len(c.values()) == 3:
+    score += 7 * min(c.values())
+print(score)
+

🟢 Shattered Cake

Solution in Python
1
 2
 3
 4
 5
-6
-7
n = int(input())
-c = [int(d) for d in input().split()]
-
-c = sorted(c, reverse=True)
-groups = [c[i : i + 3] if i + 3 < n else c[i:] for i in range(0, n, 3)]
-
-print(sum(g[-1] if len(g) == 3 else 0 for g in groups))
-

🟢 Shopping List (Easy)

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
n, m = [int(d) for d in input().split()]
-items = []
-for _ in range(n):
-    items.append(set(input().split()))
-
-ans = items[0]
-ans = ans.intersection(*items[1:])
-
-print(len(ans))
-print("\n".join(sorted(list(ans))))
-

🟢 Sibice

Solution in Python
1
-2
-3
-4
-5
-6
-7
-8
-9
import math
-
-n, w, h = [int(d) for d in input().split()]
-for _ in range(n):
-    line = int(input())
-    if line <= math.sqrt(w**2 + h**2):
-        print("DA")
-    else:
-        print("NE")
-

🟢 Sideways Sorting

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
while True:
-    r, c = [int(d) for d in input().split()]
-    if not r and not c:
-        break
-    s = []
-    for _ in range(r):
-        s.append(input())
-    items = []
-    for i in range(c):
-        items.append("".join(s[j][i] for j in range(r)))
-    items = sorted(items, key=lambda t: t.lower())
-    for i in range(r):
-        print("".join(items[j][i] for j in range(c)))
-

🟢 Digit Product

Solution in Python
 1
+6
w, n = int(input()), int(input())
+total = 0
+for _ in range(n):
+    _w, _l = [int(d) for d in input().split()]
+    total += _w * _l
+print(int(total / w))
+

🟢 Shopaholic

Solution in Python
1
+2
+3
+4
+5
+6
+7
n = int(input())
+c = [int(d) for d in input().split()]
+
+c = sorted(c, reverse=True)
+groups = [c[i : i + 3] if i + 3 < n else c[i:] for i in range(0, n, 3)]
+
+print(sum(g[-1] if len(g) == 3 else 0 for g in groups))
+

🟢 Shopping List (Easy)

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
n, m = [int(d) for d in input().split()]
+items = []
+for _ in range(n):
+    items.append(set(input().split()))
+
+ans = items[0]
+ans = ans.intersection(*items[1:])
+
+print(len(ans))
+print("\n".join(sorted(list(ans))))
+

🟢 Sibice

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
+9
import math
+
+n, w, h = [int(d) for d in input().split()]
+for _ in range(n):
+    line = int(input())
+    if line <= math.sqrt(w**2 + h**2):
+        print("DA")
+    else:
+        print("NE")
+

🟢 Sideways Sorting

Solution in Python
 1
  2
  3
  4
@@ -9708,188 +9710,188 @@
 10
 11
 12
-13
-14
def digit_product(x):
-    ans = 1
-    while x:
-        ans *= x % 10 or 1
-        x //= 10
-    return ans
-
-
-x = int(input())
-while True:
-    x = digit_product(x)
-    if x < 10:
-        break
-print(x)
-

🟢 Simon Says

Solution in Python
1
-2
-3
-4
-5
-6
-7
for _ in range(int(input())):
-    command = input()
-    start = "simon says "
-    if command.startswith(start):
-        print(command[len(start) :])
-    else:
-        print()
-

🟢 Simone

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
from collections import Counter
-
-n, k = [int(d) for d in input().split()]
-
-s = Counter(int(d) for d in input().split())
-
-least = min(s.values())
-if len(s.values()) < k:
-    least = 0
-ans = 0
-c = []
-for i in range(k):
-    if s[i + 1] == least:
-        c.append(str(i + 1))
-        ans += 1
-print(ans)
-print(" ".join(c))
-

🟢 Simon Says

Solution in Python
1
-2
-3
-4
-5
for _ in range(int(input())):
-    command = input()
-    start = "Simon says "
-    if command.startswith(start):
-        print(command[len(start) :])
-

🟢 Simple Addition

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
a, b = input(), input()
-
-a = a[::-1]
-b = b[::-1]
-i = 0
-ans = ""
-carry = 0
-while i < len(a) or i < len(b):
-    if i < len(a) and i < len(b):
-        s = int(a[i]) + int(b[i]) + carry
-
-    elif i < len(a):
-        s = int(a[i]) + carry
-
-    else:
-        s = int(b[i]) + carry
-    ans += str(s % 10)
-    carry = s // 10
-    i += 1
-if carry:
-    ans += str(carry)
-print(ans[::-1])
-
-# or simply
-# print(int(a) + int(b))
-

🟢 Simple Factoring

Solution in Python
1
-2
-3
-4
-5
-6
-7
-8
for _ in range(int(input())):
-    a, b, c = [int(d) for d in input().split()]
-    import math
-
-    if not b**2 - 4 * a * c < 0 and math.sqrt(b**2 - 4 * a * c).is_integer():
-        print("YES")
-    else:
-        print("NO")
-

🟢 Sith

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
_ = input()
-a = int(input())
-b = int(input())
-diff = int(input())
-if diff <= 0:
-    print("JEDI")
-elif a < b:
-    print("SITH")
-else:
-    print("VEIT EKKI")
-

🟢 Sjecista

Solution in Python
1
-2
n = int(input())
-print((n - 3) * (n - 2) * (n - 1) * (n) // 24)
-

🟢 Skener

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
r, _, zr, zc = [int(d) for d in input().split()]
-matrix = []
-for _ in range(r):
-    matrix.append(input())
-
-ans = []
-
-for row in matrix:
-    for i in range(zr):
-        ans.append(row)
-
-for row in ans:
-    print("".join([col * zc for col in row]))
-

🟢 Skocimis

Solutions in 2 languages
while True:
+    r, c = [int(d) for d in input().split()]
+    if not r and not c:
+        break
+    s = []
+    for _ in range(r):
+        s.append(input())
+    items = []
+    for i in range(c):
+        items.append("".join(s[j][i] for j in range(r)))
+    items = sorted(items, key=lambda t: t.lower())
+    for i in range(r):
+        print("".join(items[j][i] for j in range(c)))
+

🟢 Digit Product

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
def digit_product(x):
+    ans = 1
+    while x:
+        ans *= x % 10 or 1
+        x //= 10
+    return ans
+
+
+x = int(input())
+while True:
+    x = digit_product(x)
+    if x < 10:
+        break
+print(x)
+

🟢 Simon Says

Solution in Python
1
+2
+3
+4
+5
+6
+7
for _ in range(int(input())):
+    command = input()
+    start = "simon says "
+    if command.startswith(start):
+        print(command[len(start) :])
+    else:
+        print()
+

🟢 Simone

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
from collections import Counter
+
+n, k = [int(d) for d in input().split()]
+
+s = Counter(int(d) for d in input().split())
+
+least = min(s.values())
+if len(s.values()) < k:
+    least = 0
+ans = 0
+c = []
+for i in range(k):
+    if s[i + 1] == least:
+        c.append(str(i + 1))
+        ans += 1
+print(ans)
+print(" ".join(c))
+

🟢 Simon Says

Solution in Python
1
+2
+3
+4
+5
for _ in range(int(input())):
+    command = input()
+    start = "Simon says "
+    if command.startswith(start):
+        print(command[len(start) :])
+

🟢 Simple Addition

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
a, b = input(), input()
+
+a = a[::-1]
+b = b[::-1]
+i = 0
+ans = ""
+carry = 0
+while i < len(a) or i < len(b):
+    if i < len(a) and i < len(b):
+        s = int(a[i]) + int(b[i]) + carry
+
+    elif i < len(a):
+        s = int(a[i]) + carry
+
+    else:
+        s = int(b[i]) + carry
+    ans += str(s % 10)
+    carry = s // 10
+    i += 1
+if carry:
+    ans += str(carry)
+print(ans[::-1])
+
+# or simply
+# print(int(a) + int(b))
+

🟢 Simple Factoring

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
for _ in range(int(input())):
+    a, b, c = [int(d) for d in input().split()]
+    import math
+
+    if not b**2 - 4 * a * c < 0 and math.sqrt(b**2 - 4 * a * c).is_integer():
+        print("YES")
+    else:
+        print("NO")
+

🟢 Sith

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
_ = input()
+a = int(input())
+b = int(input())
+diff = int(input())
+if diff <= 0:
+    print("JEDI")
+elif a < b:
+    print("SITH")
+else:
+    print("VEIT EKKI")
+

🟢 Sjecista

Solution in Python
1
+2
n = int(input())
+print((n - 3) * (n - 2) * (n - 1) * (n) // 24)
+

🟢 Skener

Solution in Python
 1
  2
  3
  4
@@ -9901,102 +9903,78 @@
 10
 11
 12
-13
-14
-15
-16
-17
-18
package main
-
-import "fmt"
-
-func main() {
-    var a, b, c int
-    fmt.Scan(&a)
-    fmt.Scan(&b)
-    fmt.Scan(&c)
-    x := b - a
-    y := c - b
-    ans := x
-    if ans < y {
-        ans = y
-    }
-    ans -= 1
-    fmt.Println(ans)
-}
-
1
-2
a, b, c = [int(d) for d in input().split()]
-print(max(b - a, c - b) - 1)
-

🟢 Turn It Up!

Solution in Python
1
-2
-3
-4
-5
-6
-7
volume = 7
-for _ in range(int(input())):
-    if input() == "Skru op!":
-        volume = min(volume + 1, 10)
-    else:
-        volume = max(volume - 1, 0)
-print(volume)
-

🟢 Slatkisi

Solution in Python
1
+13
r, _, zr, zc = [int(d) for d in input().split()]
+matrix = []
+for _ in range(r):
+    matrix.append(input())
+
+ans = []
+
+for row in matrix:
+    for i in range(zr):
+        ans.append(row)
+
+for row in ans:
+    print("".join([col * zc for col in row]))
+

🟢 Skocimis

Solutions in 2 languages
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
package main
+
+import "fmt"
+
+func main() {
+    var a, b, c int
+    fmt.Scan(&a)
+    fmt.Scan(&b)
+    fmt.Scan(&c)
+    x := b - a
+    y := c - b
+    ans := x
+    if ans < y {
+        ans = y
+    }
+    ans -= 1
+    fmt.Println(ans)
+}
+
1
+2
a, b, c = [int(d) for d in input().split()]
+print(max(b - a, c - b) - 1)
+

🟢 Turn It Up!

Solution in Python
1
 2
 3
-4
c, k = [int(d) for d in input().split()]
-d = 10**k
-c = (c // d) * d + (d if (c % d) / d >= 0.5 else 0)
-print(c)
-

🟢 SMIL

Solutions in 2 languages
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
import java.util.Scanner;
-
-class SMIL {
-    public static void main(String[] args) {
-        Scanner s = new Scanner(System.in);
-        String m = s.nextLine();
-        int size = m.length();
-        int i = 0;
-        while (i < size) {
-            if (m.charAt(i) == ':' || m.charAt(i) == ';') {
-                if (i + 1 < size && m.charAt(i + 1) == ')') {
-                    System.out.println(i);
-                    i += 2;
-                    continue;
-                }
-                if (i + 2 < size && m.charAt(i + 1) == '-' && m.charAt(i + 2) == ')') {
-                    System.out.println(i);
-                    i += 3;
-                    continue;
-                }
-            }
-            i += 1;
-        }
-    }
-}
-
 1
+4
+5
+6
+7
volume = 7
+for _ in range(int(input())):
+    if input() == "Skru op!":
+        volume = min(volume + 1, 10)
+    else:
+        volume = max(volume - 1, 0)
+print(volume)
+

🟢 Slatkisi

Solution in Python
1
+2
+3
+4
c, k = [int(d) for d in input().split()]
+d = 10**k
+c = (c // d) * d + (d if (c % d) / d >= 0.5 else 0)
+print(c)
+

🟢 SMIL

Solutions in 2 languages
 1
  2
  3
  4
@@ -10011,23 +9989,41 @@
 13
 14
 15
-16
s = input()
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
import java.util.Scanner;
 
-i = 0
-size = len(s)
-while i < size:
-    if s[i] in [":", ";"]:
-        if i + 1 < size and s[i + 1] == ")":
-            print(i)
-            i += 2
-            continue
-        if i + 2 < size and s[i + 1] == "-" and s[i + 2] == ")":
-            print(i)
-            i += 3
-            continue
-
-    i += 1
-

🟢 Soda Slurper

Solutions in 2 languages
 1
+class SMIL {
+    public static void main(String[] args) {
+        Scanner s = new Scanner(System.in);
+        String m = s.nextLine();
+        int size = m.length();
+        int i = 0;
+        while (i < size) {
+            if (m.charAt(i) == ':' || m.charAt(i) == ';') {
+                if (i + 1 < size && m.charAt(i + 1) == ')') {
+                    System.out.println(i);
+                    i += 2;
+                    continue;
+                }
+                if (i + 2 < size && m.charAt(i + 1) == '-' && m.charAt(i + 2) == ')') {
+                    System.out.println(i);
+                    i += 3;
+                    continue;
+                }
+            }
+            i += 1;
+        }
+    }
+}
+
 1
  2
  3
  4
@@ -10042,93 +10038,93 @@
 13
 14
 15
-16
-17
package main
+16
s = input()
 
-import "fmt"
-
-func main() {
-    var e, f, c int
-    fmt.Scan(&e)
-    fmt.Scan(&f)
-    fmt.Scan(&c)
-    total := 0
-    s := e + f
-    for s >= c {
-        total += s / c
-        s = s%c + s/c
-    }
-    fmt.Println(total)
-}
-
1
-2
-3
-4
-5
-6
-7
e, f, c = [int(d) for d in input().split()]
-total = 0
-s = e + f
-while s >= c:
-    total += s // c
-    s = s % c + s // c
-print(total)
-

🟢 Sok

Solution in Python
1
+i = 0
+size = len(s)
+while i < size:
+    if s[i] in [":", ";"]:
+        if i + 1 < size and s[i + 1] == ")":
+            print(i)
+            i += 2
+            continue
+        if i + 2 < size and s[i + 1] == "-" and s[i + 2] == ")":
+            print(i)
+            i += 3
+            continue
+
+    i += 1
+

🟢 Soda Slurper

Solutions in 2 languages
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
package main
+
+import "fmt"
+
+func main() {
+    var e, f, c int
+    fmt.Scan(&e)
+    fmt.Scan(&f)
+    fmt.Scan(&c)
+    total := 0
+    s := e + f
+    for s >= c {
+        total += s / c
+        s = s%c + s/c
+    }
+    fmt.Println(total)
+}
+
1
 2
 3
-4
a, b, c = [int(d) for d in input().split()]
-i, j, k = [int(d) for d in input().split()]
-s = min(a / i, b / j, c / k)
-print(a - i * s, b - j * s, c - k * s)
-

🟢 Some Sum

Solution in Python
1
+4
+5
+6
+7
e, f, c = [int(d) for d in input().split()]
+total = 0
+s = e + f
+while s >= c:
+    total += s // c
+    s = s % c + s // c
+print(total)
+

🟢 Sok

Solution in Python
1
 2
 3
-4
-5
-6
-7
-8
-9
n = int(input())
-if n == 1:
-    print("Either")
-elif n == 2:
-    print("Odd")
-elif n % 2 == 0:
-    print("Even" if (n / 2) % 2 == 0 else "Odd")
-else:
-    print("Either")
-

🟢 Sort

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
from collections import Counter
-
-n, c = [int(d) for d in input().split()]
-num = [int(d) for d in input().split()]
-
-freq = Counter(num)
-print(
-    " ".join(
-        [
-            str(d)
-            for d in sorted(
-                num, key=lambda k: (freq[k], n - num.index(k)), reverse=True
-            )
-        ]
-    )
-)
-

🟢 Sort of Sorting

Solution in Python
 1
+4
a, b, c = [int(d) for d in input().split()]
+i, j, k = [int(d) for d in input().split()]
+s = min(a / i, b / j, c / k)
+print(a - i * s, b - j * s, c - k * s)
+

🟢 Some Sum

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
+9
n = int(input())
+if n == 1:
+    print("Either")
+elif n == 2:
+    print("Odd")
+elif n % 2 == 0:
+    print("Even" if (n / 2) % 2 == 0 else "Odd")
+else:
+    print("Either")
+

🟢 Sort

Solution in Python
 1
  2
  3
  4
@@ -10140,20 +10136,26 @@
 10
 11
 12
-13
first = True
-while True:
-    n = int(input())
-    if not n:
-        break
-    else:
-        if not first:
-            print()
-    first = False
-    names = []
-    for _ in range(n):
-        names.append(input())
-    print("\n".join(sorted(names, key=lambda k: k[:2])))
-

🟢 Sort Two Numbers

Solutions in 3 languages
 1
+13
+14
+15
+16
from collections import Counter
+
+n, c = [int(d) for d in input().split()]
+num = [int(d) for d in input().split()]
+
+freq = Counter(num)
+print(
+    " ".join(
+        [
+            str(d)
+            for d in sorted(
+                num, key=lambda k: (freq[k], n - num.index(k)), reverse=True
+            )
+        ]
+    )
+)
+

🟢 Sort of Sorting

Solution in Python
 1
  2
  3
  4
@@ -10165,28 +10167,20 @@
 10
 11
 12
-13
-14
-15
-16
-17
#include <iostream>
-
-using namespace std;
-
-int main()
-{
-    int a = 0, b = 0;
-    cin >> a >> b;
-    if (a < b)
-    {
-        cout << a << " " << b;
-    }
-    else
-    {
-        cout << b << " " << a;
-    }
-}
-
first = True
+while True:
+    n = int(input())
+    if not n:
+        break
+    else:
+        if not first:
+            print()
+    first = False
+    names = []
+    for _ in range(n):
+        names.append(input())
+    print("\n".join(sorted(names, key=lambda k: k[:2])))
+

🟢 Sort Two Numbers

Solutions in 3 languages
 1
  2
  3
  4
@@ -10199,153 +10193,139 @@
 11
 12
 13
-14
package main
+14
+15
+16
+17
#include <iostream>
 
-import "fmt"
+using namespace std;
 
-func main() {
-    var a, b int
-    fmt.Scan(&a)
-    fmt.Scan(&b)
-    if a < b {
-        fmt.Printf("%d %d\n", a, b)
-    } else {
-        fmt.Printf("%d %d\n", b, a)
-    }
-}
-
1
-2
-3
-4
-5
-6
line = input()
-a, b = [int(d) for d in line.split()]
-if a < b:
-    print(a, b)
-else:
-    print(b, a)
-

🟢 Sóttkví

Solutions in 2 languages
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
import java.util.Scanner;
-
-class Sottkvi {
-    public static void main(String[] args) {
-        Scanner s = new Scanner(System.in);
-        int n = s.nextInt();
-        int k = s.nextInt();
-        int today = s.nextInt();
-        int ans = 0;
-        for (int i = 0; i < n; i++) {
-            int d = s.nextInt();
-            if (d + 14 - today <= k) {
-                ans += 1;
-            }
-        }
-        System.out.println(ans);
-
-    }
-}
-
1
-2
-3
-4
-5
-6
-7
n, k, today = [int(d) for d in input().split()]
-res = 0
-for _ in range(n):
-    d = int(input())
-    if d + 14 - today <= k:
-        res += 1
-print(res)
-

🟢 Soylent

Solution in Python
1
+int main()
+{
+    int a = 0, b = 0;
+    cin >> a >> b;
+    if (a < b)
+    {
+        cout << a << " " << b;
+    }
+    else
+    {
+        cout << b << " " << a;
+    }
+}
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
package main
+
+import "fmt"
+
+func main() {
+    var a, b int
+    fmt.Scan(&a)
+    fmt.Scan(&b)
+    if a < b {
+        fmt.Printf("%d %d\n", a, b)
+    } else {
+        fmt.Printf("%d %d\n", b, a)
+    }
+}
+
1
+2
+3
+4
+5
+6
line = input()
+a, b = [int(d) for d in line.split()]
+if a < b:
+    print(a, b)
+else:
+    print(b, a)
+

🟢 Sóttkví

Solutions in 2 languages
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
import java.util.Scanner;
+
+class Sottkvi {
+    public static void main(String[] args) {
+        Scanner s = new Scanner(System.in);
+        int n = s.nextInt();
+        int k = s.nextInt();
+        int today = s.nextInt();
+        int ans = 0;
+        for (int i = 0; i < n; i++) {
+            int d = s.nextInt();
+            if (d + 14 - today <= k) {
+                ans += 1;
+            }
+        }
+        System.out.println(ans);
+
+    }
+}
+
1
 2
 3
 4
-5
import math
-
-for _ in range(int(input())):
-    n = int(input())
-    print(math.ceil(n / 400))
-

🟢 Space Race

Solution in Python
1
+5
+6
+7
n, k, today = [int(d) for d in input().split()]
+res = 0
+for _ in range(n):
+    d = int(input())
+    if d + 14 - today <= k:
+        res += 1
+print(res)
+

🟢 Soylent

Solution in Python
1
 2
 3
 4
-5
-6
-7
-8
n = int(input())
-_ = input()
-d = {}
-for _ in range(n):
-    entry = input().split()
-    d[entry[0]] = float(entry[-1])
-
-print(min(d, key=lambda k: d[k]))
-

🟢 Spavanac

Solutions in 3 languages
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
#include <iostream>
-
-using namespace std;
-
-int main()
-{
-    int h, m;
-    cin >> h >> m;
-
-    int mm = m - 45;
-    int borrow = 0;
-    if (mm < 0)
-    {
-        mm += 60;
-        borrow = 1;
-    }
-    int hh = h - borrow;
-    if (hh < 0)
-    {
-        hh += 24;
-    }
-    cout << hh << " " << mm << endl;
-    return 0;
-}
-
 1
+5
import math
+
+for _ in range(int(input())):
+    n = int(input())
+    print(math.ceil(n / 400))
+

🟢 Space Race

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
n = int(input())
+_ = input()
+d = {}
+for _ in range(n):
+    entry = input().split()
+    d[entry[0]] = float(entry[-1])
+
+print(min(d, key=lambda k: d[k]))
+

🟢 Spavanac

Solutions in 3 languages
 1
  2
  3
  4
@@ -10366,28 +10346,32 @@
 19
 20
 21
-22
import java.util.Scanner;
+22
+23
+24
#include <iostream>
 
-class Spavanac {
-    public static void main(String[] args) {
-        Scanner s = new Scanner(System.in);
-        int h = s.nextInt();
-        int m = s.nextInt();
-
-        int mm = m - 45;
-        int borrow = 0;
-        if (mm < 0) {
-            mm += 60;
-            borrow = 1;
-        }
-
-        int hh = h - borrow;
-        if (hh < 0) {
-            hh += 24;
-        }
-        System.out.println(hh + " " + mm);
+using namespace std;
+
+int main()
+{
+    int h, m;
+    cin >> h >> m;
+
+    int mm = m - 45;
+    int borrow = 0;
+    if (mm < 0)
+    {
+        mm += 60;
+        borrow = 1;
+    }
+    int hh = h - borrow;
+    if (hh < 0)
+    {
+        hh += 24;
     }
-}
+    cout << hh << " " << mm << endl;
+    return 0;
+}
 
 1
  2
  3
@@ -10401,21 +10385,37 @@
 11
 12
 13
-14
h, m = [int(d) for d in input().split()]
+14
+15
+16
+17
+18
+19
+20
+21
+22
import java.util.Scanner;
 
-mm = m - 45
-
-borrow = 0
-if mm < 0:
-    mm += 60
-    borrow = 1
-
-hh = h - borrow
-if hh < 0:
-    hh += 24
-
-print(hh, mm)
-

🟢 Speeding

Solution in Python
 1
+class Spavanac {
+    public static void main(String[] args) {
+        Scanner s = new Scanner(System.in);
+        int h = s.nextInt();
+        int m = s.nextInt();
+
+        int mm = m - 45;
+        int borrow = 0;
+        if (mm < 0) {
+            mm += 60;
+            borrow = 1;
+        }
+
+        int hh = h - borrow;
+        if (hh < 0) {
+            hh += 24;
+        }
+        System.out.println(hh + " " + mm);
+    }
+}
+
 1
  2
  3
  4
@@ -10425,18 +10425,24 @@
  8
  9
 10
-11
n = int(input())
-mile, time, max_speed = 0, 0, 0
-for _ in range(n):
-    t, s = [int(d) for d in input().split()]
-    if not t and not s:
-        continue
-    speed = int((s - mile) / (t - time))
-    if speed > max_speed:
-        max_speed = speed
-    mile, time = s, t
-print(max_speed)
-

🟢 Speed Limit

Solution in Python
 1
+11
+12
+13
+14
h, m = [int(d) for d in input().split()]
+
+mm = m - 45
+
+borrow = 0
+if mm < 0:
+    mm += 60
+    borrow = 1
+
+hh = h - borrow
+if hh < 0:
+    hh += 24
+
+print(hh, mm)
+

🟢 Speeding

Solution in Python
 1
  2
  3
  4
@@ -10446,18 +10452,18 @@
  8
  9
 10
-11
while True:
-    n = int(input())
-    if n == -1:
-        break
-    miles = 0
-    elapsed = 0
-    for _ in range(n):
-        s, t = [int(d) for d in input().split()]
-        miles += s * (t - elapsed)
-        elapsed = t
-    print(f"{miles} miles")
-

🟢 Spelling Bee

Solution in Python
n = int(input())
+mile, time, max_speed = 0, 0, 0
+for _ in range(n):
+    t, s = [int(d) for d in input().split()]
+    if not t and not s:
+        continue
+    speed = int((s - mile) / (t - time))
+    if speed > max_speed:
+        max_speed = speed
+    mile, time = s, t
+print(max_speed)
+

🟢 Speed Limit

Solution in Python
 1
  2
  3
  4
@@ -10466,247 +10472,227 @@
  7
  8
  9
-10
hexagon = input()
-c = hexagon[0]
-hexagon = set(list(hexagon))
-n = int(input())
-valid = []
-for _ in range(n):
-    w = input()
-    if c in w and len(w) >= 4 and set(list(w)) <= hexagon:
-        valid.append(w)
-print("\n".join(valid))
-

🟢 Spritt

Solution in Python
1
-2
-3
-4
-5
-6
-7
-8
n, x = [int(d) for d in input().split()]
-for _ in range(n):
-    x -= int(input())
-    if x < 0:
-        print("Neibb")
-        break
-if x >= 0:
-    print("Jebb")
-

🟢 Square Peg

Solution in Python
1
+10
+11
while True:
+    n = int(input())
+    if n == -1:
+        break
+    miles = 0
+    elapsed = 0
+    for _ in range(n):
+        s, t = [int(d) for d in input().split()]
+        miles += s * (t - elapsed)
+        elapsed = t
+    print(f"{miles} miles")
+

🟢 Spelling Bee

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
hexagon = input()
+c = hexagon[0]
+hexagon = set(list(hexagon))
+n = int(input())
+valid = []
+for _ in range(n):
+    w = input()
+    if c in w and len(w) >= 4 and set(list(w)) <= hexagon:
+        valid.append(w)
+print("\n".join(valid))
+

🟢 Spritt

Solution in Python
1
 2
 3
 4
-5
l, r = [int(d) for d in input().split()]
-if 2 * (l / 2) ** 2 <= r**2:
-    print("fits")
-else:
-    print("nope")
-

🟢 Stafur

Solution in Python
1
+5
+6
+7
+8
n, x = [int(d) for d in input().split()]
+for _ in range(n):
+    x -= int(input())
+    if x < 0:
+        print("Neibb")
+        break
+if x >= 0:
+    print("Jebb")
+

🟢 Square Peg

Solution in Python
1
 2
 3
 4
-5
-6
-7
l = input()
-if l in "AEIOU":
-    print("Jebb")
-elif l == "Y":
-    print("Kannski")
-else:
-    print("Neibb")
-

🟢 Statistics

Solution in Python
1
+5
l, r = [int(d) for d in input().split()]
+if 2 * (l / 2) ** 2 <= r**2:
+    print("fits")
+else:
+    print("nope")
+

🟢 Stafur

Solution in Python
1
 2
 3
 4
 5
 6
-7
-8
-9
case_num = 0
-while True:
-    try:
-        line = input()
-    except:
-        break
-    case_num += 1
-    numbers = [int(d) for d in line.split()[1:]]
-    print(f"Case {case_num}: {min(numbers)} {max(numbers)} {max(numbers)-min(numbers)}")
-

🟢 Sticky Keys

Solution in Python
1
+7
l = input()
+if l in "AEIOU":
+    print("Jebb")
+elif l == "Y":
+    print("Kannski")
+else:
+    print("Neibb")
+

🟢 Statistics

Solution in Python
1
 2
 3
 4
 5
 6
-7
message = input()
-
-l = [message[0]]
-for i in message[1:]:
-    if i != l[-1]:
-        l.append(i)
-print("".join(l))
-

🟢 Messy lists

Solution in Python
1
+7
+8
+9
case_num = 0
+while True:
+    try:
+        line = input()
+    except:
+        break
+    case_num += 1
+    numbers = [int(d) for d in line.split()[1:]]
+    print(f"Case {case_num}: {min(numbers)} {max(numbers)} {max(numbers)-min(numbers)}")
+

🟢 Sticky Keys

Solution in Python
1
 2
 3
-4
n = int(input())
-a = [int(d) for d in input().split()]
-s = sorted(a)
-print(sum([i != j for i, j in zip(a, s)]))
-

🟢 Stopwatch

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
n = int(input())
-times = []
-for _ in range(n):
-    times.append(int(input()))
-if n % 2:
-    print("still running")
-else:
-    seconds = 0
-    for i in range(0, n, 2):
-        seconds += times[i + 1] - times[i]
-    print(seconds)
-

🟢 Streets Ahead

Solution in Python
1
-2
-3
-4
-5
-6
-7
-8
-9
n, q = [int(d) for d in input().split()]
-
-s = {}
-for i in range(n):
-    s[input()] = i
-
-for _ in range(q):
-    a, b = input().split()
-    print(abs(s[a] - s[b]) - 1)
-

🟢 Successful Zoom

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
n = int(input())
-x = [int(d) for d in input().split()]
-found = False
-for k in range(1, n // 2 + 1):
-    v = [x[i] for i in range(k - 1, n, k)]
-    if all([v[i] < v[i + 1] for i in range(len(v) - 1)]):
-        print(k)
-        found = True
-        break
-if not found:
-    print("ABORT!")
-

🟢 Sum Kind of Problem

Solution in Python
1
-2
-3
-4
-5
-6
for _ in range(int(input())):
-    k, n = [int(d) for d in input().split()]
-    s1 = sum(range(1, n + 1))
-    s2 = sum(range(1, 2 * n + 1, 2))
-    s3 = sum(range(2, 2 * (n + 1), 2))
-    print(k, s1, s2, s3)
-

🟢 Sum of the Others

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
while True:
-    try:
-        n = [int(d) for d in input().split()]
-    except:
-        break
-
-    for i in range(len(n)):
-        if n[i] == sum([n[j] for j in range(len(n)) if j != i]):
-            print(n[i])
-            break
-

🟢 Sum Squared Digits Function

Solution in Python
1
-2
-3
-4
-5
-6
-7
for _ in range(int(input())):
-    k, b, n = [int(d) for d in input().split()]
-    ssd = 0
-    while n:
-        ssd += (n % b) ** 2
-        n //= b
-    print(k, ssd)
-

🟢 Sun and Moon

Solution in Python
1
+4
+5
+6
+7
message = input()
+
+l = [message[0]]
+for i in message[1:]:
+    if i != l[-1]:
+        l.append(i)
+print("".join(l))
+

🟢 Messy lists

Solution in Python
1
+2
+3
+4
n = int(input())
+a = [int(d) for d in input().split()]
+s = sorted(a)
+print(sum([i != j for i, j in zip(a, s)]))
+

🟢 Stopwatch

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
n = int(input())
+times = []
+for _ in range(n):
+    times.append(int(input()))
+if n % 2:
+    print("still running")
+else:
+    seconds = 0
+    for i in range(0, n, 2):
+        seconds += times[i + 1] - times[i]
+    print(seconds)
+

🟢 Streets Ahead

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
+9
n, q = [int(d) for d in input().split()]
+
+s = {}
+for i in range(n):
+    s[input()] = i
+
+for _ in range(q):
+    a, b = input().split()
+    print(abs(s[a] - s[b]) - 1)
+

🟢 Successful Zoom

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
n = int(input())
+x = [int(d) for d in input().split()]
+found = False
+for k in range(1, n // 2 + 1):
+    v = [x[i] for i in range(k - 1, n, k)]
+    if all([v[i] < v[i + 1] for i in range(len(v) - 1)]):
+        print(k)
+        found = True
+        break
+if not found:
+    print("ABORT!")
+

🟢 Sum Kind of Problem

Solution in Python
1
+2
+3
+4
+5
+6
for _ in range(int(input())):
+    k, n = [int(d) for d in input().split()]
+    s1 = sum(range(1, n + 1))
+    s2 = sum(range(1, 2 * n + 1, 2))
+    s3 = sum(range(2, 2 * (n + 1), 2))
+    print(k, s1, s2, s3)
+

🟢 Sum of the Others

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
while True:
+    try:
+        n = [int(d) for d in input().split()]
+    except:
+        break
+
+    for i in range(len(n)):
+        if n[i] == sum([n[j] for j in range(len(n)) if j != i]):
+            print(n[i])
+            break
+

🟢 Sum Squared Digits Function

Solution in Python
1
 2
 3
 4
 5
 6
-7
sun_years_ago, sun_cycle = [int(v) for v in input().split()]
-moon_years_ago, moon_cycle = [int(v) for v in input().split()]
-
-for t in range(1, 5001):
-    if (t + sun_years_ago) % sun_cycle == 0 and (t + moon_years_ago) % moon_cycle == 0:
-        print(t)
-        break
-

🟢 Symmetric Order

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
set_num = 0
-while True:
-    size = int(input())
-    if size == 0:
-        break
-
-    names = []
-    for _ in range(size):
-        names.append(input())
-
-    set_num += 1
-    print(f"SET {set_num}")
-
-    top, bottom = [], []
-    for i in range(1, size, 2):
-        bottom.append(names[i])
-    for i in range(0, size, 2):
-        top.append(names[i])
-    names = top + bottom[::-1]
-    for name in names:
-        print(name)
-

🟢 Synchronizing Lists

Solution in Python
 1
+7
for _ in range(int(input())):
+    k, b, n = [int(d) for d in input().split()]
+    ssd = 0
+    while n:
+        ssd += (n % b) ** 2
+        n //= b
+    print(k, ssd)
+

🟢 Sun and Moon

Solution in Python
1
+2
+3
+4
+5
+6
+7
sun_years_ago, sun_cycle = [int(v) for v in input().split()]
+moon_years_ago, moon_cycle = [int(v) for v in input().split()]
+
+for t in range(1, 5001):
+    if (t + sun_years_ago) % sun_cycle == 0 and (t + moon_years_ago) % moon_cycle == 0:
+        print(t)
+        break
+

🟢 Symmetric Order

Solution in Python
 1
  2
  3
  4
@@ -10718,20 +10704,36 @@
 10
 11
 12
-13
while True:
-    n = int(input())
-    if not n:
-        break
-    a, b = [], []
-    for _ in range(n):
-        a.append(int(input()))
-    for _ in range(n):
-        b.append(int(input()))
-    mapping = dict(zip(sorted(a), sorted(b)))
-    for key in a:
-        print(mapping[key])
-    print()
-

🟢 T9 Spelling

Solution in Python
 1
+13
+14
+15
+16
+17
+18
+19
+20
+21
set_num = 0
+while True:
+    size = int(input())
+    if size == 0:
+        break
+
+    names = []
+    for _ in range(size):
+        names.append(input())
+
+    set_num += 1
+    print(f"SET {set_num}")
+
+    top, bottom = [], []
+    for i in range(1, size, 2):
+        bottom.append(names[i])
+    for i in range(0, size, 2):
+        top.append(names[i])
+    names = top + bottom[::-1]
+    for name in names:
+        print(name)
+

🟢 Synchronizing Lists

Solution in Python
 1
  2
  3
  4
@@ -10743,206 +10745,212 @@
 10
 11
 12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
n = int(input())
-mapping = {
-    "2": "abc",
-    "3": "def",
-    "4": "ghi",
-    "5": "jkl",
-    "6": "mno",
-    "7": "pqrs",
-    "8": "tuv",
-    "9": "wxyz",
-    "0": " ",
-}
-
-for i in range(n):
-    ans = []
-    prev = ""
-    for c in input():
-        for d, r in mapping.items():
-            if c in r:
-                if d == prev:
-                    ans.append(" ")
-                ans.append(d * (r.index(c) + 1))
-                prev = d
-                break
-    print(f"Case #{i+1}: {''.join(ans)}")
-

🟢 Tai's formula

Solution in Python
1
-2
-3
-4
-5
-6
-7
-8
-9
n = int(input())
-t1, v1 = [float(d) for d in input().split()]
-total = 0
-for _ in range(n - 1):
-    t2, v2 = [float(d) for d in input().split()]
-    total += (v1 + v2) * (t2 - t1) / 2
-    t1, v1 = t2, v2
-total /= 1000
-print(total)
-

🟢 Tajna

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
s = input()
-
-l = len(s)
-r = int(l**0.5)
-while l % r:
-    r -= 1
-c = l // r
-
-parts = [s[i : i + r] for i in range(0, l, r)]
-
-print("".join(["".join([row[i] for row in parts]) for i in range(r)]))
-

🟢 Tarifa

Solution in Python
1
-2
-3
-4
-5
-6
x = int(input())
-n = int(input())
-used = 0
-for _ in range(n):
-    used += int(input())
-print(x * (n + 1) - used)
-

🟡 Temperature Confusion

Solution in Python
1
+13
while True:
+    n = int(input())
+    if not n:
+        break
+    a, b = [], []
+    for _ in range(n):
+        a.append(int(input()))
+    for _ in range(n):
+        b.append(int(input()))
+    mapping = dict(zip(sorted(a), sorted(b)))
+    for key in a:
+        print(mapping[key])
+    print()
+

🟢 T9 Spelling

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
n = int(input())
+mapping = {
+    "2": "abc",
+    "3": "def",
+    "4": "ghi",
+    "5": "jkl",
+    "6": "mno",
+    "7": "pqrs",
+    "8": "tuv",
+    "9": "wxyz",
+    "0": " ",
+}
+
+for i in range(n):
+    ans = []
+    prev = ""
+    for c in input():
+        for d, r in mapping.items():
+            if c in r:
+                if d == prev:
+                    ans.append(" ")
+                ans.append(d * (r.index(c) + 1))
+                prev = d
+                break
+    print(f"Case #{i+1}: {''.join(ans)}")
+

🟢 Tai's formula

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
+9
n = int(input())
+t1, v1 = [float(d) for d in input().split()]
+total = 0
+for _ in range(n - 1):
+    t2, v2 = [float(d) for d in input().split()]
+    total += (v1 + v2) * (t2 - t1) / 2
+    t1, v1 = t2, v2
+total /= 1000
+print(total)
+

🟢 Tajna

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
s = input()
+
+l = len(s)
+r = int(l**0.5)
+while l % r:
+    r -= 1
+c = l // r
+
+parts = [s[i : i + r] for i in range(0, l, r)]
+
+print("".join(["".join([row[i] for row in parts]) for i in range(r)]))
+

🟢 Tarifa

Solution in Python
1
 2
 3
 4
 5
-6
-7
-8
-9
import math
-
-a, b = [int(d) for d in input().split("/")]
-x, y = 5 * a - 160 * b, 9 * b
-gcd = math.gcd(x, y)
-x //= gcd
-y //= gcd
-
-print(f"{x}/{y}")
-

🟢 Test Drive

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
a, b, c = [int(d) for d in input().split()]
-x, y = b - a, c - b
-if x == y:
-    print("cruised")
-elif x * y < 0:
-    print("turned")
-elif abs(y) > abs(x):
-    print("accelerated")
-else:
-    print("braked")
-

🟢 Tetration

Solution in Python
1
+6
x = int(input())
+n = int(input())
+used = 0
+for _ in range(n):
+    used += int(input())
+print(x * (n + 1) - used)
+

🟢 Time Travelling Temperatures

Solution in Python
1
+2
+3
+4
+5
x, y = [int(d) for d in input().split()]
+if y == 1:
+    print("ALL GOOD" if not x else "IMPOSSIBLE")
+else:
+    print(-x / (y - 1))
+

🟡 Temperature Confusion

Solution in Python
1
 2
 3
-4
import math
+4
+5
+6
+7
+8
+9
import math
 
-n = float(input())
-print(f"{math.pow(n,1/n):.6f}")
-

🟢 Thanos

Solution in Python
1
-2
-3
-4
-5
-6
-7
for _ in range(int(input())):
-    p, r, f = [int(d) for d in input().split()]
-    y = 0
-    while p <= f:
-        p *= r
-        y += 1
-    print(y)
-

🟢 The Grand Adventure

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
mapping = {"b": "$", "t": "|", "j": "*"}
-for _ in range(int(input())):
-    a = input()
-    bag = []
-    early_fail = False
-    for i in a:
-        if i in mapping.values():
-            bag.append(i)
-        elif i in mapping:
-            if not bag or bag.pop() != mapping[i]:
-                print("NO")
-                early_fail = True
-                break
-    if not early_fail:
-        print("YES" if not bag else "NO")
-

🟢 The Last Problem

Solutions in 2 languages
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
package main
-
-import (
-    "bufio"
-    "fmt"
-    "os"
-)
-
-func main() {
-    scanner := bufio.NewScanner(os.Stdin)
-    scanner.Scan()
-    s := scanner.Text()
-    fmt.Println("Thank you,", s+",", "and farewell!")
-}
-
print(f"Thank you, {input()}, and farewell!")
-

🟢 This Ain't Your Grandpa's Checkerboard

Solution in Python
 1
+a, b = [int(d) for d in input().split("/")]
+x, y = 5 * a - 160 * b, 9 * b
+gcd = math.gcd(x, y)
+x //= gcd
+y //= gcd
+
+print(f"{x}/{y}")
+

🟢 Test Drive

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
a, b, c = [int(d) for d in input().split()]
+x, y = b - a, c - b
+if x == y:
+    print("cruised")
+elif x * y < 0:
+    print("turned")
+elif abs(y) > abs(x):
+    print("accelerated")
+else:
+    print("braked")
+

🟢 Tetration

Solution in Python
1
+2
+3
+4
import math
+
+n = float(input())
+print(f"{math.pow(n,1/n):.6f}")
+

🟢 Thanos

Solution in Python
1
+2
+3
+4
+5
+6
+7
for _ in range(int(input())):
+    p, r, f = [int(d) for d in input().split()]
+    y = 0
+    while p <= f:
+        p *= r
+        y += 1
+    print(y)
+

🟢 The Grand Adventure

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
mapping = {"b": "$", "t": "|", "j": "*"}
+for _ in range(int(input())):
+    a = input()
+    bag = []
+    early_fail = False
+    for i in a:
+        if i in mapping.values():
+            bag.append(i)
+        elif i in mapping:
+            if not bag or bag.pop() != mapping[i]:
+                print("NO")
+                early_fail = True
+                break
+    if not early_fail:
+        print("YES" if not bag else "NO")
+

🟢 The Last Problem

Solutions in 2 languages
 1
  2
  3
  4
@@ -10955,216 +10963,200 @@
 11
 12
 13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
n = int(input())
-b = []
-for _ in range(n):
-    b.append(input())
-
-
-def check(b, n):
-    for row in b:
-        if row.count("W") != row.count("B"):
-            return False
-
-        for j in range(0, n - 3):
-            if row[j] == row[j + 1] == row[j + 2]:
-                return False
-
-    for i in range(n):
-        col = ["".join(row[i]) for row in b]
-
-        if col.count("W") != col.count("B"):
-            return False
-
-        for j in range(0, n - 3):
-            if col[j] == col[j + 1] == col[j + 2]:
-                return False
-
-    return True
-
-
-valid = check(b, n)
-print(1 if valid else 0)
-

🟢 Stuck In A Time Loop

Solutions in 2 languages
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
#include <iostream>
-
-using namespace std;
-
-int main()
-{
-    int a;
-    cin >> a;
-    for (int i = 0; i < a; i++)
-    {
-        cout << i + 1 << " Abracadabra" << endl;
-    }
-}
-
1
-2
-3
n = int(input())
-for i in range(n):
-    print(f"{i+1} Abracadabra")
-

🟢 Title Cost

Solution in Python
1
-2
-3
s, c = input().split()
-c = float(c)
-print(min(c, len(s)))
-

🟢 Töflur

Solution in Python
1
+14
package main
+
+import (
+    "bufio"
+    "fmt"
+    "os"
+)
+
+func main() {
+    scanner := bufio.NewScanner(os.Stdin)
+    scanner.Scan()
+    s := scanner.Text()
+    fmt.Println("Thank you,", s+",", "and farewell!")
+}
+
print(f"Thank you, {input()}, and farewell!")
+

🟢 This Ain't Your Grandpa's Checkerboard

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
n = int(input())
+b = []
+for _ in range(n):
+    b.append(input())
+
+
+def check(b, n):
+    for row in b:
+        if row.count("W") != row.count("B"):
+            return False
+
+        for j in range(0, n - 3):
+            if row[j] == row[j + 1] == row[j + 2]:
+                return False
+
+    for i in range(n):
+        col = ["".join(row[i]) for row in b]
+
+        if col.count("W") != col.count("B"):
+            return False
+
+        for j in range(0, n - 3):
+            if col[j] == col[j + 1] == col[j + 2]:
+                return False
+
+    return True
+
+
+valid = check(b, n)
+print(1 if valid else 0)
+

🟢 Stuck In A Time Loop

Solutions in 2 languages
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
#include <iostream>
+
+using namespace std;
+
+int main()
+{
+    int a;
+    cin >> a;
+    for (int i = 0; i < a; i++)
+    {
+        cout << i + 1 << " Abracadabra" << endl;
+    }
+}
+
1
 2
-3
-4
n = int(input())
-a = sorted([int(d) for d in input().split()])
-score = sum([(a[j] - a[j + 1]) ** 2 for j in range(n - 1)])
-print(score)
-

🟢 Toilet Seat

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
t = input()
-
-
-def u(pos, preference):
-    if pos == preference == "U":
-        return 0
-    elif pos == preference == "D":
-        return 1
-    elif pos == "U" and preference == "D":
-        return 2
-    else:
-        return 1
-
-
-def l(pos, preference):
-    if pos == preference == "U":
-        return 1
-    elif pos == preference == "D":
-        return 0
-    elif pos == "U" and preference == "D":
-        return 1
-    else:
-        return 2
-
-
-def b(pos, preference):
-    if pos == preference:
-        return 0
-    else:
-        return 1
-
-
-pu = [u(pos, preference) for pos, preference in zip(t[0] + "U" * (len(t) - 2), t[1:])]
-pl = [l(pos, preference) for pos, preference in zip(t[0] + "D" * (len(t) - 2), t[1:])]
-pb = [b(pos, preference) for pos, preference in zip(t[0] + t[1:-1], t[1:])]
-
-print(sum(pu))
-print(sum(pl))
-print(sum(pb))
-

🟢 ToLower

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
p, t = [int(d) for d in input().split()]
-score = 0
-for _ in range(p):
-    solved = True
-    for _ in range(t):
-        s = input()
-        if solved:
-            s = s[0].lower() + s[1:]
-            if s.lower() == s:
-                continue
-        solved = False
-    if solved:
-        score += 1
-print(score)
-

🟢 Tower Construction

Solution in Python
1
-2
-3
-4
-5
-6
-7
-8
-9
_ = input()
-n = 0
-top = 0
-for d in [int(d) for d in input().split()]:
-    if not top or d > top:
-        n += 1
-    top = d
-
-print(n)
-

🟢 Touchscreen Keyboard

Solution in Python
 1
+3
n = int(input())
+for i in range(n):
+    print(f"{i+1} Abracadabra")
+

🟢 Title Cost

Solution in Python
1
+2
+3
s, c = input().split()
+c = float(c)
+print(min(c, len(s)))
+

🟢 Töflur

Solution in Python
1
+2
+3
+4
n = int(input())
+a = sorted([int(d) for d in input().split()])
+score = sum([(a[j] - a[j + 1]) ** 2 for j in range(n - 1)])
+print(score)
+

🟢 Toilet Seat

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
t = input()
+
+
+def u(pos, preference):
+    if pos == preference == "U":
+        return 0
+    elif pos == preference == "D":
+        return 1
+    elif pos == "U" and preference == "D":
+        return 2
+    else:
+        return 1
+
+
+def l(pos, preference):
+    if pos == preference == "U":
+        return 1
+    elif pos == preference == "D":
+        return 0
+    elif pos == "U" and preference == "D":
+        return 1
+    else:
+        return 2
+
+
+def b(pos, preference):
+    if pos == preference:
+        return 0
+    else:
+        return 1
+
+
+pu = [u(pos, preference) for pos, preference in zip(t[0] + "U" * (len(t) - 2), t[1:])]
+pl = [l(pos, preference) for pos, preference in zip(t[0] + "D" * (len(t) - 2), t[1:])]
+pb = [b(pos, preference) for pos, preference in zip(t[0] + t[1:-1], t[1:])]
+
+print(sum(pu))
+print(sum(pl))
+print(sum(pb))
+

🟢 ToLower

Solution in Python
 1
  2
  3
  4
@@ -11177,90 +11169,38 @@
 11
 12
 13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
k = [
-    "qwertyuiop",
-    "asdfghjkl",
-    "zxcvbnm",
-]
-
-
-def d(a, b):
-    for r1 in range(3):
-        if a in k[r1]:
-            c1 = k[r1].index(a)
-            break
-    for r2 in range(3):
-        if b in k[r2]:
-            c2 = k[r2].index(b)
-            break
-
-    return abs(c1 - c2) + abs(r1 - r2)
-
-
-for _ in range(int(input())):
-    x, n = input().split()
-    n, w = int(n), []
-
-    for _ in range(n):
-        y = input()
-        dist = sum([d(a, b) for a, b in zip(list(x), list(y))])
-        w.append([y, dist])
-
-    print("\n".join([f"{k} {v}" for k, v in sorted(w, key=lambda k: (k[1], k[0]))]))
-

🟢 Transit Woes

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
s, t, n = [int(d) for d in input().split()]
-ds = [int(d) for d in input().split()]
-bs = [int(d) for d in input().split()]
-cs = [int(d) for d in input().split()]
-
-for i in range(n):
-    s += ds[i]
-    if not s % cs[i]:
-        wait_b = 0
-    else:
-        wait_b = cs[i] - s % cs[i]
-    s += wait_b + bs[i]
-
-s += ds[n]
-
-if s <= t:
-    print("yes")
-else:
-    print("no")
-

🟢 Tri

Solution in Python
p, t = [int(d) for d in input().split()]
+score = 0
+for _ in range(p):
+    solved = True
+    for _ in range(t):
+        s = input()
+        if solved:
+            s = s[0].lower() + s[1:]
+            if s.lower() == s:
+                continue
+        solved = False
+    if solved:
+        score += 1
+print(score)
+

🟢 Tower Construction

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
+9
_ = input()
+n = 0
+top = 0
+for d in [int(d) for d in input().split()]:
+    if not top or d > top:
+        n += 1
+    top = d
+
+print(n)
+

🟢 Touchscreen Keyboard

Solution in Python
 1
  2
  3
  4
@@ -11275,23 +11215,51 @@
 13
 14
 15
-16
from operator import add, sub, truediv, mul
-
-a, b, c = [int(d) for d in input().split()]
-ops = {
-    "+": add,
-    "-": sub,
-    "*": mul,
-    "/": truediv,
-}
-
-for op, func in ops.items():
-    if a == func(b, c):
-        print(f"{a}={b}{op}{c}")
-        break
-    if func(a, b) == c:
-        print(f"{a}{op}{b}={c}")
-

🟢 Triangle Area

Solutions in 4 languages
 1
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
k = [
+    "qwertyuiop",
+    "asdfghjkl",
+    "zxcvbnm",
+]
+
+
+def d(a, b):
+    for r1 in range(3):
+        if a in k[r1]:
+            c1 = k[r1].index(a)
+            break
+    for r2 in range(3):
+        if b in k[r2]:
+            c2 = k[r2].index(b)
+            break
+
+    return abs(c1 - c2) + abs(r1 - r2)
+
+
+for _ in range(int(input())):
+    x, n = input().split()
+    n, w = int(n), []
+
+    for _ in range(n):
+        y = input()
+        dist = sum([d(a, b) for a, b in zip(list(x), list(y))])
+        w.append([y, dist])
+
+    print("\n".join([f"{k} {v}" for k, v in sorted(w, key=lambda k: (k[1], k[0]))]))
+

🟢 Transit Woes

Solution in Python
 1
  2
  3
  4
@@ -11301,18 +11269,34 @@
  8
  9
 10
-11
#include <iostream>
-
-using namespace std;
-
-int main()
-{
-    int h, b;
-    cin >> h >> b;
-    cout << float(h) * b / 2 << endl;
-    return 0;
-}
-
 1
+11
+12
+13
+14
+15
+16
+17
+18
+19
s, t, n = [int(d) for d in input().split()]
+ds = [int(d) for d in input().split()]
+bs = [int(d) for d in input().split()]
+cs = [int(d) for d in input().split()]
+
+for i in range(n):
+    s += ds[i]
+    if not s % cs[i]:
+        wait_b = 0
+    else:
+        wait_b = cs[i] - s % cs[i]
+    s += wait_b + bs[i]
+
+s += ds[n]
+
+if s <= t:
+    print("yes")
+else:
+    print("no")
+

🟢 Tri

Solution in Python
 1
  2
  3
  4
@@ -11321,17 +11305,29 @@
  7
  8
  9
-10
package main
+10
+11
+12
+13
+14
+15
+16
from operator import add, sub, truediv, mul
 
-import "fmt"
-
-func main() {
-    var a, b int
-    fmt.Scan(&a)
-    fmt.Scan(&b)
-    fmt.Println(float32(a) * float32(b) / 2)
-}
-
 1
+a, b, c = [int(d) for d in input().split()]
+ops = {
+    "+": add,
+    "-": sub,
+    "*": mul,
+    "/": truediv,
+}
+
+for op, func in ops.items():
+    if a == func(b, c):
+        print(f"{a}={b}{op}{c}")
+        break
+    if func(a, b) == c:
+        print(f"{a}{op}{b}={c}")
+

🟢 Triangle Area

Solutions in 4 languages
 1
  2
  3
  4
@@ -11340,20 +11336,38 @@
  7
  8
  9
-10
import java.util.Scanner;
+10
+11
#include <iostream>
 
-class TriangleArea {
-    public static void main(String[] args) {
-        Scanner s = new Scanner(System.in);
-        float a = s.nextFloat();
-        int b = s.nextInt();
-        System.out.println(a * b / 2);
-    }
-}
-
1
-2
a, b = [int(d) for d in input().split()]
-print(a * b / 2)
-

🟢 Trik

Solution in Python
 1
+using namespace std;
+
+int main()
+{
+    int h, b;
+    cin >> h >> b;
+    cout << float(h) * b / 2 << endl;
+    return 0;
+}
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
package main
+
+import "fmt"
+
+func main() {
+    var a, b int
+    fmt.Scan(&a)
+    fmt.Scan(&b)
+    fmt.Println(float32(a) * float32(b) / 2)
+}
+
 1
  2
  3
  4
@@ -11362,66 +11376,20 @@
  7
  8
  9
-10
-11
-12
-13
-14
-15
-16
moves = input()
-ball = [1, 0, 0]
-for move in moves:
-    if move == "A":
-        ball[0], ball[1] = ball[1], ball[0]
-    if move == "B":
-        ball[1], ball[2] = ball[2], ball[1]
-    if move == "C":
-        ball[0], ball[2] = ball[2], ball[0]
-
-if ball[0]:
-    print(1)
-elif ball[1]:
-    print(2)
-else:
-    print(3)
-

🟢 Triple Texting

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
from collections import Counter
-
-s = input()
-times = 3
-size = len(s) // times
-messages = []
-for i in range(0, len(s), size):
-    messages.append(s[i : i + size])
-
-original = ""
-for i in range(size):
-    chars = [m[i] for m in messages]
-    if len(set(chars)) == 1:
-        original += chars[0]
-    else:
-        c = Counter(chars)
-        original += max(c, key=lambda k: c[k])
-
-print(original)
-

🟢 Take Two Stones

Solutions in 6 languages
import java.util.Scanner;
+
+class TriangleArea {
+    public static void main(String[] args) {
+        Scanner s = new Scanner(System.in);
+        float a = s.nextFloat();
+        int b = s.nextInt();
+        System.out.println(a * b / 2);
+    }
+}
+
1
+2
a, b = [int(d) for d in input().split()]
+print(a * b / 2)
+

🟢 Trik

Solution in Python
 1
  2
  3
  4
@@ -11433,31 +11401,63 @@
 10
 11
 12
-13
package main
-
-import "fmt"
-
-func main() {
-    var n int
-    fmt.Scan(&n)
-    if n%2 == 1 {
-        fmt.Println("Alice")
-    } else {
-        fmt.Println("Bob")
-    }
-}
-
1
-2
-3
-4
-5
-6
main = do
-    input <- getLine
-    let n = (read input :: Int)
-    if  n `mod` 2  ==  1
-    then putStrLn "Alice"
-        else putStrLn "Bob"
-
 1
+13
+14
+15
+16
moves = input()
+ball = [1, 0, 0]
+for move in moves:
+    if move == "A":
+        ball[0], ball[1] = ball[1], ball[0]
+    if move == "B":
+        ball[1], ball[2] = ball[2], ball[1]
+    if move == "C":
+        ball[0], ball[2] = ball[2], ball[0]
+
+if ball[0]:
+    print(1)
+elif ball[1]:
+    print(2)
+else:
+    print(3)
+

🟢 Triple Texting

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
from collections import Counter
+
+s = input()
+times = 3
+size = len(s) // times
+messages = []
+for i in range(0, len(s), size):
+    messages.append(s[i : i + size])
+
+original = ""
+for i in range(size):
+    chars = [m[i] for m in messages]
+    if len(set(chars)) == 1:
+        original += chars[0]
+    else:
+        c = Counter(chars)
+        original += max(c, key=lambda k: c[k])
+
+print(original)
+

🟢 Take Two Stones

Solutions in 6 languages
 1
  2
  3
  4
@@ -11469,99 +11469,95 @@
 10
 11
 12
-13
import java.util.Scanner;
+13
package main
 
-class TakeTwoStones {
-    public static void main(String[] args) {
-        Scanner s = new Scanner(System.in);
-        int n = s.nextInt();
-        if (n % 2 == 1) {
-            System.out.println("Alice");
-        } else {
-            System.out.println("Bob");
-        }
+import "fmt"
+
+func main() {
+    var n int
+    fmt.Scan(&n)
+    if n%2 == 1 {
+        fmt.Println("Alice")
+    } else {
+        fmt.Println("Bob")
     }
 }
-
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
const readline = require("readline");
-const rl = readline.createInterface(process.stdin, process.stdout);
-
-rl.question("", (n) => {
-  if (parseInt(n) % 2) {
-    console.log("Alice");
-  } else {
-    console.log("Bob");
-  }
-});
-
1
-2
-3
-4
-5
-6
-7
fun main() {
-    if (readLine()!!.toInt() % 2 == 1) {
-        println("Alice")
-    } else {
-        println("Bob")
-    }
-}
-
1
-2
-3
-4
if int(input()) % 2:
-    print("Alice")
-else:
-    print("Bob")
-

🟢 Two-sum

Solutions in 4 languages
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
#include <iostream>
-
-using namespace std;
-
-int main()
-{
-    int a, b;
-    cin >> a >> b;
-    cout << a + b << endl;
-    return 0;
-}
-
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
package main
-
-import "fmt"
-
-func main() {
-    var a, b int
-    fmt.Scan(&a)
-    fmt.Scan(&b)
-    fmt.Println(a + b)
-}
-
 1
+
1
+2
+3
+4
+5
+6
main = do
+    input <- getLine
+    let n = (read input :: Int)
+    if  n `mod` 2  ==  1
+    then putStrLn "Alice"
+        else putStrLn "Bob"
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
import java.util.Scanner;
+
+class TakeTwoStones {
+    public static void main(String[] args) {
+        Scanner s = new Scanner(System.in);
+        int n = s.nextInt();
+        if (n % 2 == 1) {
+            System.out.println("Alice");
+        } else {
+            System.out.println("Bob");
+        }
+    }
+}
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
const readline = require("readline");
+const rl = readline.createInterface(process.stdin, process.stdout);
+
+rl.question("", (n) => {
+  if (parseInt(n) % 2) {
+    console.log("Alice");
+  } else {
+    console.log("Bob");
+  }
+});
+
1
+2
+3
+4
+5
+6
+7
fun main() {
+    if (readLine()!!.toInt() % 2 == 1) {
+        println("Alice")
+    } else {
+        println("Bob")
+    }
+}
+
1
+2
+3
+4
if int(input()) % 2:
+    print("Alice")
+else:
+    print("Bob")
+

🟢 Two-sum

Solutions in 4 languages
 1
  2
  3
  4
@@ -11570,118 +11566,88 @@
  7
  8
  9
-10
import java.util.Scanner;
+10
+11
#include <iostream>
 
-class TwoSum {
-    public static void main(String[] args) {
-        Scanner s = new Scanner(System.in);
-        int a = s.nextInt();
-        int b = s.nextInt();
-        System.out.println(a + b);
-    }
-}
-
1
-2
-3
line = input()
-a, b = [int(d) for d in line.split()]
-print(a + b)
-

🟢 Úllen dúllen doff

Solution in Python
1
-2
-3
-4
-5
-6
-7
n = int(input())
-names = input().split()
-if n < 13:
-    i = 13 % n - 1
-else:
-    i = 12
-print(names[i])
-

🟢 Ultimate Binary Watch

Solution in Python
1
+using namespace std;
+
+int main()
+{
+    int a, b;
+    cin >> a >> b;
+    cout << a + b << endl;
+    return 0;
+}
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
package main
+
+import "fmt"
+
+func main() {
+    var a, b int
+    fmt.Scan(&a)
+    fmt.Scan(&b)
+    fmt.Println(a + b)
+}
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
import java.util.Scanner;
+
+class TwoSum {
+    public static void main(String[] args) {
+        Scanner s = new Scanner(System.in);
+        int a = s.nextInt();
+        int b = s.nextInt();
+        System.out.println(a + b);
+    }
+}
+
1
 2
-3
-4
-5
-6
-7
t = [int(d) for d in input()]
-b = [f"{d:b}".zfill(4) for d in t]
-
-for r in range(4):
-    row = ["." if b[i][r] == "0" else "*" for i in range(4)]
-    row.insert(2, " ")
-    print(" ".join(row))
-

🟢 Undead or Alive

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
s = input()
-
-smiley = ":)" in s
-
-frowny = ":(" in s
-
-if not frowny and smiley:
-    print("alive")
-
-elif frowny and not smiley:
-    print("undead")
-
-elif frowny and smiley:
-    print("double agent")
-
-else:
-    print("machine")
-

🟢 Unlock Pattern

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
import math
-
+3
line = input()
+a, b = [int(d) for d in line.split()]
+print(a + b)
+

🟢 Úllen dúllen doff

Solution in Python
1
+2
+3
+4
+5
+6
+7
n = int(input())
+names = input().split()
+if n < 13:
+    i = 13 % n - 1
+else:
+    i = 12
+print(names[i])
+

🟢 Ultimate Binary Watch

Solution in Python
1
+2
+3
+4
+5
+6
+7
t = [int(d) for d in input()]
+b = [f"{d:b}".zfill(4) for d in t]
 
-def dist(a, b):
-    return math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)
-
-
-coords = {}
-for i in range(3):
-    n = [int(d) for d in input().split()]
-    for j in range(3):
-        coords[n[j]] = (i, j)
-
-values = [coords[k] for k in sorted(coords)]
-total, prev = 0, 0
-for i in range(1, 9):
-    total += dist(values[i], values[prev])
-    prev = i
-print(total)
-

🟢 Arrangement

Solution in Python
 1
+for r in range(4):
+    row = ["." if b[i][r] == "0" else "*" for i in range(4)]
+    row.insert(2, " ")
+    print(" ".join(row))
+

🟢 Undead or Alive

Solution in Python
 1
  2
  3
  4
@@ -11690,17 +11656,31 @@
  7
  8
  9
-10
import math
+10
+11
+12
+13
+14
+15
+16
+17
s = input()
 
-n, m = int(input()), int(input())
+smiley = ":)" in s
 
-k = math.ceil(m / n)
+frowny = ":(" in s
 
-for _ in range(n - (n * k - m)):
-    print("*" * k)
-for _ in range(n * k - m):
-    print("*" * (k - 1))
-

🟢 UTF-8

Solution in Python
 1
+if not frowny and smiley:
+    print("alive")
+
+elif frowny and not smiley:
+    print("undead")
+
+elif frowny and smiley:
+    print("double agent")
+
+else:
+    print("machine")
+

🟢 Unlock Pattern

Solution in Python
 1
  2
  3
  4
@@ -11718,56 +11698,26 @@
 16
 17
 18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
n = int(input())
-s = []
-for _ in range(n):
-    s.append(input())
-
-i = 0
-num = 0
-err = False
-t = [0] * 4
-while i < n:
-    a = s[i]
-    if a.startswith("0") and not num:
-        num = 0
-        t[0] += 1
-    elif a.startswith("110") and not num:
-        t[1] += 1
-        num = 1
-    elif a.startswith("1110") and not num:
-        t[2] += 1
-        num = 2
-    elif a.startswith("11110") and not num:
-        t[3] += 1
-        num = 3
-    elif a.startswith("10") and num:
-        num -= 1
-    else:
-        err = True
-        break
-    i += 1
-
-if err or num:
-    print("invalid")
-else:
-    print("\n".join([str(d) for d in t]))
-

🟡 Vaccine Efficacy

Solution in Python
import math
+
+
+def dist(a, b):
+    return math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)
+
+
+coords = {}
+for i in range(3):
+    n = [int(d) for d in input().split()]
+    for j in range(3):
+        coords[n[j]] = (i, j)
+
+values = [coords[k] for k in sorted(coords)]
+total, prev = 0, 0
+for i in range(1, 9):
+    total += dist(values[i], values[prev])
+    prev = i
+print(total)
+

🟢 Arrangement

Solution in Python
 1
  2
  3
  4
@@ -11776,139 +11726,17 @@
  7
  8
  9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
-63
-64
-65
-66
-67
-68
-69
-70
-71
participants = int(input())
+10
import math
 
-vaccinated = 0
-control = 0
-infected_control_a = 0
-infected_vaccinated_a = 0
-infected_control_b = 0
-infected_vaccinated_b = 0
-infected_control_c = 0
-infected_vaccinated_c = 0
-
-for p in range(participants):
-    record = input()
-    v, a, b, c = list(record)
-
-    if v == "N":
-        control += 1
-    else:
-        vaccinated += 1
-
-    if a == "Y":
-        if v == "N":
-            infected_control_a += 1
-        else:
-            infected_vaccinated_a += 1
-
-    if b == "Y":
-        if v == "N":
-            infected_control_b += 1
-        else:
-            infected_vaccinated_b += 1
-
-    if c == "Y":
-        if v == "N":
-            infected_control_c += 1
-        else:
-            infected_vaccinated_c += 1
-
-
-def get_vaccine_efficacy(infected_vaccinated, vaccinated, infected_control, control):
-    infection_rate_vaccinated = infected_vaccinated / vaccinated
-    infection_rate_control = infected_control / control
-    return 1 - infection_rate_vaccinated / infection_rate_control
-
-
-vaccine_efficacy = [
-    get_vaccine_efficacy(
-        infected_vaccinated_a,
-        vaccinated,
-        infected_control_a,
-        control,
-    ),
-    get_vaccine_efficacy(
-        infected_vaccinated_b,
-        vaccinated,
-        infected_control_b,
-        control,
-    ),
-    get_vaccine_efficacy(
-        infected_vaccinated_c,
-        vaccinated,
-        infected_control_c,
-        control,
-    ),
-]
-
-for value in vaccine_efficacy:
-    if value <= 0:
-        print("Not Effective")
-    else:
-        print(f"{value*100:.6f}")
-

🟢 Right-of-Way

Solution in Python
 1
+n, m = int(input()), int(input())
+
+k = math.ceil(m / n)
+
+for _ in range(n - (n * k - m)):
+    print("*" * k)
+for _ in range(n * k - m):
+    print("*" * (k - 1))
+

🟢 UTF-8

Solution in Python
 1
  2
  3
  4
@@ -11923,23 +11751,59 @@
 13
 14
 15
-16
d = ["North", "East", "South", "West"]
-a, b, c = input().split()
-ia = d.index(a)
-ib = d.index(b)
-ic = d.index(c)
-
-ib = (ib - ia) % 4
-ic = (ic - ia) % 4
-ia -= ia
-
-if ib == 2:
-    print("Yes" if ic == 3 else "No")
-elif ib == 1:
-    print("Yes" if ic in [2, 3] else "No")
-else:
-    print("No")
-

🟢 Variable Arithmetic

Solution in Python
 1
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
n = int(input())
+s = []
+for _ in range(n):
+    s.append(input())
+
+i = 0
+num = 0
+err = False
+t = [0] * 4
+while i < n:
+    a = s[i]
+    if a.startswith("0") and not num:
+        num = 0
+        t[0] += 1
+    elif a.startswith("110") and not num:
+        t[1] += 1
+        num = 1
+    elif a.startswith("1110") and not num:
+        t[2] += 1
+        num = 2
+    elif a.startswith("11110") and not num:
+        t[3] += 1
+        num = 3
+    elif a.startswith("10") and num:
+        num -= 1
+    else:
+        err = True
+        break
+    i += 1
+
+if err or num:
+    print("invalid")
+else:
+    print("\n".join([str(d) for d in t]))
+

🟡 Vaccine Efficacy

Solution in Python
 1
  2
  3
  4
@@ -11961,30 +11825,126 @@
 20
 21
 22
-23
context = {}
-while True:
-    s = input()
-    if s == "0":
-        break
-
-    if "=" in s:
-        x, y = [d.strip() for d in s.split("=")]
-        context[x] = int(y)
-    else:
-        v = [d.strip() for d in s.split("+")]
-        t = 0
-        n = []
-        for d in v:
-            if d.isdigit():
-                t += int(d)
-            elif d in context:
-                t += context[d]
-            else:
-                n.append(d)
-        if len(n) < len(v):
-            n = [str(t)] + n
-        print(" + ".join(n))
-

🟢 Veci

Solution in Python
 1
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
participants = int(input())
+
+vaccinated = 0
+control = 0
+infected_control_a = 0
+infected_vaccinated_a = 0
+infected_control_b = 0
+infected_vaccinated_b = 0
+infected_control_c = 0
+infected_vaccinated_c = 0
+
+for p in range(participants):
+    record = input()
+    v, a, b, c = list(record)
+
+    if v == "N":
+        control += 1
+    else:
+        vaccinated += 1
+
+    if a == "Y":
+        if v == "N":
+            infected_control_a += 1
+        else:
+            infected_vaccinated_a += 1
+
+    if b == "Y":
+        if v == "N":
+            infected_control_b += 1
+        else:
+            infected_vaccinated_b += 1
+
+    if c == "Y":
+        if v == "N":
+            infected_control_c += 1
+        else:
+            infected_vaccinated_c += 1
+
+
+def get_vaccine_efficacy(infected_vaccinated, vaccinated, infected_control, control):
+    infection_rate_vaccinated = infected_vaccinated / vaccinated
+    infection_rate_control = infected_control / control
+    return 1 - infection_rate_vaccinated / infection_rate_control
+
+
+vaccine_efficacy = [
+    get_vaccine_efficacy(
+        infected_vaccinated_a,
+        vaccinated,
+        infected_control_a,
+        control,
+    ),
+    get_vaccine_efficacy(
+        infected_vaccinated_b,
+        vaccinated,
+        infected_control_b,
+        control,
+    ),
+    get_vaccine_efficacy(
+        infected_vaccinated_c,
+        vaccinated,
+        infected_control_c,
+        control,
+    ),
+]
+
+for value in vaccine_efficacy:
+    if value <= 0:
+        print("Not Effective")
+    else:
+        print(f"{value*100:.6f}")
+

🟢 Right-of-Way

Solution in Python
 1
  2
  3
  4
@@ -11994,18 +11954,28 @@
  8
  9
 10
-11
from itertools import permutations
-
-x = input()
-
-values = sorted(set([int("".join(v)) for v in permutations(x, len(x))]))
+11
+12
+13
+14
+15
+16
d = ["North", "East", "South", "West"]
+a, b, c = input().split()
+ia = d.index(a)
+ib = d.index(b)
+ic = d.index(c)
 
-index = values.index(int(x))
-if index + 1 < len(values):
-    print(values[index + 1])
-else:
-    print(0)
-

🟡 Vector Functions

Solution in C++
 1
+ib = (ib - ia) % 4
+ic = (ic - ia) % 4
+ia -= ia
+
+if ib == 2:
+    print("Yes" if ic == 3 else "No")
+elif ib == 1:
+    print("Yes" if ic in [2, 3] else "No")
+else:
+    print("No")
+

🟢 Variable Arithmetic

Solution in Python
 1
  2
  3
  4
@@ -12027,89 +11997,51 @@
 20
 21
 22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
#include "vectorfunctions.h"
-#include <algorithm>
-
-void backwards(std::vector<int> &vec)
-{
-    vec = std::vector<int>(vec.rbegin(), vec.rend());
-}
-
-std::vector<int> everyOther(const std::vector<int> &vec)
-{
-    std::vector<int> ans;
-
-    for (int i = 0; i < vec.size(); i += 2)
-        ans.push_back(vec[i]);
-
-    return ans;
-}
-
-int smallest(const std::vector<int> &vec)
-{
-    return *min_element(vec.begin(), vec.end());
-}
-
-int sum(const std::vector<int> &vec)
-{
-    int ans = 0;
-
-    for (auto it = begin(vec); it != end(vec); ++it)
-    {
-        ans += *it;
-    }
-
-    return ans;
-}
-
-int veryOdd(const std::vector<int> &suchVector)
-{
-    int ans = 0;
-    for (int i = 1; i < suchVector.size(); i += 2)
-    {
-        if (suchVector[i] % 2 == 1)
-            ans++;
-    }
-
-    return ans;
-}
-

🟢 Veður - Lokaðar heiðar

Solution in Python
1
-2
-3
-4
-5
-6
-7
v = int(input())
-for _ in range(int(input())):
-    s, k = input().split()
-    if int(k) >= v:
-        print(s, "opin")
-    else:
-        print(s, "lokud")
-

🟢 Veður - Vindhraði

Solution in Python
context = {}
+while True:
+    s = input()
+    if s == "0":
+        break
+
+    if "=" in s:
+        x, y = [d.strip() for d in s.split("=")]
+        context[x] = int(y)
+    else:
+        v = [d.strip() for d in s.split("+")]
+        t = 0
+        n = []
+        for d in v:
+            if d.isdigit():
+                t += int(d)
+            elif d in context:
+                t += context[d]
+            else:
+                n.append(d)
+        if len(n) < len(v):
+            n = [str(t)] + n
+        print(" + ".join(n))
+

🟢 Veci

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
from itertools import permutations
+
+x = input()
+
+values = sorted(set([int("".join(v)) for v in permutations(x, len(x))]))
+
+index = values.index(int(x))
+if index + 1 < len(values):
+    print(values[index + 1])
+else:
+    print(0)
+

🟡 Vector Functions

Solution in C++
 1
  2
  3
  4
@@ -12136,122 +12068,204 @@
 25
 26
 27
-28
k = float(input())
-if k < 0.3:
-    print("logn")
-elif k < 1.6:
-    print("Andvari")
-elif k < 3.4:
-    print("Kul")
-elif k < 5.5:
-    print("Gola")
-elif k < 8.0:
-    print("Stinningsgola")
-elif k < 10.8:
-    print("Kaldi")
-elif k < 13.9:
-    print("Stinningskaldi")
-elif k < 17.2:
-    print("Allhvass vindur")
-elif k < 20.8:
-    print("Hvassvidri")
-elif k < 24.5:
-    print("Stormur")
-elif k < 28.5:
-    print("Rok")
-
-elif k < 32.7:
-    print("Ofsavedur")
-else:
-    print("Farvidri")
-

🟢 Vefþjónatjón

Solution in Python
1
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
#include "vectorfunctions.h"
+#include <algorithm>
+
+void backwards(std::vector<int> &vec)
+{
+    vec = std::vector<int>(vec.rbegin(), vec.rend());
+}
+
+std::vector<int> everyOther(const std::vector<int> &vec)
+{
+    std::vector<int> ans;
+
+    for (int i = 0; i < vec.size(); i += 2)
+        ans.push_back(vec[i]);
+
+    return ans;
+}
+
+int smallest(const std::vector<int> &vec)
+{
+    return *min_element(vec.begin(), vec.end());
+}
+
+int sum(const std::vector<int> &vec)
+{
+    int ans = 0;
+
+    for (auto it = begin(vec); it != end(vec); ++it)
+    {
+        ans += *it;
+    }
+
+    return ans;
+}
+
+int veryOdd(const std::vector<int> &suchVector)
+{
+    int ans = 0;
+    for (int i = 1; i < suchVector.size(); i += 2)
+    {
+        if (suchVector[i] % 2 == 1)
+            ans++;
+    }
+
+    return ans;
+}
+

🟢 Veður - Lokaðar heiðar

Solution in Python
1
 2
 3
 4
 5
 6
-7
n = int(input())
-parts = [0, 0, 0]
-for _ in range(n):
-    for i, value in enumerate(input().split()):
-        if value == "J":
-            parts[i] += 1
-print(min(parts))
-

🟢 Velkomin!

Solution in Python
print("VELKOMIN!")
-

🟢 Who wins?

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
board = []
-for _ in range(3):
-    board.append(input().split())
-
-winner = ""
-for i in range(3):
-    if board[i][0] == board[i][1] == board[i][2] and board[i][0] != "_":
-        winner = board[i][0]
-        break
-    elif board[0][i] == board[1][i] == board[2][i] and board[0][i] != "_":
-        winner = board[0][i]
-        break
-
-if board[0][0] == board[1][1] == board[2][2] and board[1][1] != "_":
-    winner = board[1][1]
-elif board[0][2] == board[1][1] == board[2][0] and board[1][1] != "_":
-    winner = board[1][1]
-
-if not winner:
-    winner = "ingen"
-elif winner == "X":
-    winner = "Johan"
-else:
-    winner = "Abdullah"
-
-print(f"{winner} har vunnit")
-

🟢 Video Speedup

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
n, p, k = [int(d) for d in input().split()]
-i = [int(d) for d in input().split()]
-
-start, total = 0, 0
-speed = 1
-for ti in i:
-    total += speed * (ti - start)
-    start = ti
-    speed += p / 100
-total += speed * (k - start)
-print(f"{total:.3f}")
-

🟢 Viðsnúningur

Solution in Python
print(input()[::-1])
-
Solution in Python
 1
+7
v = int(input())
+for _ in range(int(input())):
+    s, k = input().split()
+    if int(k) >= v:
+        print(s, "opin")
+    else:
+        print(s, "lokud")
+

🟢 Veður - Vindhraði

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
k = float(input())
+if k < 0.3:
+    print("logn")
+elif k < 1.6:
+    print("Andvari")
+elif k < 3.4:
+    print("Kul")
+elif k < 5.5:
+    print("Gola")
+elif k < 8.0:
+    print("Stinningsgola")
+elif k < 10.8:
+    print("Kaldi")
+elif k < 13.9:
+    print("Stinningskaldi")
+elif k < 17.2:
+    print("Allhvass vindur")
+elif k < 20.8:
+    print("Hvassvidri")
+elif k < 24.5:
+    print("Stormur")
+elif k < 28.5:
+    print("Rok")
+
+elif k < 32.7:
+    print("Ofsavedur")
+else:
+    print("Farvidri")
+

🟢 Vefþjónatjón

Solution in Python
1
+2
+3
+4
+5
+6
+7
n = int(input())
+parts = [0, 0, 0]
+for _ in range(n):
+    for i, value in enumerate(input().split()):
+        if value == "J":
+            parts[i] += 1
+print(min(parts))
+

🟢 Velkomin!

Solution in Python
print("VELKOMIN!")
+

🟢 Who wins?

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
board = []
+for _ in range(3):
+    board.append(input().split())
+
+winner = ""
+for i in range(3):
+    if board[i][0] == board[i][1] == board[i][2] and board[i][0] != "_":
+        winner = board[i][0]
+        break
+    elif board[0][i] == board[1][i] == board[2][i] and board[0][i] != "_":
+        winner = board[0][i]
+        break
+
+if board[0][0] == board[1][1] == board[2][2] and board[1][1] != "_":
+    winner = board[1][1]
+elif board[0][2] == board[1][1] == board[2][0] and board[1][1] != "_":
+    winner = board[1][1]
+
+if not winner:
+    winner = "ingen"
+elif winner == "X":
+    winner = "Johan"
+else:
+    winner = "Abdullah"
+
+print(f"{winner} har vunnit")
+

🟢 Video Speedup

Solution in Python
 1
  2
  3
  4
@@ -12261,55 +12275,19 @@
  8
  9
 10
-11
-12
-13
-14
for _ in range(int(input())):
-    n = int(input())
-    votes = [int(input()) for _ in range(n)]
-    largest = max(votes)
-    if votes.count(largest) > 1:
-        print("no winner")
-    else:
-        total = sum(votes)
-        winner = votes.index(largest)
-        print(
-            "majority" if votes[winner] > total / 2 else "minority",
-            "winner",
-            winner + 1,
-        )
-

🟢 Warehouse

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
for _ in range(int(input())):
-    n = int(input())
-    warehouse = {}
-    for _ in range(n):
-        s = input().split()
-        name, quantity = s[0], int(s[1])
-        if name not in warehouse:
-            warehouse[name] = quantity
-        else:
-            warehouse[name] += quantity
-    print(len(warehouse))
-    names = sorted(warehouse)
-    for name in sorted(
-        warehouse, key=lambda k: (warehouse[k], -names.index(k)), reverse=True
-    ):
-        print(name, warehouse[name])
-

🟢 Weak Vertices

Solution in Python
n, p, k = [int(d) for d in input().split()]
+i = [int(d) for d in input().split()]
+
+start, total = 0, 0
+speed = 1
+for ti in i:
+    total += speed * (ti - start)
+    start = ti
+    speed += p / 100
+total += speed * (k - start)
+print(f"{total:.3f}")
+

🟢 Viðsnúningur

Solution in Python
print(input()[::-1])
+
Solution in Python
 1
  2
  3
  4
@@ -12322,51 +12300,21 @@
 11
 12
 13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
from itertools import combinations
-
-while True:
-    n = int(input())
-    if n == -1:
-        break
-    graph = {}
-    for i in range(n):
-        graph[str(i)] = [str(v) for v, e in zip(range(n), input().split()) if e == "1"]
-
-    # listing the weak vertices ordered from least to greatest
-    # I guess it means vertex number, not the weakness
-    # keys = sorted(graph, key=lambda x: len(graph[x]), reverse=True)
-
-    keys = graph.keys()
-
-    result = []
-
-    for key in keys:
-        has_triangle = False
-        for a, b in combinations(graph[key], 2):
-            if a in graph[b] and b in graph[a]:
-                has_triangle = True
-                break
-
-        if not has_triangle:
-            result.append(key)
-
-    print(" ".join(result))
-

🟡 WERTYU

Solution in Python
for _ in range(int(input())):
+    n = int(input())
+    votes = [int(input()) for _ in range(n)]
+    largest = max(votes)
+    if votes.count(largest) > 1:
+        print("no winner")
+    else:
+        total = sum(votes)
+        winner = votes.index(largest)
+        print(
+            "majority" if votes[winner] > total / 2 else "minority",
+            "winner",
+            winner + 1,
+        )
+

🟢 Warehouse

Solution in Python
 1
  2
  3
  4
@@ -12381,105 +12329,23 @@
 13
 14
 15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
mapping = {
-    # row 1
-    "1": "`",
-    "2": "1",
-    "3": "2",
-    "4": "3",
-    "5": "4",
-    "6": "5",
-    "7": "6",
-    "8": "7",
-    "9": "8",
-    "0": "9",
-    "-": "0",
-    "=": "-",
-    # row 2
-    "W": "Q",
-    "E": "W",
-    "R": "E",
-    "T": "R",
-    "Y": "T",
-    "U": "Y",
-    "I": "U",
-    "O": "I",
-    "P": "O",
-    "[": "P",
-    "]": "[",
-    "\\": "]",
-    # row 3
-    "S": "A",
-    "D": "S",
-    "F": "D",
-    "G": "F",
-    "H": "G",
-    "J": "H",
-    "K": "J",
-    "L": "K",
-    ";": "L",
-    "'": ";",
-    # row 4
-    "X": "Z",
-    "C": "X",
-    "V": "C",
-    "B": "V",
-    "N": "B",
-    "M": "N",
-    ",": "M",
-    ".": ",",
-    "/": ".",
-    " ": " ",
-}
-
-while True:
-    try:
-        s = input()
-    except:
-        break
-    print("".join([mapping[c] for c in s]))
-

🟢 What does the fox say?

Solution in Python
for _ in range(int(input())):
+    n = int(input())
+    warehouse = {}
+    for _ in range(n):
+        s = input().split()
+        name, quantity = s[0], int(s[1])
+        if name not in warehouse:
+            warehouse[name] = quantity
+        else:
+            warehouse[name] += quantity
+    print(len(warehouse))
+    names = sorted(warehouse)
+    for name in sorted(
+        warehouse, key=lambda k: (warehouse[k], -names.index(k)), reverse=True
+    ):
+        print(name, warehouse[name])
+

🟢 Weak Vertices

Solution in Python
 1
  2
  3
  4
@@ -12488,17 +12354,55 @@
  7
  8
  9
-10
for _ in range(int(input())):
-    words = input().split()
-    others = set()
-    while True:
-        line = input()
-        if line == "what does the fox say?":
-            break
-        w = line.split()[-1]
-        others.add(w)
-    print(" ".join(w for w in words if w not in others))
-

🟢 Which is Greater?

Solutions in 5 languages
 1
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
from itertools import combinations
+
+while True:
+    n = int(input())
+    if n == -1:
+        break
+    graph = {}
+    for i in range(n):
+        graph[str(i)] = [str(v) for v, e in zip(range(n), input().split()) if e == "1"]
+
+    # listing the weak vertices ordered from least to greatest
+    # I guess it means vertex number, not the weakness
+    # keys = sorted(graph, key=lambda x: len(graph[x]), reverse=True)
+
+    keys = graph.keys()
+
+    result = []
+
+    for key in keys:
+        has_triangle = False
+        for a, b in combinations(graph[key], 2):
+            if a in graph[b] and b in graph[a]:
+                has_triangle = True
+                break
+
+        if not has_triangle:
+            result.append(key)
+
+    print(" ".join(result))
+

🟡 WERTYU

Solution in Python
 1
  2
  3
  4
@@ -12509,19 +12413,109 @@
  9
 10
 11
-12
#include <iostream>
-
-using namespace std;
-
-int main()
-{
-    int a, b;
-    cin >> a >> b;
-    int ans = (a > b) ? 1 : 0;
-    cout << ans << endl;
-    return 0;
-}
-
 1
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
mapping = {
+    # row 1
+    "1": "`",
+    "2": "1",
+    "3": "2",
+    "4": "3",
+    "5": "4",
+    "6": "5",
+    "7": "6",
+    "8": "7",
+    "9": "8",
+    "0": "9",
+    "-": "0",
+    "=": "-",
+    # row 2
+    "W": "Q",
+    "E": "W",
+    "R": "E",
+    "T": "R",
+    "Y": "T",
+    "U": "Y",
+    "I": "U",
+    "O": "I",
+    "P": "O",
+    "[": "P",
+    "]": "[",
+    "\\": "]",
+    # row 3
+    "S": "A",
+    "D": "S",
+    "F": "D",
+    "G": "F",
+    "H": "G",
+    "J": "H",
+    "K": "J",
+    "L": "K",
+    ";": "L",
+    "'": ";",
+    # row 4
+    "X": "Z",
+    "C": "X",
+    "V": "C",
+    "B": "V",
+    "N": "B",
+    "M": "N",
+    ",": "M",
+    ".": ",",
+    "/": ".",
+    " ": " ",
+}
+
+while True:
+    try:
+        s = input()
+    except:
+        break
+    print("".join([mapping[c] for c in s]))
+

🟢 What does the fox say?

Solution in Python
 1
  2
  3
  4
@@ -12530,25 +12524,17 @@
  7
  8
  9
-10
-11
-12
-13
-14
package main
-
-import "fmt"
-
-func main() {
-    var a, b int
-    fmt.Scan(&a)
-    fmt.Scan(&b)
-    if a > b {
-        fmt.Println(1)
-    } else {
-        fmt.Println(0)
-    }
-}
-
for _ in range(int(input())):
+    words = input().split()
+    others = set()
+    while True:
+        line = input()
+        if line == "what does the fox say?":
+            break
+        w = line.split()[-1]
+        others.add(w)
+    print(" ".join(w for w in words if w not in others))
+

🟢 Which is Greater?

Solutions in 5 languages
 1
  2
  3
  4
@@ -12559,22 +12545,18 @@
  9
 10
 11
-12
-13
-14
import java.util.Scanner;
+12
#include <iostream>
 
-class WhichisGreater {
-    public static void main(String[] args) {
-        Scanner s = new Scanner(System.in);
-        int a = s.nextInt();
-        int b = s.nextInt();
-        if (a>b){
-            System.out.println(1);
-        }else{
-            System.out.println(0);
-        }
-    }
-}
+using namespace std;
+
+int main()
+{
+    int a, b;
+    cin >> a >> b;
+    int ans = (a > b) ? 1 : 0;
+    cout << ans << endl;
+    return 0;
+}
 
 1
  2
  3
@@ -12588,139 +12570,99 @@
 11
 12
 13
-14
const readline = require("readline");
-const rl = readline.createInterface(process.stdin, process.stdout);
-
-rl.question("", (line) => {
-  [a, b] = line
-    .trim()
-    .split(" ")
-    .map((e) => parseInt(e));
-  if (a > b) {
-    console.log(1);
-  } else {
-    console.log(0);
-  }
-});
-
1
-2
-3
-4
-5
a, b = [int(d) for d in input().split()]
-if a > b:
-    print(1)
-else:
-    print(0)
-

🟡 Wizard of Odds

Solution in Python
1
-2
-3
-4
-5
-6
-7
-8
import math
-
-n, k = [int(d) for d in input().split()]
-ans = math.log(n, 2) <= k
-if ans:
-    print("Your wish is granted!")
-else:
-    print("You will become a flying monkey!")
-

🟡 Words for Numbers

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
mapping = {
-    0: "zero",
-    1: "one",
-    2: "two",
-    3: "three",
-    4: "four",
-    5: "five",
-    6: "six",
-    7: "seven",
-    8: "eight",
-    9: "nine",
-    10: "ten",
-    11: "eleven",
-    12: "twelve",
-}
-
-
-def f(d):
-    if d < 13:
-        return mapping[d]
-
-    ones = d % 10
-    if d < 20:
-        return {3: "thir", 5: "fif", 8: "eigh"}.get(ones, mapping[ones]) + "teen"
-
-    tens = d // 10
-    return (
-        {2: "twen", 3: "thir", 4: "for", 5: "fif", 8: "eigh"}.get(tens, mapping[tens])
-        + "ty"
-        + ("-" + mapping[ones] if ones else "")
-    )
-
-
-def t(w):
-    if w.isdigit():
-        return f(int(w))
-    else:
-        return w
-
-
-while True:
-    try:
-        words = input()
-    except:
-        break
-    print(" ".join([t(w) for w in words.split()]))
-

🟢 Yin and Yang Stones

Solution in Python
1
-2
s = input()
-print(1 if s.count("W") == s.count("B") else 0)
-

🟢 Yoda

Solution in Python
package main
+
+import "fmt"
+
+func main() {
+    var a, b int
+    fmt.Scan(&a)
+    fmt.Scan(&b)
+    if a > b {
+        fmt.Println(1)
+    } else {
+        fmt.Println(0)
+    }
+}
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
import java.util.Scanner;
+
+class WhichisGreater {
+    public static void main(String[] args) {
+        Scanner s = new Scanner(System.in);
+        int a = s.nextInt();
+        int b = s.nextInt();
+        if (a>b){
+            System.out.println(1);
+        }else{
+            System.out.println(0);
+        }
+    }
+}
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
const readline = require("readline");
+const rl = readline.createInterface(process.stdin, process.stdout);
+
+rl.question("", (line) => {
+  [a, b] = line
+    .trim()
+    .split(" ")
+    .map((e) => parseInt(e));
+  if (a > b) {
+    console.log(1);
+  } else {
+    console.log(0);
+  }
+});
+
1
+2
+3
+4
+5
a, b = [int(d) for d in input().split()]
+if a > b:
+    print(1)
+else:
+    print(0)
+

🟡 Wizard of Odds

Solution in Python
1
+2
+3
+4
+5
+6
+7
+8
import math
+
+n, k = [int(d) for d in input().split()]
+ans = math.log(n, 2) <= k
+if ans:
+    print("Your wish is granted!")
+else:
+    print("You will become a flying monkey!")
+

🟡 Words for Numbers

Solution in Python
 1
  2
  3
  4
@@ -12738,49 +12680,83 @@
 16
 17
 18
-19
a, b = input(), input()
-size = max(len(a), len(b))
-
-a = [int(d) for d in a.zfill(size)]
-b = [int(d) for d in b.zfill(size)]
-
-ans_a = [d1 for d1, d2 in zip(a, b) if d1 >= d2]
-ans_b = [d2 for d1, d2 in zip(a, b) if d2 >= d1]
-
-
-def f(ans):
-    if not ans:
-        return "YODA"
-    else:
-        return int("".join([str(d) for d in ans]))
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
mapping = {
+    0: "zero",
+    1: "one",
+    2: "two",
+    3: "three",
+    4: "four",
+    5: "five",
+    6: "six",
+    7: "seven",
+    8: "eight",
+    9: "nine",
+    10: "ten",
+    11: "eleven",
+    12: "twelve",
+}
 
 
-print(f(ans_a))
-print(f(ans_b))
-

🟢 Zamka

Solution in Python
 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
l, d, x = input(), input(), input()
-l, d, x = int(l), int(d), int(x)
-
-for i in range(l, d + 1):
-    if sum([int(d) for d in str(i)]) == x:
-        print(i)
-        break
-
-for i in range(d, l - 1, -1):
-    if sum([int(d) for d in str(i)]) == x:
-        print(i)
-        break
-

🟢 Stand on Zanzibar

Solutions in 2 languages
 1
+def f(d):
+    if d < 13:
+        return mapping[d]
+
+    ones = d % 10
+    if d < 20:
+        return {3: "thir", 5: "fif", 8: "eigh"}.get(ones, mapping[ones]) + "teen"
+
+    tens = d // 10
+    return (
+        {2: "twen", 3: "thir", 4: "for", 5: "fif", 8: "eigh"}.get(tens, mapping[tens])
+        + "ty"
+        + ("-" + mapping[ones] if ones else "")
+    )
+
+
+def t(w):
+    if w.isdigit():
+        return f(int(w))
+    else:
+        return w
+
+
+while True:
+    try:
+        words = input()
+    except:
+        break
+    print(" ".join([t(w) for w in words.split()]))
+

🟢 Yin and Yang Stones

Solution in Python
1
+2
s = input()
+print(1 if s.count("W") == s.count("B") else 0)
+

🟢 Yoda

Solution in Python
 1
  2
  3
  4
@@ -12798,43 +12774,49 @@
 16
 17
 18
-19
-20
-21
-22
import java.util.Scanner;
-
-class StandOnZanzibar {
-    public static void main(String[] args) {
-        Scanner s = new Scanner(System.in);
-        int t = s.nextInt();
-        for (int i = 0; i < t; i++) {
-            int total = 0;
-            int n = 0;
-            int init = 1;
-            while (true) {
-                n = s.nextInt();
-                if (n == 0) {
-                    break;
-                }
-                total += Math.max(n - 2 * init, 0);
-                init = n;
-            }
-            System.out.println(total);
-        }
-    }
-}
-
1
-2
-3
-4
-5
-6
for _ in range(int(input())):
-    numbers = [int(d) for d in input().split()[:-1]]
-    total = 0
-    for i in range(1, len(numbers)):
-        total += max(numbers[i] - 2 * numbers[i - 1], 0)
-    print(total)
-

🟢 Un-bear-able Zoo

Solution in Python
a, b = input(), input()
+size = max(len(a), len(b))
+
+a = [int(d) for d in a.zfill(size)]
+b = [int(d) for d in b.zfill(size)]
+
+ans_a = [d1 for d1, d2 in zip(a, b) if d1 >= d2]
+ans_b = [d2 for d1, d2 in zip(a, b) if d2 >= d1]
+
+
+def f(ans):
+    if not ans:
+        return "YODA"
+    else:
+        return int("".join([str(d) for d in ans]))
+
+
+print(f(ans_a))
+print(f(ans_b))
+

🟢 Zamka

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
l, d, x = input(), input(), input()
+l, d, x = int(l), int(d), int(x)
+
+for i in range(l, d + 1):
+    if sum([int(d) for d in str(i)]) == x:
+        print(i)
+        break
+
+for i in range(d, l - 1, -1):
+    if sum([int(d) for d in str(i)]) == x:
+        print(i)
+        break
+

🟢 Stand on Zanzibar

Solutions in 2 languages
 1
  2
  3
  4
@@ -12847,23 +12829,77 @@
 11
 12
 13
-14
from collections import Counter
+14
+15
+16
+17
+18
+19
+20
+21
+22
import java.util.Scanner;
 
-lc = 0
-while True:
-    n = int(input())
-    if not n:
-        break
-    lc += 1
-    l = Counter()
-    for _ in range(n):
-        animal = input().lower().split()
-        l[animal[-1]] += 1
-    print(f"List {lc}:")
-    print("\n".join([f"{k} | {l[k]}" for k in sorted(l)]))
-

🟢 Zoom

Solution in Python
1
+class StandOnZanzibar {
+    public static void main(String[] args) {
+        Scanner s = new Scanner(System.in);
+        int t = s.nextInt();
+        for (int i = 0; i < t; i++) {
+            int total = 0;
+            int n = 0;
+            int init = 1;
+            while (true) {
+                n = s.nextInt();
+                if (n == 0) {
+                    break;
+                }
+                total += Math.max(n - 2 * init, 0);
+                init = n;
+            }
+            System.out.println(total);
+        }
+    }
+}
+
1
 2
-3
n, k = [int(d) for d in input().split()]
-x = [int(d) for d in input().split()]
-print(" ".join([str(x[i]) for i in range(k - 1, n, k)]))
-

Last update: 2023-11-06
Created: 2023-09-28
\ No newline at end of file +3 +4 +5 +6
for _ in range(int(input())):
+    numbers = [int(d) for d in input().split()[:-1]]
+    total = 0
+    for i in range(1, len(numbers)):
+        total += max(numbers[i] - 2 * numbers[i - 1], 0)
+    print(total)
+

🟢 Un-bear-able Zoo

Solution in Python
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
from collections import Counter
+
+lc = 0
+while True:
+    n = int(input())
+    if not n:
+        break
+    lc += 1
+    l = Counter()
+    for _ in range(n):
+        animal = input().lower().split()
+        l[animal[-1]] += 1
+    print(f"List {lc}:")
+    print("\n".join([f"{k} | {l[k]}" for k in sorted(l)]))
+

🟢 Zoom

Solution in Python
1
+2
+3
n, k = [int(d) for d in input().split()]
+x = [int(d) for d in input().split()]
+print(" ".join([str(x[i]) for i in range(k - 1, n, k)]))
+

Last update: 2023-11-07
Created: 2023-09-28
\ No newline at end of file