{"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const k = +readLine();\n const l = +readLine();\n const m = +readLine();\n const n = +readLine();\n const d = +readLine();\n const arr = Array(d).fill(1);\n let count = 0;\n function isDivisible(num) {\n return num % k === 0 || num % l === 0 || num % m === 0 || num % n === 0;\n }\n for (let i = 0; i < d; i++) {\n if (arr[i] === 1 && isDivisible(i + 1)) {\n arr[i] = -1;\n }\n }\n for (let i = 0; i < d; i++) {\n if (arr[i] === -1) count++;\n }\n console.log(count);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "321a43db61f4541fc0c02d26cc315d31", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const main = async () => {\n const arr = [];\n let len = [];\n \n const rl = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n let m,n;\n let i = 1;\n for await (const line of rl) {\n \n if (!len.length) {\n len = line.split(' ').map(Number);\n n = len[0];\n m = len[1];\n arr[n+1] = [];\n arr[0] = [];\n for (let x = 0; x < m+2; x++) {\n arr[0].push('.');\n arr[n+1].push('.');\n }\n } else {\n if (i < n) {\n arr[i] = ['.'];\n arr[i].push(...line.split(''));\n arr[i].push('.');\n } else {\n arr[i] = ['.'];\n arr[i].push(...line.split(''));\n arr[i].push('.');\n rl.close();\n }\n i++;\n }\n }\n runGame(arr, m, n);\n };\n \n const runGame = (arr, m, n) => {\n let output = 0;\n\n for (let i = 1; i < n + 1; i++) {\n for (let j = 1; j < m + 1; j++) {\n if (arr[i][j] == 'W') {\n if (arr[i-1][j] == 'P' || arr[i+1][j] == 'P' || arr[i][j-1] == 'P' || arr[i][j+1] == 'P' ) {\n output++;\n }\n }\n \n }\n }\n console.log(output);\n };\n \n main();", "lang_cluster": "Javascript", "tags": ["greedy", "implementation"], "code_uid": "c80ae8f672927a34c5aa591e84341d9a", "src_uid": "969b24ed98d916184821b2b2f8fd3aac", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// https://codeforces.com/problemset/problem/112/A\n\nfunction main(stdin) {\n const a = stdin.shift().toLowerCase()\n const b = stdin.shift().toLowerCase()\n process.stdout.write(a.localeCompare(b) + '')\n}\n\n// Handle standard input\nprocess.stdin.resume()\nprocess.stdin.setEncoding('utf-8')\n\nlet inputString = ''\n\nprocess.stdin.on('data', (inputStdin) => inputString += inputStdin)\nprocess.stdin.on('end', () =>\n main(inputString.trim().split('\\n').map(s => s.trim())))\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "369ae92b6ce5bd0a240222ad24b37245", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n const [n, m] = input[0].split(' ').map(x => parseInt(x));\n const nums = input[1].split(' ').map(x => parseInt(x));\n nums.sort((a, b) => a - b);\n\n let answer = 0; let min = Number.MAX_SAFE_INTEGER;\n\n for (let i = 0; i < nums.length; i += 1) {\n if ( i + n - 1 < nums.length && nums[i + n - 1] - nums[i] < min) {\n min = nums[i + n - 1] - nums[i];\n }\n }\n\n console.log(min);\n});", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "bc70c2a489e8e29fd5dd6c952fe8a517", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var stdin = process.openStdin();\n\nstdin.addListener(\"data\", function(d) {\n const arr = d.toString().trim().split(\" \");\n console.log(findg(parseInt(arr[0]), parseInt(arr[1])));\n });\n \n function findg(n, m){\n if(n === m){\n return 0;\n } else if(m === 0){\n return 1;\n }\n m--;\n n--;\n let gcount = 1;\n for(let i = 0; i < m; i++){\n if(n === 0 || n === 1){\n gcount--;\n } else if (n === 2) {\n n-=2;\n } else {\n gcount++;\n n-=2;\n }\n }\n return gcount;\n }", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "e44f34a440ca3907245fc96057f08d88", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const [x, y, z] = d.split(' ').map(Number);\n\n if (y - x >= 0 && z - x >= 0) {\n console.log('YES');\n }\n else {\n console.log('NO');\n }\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "496cb79d05fe017775e42202e3d9ee20", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n input.forEach( (line , i) => {\n line.split(' ').forEach( (x, j) => {\n if (x === '1') {\n console.log(\n Math.abs(2-i) + Math.abs(2-j)\n );\n process.exit();\n }\n });\n });\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "8120c42b1a2b7427239e85c02740cb87", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\nvar rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n});\n\nrl.on('line', function(line) {\n var l = line.split(' ');\n var num = l[0];\n var count = +l[1];\n function ws(num, c) {\n if (c === 0 || num == '0') {\n console.log(num);\n } else {\n var n = (''+num).split('');\n if (n[n.length-1] == 0) {\n n[n.length-1] = ''\n } else {\n n[n.length-1] = (+n[n.length-1]) - 1;\n } \n ws(n.join(''), c-1);\n }\n }\n ws(num, count);\t\n\trl.close();\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0607ded4a0e5a2fb305f96f71eb70c76", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n\tvar one = nextIntArray();\n\tvar A = one[0];\n\tvar B = one[1];\n\tvar C = one[2];\n\tvar output = 0;\n\tif(C - 1 <= B && C - 2 <= A){\n\t\toutput = Math.max(output, 3 * C - 3);\n\t}\n\tif(B - 1 <= A && B + 1 <= C){\n\t\toutput = Math.max(output, 3 * B);\n\t}\n\tif(A + 1 <= B && A + 2 <= C){\n\t\toutput = Math.max(output, 3 * A + 3);\n\t}\n\tmyout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "2a7cb521fd10e3e1493e658972320561", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const find = (tasks, reserved) => {\n let bad = tasks * 2;\n let good = 0;\n let perTask = 5;\n\n const sum = (tasksCount) => \n (2 * perTask + perTask * (tasksCount - 1)) \n / 2 \n * tasksCount \n + reserved;\n\n while (bad - good > 1) {\n let middle = (good + bad) >> 1;\n\n if (sum(middle) <= 240) {\n good = middle;\n } else {\n bad = middle;\n }\n }\n\n console.log(Math.min(good, tasks));\n};\n\nlet _input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n _input += input;\n});\n\nprocess.stdin.on(\"end\", function () {\n find(..._input.split('\\n')[0].split(' ').map(Number));\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation", "binary search"], "code_uid": "0345ea2885e0a3fc551d0485f9b3a8e7", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const [n, m] = readLine()\n .split(\" \")\n .map((n) => parseInt(n));\n let count = 0;\n\n const max = Math.max(n, m);\n for (let a = 0; a <= max; a++) {\n for (let b = 0; b <= max; b++) {\n if (a * a + b === n && a + b * b === m) count++;\n }\n }\n console.log(count);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "2aae38d4d8518e45bbd65d50159a0e1a", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let globalStdin = '';\nconst {EOL} = require('os');\nprocess.stdin.on('data', i => globalStdin += i);\n\nprocess.stdin.on('end', async () => {\n const lines = globalStdin.split(EOL);\n let [n, k] = lines[0].split(' ').map((v) => parseInt(v));\n let dp = Array.from({length: n+1}, () => new Array(n+1).fill(0));\n dp[0][0] = 1;\n let prev = {};\n for (let i = 1; i <= n; i++) {\n dp[i][0] = 1;\n let c = lines[1][i-1];\n for (let j = 1; j <= n; j++) {\n dp[i][j] = dp[i-1][j-1] + dp[i-1][j];\n if (prev[c]) dp[i][j] -= dp[prev[c] - 1][j - 1];\n }\n prev[c] = i;\n }\n let sum = 0;\n for (let i = n; i >= 0; i--) {\n if (dp[n][i] > k) {\n sum += (n - i) * k;\n k = 0;\n break;\n }\n k -= dp[n][i];\n sum += (n - i) * dp[n][i];\n } \n console.log(k ? -1 : sum);\n});", "lang_cluster": "Javascript", "tags": ["strings", "dp"], "code_uid": "bc14eb9614803bfc616320177084dee0", "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n\n\nfunction main() {\n const l = parseInt(readLine().split(' '));\n\nlet arr = [];\n let matrix = [];\n for (let i = 0; i < l; ++i) {\n matrix[i] = [];\n for (let j = 0; j < l; ++j) {\n if (i == 0 && j == 0) {\n matrix[i][j] = 2;\n } else if (j == 0) {\n matrix[i][j] = matrix[i - 1][j] + 1;\n } else if (i == 0) {\n matrix[i][j] = matrix[i][j - 1] + 1;\n } else {\n matrix[i][j] = matrix[i - 1][j] + matrix[i][j - 1];\n }\n\n matrix[0][j] = 1;\n matrix[i][0] = 1;\n }\n }\n\n for (let g = 0; g < l; ++g) {\n for (k = 0; k < l; ++k) {\n if (k == g) {\n arr.push(matrix[g][k]);\n }\n }\n }\n console.log(arr.pop());\n }\n \n ", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "adb3b5d2c415eff05a9615d2236109a6", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let s = readLine();\n let totalOfLowerCase = s.split('').filter((value) => {\n return value.charCodeAt(0) >= 97\n }).length;\n let totalOfUpperCase = s.split('').filter((value) => {\n return value.charCodeAt(0) < 97\n }).length;\n if (totalOfUpperCase > totalOfLowerCase) {\n console.log(s.toUpperCase());\n } else {\n console.log(s.toLowerCase());\n }\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "ab343b56ec455f5ac47e9b192d6c9fbf", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n');\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr('time : ' + end + 'ms');\n myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var N = nextInt();\n while(true){\n \tvar tmp = makeClone(N);\n \tvar sum = 0;\n \twhile(tmp > 0){\n \t\tsum += tmp % 10;\n \t\ttmp = Math.floor(tmp / 10);\n \t}\n \tif(sum % 4 == 0){\n \t\tmyout(N);\n \t\treturn;\n \t}\n \tN++;\n }\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "102dcce8a00745144b51a233991e078f", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "async function solve() {\n let s = await line()\n const vk = s.split('VK').length - 1\n s = s.split('VK').join('X')\n const vv = s.split('VV').length > 1\n const kk = s.split('KK').length > 1\n\n print(vk + (vv || kk ? 1 : 0))\n}\n\n// read the input\nconst readline = require('readline')\nconst _lines = []\nlet _lineIndex = 0\nlet _ended = false\nconst _rl = readline.createInterface(process.stdin)\n_rl.on('line', line => _lines.push(line))\n_rl.on('end', () => (ended = true))\nconst wait = ms => new Promise(resolve => setTimeout(resolve, ms))\nconst line = async () => {\n while (!_ended && _lines.length <= _lineIndex) await wait(10)\n const result = _lines[_lineIndex].trim()\n _lines[_lineIndex] = null\n _lineIndex++\n return result\n}\nconst words = async () => (await line()).split(' ')\nconst chars = async () => (await line()).split('')\nconst int = async () => parseInt(await line())\nconst ints = async () => (await words()).map(x => parseInt(x))\nconst big = async () => BigInt(await line())\nconst bigs = async () => (await words()).map(x => BigInt(x))\n\nconst print = console.log\n\nsolve()\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "82426fe09a17a4a1206d3e5e706745ba", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data',c=>console.log(Math.pow(2,c.toString())%24>8?\"YES\":\"NO\"))", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "c1042d08afc9644da44753e1082a0c3d", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let readline = require('readline');\nlet intInput = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n});\nlet num, i = 2;\n\nintInput.on('line', (line) => {\n\tnum = Number(line)\n});\n\nintInput.on('close', () => {\n\tlet staticNum = num;\n\tlet c = 0;\n\tlet result = 1;\n\tlet dict = {};\n\twhile (i <= staticNum){\n\t\tif (num % i == 0){\n\t\t\tnum = num / i;\n\t\t\tc++;\n\t\t} else {\n\t\t\tdict[i] = c;\n\t\t\tc = 0;\n\t\t\ti++\n\t\t}\n\t}\n\tfor (let key in dict){\n\t\tlet c = dict[key]\n\t\tresult = result * (c + 1)\n\t}\n\tconsole.log(result - 1);\n})", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "6ffdb87fd878489e10f146092bb7f65c", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n });\n rl.question(\"\",function (x) {\n \n \n\n\n if (x%2 === 0 && x!=2 ) {\n console.log('YES');\n \n }else {\n console.log('NO')\n }\n \n })", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "c17503247c232489f2f28b5dac645d07", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = ''\nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os')\n const lines = i.split(EOL) /*your input text, split by lines*/\n\n const input = lines[1];\n const vector = input.split(' ').map(\n n => parseInt(n)\n );\n\n const insertionSort = (vector) => {\n let res = 0;\n\n for (let i = 0; i < vector.length; i++) {\n let minIndex = i;\n\n for (let j = i + 1; j < vector.length; j++) {\n if (vector[j] < vector[minIndex]) {\n minIndex = j;\n }\n }\n\n let temp = vector[i];\n vector[i] = vector[minIndex];\n vector[minIndex] = temp;\n\n if (i !== 0 && i % 2 === 1) {\n res += vector[i] - vector[i -1]\n }\n }\n\n console.log(res);\n };\n\n insertionSort(vector);\n});\n\n//////\n\n\n", "lang_cluster": "Javascript", "tags": ["sortings"], "code_uid": "52d268389e4b41924b57f12d87a4bf10", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction print(s) {\n process.stdout.write(`${s}`);\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n // input\n let [a, b] = readline().split(' ').map(x => parseInt(x));\n\n // solve\n let i = 0;\n\n while(a <= b) {\n a *= 3;\n b *= 2;\n i++;\n }\n\n // output\n print(i);\n}\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "60ab2dadd46ba013aefaa98cf953a07d", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction readAsInt(){\n return parseInt(readline());\n}\n\nfunction readAsIntList(){\n return readline().split(' ').filter(i => i).map(i => parseInt(i));\n}\n\n\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n let s = readline();\n let n = s.replace(/[^47]+/gi,'').length;\n console.log([4,7].includes(n) ? 'YES' : 'NO');\n}\n \n\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0bba1f41f5f0264e1a389fab8ed2069a", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\nreadline.question(\"\", nk => {\n readline.question(\"\", c => {\n nk = nk.split(\" \");\n c = c.split(\" \");\n console.log(c.filter(p => {return p >= parseInt(c[nk[1] - 1]) && p >= 1 ? p : void 0;}).length)\n readline.close();\n })\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "63126569c3a096f9fb763039175bcc12", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', line => {\n var result = line.toLowerCase().replace(/[aoyeui]/g,'').split('').join('.');\n console.log(result ? '.' + result : result);\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "c2ea4fec3f6d27556329babade541174", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet inputString = \"\";\nlet currentLine = 0;\n\nprocess.stdin.on(\"data\", inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on(\"end\", function() {\n inputString = inputString\n .replace(/\\s*$/, \"\")\n .split(\"\\n\")\n .map(str => str.replace(/\\s*$/, \"\"));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n const firstLine = readLine();\n const weight = parseInt(firstLine, 10);\n // const a = readLine().split(' ').map(aTemp => parseInt(aTemp, 10));\n\n console.log(watermelon(weight));\n}\n\nfunction watermelon(weight) {\n return weight === 2 || (weight & 1) === 1 ? \"NO\" : \"YES\";\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "bf6621cab6392753ad53fd52578f4bc5", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let s1 = readline().toLowerCase();\n let length = [];\n for (let i =0,c=s1.length ; i < c ; i++ ){\n if (length.indexOf(s1[i]) === -1 ) length.push(s1[i])\n }\n\n console.log((length.length % 2 === 0 ) ? \"CHAT WITH HER!\": \"IGNORE HIM!\")\n}\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "05ebfaf90b28d5f244821b02c1af405a", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let k = parseInt(readLine());\n let l = parseInt(readLine());\n let m = parseInt(readLine());\n let n = parseInt(readLine());\n let d = parseInt(readLine());\n let cont = d;\n if (k == 1 || l == 1 || m == 1 || n == 1) {\n console.log(cont);\n } else {\n for (var i = 1; i <= d; i++) {\n if ((i % k != 0) && (i % l != 0) && (i % m != 0) && (i % n != 0)) {\n cont--;\n }\n }\n console.log(cont);\n }\n}", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "cc4a357b70f928920da6ee42f145f448", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const {EOL} = require('os')\n\nlet ipt = ''\nprocess.stdin.on('data', s => ipt += s)\nprocess.stdin.on('end', () => {\n let [h, m] = ipt.split(EOL).slice(0, -1)[0].split(':').map(v => parseInt(v))\n if (h >= 12) h -= 12\n\n let y = m * 6\n let x = h * 30 + y / 12\n\n console.log(x, y)\n})", "lang_cluster": "Javascript", "tags": ["math", "geometry"], "code_uid": "de728f985ebd3c095dc72656faa1abb3", "src_uid": "175dc0bdb5c9513feb49be6644d0d150", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n \nreadLine.on('close', () => {\n let [n, k] = input[0].split(' ').map(x => +x);\n for (let i = 0; i < k; i++) {\n n = n % 10 === 0 ? Math.floor(n / 10) : n - 1;\n }\n console.log(n);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "4202fffadc4c45666851dc74d305cefa", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n let [n, k] = d.split(' ').map(Number);\n\n let mid = Math.floor(n / 2);\n let x = mid % (k + 1);\n let a = (mid - x) / (k + 1);\n let b = a * k;\n let c = n - a - b;\n\n console.log(`${a} ${b} ${c}`);\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "b42094de2f24bf837c880beaae678178", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//118B\nconst readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nrl.question('', (answer) => {\n rl.close()\n let word = answer.toLowerCase()\n let noVowel = word.replace(/a|e|i|o|u|y/gi, \"\")\n let wordArray = noVowel.split(\"\")\n let finishedArray = []\n wordArray.forEach(function(word) {\n finishedArray.push(`.${word}`)\n })\n let finalword = finishedArray.join(\"\")\n console.log(finalword)\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "0d579f9084b93e7f396a90f8588cf05a", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\nconst translation = () => {\n let ar = [];\n for (const x of input[0]) {\n ar.push(x);\n }\n let newString = '';\n for (let i = ar.length-1; i >= 0; i--) {\n newString += ar[i];\n }\n console.log(newString === input[1] ? 'YES' : 'NO');\n};\nreadLine.on('close', translation);\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "2ee7d52b6071743a8d69a90010d3f258", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n//rl.question();\nrl.question('', (input) => {\n var ans = main(input.split(' '));\n console.log(ans); \n process.exit();\n});\nfunction main(input){\n var m = Number(input[0]);\n var n = Number(input[1]);\n var a = Number(input[2]);\n var ans;\n ans = Math.ceil(m/a)*Math.ceil(n/a);\n return ans;\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "87a8b40aaa60df32477585617dba175a", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').join(' ').split(' ').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction read() {\n return inputString[currentLine++];\n}\n\n\nfunction main() {\n const n = Number(read())\n if (n % 2 === 0 && n > 2) {\n process.stdout.write(\"YES\")\n } else {\n process.stdout.write(\"NO\")\n }\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "76db3f849bf2e648b10b2fa305092d0b", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nlet _inputLines;\nlet _lineNumber = 0;\nlet inputReader = _inputReader ();\n\nfunction _main() {\n\t\n\t_inputLines = _inputData.trim().split('\\n').map((string) => {\n\t\treturn string.trim();\n\t});;\n\tlet [n, k] = inputReader.readNumberArray();\n\tlet arr = inputReader.readNumberArray();\n\tlet total = 0,\n\t\textra = 0,\n\t\tflag = false,\n\t\tdays = 0;\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tif (arr[i] >= 8) {\n\t\t\ttotal += 8;\n\t\t\textra += arr[i] - 8;\n\t\t\tdays++;\n\t\t} else {\n\t\t\ttotal += arr[i];\n\t\t\tdays++;\n\t\t\tif (extra + arr[i] <= 8) {\n\t\t\t\ttotal += extra;\n\t\t\t\textra = 0;\n\t\t\t} else {\n\t\t\t\tlet temp = 8 - arr[i];\n\t\t\t\textra -= temp;\n\t\t\t\ttotal += temp;\n\t\t\t}\n\t\t}\n\t\tif (total >= k) {\n\t\t\tflag = true;\n\t\t\tbreak;\n\t\t}\n\t\t//console.log(extra,total);\n\t}\n\tif (flag) console.log(days);\n\telse console.log(-1);\n\n}\n\nvar _inputData = '';\nfunction cacheInput(data) {\n\t_inputData += data;\n}\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf8');\nprocess.stdin.on('data', cacheInput).on('end', _main);\n\nfunction _inputReader () {\n\tfunction readNumberArray(){\n\t\treturn _inputLines[_lineNumber++].split(' ').map(val => Number(val));\n\t}\n\t\t\n\t\n\treturn {\n\t\treadNumberArray,\n\t}\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "9f424e7a09aabae271b02b6c43c55c3e", "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nconst solver = input => {\n let result = input[0];\n for (let i = 0; i < input[1]; i++) {\n result = (result % 10 != 0) ? result - 1 : result / 10;\n }\n console.log(result);\n};\n\nrl.on(\"line\", l => {\n rl.close();\n solver(l.split(' ').map(x => parseInt(x)));\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "61c0c8b745b2f4b5c9f54cb2cd3c1592", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n\tvar one = nextIntArray();\n\tvar k = one[0];\n\tvar n = one[1];\n\tvar s = one[2];\n\tvar p = one[3];\n\tvar req = k * Math.ceil(n / s);\n\tmyout(Math.ceil(req / p));\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "bf48764b6ef80a27db6859f472d3fecb", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet l = 0;\nrl.on('line', (input) => {\n if (l === 0) { l++ }\n else {\n rl.close();\n let res = \"\"\n for (let i = 0, c = 0; i < input.length; c++ , i += c) {\n res += input.charAt(i);\n }\n console.log(res)\n return 0;\n }\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "2efcb27c737afc97464a90669eac0204", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const funkyNumbers = n => {\n let funkyNumber = 'NO';\n\n let maxTriangle = maxTrianglePossible(n);\n\n for(let i = maxTriangle; i > 0; i--) {\n let firstTriangle = triangleNumbers(i);\n let rem = n - firstTriangle;\n\n if(rem === 0) continue;\n\n let secFactor = maxTrianglePossible(rem);\n let secTriangle = triangleNumbers(secFactor);\n\n let triangles = firstTriangle + secTriangle;\n\n if(triangles == n) {\n funkyNumber = 'YES';\n break;\n } \n \n }\n \n return funkyNumber; \n}\n\nconst maxTrianglePossible = n => Math.floor( Math.sqrt(n*2) );\n\nconst triangleNumbers = x => ( x * (x + 1) ) / 2;\n\n//stdin → stdout\nconst readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n \nreadline.on('line', n => {\n readline.close();\n \n let res = funkyNumbers(n);\n console.log(res);\n});", "lang_cluster": "Javascript", "tags": ["brute force", "implementation", "binary search"], "code_uid": "2ac0fba697ead5ed375047ee0a8201b8", "src_uid": "245ec0831cd817714a4e5c531bffd099", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nlet z = '';\nprocess.stdin.on('data', c => z += c);\nprocess.stdin.on('end', () => {\n const {\n EOL\n } = require('os');\n let input = z.split(EOL)[0];\n input = input.split(' ').map(item => parseInt(item));\n while (true) {\n if (input[1] === input[3]) {\n console.log('YES');\n return 0;\n }\n if (input[1] === input[2] || input[3] === input[4]) {\n break;\n }\n\n input[3] = (input[3] === 1) ? input[0] : (input[3] - 1);\n input[1] = (input[1] === input[0]) ? 1 : (input[1] + 1);\n }\n if (input[1] === input[3])\n console.log('YES');\n else\n console.log('NO');\n\n\n\n\n});", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "9db4269f44e82f1f6ba44a9f0f2e22da", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const str = readLine();\n\n for (let i = 0; i < str.length; i++) {\n const [prevNum, currentNum, nextNum] = [+str[i - 1], +str[i], +str[i + 1]];\n\n if (currentNum !== 1 && currentNum !== 4) {\n console.log(\"NO\");\n return;\n }\n if (currentNum === 4) {\n if (prevNum !== 1 && prevNum !== 4) {\n console.log(\"NO\");\n return;\n }\n if (prevNum === 4 && nextNum !== 1 && i < str.length - 1) {\n console.log(\"NO\");\n return;\n }\n }\n }\n console.log(\"YES\");\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "greedy"], "code_uid": "c013dee25f24bed9322f7a5e30aabfa0", "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let input1 = readline().split(' ');\n let students = input1[0];\n\n let puzzles = readline().split(' ');\n puzzles = puzzles.map(ele => parseInt(ele));\n\n leastDifference(students, puzzles);\n}\n\nfunction leastDifference(students, puzzles){\n puzzles = puzzles.sort((a, b) => a - b);\n\n let minDif = Infinity;\n\n let startIdx = 0;\n let endIdx = students - 1;\n\n while(endIdx < puzzles.length){\n let curDif = puzzles[endIdx] - puzzles[startIdx];\n minDif = Math.min(minDif, curDif); \n startIdx ++;\n endIdx++;\n }\n console.log(minDif);\n return minDif;\n}\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "425f283f9fb5622131f27f03d74d0416", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const { stderr } = require(\"process\");\n\nconst readline = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nreadline.on(\"line\", (line) => {\n const str = line.split(\" \")[0];\n readline.close();\n main(str);\n return;\n});\n\nconst main = (str) => {\n const string = str.toLowerCase();\n const vowelSet = new Set([\"a\", \"o\", \"y\", \"e\", \"u\", \"i\"]);\n let result = \"\";\n const stringArr = [...string];\n\n stringArr.forEach((val) => {\n if (!vowelSet.has(val)) {\n result += \".\";\n result += val;\n }\n });\n console.log(result);\n return;\n};\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "e4f2ced386d5eefb918b8d8c09ef5334", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// https://codeforces.com/problemset/problem/977/B\n// Big O:\n// n: string length\n// Time complexity: O(n)\n// Space complexity:\n\nconst readline = require(\"readline\");\n\n// Read input\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet stringLength;\nrl.on('line', (input) => {\n if (stringLength) {\n console.log(findMostCommonGram(input, stringLength));\n rl.close();\n } else {\n stringLength = input;\n }\n});\n\n// Problem\nfunction findMostCommonGram(string, stringLength) {\n let mostCommonGram = \"\";\n const gramOccurrences = {};\n\n for (let i = 0; i < stringLength - 1; i++) {\n const twogram = string[i] + string[i + 1];\n const occurrences = gramOccurrences[twogram] ? gramOccurrences[twogram] + 1 : 1;\n const mostCommonOccurrences = gramOccurrences[mostCommonGram] ? gramOccurrences[mostCommonGram] : 0;\n if (occurrences > mostCommonOccurrences) {\n mostCommonGram = twogram;\n }\n\n gramOccurrences[twogram] = occurrences;\n }\n\n return mostCommonGram;\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "144f897f4907073b513bd9b9dc78c777", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n const home = [], setOut = {};\n let answer = 0;\n input.forEach((x, i) => {\n if (i === 0) return;\n let nums = x.split(' ').map(x => parseInt(x));\n home.push(nums[0]); (setOut[nums[1]] === undefined) ? setOut[nums[1]] = 1 : setOut[nums[1]] += 1;\n });\n\n home.forEach(i => {\n if (setOut[i] !== undefined) answer += setOut[i];\n });\n\n console.log(answer);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "b74df8a18a86f7f8d8f5866b00e2fa90", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let fs = require(\"fs\");\n\nlet txt = fs.readFileSync(0, \"utf-8\").split(\"\\r\\n\").filter(data => {\n return data.length > 0\n});\n// txt.shift();\nfor (let index = 0; index < txt.length; index++) {\n\n doit(txt[index] * 1);\n\n}\n\nfunction doit(num) {\n let lucky = [4, 7, 47, 74, 444, 447, 744, 774, 777]\n let tab = String(num).split(\"\").filter(data => {\n if (data != 4 && data != 7 && data != \" \") {\n return data;\n }\n }).length;\n if (tab == 0) {\n console.log(\"YES\");\n } else {\n for (let i = 0; i < lucky.length; i++) {\n if(num%lucky[i]==0){\n console.log(\"YES\");\n return;\n } \n }\n console.log(\"NO\");\n }\n}", "lang_cluster": "Javascript", "tags": ["brute force", "number theory"], "code_uid": "25d6083fa84079c50ed876841ea1ac5e", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var N = nextInt();\n var sum = 0;\n for(var i = 1; i < 100000; i++){\n sum += i;\n if(N >= sum){\n N -= sum;\n }else{\n myout(i - 1);\n return;\n }\n }\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "065fc09d121aa49935048b4ac2c67969", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\nlet input = [];\nreadline.on('line', line => {\n input.push(line);\n});\nprocess.stdin.on('end', () => {\n const inp = input[0].split(' ');\n const max = Math.max(inp[0], inp[1]);\n const map = {\n 1: \"1/1\",\n 2: \"5/6\",\n 3: \"2/3\",\n 4: \"1/2\",\n 5: \"1/3\",\n 6: \"1/6\",\n };\n console.log(map[max]);\n});", "lang_cluster": "Javascript", "tags": ["math", "probabilities"], "code_uid": "80d84f834716a14b0d2bc8dde19c6fb2", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const solve = (w) => {\n if (w == 2) return false;\n if (w % 2 != 0) return false;\n return true;\n};\n\nconst main = () => {\n const readline = require('readline');\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n });\n\n let input;\n rl.on('line', (line) => {\n input = Number(line);\n });\n\n rl.on('close', () => {\n let res = solve(input) ? 'YES' : 'NO';\n console.log(res);\n });\n\n};\n\nmain()", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "baa5a4e559d1e643d47f56c2ce6e5e4f", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n const arr = d.split(' ').map(Number).sort((a, b) => a - b);\n let ans = 0;\n\n for (let i = 0; i < arr.length; i++) {\n if (i % 2) {\n ans += arr[i];\n }\n else {\n ans -= arr[i];\n }\n }\n\n console.log(Math.abs(ans));\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["sortings"], "code_uid": "c4a37cda653f0ce5e36bd5872537f93f", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nconst arr = [];\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n arr.push(d.split(' ').map(Number));\n\n c++;\n});\n\nrl.on('close', () => {\n let ans = 0;\n let n = arr.length;\n\n for (let i = 0; i < arr.length; i++) {\n for (let j = 0; j < arr.length; j++) {\n if (i == j || i == Math.floor(n / 2) || j == Math.floor(n / 2) || i + j == n-1) {\n ans += arr[i][j];\n }\n }\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "1b4ce3feed61ac21849b44ed6afdb906", "src_uid": "5ebfad36e56d30c58945c5800139b880", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({input: process.stdin})\nlet lines = [];\nreadline.on(\"line\", line => {\n lines.push(line);\n}).on(\"close\", () => {\n \n let stones = lines[1];\n let removed = 0;\n\n for (let i = 0; i < stones.length; i++) {\n if (stones[i] === stones[i+1]) {\n removed++;\n }\n }\n \n console.log(removed);\n \n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "9d384fa3b373bd6e7d72292332641163", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (str) => {\n if (c === 0) {\n c++;\n return;\n }\n\n let arr = [...str];\n const len = arr.length;\n for (let i = 2; i <= len; i++) {\n if (len % i === 0) {\n const firstPart = arr.slice(0, i);\n const secondPart = arr.slice(i);\n\n firstPart.reverse();\n\n arr = [...firstPart, ...secondPart];\n }\n }\n\n console.log(arr.join(''));\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "47c1039bd9e24b025c83f8c8d186f644", "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let fs = require(\"fs\");\n\nlet txt = fs.readFileSync(0, \"utf-8\").split(\"\\r\\n\").filter(data => {\n return data.length > 0\n});\n// txt.shift();\nfor (let index = 0; index < txt.length; index++) {\n doit(txt[index])\n}\n\nfunction doit(str) {\n let mot = [\"h\", \"e\", \"l\", \"l\", \"o\"]\n let tab = str.split(\"\").filter(data => {\n return data.length > 0\n })\n let pnt=-1;\n for (let i = 0; i < mot.length; i++) {\n let t=tab.map((data1,index)=>{if(mot[i]==data1)return index;}).filter(data=>{return data!=undefined});\n if(t.length==0){\n console.log(\"NO\");\n return;\n }\n let test=false;\n for (let i1 = 0; i1 < t.length; i1++) {\n if(t[i1]>pnt){\n pnt=t[i1]\n test=true\n break;\n }\n }\n if(!test){\n console.log(\"NO\");\n return;\n }\n }\n console.log(\"YES\");\n \n}", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "5ee4cda6d4e8ceb8141b1914b315a4d7", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction print(s) {\n process.stdout.write(`${s}`);\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n // input\n const n = +readline();\n const p = readline();\n const m = new Set();\n for (let i = 0; i < n; i++) {\n m.add(p.charAt(i).toLocaleLowerCase());\n }\n print(m.size === 26 ? 'YES' : 'NO');\n}\n\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "328854e6cbc2cde05512e44242fe8141", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline=require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n });\n \nreadline.question('', str=>{\n let arr=[];\n for(let i=0;i str += input);\r\nprocess.stdin.on('end', async () => {\r\n inputs = str.split('\\n').values();\r\n const output = await main(read);\r\n process.stdout.write(output);\r\n});\r\n", "lang_cluster": "Javascript", "tags": ["brute force", "greedy", "implementation", "math"], "code_uid": "a39d00439aace36870ffeab2271aad91", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let data = '';\nprocess.stdin.on('data',c => data += c);\nconst solution = () => {\n\tlet [n, k, m] = data.split(' ').map(v => parseInt(v, 10));\n\tlet r = Math.trunc(((m-1)%(2*k))/2) + 1;\n\tlet d = Math.trunc((m-1)/(2 * k)) + 1;\n\tlet v = (m%2 === 0)?\"R\":\"L\";\n\tconsole.log(`${d} ${r} ${v}`);\n};\n\nprocess.stdin.on('end', solution);", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "9ed6853423a7141cffc12b8304d5aeb2", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n \nlet stdinInput = '';\n \nprocess.stdin.on('data', input => {\n stdinInput += input;\n})\n \nprocess.stdin.on('end', () => {\n main(stdinInput);\n})\n \nfunction main(data) {\n data = data.split(/\\r?\\n/);\n data = data[0].split(\" \");\n solve(data)\n}\n\nfunction solve(numbers) {\n let num = numbers[0] * 1\n let sub = numbers[1]\n\n let i;\n for(i = 0; i < sub; i++) {\n if (num % 10 === 0) {\n num = Math.floor(num / 10)\n } else {\n num = num - 1\n }\n }\n console.log(num)\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "cbc230815746eb2531023ca35e9378b7", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet l = 0;\nrl.on('line', (input) => {\n if (l === 0) { l++ }\n else {\n rl.close();\n let arr = input.split(\" \").map(x => parseInt(x))\n let cnt = 0\n let max = 0\n for (let i = 1; i < arr.length; i++) {\n if (arr[i]===arr[i-1]+1) {\n cnt++\n if(i===1 && arr[i-1]===1){\n cnt++\n }\n if(i+1max){\n max=cnt\n }\n } else {\n cnt=0\n }\n }\n console.log(max)\n return 0;\n }\n})\n", "lang_cluster": "Javascript", "tags": ["greedy", "implementation"], "code_uid": "d2a5e9eb461b09a6a220c8f2298bb582", "src_uid": "858b5e75e21c4cba6d08f3f66be0c198", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar sumInBase = function (num, div) {\n\n let ans = 0;\n while (num > 0) {\n ans += num % div;\n num = parseInt(num / div);\n }\n return ans;\n}\n\nvar GCD = function (num1, num2) {\n if (num2 == 0) return num1;\n return GCD(num2, num1 % num2);\n}\n\nvar sum = 0;\nrl.on('line', (input) => {\n let num = parseInt(input);\n for (let i = 2; i < num; i++)\n sum += sumInBase(num, i);\n temp = GCD(sum, num - 2);\n console.log(\"%d/%d\",sum/temp,(num-2)/temp);\n\n rl.close();\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "9e4d489280c2cdde38fccbb08d32e18e", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nfunction GCD(a,b)\n{\n if (b===0) return a; \n\n return GCD (b, a%b);\n}\n\nrl.on(\"line\", input => {\n\n var array = input.split(' ');\n var y = parseInt(array[0]);\n var w = parseInt(array[1]);\n var maxim= Math.max(y,w);\n var n = 6-maxim+1;\n var temp = GCD(6,n);\n console.log(n/temp+\"/\"+6/temp);\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["math", "probabilities"], "code_uid": "213f8eba6591d269f869b4e7bb5fba77", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\r\nprocess.stdin.setEncoding(\"utf-8\");\r\n\r\nlet inputString = '';\r\n\r\nprocess.stdin.on(\"data\", (inputStdin) => {\r\n inputString += inputStdin;\r\n});\r\n\r\nprocess.stdin.on(\"end\", (_) => {\r\n const lines = inputString.trim().split(\"\\n\").map(string => string.trim()).filter(Boolean);\r\n\r\n main(lines);\r\n});\r\n\r\nfunction main(lines) {\r\n let index = 0;\r\n let T = Number(lines[index++]);\r\n let N;\r\n \r\n while (T--) {\r\n N = Number(lines[index++]);\r\n solve(N);\r\n }\r\n}\r\n \r\nfunction solve(N) {\r\n const seen = new Set();\r\n let result = 1;\r\n let sqrtN = Math.floor(Math.sqrt(N));\r\n let a, b;\r\n \r\n for (let n = 2; n <= sqrtN; ++n) {\r\n a = n ** 2;\r\n b = n ** 3;\r\n \r\n if (a <= N && !seen.has(a)) {\r\n result++;\r\n seen.add(a);\r\n }\r\n \r\n if (b <= N && !seen.has(b)) {\r\n result++;\r\n seen.add(b);\r\n }\r\n }\r\n \r\n console.log(result);\r\n}", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "520bc10430f77831557b75d5ca9c87de", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nvar dp = {};\n\nfunction fibonacci(n) {\n\tif (n === 0) return 0;\n\tif (n === 1) return 1;\n\n\tif (dp[n] !== undefined) return dp[n];\n\tlet result = fibonacci(n - 1) + fibonacci(n - 2);\n\treturn (dp[n] = result);\n}\n\nfunction main() {\n\tlet rem = readLine()\n\t\t.replace(/WUB/g, ' ')\n\t\t.replace(/\\s{2,}/g, ' ')\n\t\t.trim();\n\tconsole.log(rem);\n}\n", "lang_cluster": "Javascript", "tags": ["strings"], "code_uid": "5ca80173b458897cd33ef367c361eb9a", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nfunction f(n, k) {\n const np = n % 10\n return k <= np ? n - k : f(Math.floor(n / 10), k - np - 1)\n}\n\nasync function algo() {\n const [n, k] = await ints()\n console.log(f(n, k));\n}\n\n\n// read the input\nconst _lines = []\nlet _lineIndex = 0\nlet _ended = false\nconst _rl = readline.createInterface(process.stdin)\n_rl.on('line', line => _lines.push(line))\n_rl.on('end', () => (ended = true))\nconst wait = ms => new Promise(resolve => setTimeout(resolve, ms))\nconst line = async () => {\n while (!_ended && _lines.length <= _lineIndex) await wait(10)\n const result = _lines[_lineIndex].trim()\n _lines[_lineIndex] = null\n _lineIndex++\n return result\n}\nconst words = async () => (await line()).split(' ')\nconst chars = async () => (await line()).split('')\nconst int = async () => parseInt(await line())\nconst ints = async () => (await words()).map(x => parseInt(x))\nconst big = async () => BigInt(await line())\nconst bigs = async () => (await words()).map(x => BigInt(x))\n\nalgo()", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "1ac51161468e68e98d7aa862bf46e55b", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "console.log(25);", "lang_cluster": "Javascript", "tags": ["number theory"], "code_uid": "3b8d51b9b5ea8a75ad21249009bda34c", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n\nfunction splbsi(line) {\n return line.split(\" \").map((x) => parseInt(x));\n}\n\nconst readLine = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nreadLine.on(\"line\", (line) => {\n input.push(line);\n});\n\nreadLine.on(\"close\", () => {\n const n = parseInt(input[0]);\n const nums = [4, 7, 47, 44, 77, 74, 444, 447, 477, 474, 744, 747, 777];\n\n for (const num of nums) {\n if (n % num === 0) {\n console.log(\"YES\");\n return;\n }\n }\n\n console.log(\"NO\");\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "number theory"], "code_uid": "1a506ae829c5c4f3c3f76395bb81b9a4", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n const arr = d.split(' ').map(Number);\n const sum = arr.reduce((a, b) => a + b, 0);\n let max = Math.max(...arr);\n let r = 0;\n\n for (let i = 0; i < arr.length; i++) {\n r += max - arr[i];\n }\n\n while (r <= sum) {\n r += arr.length;\n max++;\n }\n\n console.log(max);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "024bf2c149793d7eb554ee55f6423c0e", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume()\nprocess.stdin.setEncoding('utf-8')\n\nlet standardInputString = ''\nlet currentLine = 0\n\nfunction readLine() {\n return standardInputString[currentLine++]\n}\n\nprocess.stdin.on('data', rawData => {\n standardInputString += rawData\n})\n\nprocess.stdin.on('end', _ => {\n standardInputString = standardInputString.trim().split('\\n').map(line => {\n return line.trim()\n })\n\n main()\n})\nfunction main() {\n\n let line = []\n for (let k = 0; k < 5; k++) {\n line[k] = readLine().split(' ').map(Number)\n }\n let res = 0\n for (let i = 0; i < 5; i++) {\n for (let j = 0; j < 5; j++) {\n if (i === 0 && j === 0) {\n if (line[i][j] === 1) {\n res = 4\n } else {\n res = 0\n }\n } else if (line[i][j] === 1) {\n res = Math.abs(i - 2) + Math.abs(j - 2)\n }\n }\n }\n\n console.log(res)\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "7db8aeaad3e0401466a1783ddf3d2290", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n↑入力 ↓出力');\n Main();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var s = next();\n var count = 0;\n for(var i = 0; i < s.length; i++){\n count += (s[i] == 'a') ? 1 : 0;\n }\n if(count <= s.length / 2){\n myout(count * 2 - 1);\n }else{\n myout(s.length);\n }\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "57a1d202e2d6991c4ddeaaed78c5b4c3", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data',c=>{[n,m,a]=c.toString().split(' ');console.log(Math.ceil(n/a)*Math.ceil(m/a))})", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "d928912ac1cce88103b1aafb67ab9e7f", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var stdin = process.openStdin();\n\nstdin.addListener(\"data\", function(d) {\n let weight = d.toString().trim()\n\n if (weight % 2 == 0 && weight > 2) {\n console.log(\"YES\");\n } else {\n console.log(\"NO\");\n }\n });\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "1cbfd2dbd2f744387ce0973b10079190", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout,\n\tterminal: false\n});\nlet n, k, f = 0;\n\nrl.on('line', function(line) {\n\tif (!n) {\n\t\t[n, k] = line.split(' ').map(i => parseInt(i));\n\t} else {\n\t\tconst score = line.split(' ').map(i => parseInt(i));\n\t\tconst kScore = score[k - 1];\n\t\tif (kScore > 0) {\n\t\t\tf = k;\n\t\t\tlet i = k;\n\t\t\twhile ((i < score.length) && (score[i] >= kScore)) {\n\t\t\t\tf++;\n\t\t\t\ti++;\n\t\t\t}\n\t\t} else {\n\t\t\tlet i = 0;\n\t\t\twhile (score[i] > 0) {\n\t\t\t\tf++;\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\t\tconsole.log(f);\n\t\trl.close();\n\t}\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "1ac3901f140540012dbd961d07260052", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction main() {\n\tlet n = readLine() >> 0;\n\tlet s = readLine().split('');\n\n\tlet c = s[0];\n\tlet r = 0;\n\n\tfor (let i = 1; i < s.length; ++i) {\n\t\tif (c === s[i]) {\n\t\t\tr++;\n\t\t} else {\n\t\t\tc = s[i];\n\t\t}\n\t}\n\n\tconsole.log(r);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "2d8b5ef2b0886bc17378c7cbfb542c72", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nvar STATE = 1;\nvar n;\nrl.on('line', function (input) {\n switch (STATE) {\n case 1:\n n = parseInt(input, 10);\n // console.log(STATE + ':', n);\n STATE = 2;\n break;\n case 2:\n // console.log(STATE + ':', input);\n var init = 0;\n var added = 0;\n for (var i = 0, len = input.length; i < len; i++) {\n var char = input[i];\n switch (char) {\n case '+':\n added++;\n break;\n case '-':\n if (added) {\n added--;\n } else {\n init++;\n }\n break; \n default:\n throw new Error('Error case');\n }\n }\n // console.log(init, added);\n console.log(added);\n STATE = 1;\n break;\n default:\n // code\n }\n}).on('close', function() {\n process.exit(0);\n});", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "1f5aa2ff6fd4f228437c3fc757a89a62", "src_uid": "a593016e4992f695be7c7cd3c920d1ed", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const [n, k] = d.split(' ').map(Number);\n console.log(Math.floor(n / k) * k + k);\n // const reminder = (n + 1) % k;\n // const ans = reminder !== 0 ? k - reminder + n + 1 : n + 1;\n // console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "06bca92a4a72f5332413d2e34399b737", "src_uid": "75f3835c969c871a609b978e04476542", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var _line = '';\r\nvar _line_data;\r\nvar _current_line = 0;\r\nprocess.stdin.on('data', function (input) {\r\n _line += input;\r\n});\r\nprocess.stdin.on('end', function () {\r\n _line_data = _line.split('\\n').map(function (line) { return line.trim(); });\r\n main();\r\n});\r\nfunction readline() {\r\n if (_line_data.length <= _current_line) {\r\n throw Error('[ERROR] Nothing to read from stdin');\r\n }\r\n return _line_data[_current_line++];\r\n}\r\nfunction println(data, end) {\r\n if (end === void 0) { end = '\\n'; }\r\n process.stdout.write(\"\" + data + end);\r\n}\r\n// START\r\nfunction main() {\r\n var cases = parseInt(readline());\r\n for (var i = 0; i < cases; i += 1) {\r\n var data = parseInt(readline());\r\n var twoData = Math.floor(Math.sqrt(data));\r\n var j = 2;\r\n var cubeCalc = Math.pow(j, 3);\r\n while (cubeCalc <= data) {\r\n var cubeRoot = Math.sqrt(cubeCalc);\r\n if (cubeRoot !== Math.floor(cubeRoot)) {\r\n twoData += 1;\r\n }\r\n j += 1;\r\n cubeCalc = Math.pow(j, 3);\r\n }\r\n println(twoData);\r\n }\r\n}\r\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "cc9e6cc24d0962b9f1848646ef437018", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nconst input = [];\nreadline.on('line', line => input.push(line));\n\nreadline.on('close', () => {\n let [n, k] = input[0].split(' ').map(x => +x);\n for (let i = 0; i < k; i++) {\n if (n % 10 != 0) {\n n--;\n }\n else {\n n /= 10;\n }\n }\n console.log(n);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "7d1eca19db9c51e47f06ee8bbed464e7", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input.push(parseInt(line));\n});\n\nRL.on('close', () => {\n let n = input[0];\n \n if(n == 1)\n console.log('Ehab');\n else if(n == 2)\n console.log('Mahmoud');\n else {\n if(n % 2 == 0)\n console.log('Mahmoud');\n else\n console.log('Ehab');\n }\n});\n\n", "lang_cluster": "Javascript", "tags": ["math", "games"], "code_uid": "2426d4399d83fae3f8acb2a10c80cf49", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar cont = [];\nrl.on('line', (input) => {\n\n\n //cont=input.split(' ').map(function(e){return parseInt(e);});\n cont=input.split(' ').map((e)=>{return parseInt(e);});\n //cont=input.split(' ').map(myFunc);\n var n=cont[0];\n var m=cont[1];\n var a=cont[2];\n\n var X,Y;\n X=Math.floor (n/a) + !!(n%a);\n Y=Math.floor (m/a) + !!(m%a);\n //console.log(\"*********************\");\n /*console.log(\"ArraycontentIs: \");\n cont.forEach(element => {\n console.log(\"element= \" + element + \"; data type is: \" + typeof element);\n });*/\n /*console.log(\"X= \" + X + \"; data type is: \" + typeof X);\n console.log(\"Y= \" + Y + \"; data type is: \" + typeof Y);*/\n //console.log(parseInt ( Math.floor(100/1000000000)) );\n // console.log(!!(100%1000000000) );\n console.log(X*Y);\n rl.close();\n\n\n});\n\n/*var myFunc = function(e){\n return parseInt(e);\n}*/\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "4a980c8a3b5556738e0c971bb58f7512", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.addListener(\"data\", data => {\n const str = data.toString();\n console.log(isHello(str));\n});\n\nfunction isHello(s) {\n let desired = [\"h\", \"e\", \"l\", \"l\", \"o\"];\n for (let i = 0; i < s.length; i++) {\n if (s[i] === desired[0]) {\n desired.splice(0, 1);\n if (desired.length === 0) return \"YES\";\n }\n }\n return \"NO\";\n}", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "db45ee9b3d48c4721763521ba2d44ba7", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n const music = input[0];\n\n const filter = [];\n for (let i = 0; i < music.length; i += 1) {\n if (i+2 < music.length) {\n if (music[i] === 'W' && music[i+1] === 'U' && music[i+2] === 'B') {\n i += 2; \n filter.push(' ');\n continue;\n }\n }\n filter.push(music[i]);\n }\n\n console.log(filter.join('').trim());\n});", "lang_cluster": "Javascript", "tags": ["strings"], "code_uid": "b450b48e07150bac4ff0f7904aaec3fd", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let string1 = readLine().toLowerCase();\n let string2 = readLine().toLowerCase();\n\n if (string1 < string2) {\n console.log(-1);\n } else if (string1 > string2) {\n console.log(1);\n } else {\n console.log(0);\n }\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "9fb7563876b7a4ab6d319c367aca2272", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\n\nlet inputs = [];\n\nconst rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n});\n\nrl.on(\"line\", line => inputs.push(line));\n\nrl.on(\"close\", () => console.log(solution(inputs)));\n\nconst distance = (a, b) => a > b ? a - b : b > a ? b - a : 0;\n\nfunction solution(data) {\n const matrix = data.map(str => str.split(\" \").map(Number));\n let a = 1, b = 1;\n for (let i = a; i <= matrix.length; i++) {\n for (let j = b; j <= matrix[0].length; j++) {\n if (matrix[(i-1)][(j-1)] === 1) {\n a = i;\n b = j;\n break;\n }\n }\n if (a !== 1 || b !== 1) break;\n };\n\n\treturn distance(3, a) + distance(3, b);\n};\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "b1ebb177b4e0a599c1ae265862407f54", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputBuffer = \"\", curLine = 0;\n\nfunction readline() {\n\treturn inputBuffer[curLine++];\n}\n\nlet curTokens = [], curToken = 0;\n\nfunction next() {\n\twhile (curToken >= curTokens.length) {\n\t\tcurTokens = readline().split(/[\\s]+/);\n\t\tcurToken = 0;\n\t}\n\treturn curTokens[curToken++];\n}\n\nfunction nextInt () {\n\treturn parseInt(next(), 10);\n}\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf8\");\n\nprocess.stdin.on('data', (chunk) => {\n\tinputBuffer += chunk;\n});\n\nprocess.stdin.on('end', () => {\n\tinputBuffer = inputBuffer.trim().split('\\n').map(line => line.trim());\n\tmain();\n});\n\n\n\nfunction print(data) {\n\tprocess.stdout.write(data + \"\\n\");\n}\n\nfunction main () {\n\tconst n = nextInt();\n\n\tprint(Math.ceil(n/5));\n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "6eace82dd97418cefd5eafa4aad9b46a", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n var arr=stdin[0].split(' ').map(a => Number(a)),\n a=arr[0],\n b=arr[1],\n i=0;\n while(a<=b){\n i++;\n a=3*a;\n b=2*b;\n }\n console.log(i);\n}\n\nconst readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar stdin = [];\nrl.on('line', function (line) {stdin.push(line);});\nrl.on('close', main);", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "2bdf4b8e124c3c02eead182e07f1f3b6", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n\tvar one = nextIntArray();\n\tvar N = one[0];\n\tvar k = one[1];\n\tvar x = one[2];\n\tvar output = 0;\n\tvar list = nextIntArray();\n\tlist.sort(function(a,b){\n\t\treturn b - a;\n\t})\n\tfor(var i = 0; i < N; i++){\n\t\tif(list[i] > x && k > 0){\n\t\t\toutput += x;\n\t\t\tk--;\n\t\t}else{\n\t\t\toutput += list[i];\n\t\t}\n\t}\n\tmyout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "864558cae90bf55bef01131ecfea38a1", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction readAsInt(){\n return parseInt(readline());\n}\n\nfunction readAsIntList(){\n return readline().split(' ').filter(i => i).map(i => parseInt(i));\n}\n\n\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n let [n, t] = readAsIntList();\n let s = readline();\n for(let i = 1; i <= t; i++){\n s = s.replace(/BG/gi,'GB');\n }\n console.log(s);\n}\n \n\n\n", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "cd9c31830bca655f8880aa62df9a721a", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nrl.on('line', n => {\n n % 2 === 0 ? console.log('Mahmoud') : console.log('Ehab');\n return rl.close();\n});", "lang_cluster": "Javascript", "tags": ["math", "games"], "code_uid": "6f077be8c1577a81506001559f24b838", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n\n// Write your code here\nfunction nameLookUp(str) {\n let nNames = str.trim().split(' ');\n let sum = 0;\n for (let i = 1; i <= nNames[2]; i++) {\n sum = sum + (i * nNames[0]);\n }\n let borrowedMoney = sum - parseInt(nNames[1]);\n if (borrowedMoney <= 0) {\n borrowedMoney = 0;\n }\n return borrowedMoney.toString();\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "818b601db9774f60006ceea1d2445d60", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n var arr=stdin[0].split(' ').map(a => Number.parseInt(a)),s;\n s=(arr[0] <=arr[1] && arr[0]<=arr[2]) ? 'Yes' : 'No';\n console.log(s);\n}\n\nconst readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar stdin = [];\nrl.on('line', function (line) {stdin.push(line);});\nrl.on('close', main);", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "c55928995f7486247142d71b3b03d248", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n\tvar N = nextInt();\n\tvar list = next();\n\tvar output = \"\";\n\tvar mae = \"\";\n\tvar ng = new Set([\"a\",\"e\",\"i\",\"o\",\"u\",\"y\"]);\n\tfor(var i = 0; i < N; i++){\n\t\tif(!ng.has(mae) || !ng.has(list[i])){\n\t\t\tmae = list[i];\n\t\t\toutput += list[i];\n\t\t}\n\t}\n\tmyout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "ccdf4c169f691209722954d9b3e7e641", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet currentLine = 0;\nlet inputString = \"\";\n\nprocess.stdin.on(\"data\", (raw_data) => {\n inputString += raw_data;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((line) => {\n return line.trim();\n });\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n/******** Main function*************/\n\nfunction main() {\n var n = +readLine();\n console.log(25);\n}\n", "lang_cluster": "Javascript", "tags": ["number theory"], "code_uid": "e6d6a463d65acdfc71be1466adbc9ef3", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst rl = readline.createInterface({\n\t \tinput: process.stdin,\n \t\toutput: process.stdout\n})\n\n\nasync function getData() {\n\tlet str = ''\n\treturn new Promise((res,rej)=>{\n\t\trl.question(str,ans=>res(ans))\n\t})\n}\n\nfunction count(price,dollars,bananas){\n\tlet cost = 0\n\tfor(let i = 0; i <= bananas;i++){\n\t\tcost += price*i\n\t}\n\n\tlet difference = cost - dollars\n\n\tif(difference < 0 ) console.info(0)\n\t\telse console.info(difference)\n}\n\nasync function main(){\n\tlet data = await getData()\n\n\tdata = data.trim().split(' ').map((val)=>{\n\t\treturn parseInt(val,10)\n\t})\n\tcount(...data)\n}\n\nmain()", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "d6e0c5c1ae7573b160af16292580244a", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nfunction getResult(firstNumber, secondNumber) {\n\n\n if (firstNumber > 10 ** 9 || firstNumber < 2) throw Error('Got Bad Inputs 1');\n else if (secondNumber < 1 || secondNumber > 50) throw Error('Got Bad Input 2');\n\n\n if (firstNumber.toString()[firstNumber.toString().length - 1] == 0) {\n if (secondNumber - 1 === 0) return firstNumber / 10;\n return getResult(firstNumber / 10, secondNumber - 1);\n } \n if (secondNumber - 1 === 0) {\n return firstNumber - 1;\n };\n return getResult(firstNumber - 1, secondNumber - 1);\n\n}\n\n\nconst readline = require(\"readline\");\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.question('', function(nums) {\n const res = getResult(parseInt(nums.split(' ')[0]) , parseInt(nums.split(' ')[1])) ; \n console.log(res) ; \n rl.close() ;\n});\n\nrl.on(\"close\", function() {\n process.exit(0);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "4898f03c80c38c835559aac87241b26d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var N = nextInt();\n var s = next();\n var ei = 0;\n for(var i = 0; i < N; i++){\n if(s[i] == \"8\"){\n ei++;\n }\n }\n if(ei > 0){\n myout(Math.min(ei, Math.floor(N / 11)));\n }else{\n myout(0);\n }\n \n}\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "698f6d250a1c27a4bbe5ef6198961e17", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n \nconst input = [];\nreadLine.on('line', line => input.push(line));\n \nreadLine.on('close', () => {\n\tlet _input = parseInt(input[0], 10)\n\tlet result = 0\n\tconst _return_ = (num, min) => {\n\t\tconst it1 = num / min\n\t\tconst it2 = Math.floor(it1) // получаем целое число\n\t\tconst it3 = min * it2 // какое кол-во едениц можно отнять\n\t\tconst it4 = num - it3 // остаток\n\t\tresult += it2\n\t\treturn it4\n\t}\n\tconst count_min = (now) => {\n\t\tif (now >= 100) {\n\t\t\tcount_min(_return_(now, 100))\n\t\t} else {\n\t\t\tif (now >= 20) {\n\t\t\t\tcount_min(_return_(now, 20))\n\t\t\t} else {\n\t\t\t\tif (now >= 10) {\n\t\t\t\t\tcount_min(_return_(now, 10))\n\t\t\t\t} else {\n\t\t\t\t\tif (now >= 5) {\n\t\t\t\t\t\tcount_min(_return_(now, 5))\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (now > 0) {\n\t\t\t\t\t\t\tcount_min(_return_(now, 1))\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tcount_min(_input)\n\tconsole.log(result)\n})", "lang_cluster": "Javascript", "tags": ["greedy", "dp"], "code_uid": "a413633cef26457aae02c6b87d53ace1", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\n \nfunction main() {\n comparison(stdin[0],stdin[1]) \n}\n \nvar stdin = [];\nrl.on('line', function (line) {stdin.push(line);});\nrl.on('close', main);\n/*\nconst main = async () => {\n await question1()\n rl.close()\n}\n\nmain()\n*/\n\nfunction comparison(n, m) {\n var firstStr = String(n);\n if(String(n).length == 1 || String(m).length == 1){\n return n == m ? console.log(\"OK\") : console.log(\"WRONG_ANSWER\")\n } \n var result = '';\n var count = 0\n while( firstStr ) {\n var min = 999;\n for(var i = 0; i < firstStr.length; i++) {\n if(Number(firstStr[i] < min)) {\n \tif(count == 0 && Number(firstStr[i]) == 0){ \n } else {\n \tmin = firstStr[i]\n }\n }\n \t}\n var index = firstStr.indexOf(min);\n result += firstStr.slice(index, index+1)\n firstStr = firstStr.slice(0, index) + firstStr.slice(index+1, firstStr.length)\n count ++\n } \n if(result == m) {\n \tconsole.log(\"OK\")\n } else {\n \tconsole.log(\"WRONG_ANSWER\")\n }\n}", "lang_cluster": "Javascript", "tags": ["sortings", "implementation"], "code_uid": "043cb7a5c7353b9af293003ba363f670", "src_uid": "d1e381b72a6c09a0723cfe72c0917372", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nfunction main() {\n const is = new Scanner();\n const word = `${is.nextLine()} `;\n let answer = true;\n for (let i = 0; i < word.length - 1; i += 1) {\n if (!isVowel(word[i]) && word[i] !== 'n') {\n if (!isVowel(word[i + 1])) {\n answer = false;\n break;\n }\n }\n }\n\n console.log(answer ? 'YES' : 'NO');\n\n function isVowel(n) {\n return n === 'a' || n === 'e' || n === 'i' || n === 'o' || n === 'u';\n }\n}\n\n\n\n/*\n * api stdin\n */\n\nclass Scanner {\n constructor() {\n this.index = 0;\n this.lines = stdinInput.trim().split('\\n');\n }\n\n nextLine() {\n return this.lines[this.index++];\n }\n\n nextInt() {\n return parseInt(this.nextLine(), 10);\n }\n\n nextDouble() {\n return parseFloat(this.nextLine());\n }\n\n nextArray() {\n return this.nextLine().split(' ');\n }\n\n hasNext() {\n return this.index < this.lines.length;\n }\n}\n\nlet stdinInput = '';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nprocess.stdin.on('data', input => { stdinInput += input; });\nprocess.stdin.on('end', () => { main(); });\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "75fe9a6ed0be16a5b135bd3366fcacd0", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet input;\n\nrl.question('', (usrIn) => {\n input = usrIn.split(' ');\n printResult(input);\n rl.close();\n});\n\nfunction printResult(input) {\n\n let num = parseInt(input[0]);\n\n for (let i = 1; i <= parseInt(input[1]); i++) {\n\n if(num % 10 === 0) {\n num /= 10;\n } else {\n num -= 1;\n }\n }\n\n console.log(num)\n}\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "06f8ad52cb835eb254e880ebf5c5a0f0", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nconst pad2 = (x) => (\"0\" + x).slice(-2);\n\nconst readTime = (s) => s.replace(/\\r?\\n|\\r/, \"\").split(\":\");\n\nrl.question(\"\", (time1) => {\n const [h1, m1] = readTime(time1);\n rl.question(\"\", (time2) => {\n const [h2, m2] = readTime(time2);\n const [A, B] = [\n new Date(0, 0, 0, h1, m1).getTime(),\n new Date(0, 0, 0, h2, m2).getTime(),\n ].sort();\n \n const result = new Date(A + (B - A) / 2); \n \n process.stdout.write(\n `${pad2(result.getHours())}:${pad2(result.getMinutes())}\\n`\n );\n process.exit();\n });\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "8ad24c416a089768449087c1a0e7be4c", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf8');\n\nvar input = [], readline, print;\n\nprocess.stdin.on('data', function(chunk) {\n input.push(chunk);\n});\n\nprocess.stdin.on('end', function() {\n print = function(data) {process.stdout.write(data+'\\n')};\n var inputLineIndex = 0;\n readline = function(){return inputLineIndex>=input.length?undefined:input[inputLineIndex++]};\n process.exit(main() || 0);\n});\n\nfunction main()\n{\n var n = readline().split(' ');\n print(Math.ceil(n[0] / n[2]) * Math.ceil(n[1] / n[2])); // Your code here\n return 0;\n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "eece7a22a2116121149faeca398d6a73", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var input='';\n\nprocess.stdin.on('data',givenInput=>{\n input+=givenInput;\n});\n\nprocess.stdin.on('end',()=>{\n main(input);\n});\n\nconst main=(input)=>{\n let limak=Number(input.split(' ')[0]);\n let bob=Number(input.split(' ')[1]);\n let count=0;\n \n while(true){\n if(limak>bob){\n break;\n }\n limak*=3;\n bob*=2;\n count++;\n }\n \n console.log(count);\n};", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "4105d34ec541200ebe2995dc2e1ba4c7", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.setEncoding('utf8');\nlet input = [];\nprocess.stdin.on('readable', () => {\n const chunk = process.stdin.read();\n if (chunk !== null) {\n let re = /\\n\\s*| /;\n input = chunk.split(re).slice(0, -1);\n let [w, h, u1, d1, u2, d2] = input.map(value => parseInt(value));\n for (; h >= 0; h--) {\n w += h;\n if (h == d1) w -= u1;\n if (h == d2) w -= u2;\n w = Math.max(w, 0);\n }\n console.log(w);\n process.exit();\n }\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "41bed593ff143d2487027919dff7c3c8", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n let n = +d;\n const ans = [];\n\n let inc = 0;\n while (inc < n) {\n let curr = 1;\n ans.push(curr);\n let idx = ans[ans.length - 2];\n\n while (curr === idx) {\n curr++;\n ans[ans.length - 2] = curr;\n ans.pop();\n idx = ans[ans.length - 2];\n }\n inc++;\n }\n\n console.log(ans.join(' '));\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3494cdd6c6c0c6d0ee4373c392afe89a", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n var f=Number(stdin[0]);\n var count=0;\n while(f!==0){\n if(f%5!==f){\n count+=Math.floor(f/5);\n f=f%5;\n }else if(f%4!==f){\n count+=Math.floor(f/4);\n f=f%4;\n }else if(f%3!==f){\n count+=Math.floor(f/3);\n f=f%3;\n }else if(f%2!==f){\n count+=Math.floor(f/2);\n f=f%2;\n }else{\n count+=1;\n break;\n }\n }\n console.log(count);\n}\n\nconst readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar stdin = [];\nrl.on('line', function (line) {stdin.push(line);});\nrl.on('close', main);", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "d1ab628e4a51fd5bf99c3919a509fdf6", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet max;\nlet arr1, arr2;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n max = +d;\n return;\n }\n\n if (c === 1) {\n arr1 = d.split(' ').map(Number);\n c++;\n return;\n }\n\n arr2 = d.split(' ').map(Number);\n\n c++;\n});\n\nrl.on('close', () => {\n let common = 0;\n\n for (let i = 0; i < arr1.length; i++) {\n common += arr1[i] && arr2[i];\n }\n\n let sum1 = arr1.reduce((a, x) => a + x, 0) - common;\n let sum2 = arr2.reduce((a, x) => a + x, 0) - common;\n\n if (!sum1) {\n console.log(-1);\n }\n else {\n console.log(Math.ceil( (sum2 + 1) / sum1));\n }\n\n // let common = 0;\n\n // for (let i = 0; i < arr1.length; i++) {\n // common += arr1[i] && arr2[i];\n // }\n\n // let sum1 = arr1.reduce((a, x) => a + x, 0) - common;\n // let sum2 = arr2.reduce((a, x) => a + x, 0) - common;\n // let ans = sum1 > sum2 ? 1 : -1;\n\n // for (let i = 1; i <= max; i++) {\n // if (sum1 * i > sum2) {\n // ans = i;\n // break;\n // }\n // }\n\n // console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "a705d5e25a6824ce651760319d2dd3e4", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet currentLine = 0;\nlet inputString = \"\";\n\nprocess.stdin.on(\"data\", (raw_data) => {\n inputString += raw_data;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((line) => {\n return line.trim();\n });\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n/******** Main function*************/\n\nfunction main() {\n var [M, N] = readLine().split(\" \").map(Number);\n\n var r = M * N;\n var n = Math.floor(r / 2);\n console.log(n);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "70ef1c443e2779b95d7aa2b3f304cbe5", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n var n = Number(stdin[0]),\n name = n % 2 === 0 ? \"Mahmoud\" : \"Ehab\";\n console.log(name);\n}\n\nconst readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar stdin = [];\nrl.on('line', function (line) {\n stdin.push(line);\n});\nrl.on('close', main);\n", "lang_cluster": "Javascript", "tags": ["math", "games"], "code_uid": "501b532626d2b272adfbd284e2e6d32f", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const {EOL} = require('os')\n\nlet ipt = ''\nprocess.stdin.on('data', s => ipt += s)\nprocess.stdin.on('end', () => {\n let [x, y] = ipt.split(EOL).slice(0, -1)[0].split(' ').map(v => parseInt(v))\n for (let i = 0; ; i++) {\n if (i % 2) {\n if (y >= 22) {\n y -= 22\n } else if (y >= 12 && x >= 1) {\n x -= 1\n y -= 12\n } else if (y >= 2 && x >= 2) {\n x -= 2\n y -= 2\n } else {\n return console.log('Ciel')\n }\n } else {\n if (x >= 2 && y >= 2) {\n x -= 2\n y -= 2\n } else if (x == 1 && y >= 12) {\n x = 0\n y -= 12\n } else if (y >= 22) {\n y -= 22\n } else {\n return console.log('Hanako')\n }\n }\n }\n})", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "7779e7270033dffb39497faee4aa8d7c", "src_uid": "8ffee18bbc4bb281027f91193002b7f5", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst rl = readline.createInterface({\n\t input: process.stdin,\n\t output: process.stdout,\n\tterminal : false\n});\n\n\nrl.on(\"line\", main)\nlet i = 1\nlet n = 0\nlet k = 0\nlet w = 0\nlet score = 0\nfunction main(input){\n\tif(n == 0 ){\n\t\tlet arr = input.split(' ')\n\t\tn = arr[0]\n\t\tk = arr[1]\n\t\treturn\n\t}\n\n\t\n\tconst arr = input.split(' ')\n\t\n\n\n\tscore = arr[k-1]\n\tfor(var i = 0; i < n; i++){\n\t\tlet a = arr[i]\n\t\tif( parseInt(a) >= parseInt(score) && parseInt(a) > 0){\n\t\t\tw++\n\t\t}\n\t}\n\tconsole.log(w)\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "6137c15eb11770c3ee1f3de6a866aa6a", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nrl.on('line', (employees) => {\n let teamLeaders = ways = 0;\n for (let index = 1; index < employees; index++) {\n if (teamLeaders >= employees) {\n console.log(ways);\n return rl.close();\n } else if ((employees - index) % (teamLeaders + index) === 0) {\n teamLeaders += index;\n employees -= index;\n ways += 1;\n index -= index;\n }\n }\n console.log(ways);\n return rl.close();\n});", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "4cbfb5f3104f00e853f46e4acae329c9", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "/**\n * @author 'Sunwarul Islam'\n * Full Stack JavaScript Developer \n */\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', inputStd => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', () => {\n inputString = inputString.trim().split('\\n').map(str => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const n = +(readLine());\n const result = (n / 5) + ((n % 5) ? 1 : 0);\n console.log(parseInt(result));\n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "958fbb2aca9c5bb7a9e39b8d70156482", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n\tvar N = nextInt();\n\tvar max = 0;\n\tvar maxIndex = {\n\t\tx : 0,\n\t\ty : 0\n\t}\n\tfor(var i = 1; i < N; i++){\n\t\tvar x = i;\n\t\tvar y = N - i;\n\t\tif(x < y && max < (x / y) && gcd(x, y) == 1){\n\t\t\tmax = x / y;\n\t\t\tmaxIndex.x = x;\n\t\t\tmaxIndex.y = y;\n\t\t}\n\t}\n\tmyout(maxIndex.x + \" \" + maxIndex.y);\n}\nfunction gcd(m, n) {return n != 0 ? gcd(n, m % n) : m;}", "lang_cluster": "Javascript", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "c3faea71e009ada1c00f433d8eaf4707", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nconst readline = require('readline');\n\nlet lines = [];\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\nrl.on('line', (line) => {\n lines.push(line);\n});\n\n\n\nrl.on('close', (cmd) => {\n let arr = lines[0].split(' ').map(Number);\n let ret = 0;\n while (arr[0] <= arr[1]) {\n arr[0] *= 3;\n arr[1]*= 2;\n ++ret; \n }\n console.log(ret);\n process.exit(0);\n\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0c03dfbcc308f42b536e4b621c41b095", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": " /*\nOwn input stream*/\nconst readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n terminal: false\n});\n\nprocess.stdin.setEncoding('utf8');\nlet arr=[]\nrl.on('line', (input) => {\n if(input!=='') arr.push(input)\n \n}).on('close', () => {\n console.log(minfill(arr))\n process.exit(0);\n \n});\nfunction minfill(arr){\nreturn (arr>2&&arr%2===0?\"YES\":\"NO\")\n \n \n}\n\n\nmodule.exports=(minfill)\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "497decf66caaab3d36ef0bfbaab6ae9e", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Recurse k times\n// If ends in 0, then divide by 10\n// Else subtract 1\n\nlet stdin = process.stdin;\nstdin.setEncoding('utf8');\nstdin.on('data', function (data) {\n let input = data.split('\\n');\n let n = input[0].split(' ').map(function (a) { return parseInt(a); });\n let result = wrongSubtract(n[0], n[1]);\n console.log(result);\n});\n\nfunction wrongSubtract (val, k) {\n if (k == 0) {\n return val;\n }\n if (val % 10 == 0) {\n val = val / 10\n } else {\n val -= 1\n }\n return wrongSubtract(val, k - 1)\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f1578f9cdd5fc74aaf0d93a3b28bfb03", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */\n//codeforces_80A\nvar gi = process.stdin;\ngi.setEncoding('utf8');\nvar go = (x) => process.stdout.write(x);\nfunction parseArray(line) { return line.split(' ').map(function (a) { return parseInt(a); }); }\n\nlet main = function(data){\n\tvar lines = data.split(\"\\n\");\n\tvar a = parseArray(lines[0]);\n\tvar x = a[0];\n\tvar y = a[1];\n\twhile (x <= y){\n\t\tx++;\n\t\tvar flag = false;\n\t\tfor (var k = 2; k*k <= x; k++) {\n\t\t\tif (x%k == 0) {\n\t\t\t\tflag = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!flag && x < y) {\n\t\t\tgo(\"NO\\n\");\n\t\t\treturn 0;\n\t\t}if (!flag && x == y){\n\t\t\tgo(\"YES\\n\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\tgo(\"NO\\n\");\n\treturn 0;\n}\ngi.on(\"data\", main);", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "851d6e87af4825de62ed652afe5f2427", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n var str = readLine()\n .split(\"+\")\n .map(Number)\n .sort((a, b) => a - b)\n .join(\"+\");\n console.log(str);\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "b13eccb559e1db2c7797c51748996cc3", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "(()=>{\"use strict\";var t={312:function(t,e,r){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,\"__esModule\",{value:!0});const u=n(r(747));let o=\"\",i=[],s=0,l=\"\";const a=\"local\"===process.argv[2],f=t=>{if(a)return i=u.default.readFileSync(\"input.txt\").toString().trim().split(\"\\n\").map((t=>t.trim())),t(),void u.default.writeFileSync(\"output.txt\",l);process.stdin.resume(),process.stdin.setEncoding(\"utf-8\"),process.stdin.on(\"data\",(t=>{o+=t})),process.stdin.on(\"end\",(e=>{i=o.trim().split(\"\\n\").map((t=>t.trim())),t(),console.log(l)}))};function c(){return i[s++]}function p(){return c().split(\" \").map((t=>parseFloat(t)))}function d(){return c().split(\"\")}e.default={runMain:f,runEachTest:t=>{f((()=>{let[e]=p();for(;e>0;)t(),e--}))},readline:c,nextNumbers:p,nextNumbersMatrix:function(t){let e=[];for(let r=0;r=t||f>=e||a<0||f<0)&&\"W\"==r[a][f]){r[a][f]=\".\",i++;break}}u.default.put(i)}))},747:t=>{t.exports=require(\"fs\")}},e={};!function r(n){if(e[n])return e[n].exports;var u=e[n]={exports:{}};return t[n].call(u.exports,u,u.exports,r),u.exports}(965)})();", "lang_cluster": "Javascript", "tags": ["greedy", "implementation"], "code_uid": "c67bd9cd426522b026535a9b9f7a1103", "src_uid": "969b24ed98d916184821b2b2f8fd3aac", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let buf='';\r\n\r\nprocess.stdin.on('readable', function(){\r\n let chunk=process.stdin.read();\r\n if(chunk) buf+=chunk.toString();\r\n})\r\n\r\nprocess.stdin.on('end', function(){\r\n const {EOL}=require('os');\r\n let line=buf.split(EOL);\r\n let t=parseInt(line[0]);\r\n for(let _=1;_<=t;_++)\r\n {\r\n let n=parseInt(line[_]);\r\n console.log((1< Number(a));\n var sign;\n if (arr[0] - arr[1] > arr[2]) {\n sign = '+';\n } else if (arr[1] - arr[0] > arr[2]) {\n sign = '-';\n } else if (arr[0] === arr[1] && arr[2] === 0) {\n sign = '0';\n } else {\n sign = '?';\n }\n console.log(sign);\n}\n\nconst readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar stdin = [];\nrl.on('line', function (line) {\n stdin.push(line);\n});\nrl.on('close', main);\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "51d0f1cbc184a71e552d15a67cf40ba0", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction main() {\n\tconst str = readLine()\n\t\t.toLowerCase()\n\t\t.replace(/[aeiouy]/g, '')\n\t\t.split('')\n\t\t.map(char => `.${char}`)\n\t\t.join('');\n\tconsole.log(str);\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "5b9eff77d233b4f4968c85ac93b03527", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nconst solution = (input) => {\n const str = input;\n const vowels = [\"A\", \"O\", \"Y\", \"E\", \"U\", \"I\"];\n const vowelsLowerCase = vowels.map((item) => {\n return item.toLowerCase();\n });\n\n let arr = Array.from(str);\n\n let consonants = arr.filter((item) => {\n return !(vowels.includes(item) || vowelsLowerCase.includes(item));\n }).map((item) => {\n return item.toLowerCase();\n });\n\n console.log(`.${consonants.join('.')}`);\n\n rl.close();\n}\n\nrl.question('', (input) => {\n solution(input);\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "ffa0cc93ceac7fc6ee667cd4143394e3", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main(rawInput) {\n var lines = rawInput.trim().split(\"\\n\").map(function (v) { return v.trim().split(\" \").map(function (u) { return parseInt(u, 10); }); });\n var n = lines.shift()[0];\n var ra = lines.shift();\n var rb = lines.shift();\n var sca = 0;\n var scb = 0;\n var unqa = 0;\n for (var i = 0; i < n; i++) {\n if (ra[i] == 1) {\n sca++;\n }\n if (rb[i] == 1) {\n scb++;\n }\n if (ra[i] > rb[i]) {\n unqa++;\n }\n }\n // console.error(sca, scb, unqa);\n if (sca > scb) {\n console.log(1);\n }\n else if (unqa > 0) {\n if ((scb - (sca - unqa)) % unqa == 0) {\n console.log((scb - (sca - unqa)) / unqa + 1);\n }\n else {\n console.log(Math.ceil((scb - (sca - unqa)) / unqa));\n }\n }\n else {\n console.log(-1);\n }\n // console.log('----')\n}\n// main(`5\n// 1 1 1 0 0\n// 0 1 1 1 1`);\n// main(`3\n// 0 0 0\n// 0 0 0`);\n// main(`4\n// 1 1 1 1\n// 1 1 1 1`);\n// main(\n// `9\n// 1 0 0 0 0 0 0 0 1\n// 0 1 1 0 1 1 1 1 0`\n// );\n// main(`2\n// 1 1\n// 1 0`);\n// main(`3\n// 0 1 1\n// 1 0 0`);\n// main(`7\n// 0 1 1 1 0 1 1\n// 1 0 1 1 1 1 1`);\n(function () {\n var d = \"\";\n process.stdin.on(\"data\", function (v) { return d += v; });\n process.stdin.on(\"end\", function () { return main(d); });\n})();\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "c346df5f701130ef4e2d3b0abb0c8147", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var one = nextIntArray();\n var N = one[0];\n var D = one[1];\n var list = next();\n var dp = new Array(N).fill(-1);\n dp[0] = 0;\n for(var i = 0; i < N; i++){\n if(list[i] == \"1\" && dp[i] != -1){\n for(var j = 1; j <= D; j++){\n if(list[i + j] == \"1\"){\n if(dp[i + j] == -1){\n dp[i + j] = dp[i] + 1;\n }else{\n dp[i + j] = Math.min(dp[i] + 1, dp[i + j]);\n }\n }\n }\n }\n }\n myout(dp[N - 1]);\n}", "lang_cluster": "Javascript", "tags": ["dfs and similar", "greedy", "dp", "implementation"], "code_uid": "5be434f9ad76f72ee792c8f4b7dcb3c8", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nlet inputs = []\n\n// Create readline Interface\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\n// Read Inputs\nrl.on('line', lineInput => {\n let s = lineInput\n let sentence = []\n let words = []\n\n for (let i = 0; i < s.length; i++) {\n while (s[i] == 'W' && s[i + 1] == 'U' && s[i + 2] == 'B') {\n i += 3\n }\n let word = s[i]\n while (nextNotWUB(s, i) && i < s.length - 1) {\n i++\n word += s[i]\n }\n words.push(word)\n i += 3\n }\n\n\n console.log(words.join(' '))\n\n function nextNotWUB(s, i) {\n return s[i + 1] + s[i + 2] + s[i + 3] != 'WUB'\n }\n})\n\nrl.on('close', () => {})", "lang_cluster": "Javascript", "tags": ["strings"], "code_uid": "cd2a6eaa0d2e23b2897152554f5de5fa", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet first = true;\nlet s = '';\nlet t = '';\nrl.on('line', (line) => {\n if (first) {\n first = false;\n s = line;\n return;\n } else {\n first = true;\n t = line;\n console.log(solution(s, t));\n return;\n }\n});\n\n\nfunction solution(first, second) {\n // Let's reverse without using an api since that\n // is kinda the point of this challenge\n if (first.length !== second.length) {\n return \"NO\";\n }\n for (let i = 0; i < first.length; i++) {\n let j = (first.length - 1) - i;\n if (first[i] !== second[j]) {\n return \"NO\";\n }\n }\n return \"YES\";\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "0d7ac6936ba70c2267851ee7e2182674", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var line_number = 0;\nconst cs = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nvar lines = {};\ncs.on(\"line\", (input) => {\n if (input == \"\") {\n cs.close();\n }\n lines[line_number] = input.split(\" \");\n line_number += 1;\n}).on(\"close\", () => {\n main();\n process.exit();\n});\n\nfunction isOp(str) {\n return str.length === 1 && str.match(/[<=>]/);\n}\nfunction isChr(str) {\n return str.length === 1 && str.match(/[a-z]/i);\n}\nfunction isInt(str) {\n return str.length === 1 && !isNaN(str);\n}\n\nfunction print(str) {\n console.log(str);\n}\n\nfunction exit(status = 0) {\n process.exit(status);\n}\n\nfunction predict(test) {\n let op = \"\";\n let ops = [];\n let opVariables = [];\n let limits = [];\n for (let t of test) {\n // console.log(t);\n for (let i = 0; i < t.length; i++) {\n if (isOp(t[i])) {\n op = t[i];\n if (isOp(t[i + 1])) {\n op += t[i + 1];\n i += 1;\n }\n ops.push(op);\n op = \"\";\n } else if (isChr(t[i])) {\n // console.log(t[i])\n op = t[i];\n for (var j = i + 1; j < t.length; j++) {\n if (isChr(t[j]) || isInt(t[j])) {\n op += t[j];\n i = j;\n } else break;\n }\n opVariables.push(op);\n op = \"\";\n } else {\n if (i == 0 || (i > 0 && isOp(t[i - 1]))) {\n op = t[i];\n let j = i + 1;\n for (; j < t.length; j++) {\n if (isInt(t[j])) {\n op += t[j];\n i = j;\n } else break;\n }\n limits.push(op);\n op = \"\";\n }\n }\n }\n }\n\n let min = limits[0];\n let max = limits[1];\n\n let pvs = ops.map((o, i) => [o, opVariables[i]]);\n\n for (let pv of pvs) {\n if (pv[1] == undefined) {\n pv[1] = max;\n }\n // print(`${min} ${pv[0]} ${pv[1]} ?`)\n if (eval(`${min}${pv[0]}${pv[1]}`)) {\n // print(` ${min} ${pv[0]} ${pv[1]} true`)\n min = pv[1];\n } else {\n print(\"input error\");\n exit();\n }\n }\n}\n\nvar n;\nfunction main() {\n let s = lines[0][0];\n n = s.length\n predict([\"1<=n<=100\"])\n\n let gender = {}\n for(let i=0; i {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n const matrix = [];\n let minNumOfSwap;\n for( let i = 0 ; i < 5 ; i++){\n matrix[i] = readline().split(' ').map(x => parseInt(x))\n }\n\n\n for (let i=0 ; i <5 ;i++){\n for (let j =0 ; j < 5 ; j++){\n if (matrix[i][j] === 1 ){\n minNumOfSwap = Math.abs( i - 2) + Math.abs(j -2);\n break;\n }\n }\n }\n console.log(minNumOfSwap)\n\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "dad5e3cbca0deeca064d9d6c8cdb8191", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\n'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\n\nfunction main() {\n const length = readline();\n let hosts=[];\n let guests=[];\n let str=\"\";\n let result =0;\n\n for( let i =0; i {\n let line = data.toString().trim().split(/\\n/).map(String);\n solution(line);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0bc5b17018a3e61c384ebd7bf6fd0965", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nlet input = [];\n\nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input = line.split(' ').map((x) => { return parseInt(x) });\n let n = input[0];\n for (let k = input[1]; k--;) {\n if (n % 10) {\n n--;\n } else {\n n /= 10;\n }\n }\n console.log(n);\n});\n\nRL.on('close', () => {\n //console.log(input);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "fa7a92078923aec9dc20a3780187b623", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// https://codeforces.com/problemset/problem/977/B\n// Big O:\n// n: string length\n// Time complexity: O(n)\n// Space complexity:\n\nconst readline = require(\"readline\");\n\n// Read input\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet stringLength;\nrl.on('line', (input) => {\n if (stringLength) {\n console.log(findMostCommonGram(input, stringLength));\n rl.close();\n } else {\n stringLength = input;\n }\n});\n\n// Problem\nfunction findMostCommonGram(string, stringLength) {\n let mostCommonGram = \"\";\n let mostCommonGramOccurrences = 0;\n const gramOccurrences = {};\n\n for (let i = 0; i < stringLength - 1; i++) {\n const twogram = string[i] + string[i + 1];\n const occurrences = gramOccurrences[twogram] ? gramOccurrences[twogram] + 1 : 1;\n if (occurrences > mostCommonGramOccurrences) {\n mostCommonGram = twogram;\n mostCommonGramOccurrences = occurrences;\n }\n\n gramOccurrences[twogram] = occurrences;\n }\n\n return mostCommonGram;\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "5660e50e25b2e37c83b6e5aa24b54a3d", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\r\n\r\nvar readline = require('readline');\r\n\r\nfunction _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }\r\n\r\nvar readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);\r\n\r\nasync function solve(r) {\r\n const rbs = async () => {\r\n return (await r()).split(' ').filter(s => s !== '').map(BigInt);\r\n };\r\n const [n, m] = await rbs();\r\n if (m === 1n) return n - 1n;\r\n return n * (m - 1n);\r\n}\r\n\r\nasync function main(r) {\r\n try {\r\n let t = 1;\r\n let res = new Array(t);\r\n for (let i = 0; i < t; i++) {\r\n res[i] = await solve(r);\r\n }\r\n return res.join('\\n');\r\n } catch (error) {\r\n console.log('zdebug' + error);\r\n }\r\n}\r\n\r\nconst rl = readline__default[\"default\"].createInterface({\r\n input: process.stdin,\r\n output: process.stdout\r\n});\r\nconst it = rl[Symbol.asyncIterator]();\r\nasync function read() {\r\n return (await it.next()).value;\r\n}\r\nvoid async function () {\r\n const output = await main(read);\r\n process.stdout.write(output);\r\n}();\r\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "0ce67435e2c3b26859ee733b7fa2794e", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function calNumberYear(weights) {\n let limak = parseInt(weights[0]) ;\n let bob = parseInt(weights[1]) ; \n\n for(let i=1 ; i < Infinity ; i++) {\n limak = limak * 3 ; \n bob = bob * 2 ;\n \n if (limak > bob) return console.log(i) ;\n }\n\n};\n\n\n\n\nconst readline = require(\"readline\");\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.question('', function (weights) {\n\n calNumberYear(weights.split(' ')) ; \n rl.close();\n\n});\n\nrl.on(\"close\", function () {\n process.exit(0);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "7df21ade331a936d1c97358a42e6c8fd", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\r\nconst fs = require(\"fs\");\r\n//let filename = \"0.txt\";\r\nlet filename = 0;\r\nconst input = fs.readFileSync(filename, \"utf8\").trim().split(\"\\n\");\r\nlet line = 0;\r\nfunction readline() {\r\n return input[line++];\r\n}\r\nconst solve = () => {\r\n let t = parseInt(readline());\r\n while (t--) {\r\n let t1 = readline()\r\n .trim()\r\n .split(\" \")\r\n .map((cur) => parseInt(cur));\r\n let t2 = readline()\r\n .trim()\r\n .split(\" \")\r\n .map((cur) => parseInt(cur));\r\n let cnt = 0;\r\n for (let i = 0; i < 2; i++) if (t1[i] === 1) cnt++;\r\n for (let i = 0; i < 2; i++) if (t2[i] === 1) cnt++;\r\n if (cnt === 0) console.log(0);\r\n else if (cnt === 4) console.log(2);\r\n else console.log(1);\r\n }\r\n};\r\nsolve();\r\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f242f4d21bc5aa2ec73c5106ac9022b3", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet inputString = \"\";\nlet currentLine = 0;\n\nprocess.stdin.on(\"data\", (inputStdin) => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((string) => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n const x = readline();\n \nlet matrix = [];\n for (let i = 0; i < x; i++) {\n \n matrix.push(\n readline()\n .split(\" \")\n .map((x) => +x)\n );\n }\n \n gamesHomeGuest(matrix);\n}\n\nfunction gamesHomeGuest(teams) {\n let htWearGuestCount = 0;\n for (let i = 0; i < teams.length; i++) {\n const homeTeam = teams[i];\n\n for (let j = 0; j < teams.length; j++) {\n const awayTeam = teams[j];\n\n if (homeTeam[0] === awayTeam[1]) htWearGuestCount++;\n }\n }\n console.log(htWearGuestCount);\n\n return htWearGuestCount;\n}\n\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "8baa7dad98ce626529b44926d6303deb", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "function solve() {\n var n = Number(read());\n var i = 2;\n while (i * i <= n && (n % i)) {\n i++;\n }\n if (i * i > n) {\n write('1 ' + (n - 1));\n } else {\n var k = Math.floor(n / i);\n write('' + k + ' ' + k * (i - 1));\n }\n}\n\nfunction init() {\n var T;\n T = 1;\n T = Number(read());\n for (var t = 0; t < T; t++) {\n solve();\n }\n}\n\n\nvar isNode = typeof console !== 'undefined';\nvar MEMORY = [];\nvar MEMORY_INDEX = 0;\nif (isNode) {\n var fs = require('fs');\n var path = require('path');\n \n var inTextName;\n var outTextName;\n if (process.argv.length === 5) {\n inTextName = process.argv[3];\n outTextName = process.argv[4];\n }\n \n if (inTextName) {\n fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {\n MEMORY = data.split('\\r\\n');\n init();\n });\n } else {\n var RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n });\n \n RL.on('line', (line) => {\n MEMORY.push(line);\n });\n \n RL.on('close', init);\n }\n} else {\n init();\n}\n \nfunction write(value) {\n isNode ? console.log(value) : print(value);\n}\nfunction read() {\n return isNode ? MEMORY[MEMORY_INDEX++] : readline();\n}\n", "lang_cluster": "Javascript", "tags": ["math", "greedy", "number theory"], "code_uid": "df468a7bd16aba1cc3e662da4bcf4d5f", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on( 'line', ( line )=>{\n rl.on( 'line', ( input )=>{ \n let flag = false;\n for(let i = 0; i < line.length; i+=1){\n if( input.toLowerCase().charCodeAt(i) > line.toLowerCase().charCodeAt(i) ){\n console.log(-1);\n rl.close(); \n flag = true;\n break;\n }else if( input.toLowerCase().charCodeAt(i) < line.toLowerCase().charCodeAt(i) ){\n console.log(1);\n rl.close();\n flag = true;\n break;\n }\n } \n //console.log(`Line: ${line} Input: ${input}`);\n flag || console.log(0);\n rl.close();\n });\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "e9df6b13664492c6aa9a8e7cf8070a58", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n↑入力 ↓出力');\n Main();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var one = nextIntArray();\n var list = [one[0], one[1], one[2]];\n var d = one[3];\n list.sort(function(a,b){\n return a - b;\n });\n var output = Math.max(d - (list[1] - list[0]), 0) + Math.max(d - (list[2] - list[1]), 0);\n myout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "75995e92a0ad122d5c51a9be15240aba", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nlet inputs = [];\n\n// Create readline Interface\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\n\n// Read Inputs\nrl.on('line', lineInput => {\n inputs.push(lineInput)\n})\n\nrl.on('close', () => {\n\n const n = inputs[0].split(' ').map(num => parseInt(num))[0];\n let puzzles = inputs[1].split(' ').map(num => parseInt(num)).sort((a, b) => a - b);\n let result = [];\n\n for (let i = 0; i <= puzzles.length - n; i++) {\n result.push(puzzles[i + n - 1] - puzzles[i]);\n }\n\n console.log(Math.min(...result))\n\n\n})", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "544f0de76651e1df3ebd1d1204c8bdef", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\n\"use strict\";\nlet input = [];\nconst readline=require('readline');\nconst RL=readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nRL.on('line', (line)=>{\n input.push(line.trim());\n});\nRL.on('close', ()=>{\n const answer=input[0].includes(\"1111111\") || input[0].includes(\"0000000\");\n if(answer){\n console.log(\"YES\");\n } else{\n console.log(\"NO\");\n }\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "0290681968d3ad17094278be97f9b4ae", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nlet isDivisibleByFour = (str) => {\n let ans = 0;\n\n for (let i = 0; i < str.length; i++) {\n ans += Number(str[i]);\n }\n\n return ans % 4 === 0;\n}\n\nrl.on('line', (d) => {\n let ans = +d;\n\n while (!isDivisibleByFour(d)) {\n ans++;\n d = String(ans);\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "56bf57b974d2c74877db33bff2f57d57", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// GOOD\nreadline = require('readline')\nrl = readline.createInterface({\n input: process.stdin\n})\n\nlet lineNum = 0;\nlet n, v;\nrl.on('line', (l) => {\n lineNum++;\n [n, v] = l.split(\" \").map(x => parseInt(x));\n \n // fill as much as needed at the start\n let perunitCost = 1;\n let cost = v < n ? v : n-1;\n let d = 1 + cost/perunitCost;\n \n while (d < n) {\n perunitCost++;\n cost += perunitCost\n d++\n }\n console.log(cost)\n rl.close()\n})", "lang_cluster": "Javascript", "tags": ["math", "greedy", "dp"], "code_uid": "d50d194cfa62d2c4a17575838d4590ee", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const [x, y, z, t1, t2, t3] = d.split(' ').map(Number);\n const stairTime = Math.abs(x - y) * t1;\n const elevatorTime = t3 * 3 + Math.abs(x - y) * t2 + Math.abs(x - z) * t2;\n\n if (stairTime < elevatorTime) {\n console.log('NO');\n }\n else {\n console.log('YES');\n }\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "55ea705d436fb016e72e1ef44c509dd8", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\nvar maxSize = 0;\n\nrl.on('line', (s) => {\n var N = s.length;\n for (let i = 0; i < N; i++) {\n for (let counter = 1; counter <= N - i; counter++) {\n for (let j = 0; j <= N - counter; j++) {\n if (j == i) continue;\n var sub = s.substr(i, counter);\n var sub2 = s.substr(j, counter);\n if (sub == sub2) {\n if (maxSize < counter) maxSize = counter;\n break;\n }\n }\n }\n }\n}).on('close', () => {\n console.log(maxSize);\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["brute force", "greedy"], "code_uid": "5c1dde82165b2a947034cacee0f662d4", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const start=(main, readlineFun, printFun) => {\n if (readlineFun && printFun) {\n main(readlineFun, printFun);\n return;\n }\n\n process.stdin.resume();\n process.stdin.setEncoding('utf8');\n\n let input = '',\n readline,\n print;\n\n process.stdin.on('data', function(chunk) {\n input += chunk;\n });\n\n process.stdin.on('end', function() {\n input = input.split('\\n');\n print = function(data) {\n process.stdout.write(data + '\\n');\n };\n let inputLineIndex = 0;\n readline = function() {\n return inputLineIndex >= input.length ? undefined : input[inputLineIndex++];\n };\n process.exit(main(readline, print) || 0);\n });\n} \n function main(readline, print) {\n const x = parseInt(readline());\n print(Math.floor(x / 5) + (x % 5 > 0 ? 1 : 0));\n} \n start(main);", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "13e66d2600d22e8bc27d5da7700b7019", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "/**\n * Problem - http://codeforces.com/contest/1064/problem/A\n */\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf8');\n\nvar input_stdin = '';\nvar input_stdin_array = '';\nvar input_currentline = 0;\n\nprocess.stdin.on('data', function (data) {\n input_stdin += data;\n});\n\nprocess.stdin.on('end', function () {\n input_stdin_array = input_stdin.split('\\n');\n main();\n});\n\nfunction readLine() {\n return input_stdin_array[input_currentline++];\n}\n\nfunction main() {\n let input = readLine();\n\n inputArray = input.split(' ').map(Number);\n inputArraySum = inputArray.reduce((acc, currentValue) => acc + currentValue, 0);\n let maxSide = Math.max(...inputArray);\n\n process.stdout.write(String(Math.max(2 * maxSide - inputArraySum + 1, 0)));\n \n process.exit();\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math", "geometry"], "code_uid": "3b787bb7f44ca72553ca0985966123da", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nfunction readLines(number, cb) {\n const lines = [];\n rl.on('line', function(line) {\n lines.push(line);\n if (lines.length === number) {\n rl.close();\n cb(lines);\n }\n });\n};\n\nfunction readLines(number, cb) {\n const lines = [];\n rl.on('line', function(line) {\n lines.push(line);\n if (lines.length === number) {\n rl.close();\n cb(lines);\n }\n });\n};\n\nfunction doIt(lines) {\n const n = parseInt(lines[0]);\n const w = Math.ceil(Math.sqrt(n));\n let h = 1;\n while (h*w < n) {\n h++\n }\n console.log(w+h);\n}\n\nreadLines(1, doIt);", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms", "binary search"], "code_uid": "58b451ebfd7b777c1b425ab525ed5c60", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let stop = '';\nprocess.stdin.on('data', c => stop += c);\nprocess.stdin.on('end', () => {\n const {EOL} = require('os');\n const lines = stop.split(EOL);\n var t = lines[0];\n for(i = 1; i <= t; i++){\n var n = lines[i];\n var a = new Map();\n for(j = 1; j * j <= n; j++){\n a.set(j * j, 1);\n }\n for(j = 1; j * j * j <= n; j++){\n a.set(j * j * j, 1);\n }\n console.log(a.size);\n }\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "c0fc0406d15eacf239d3090a9f40262b", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const arr = readLine()\n .split(\" \")\n .map((n) => parseInt(n));\n const map = {};\n let count = 0;\n arr.forEach((n) => {\n if (!map[n]) map[n] = 1;\n else count++;\n });\n\n console.log(count);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0b59b548222891e00f61c0c9cde96fa4", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar n,m,a;\nrl.on('line', (line) => {\n [n,m,a]=line.split(' ');\n}).on('close',()=>{\n var ans=Math.ceil(n/a)*Math.ceil(m/a);\n console.log(ans);\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "0fdb3e2010512ef86471983db0e99d0a", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nasync function algo() {\n let n = await int()\n let bills = 0\n ;[100, 20, 10, 5, 1].forEach(x => {\n bills += Math.floor(n / x)\n n = n % x\n })\n console.log(bills)\n}\n\n\n// read the input\nconst _lines = []\nlet _lineIndex = 0\nlet _ended = false\nconst _rl = readline.createInterface(process.stdin)\n_rl.on('line', line => _lines.push(line))\n_rl.on('end', () => (ended = true))\nconst wait = ms => new Promise(resolve => setTimeout(resolve, ms))\nconst line = async () => {\n while (!_ended && _lines.length <= _lineIndex) await wait(10)\n const result = _lines[_lineIndex].trim()\n _lines[_lineIndex] = null\n _lineIndex++\n return result\n}\nconst words = async () => (await line()).split(' ')\nconst chars = async () => (await line()).split('')\nconst int = async () => parseInt(await line())\nconst ints = async () => (await words()).map(x => parseInt(x))\nconst big = async () => BigInt(await line())\nconst bigs = async () => (await words()).map(x => BigInt(x))\n\nalgo()", "lang_cluster": "Javascript", "tags": ["greedy", "dp"], "code_uid": "f8b8d680b722f56a163d02811b489672", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\nconst bears = () => {\n let [limak, bob] = input[0].split(' ').map(x => +x);\n let count = 0;\n for (limak, bob; limak <= bob; limak*= 3, bob *= 2) {\n count++;\n }\n console.log(count);\n};\n\nreadLine.on('close', bears);", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "988c361b381f10a72056a789f575ca0d", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// http://codeforces.com/problemset/problem/977/A\nmodule.exports = solve;\nfunction solve(line) {\n let [n, minus] = line.split(' ');\n while (minus--) {\n if (n % 10) n--;\n else n = ~~(n / 10);\n }\n return n;\n}\n\n\nconst rl = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n \nrl.on('line', (line) => {\n console.log(solve(line))\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "ddf3c9eee59ad73d992303b6973f385d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let fs = require('fs');\nlet txt = fs.readFileSync(0, \"utf-8\").split(/[\\n\\r]/).filter(data => data.length > 0);\nlet ind, tab;\nfor (let i = 0; i < txt.length; i++) {\n ind = -Infinity;\n tab = [];\n let data = txt[i].split(\" \").filter(data => data.length > 0).map(data => data * 1);\n doit(data.shift(), ...data.sort((a, b) => b - a));\n}\n\nfunction doit(n, a, b, c) {\n calc(n, a, b, c, 0);\n console.log(ind);\n}\n\nfunction calc(n, a, b, c, index) {\n if(tab.includes(n))return;\n \n if(n===0){\n if(index>ind)ind=index;\n return;\n }else if(n= c) calc(n - c, a, b, c, index);\n if (n >= b) calc(n - b, a, b, c, index);\n if (n >= a) calc(n - a, a, b, c, index);\n return;\n}", "lang_cluster": "Javascript", "tags": ["brute force", "dp"], "code_uid": "ef8f79214618ff043f05e83a1d9ea4d6", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar idx = 0;\nvar out = 0;\nvar totalScores = 0;\nvar passScore = 0; \nrl.on(\"line\", (theLine) => {\n var lines = theLine.split(\" \");\n width = parseInt(lines[0]);\n height = parseInt(lines[1]);\n out = (width*height)/2;\n \n rl.close();\n console.log(Math.trunc(out).toString());\n }\n);", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "e9f48e870500c0bb565316a7305f3d58", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict'\n\nconst {EOL} = require('os')\n\nlet ipt = ''\nprocess.stdin.on('data', s => ipt += s)\nprocess.stdin.on('end', () => {\n const [a, b] = ipt.split(EOL).slice(0, -1)\n const c = ((+a + +b) + '').replace(/0/g, '') || 0\n const x = a.replace(/0/g, '') || 0\n const y = b.replace(/0/g, '') || 0\n const z = +x + +y\n console.log(c == z ? 'YES' : 'NO')\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "c23df05231e94537a11eacc4c52bc141", "src_uid": "ac6971f4feea0662d82da8e0862031ad", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//1191A\n\nconst readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nfunction rankHP(currentHP){\n if(currentHP % 4 == 1){\n return(1);\n } else if(currentHP % 4 == 3) {\n return(3);\n } else if (currentHP % 4 == 2) {\n return(2);\n } else if (currentHP % 4 == 0) {\n return(0);\n }\n}\n\nfunction rankAchievedToLetter(rankAchieved){\n if(rankAchieved == 1){\n return(' A');\n } else if(rankAchieved == 3) {\n return(' B');\n } else if (rankAchieved == 2) {\n return(' C');\n } else if (rankAchieved == 0) {\n return(' D');\n }\n}\n\nfunction getResult(hp){\n let ranks = [0,0,0];\n let rankAchieved = rankHP(hp);\n if (rankAchieved == '1'){\n return 0 + rankAchievedToLetter(rankAchieved);\n } else {\n ranks = [rankAchieved, rankHP(hp+1), rankHP(hp+2)];\n //console.log(ranks);\n if (ranks.includes(1)){\n obama = rankHP(ranks[ranks.indexOf(1)]);\n //console.log(obama);\n return (ranks.indexOf(1)) + rankAchievedToLetter(obama);\n } else {\n obama = ranks[ranks.indexOf(Math.max(...ranks))];\n //console.log(obama);\n return (ranks.indexOf(Math.max(...ranks))) + rankAchievedToLetter(obama);\n };\n \n };\n};\n\nrl.question('', (answer) => {\n hp = answer;\n //console.log('hp', hp, typeof hp);\n console.log(getResult(parseInt(hp)));\n process.exit();\n});", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "11f5c88214050e68f0603ef1491dc428", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n var T = readLine();\n var str = readLine().split(\"\");\n var count = [];\n for (let i = 0; i < str.length; i++) {\n let nextText = i + 1;\n if (str[i] === str[nextText]) {\n count.push(str[i]);\n }\n }\n console.log(count.length);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0ebf245fd00286e3a4202d1ccb12cb0b", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf8');\n\nvar input= '', readline, print;\n\nprocess.stdin.on('data', function(chunk) {\n input+=chunk;\n});\n\nprocess.stdin.on('end', function() {\n input = input.split('\\n');\n print = function(data) {process.stdout.write(data+'\\n')};\n var inputLineIndex = 0;\n readline = function(){return inputLineIndex>=input.length?undefined:input[inputLineIndex++]};\n\n process.exit(main(...input) || 0);\n});\n\nconst even = ['a', 'o', 'u', 'i', 'e'];\n\nfunction minPrice(n, v) {\n var currentPrice = Math.min(v, n - 1);\n var currentLiters = Math.min(v, n - 1);\n\n for(var i = 2; i < n; i++) {\n if(currentLiters >= n - 1) break;\n\n currentLiters++;\n currentPrice += i;\n }\n\n return currentPrice;\n}\n\nfunction main(n, v) {\n arr = n.split(' ');\n console.log(minPrice(+arr[0], +arr[1]));\n}\n\n//console.log(minPrice(4, 2)); // 1 2 3 4 5 -> 2 4 7", "lang_cluster": "Javascript", "tags": ["math", "greedy", "dp"], "code_uid": "131093a6bce349fa7168d3d72e0eed48", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar IsPrime = function (Num) {\n if (Num == 2)\n return true;\n if (Num < 2 || Num % 2 == 0)\n return false;\n let limit = parseInt(Math.sqrt(Num));\n for (let i = 3; i <= limit; i+=2){\n if (!(Num % i))\n return false;\n }\n return true;\n}\n\nrl.on('line', (input) => {\n let temp = input.split(' ').map(item => parseInt(item));\n let n = temp[0];\n let k = temp[1];\n let prev = 2, counter = 0;\n\n for (let i = 3; i < n; i++){\n if (IsPrime(i)){\n let helper = prev + i + 1;\n counter += (IsPrime(helper) && helper <= n);\n prev = i;\n }\n }\n console.log(counter >= k?\"YES\":\"NO\");\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math", "number theory"], "code_uid": "c5c34c955c320a4cee340984620d1f46", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nconst fs = require('fs');\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++].split(' ');\n}\n\nfunction readInt(s) {\n return parseInt(s, 10);\n}\n\nfunction readIntArray(a) {\n return a.map(e => parseInt(e, 10));\n}\n\nfunction solve(n, ar) {\n ar.sort((a, b) => a - b);\n let ans = (ar[n - 1] - ar[0]) % 2 === 0 ? (ar[n - 1] - ar[0]) / 2 : -1;\n for (let i = 0; i < n; i++) {\n if (ar[i] !== ar[0] && ar[i] !== ar[n - 1] && ar[i] !== ar[0] + ans) ans = -1;\n }\n if (ans === -1) {\n ans = ar[n - 1] - ar[0];\n for (let i = 0; i < n; i++) {\n if (ar[i] !== ar[0] && ar[i] !== ar[n - 1]) ans = -1;\n }\n }\n\n\n return ans;\n}\n\nfunction main() {\n\n const nk = readLine();\n\n const n = readInt(nk[0]);\n const a = readIntArray(readLine());\n\n let result = solve(n, a);\n console.log(result);\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "7db3d43c379ad7e126ad7234967100fc", "src_uid": "d486a88939c132848a7efdf257b9b066", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nconst getPrimes = (d) => {\n const maxN = d;\n const arr = new Array(maxN + 1).fill(1);\n arr[0] = 0;\n arr[1] = 0;\n\n for (let i = 2; i*i <= maxN; i++) {\n if (arr[i]) {\n for (let j = i*i; j <= maxN; j += i) {\n arr[j] = 0;\n }\n }\n }\n\n const primes = [];\n\n for (let i = 0; i < arr.length; i++) {\n if (arr[i]) {\n primes.push(i);\n }\n }\n\n return primes;\n}\n\nrl.on('line', (d) => {\n const primes = getPrimes(+d);\n\n let ans = 0;\n\n for (let i = 6; i <= +d; i++) {\n let primeDivisors = 0;\n for (let p = 0; p < primes.length; p++) {\n if (i % primes[p] === 0) {\n primeDivisors++;\n }\n }\n\n if (primeDivisors === 2) {\n ans++;\n }\n }\n\n console.log(ans);\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["number theory"], "code_uid": "a57c489ec922312c08a1b7b8671586be", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume()\nprocess.stdin.setEncoding('utf-8')\nlet inputs = \"\"\nprocess.stdin.on('data', rawData => inputs += rawData)\nprocess.stdin.on('end', _ => {\n inputs = inputs.trim().split('').map(line => parseInt(line))\n main()\n})\nfunction main() {\n let playersNumber = 0\n let team = 0\n let shouldExit = false\n let result = \"NO\"\n inputs.map((i,index) => {\n if (playersNumber === 7) {\n result = \"YES\"\n shouldExit = true\n return;\n }\n if (shouldExit)\n return;\n if (i !== team){\n team = i\n playersNumber = 0\n }\n playersNumber++\n })\n console.log(playersNumber >= 7 ? \"YES\" : \"NO\" )\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "e5da174029b19426f407edbb5199e727", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet data = [];\nrl.on('line', (input) => {\n data.push(input);\n});\n\nrl.on('close', () => {\n solve(data);\n});\n\nfunction solve(data) {\n\n [n, m] = data[0].split(\" \").map(x => parseInt(x));\n\n console.log(Math.floor(n * m / 2));\n\n}\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "2c9c9cbb6cec5aa113839c7e1c62cc7c", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet currentLine = 0;\nlet inputString = \"\";\n\nprocess.stdin.on(\"data\", (raw_data) => {\n inputString += raw_data;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((line) => {\n return line.trim();\n });\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n/******** Main function*************/\n\nfunction main() {\n var [a, b] = readLine().split(\" \").map(Number);\n\n if (a >= 1 && b <= 10) {\n var count = 0;\n for (;;) {\n if (a > b) {\n break;\n }\n a *= 3;\n b *= 2;\n count++;\n }\n console.log(count);\n }\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "5c38540db00f9acf16c292eb560a19d4", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": " process.stdin.resume();\n process.stdin.setEncoding('utf-8');\n \n let stdinInput = '';\n \n process.stdin.on('data', input => {\n stdinInput += input;\n })\n \n process.stdin.on('end', () => {\n main(stdinInput);\n })\n \n function main(data) {\n data = data.split('\\n');\n const contestant = data[0].split(' ');\n const score = data[1].split(' ');\n const kScore = +contestant[1] - 1;\n let count = 0;\n for (let i = 0; i < score.length; i += 1) {\n if (+score[i] < 1 || +score[i] < score[kScore]) break;\n count += 1;\n }\n process.stdout.write(count + '');\n }", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "6b8f2a34063b93168730b6c0775be32f", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let fs = require('fs');\nlet txt = fs.readFileSync(0, 'utf-8').split(\"\\r\\n\").filter(data => {\n return data.length > 0\n});\nfor (let index = 0; index < txt.length; index++) {\n let info=txt[index].split(\" \")\n subs(info[0]*1,info[1]*1)\n\n}\nfunction subs(num,count){\n let tab=String(num).split(\"\");\n while (count>0) {\n if(tab[tab.length-1]==0){\n tab.pop();\n }else{\n --tab[tab.length-1];\n }\n --count;\n }\n console.log(tab.join(\"\")); \n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "5076d058a320bcf4369b90d2994a48b0", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const str = \"hello\";\n let j = 0;\n let pass = 0;\n const inputStr = readLine();\n for (let i = 0; i < inputStr.length; i++) {\n if (str[j] === inputStr[i]) {\n j++;\n pass++;\n if (pass === 5) break;\n }\n }\n if (pass === 5) {\n console.log(\"YES\");\n } else {\n console.log(\"NO\");\n }\n}\n", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "798fc7d109607481b8a43ba6d7cfcb43", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input.push(parseInt(line));\n});\n\nRL.on('close', () => {\n let money = [100, 20, 10, 5, 1];\n let n = input[0];\n let count_b = 0;\n for(let i = 0; i < money.length; i++){\n while(true){\n if(n-money[i] >= 0){\n count_b++; n -= money[i];\n } else break;\n }\n }\n console.log(count_b);\n});\n\n", "lang_cluster": "Javascript", "tags": ["greedy", "dp"], "code_uid": "c3f7afb0c2ba053beec8d7a503f0325c", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false,\n});\n\nrl.on(\"line\", (d) => {\n const [start, shop1, shop2] = d.split(\" \").map(Number);\n\n console.log(\n Math.min(\n start * 2 + shop1 + shop2,\n start * 2 + shop1 * 2,\n start * 2 + shop2 * 2,\n shop1 * 2 + shop2 * 2,\n start + shop1 + shop2\n )\n );\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "89c737604b1f4fb3de313b766bda05d8", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction readAsInt(){\n return parseInt(readline());\n}\n\nfunction readAsIntList(){\n return readline().split(' ').filter(i => i).map(i => parseInt(i));\n}\n\n\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n const s1 = readline().toLowerCase();\n const s2 = readline().toLowerCase();\n for (let i = 0; i < s1.length; i++) {\n if (s1[i].charCodeAt() > s2[i].charCodeAt()) {\n console.log(1);\n return;\n }else if (s1[i].charCodeAt() < s2[i].charCodeAt()){\n console.log(-1);\n return;\n }\n }\n console.log(0);\n}\n\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "a1d16d070847469e5e66ec6bf4a68ef8", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet currentLine = 0;\nlet inputString = \"\";\n\nprocess.stdin.on(\"data\", (raw_data) => {\n inputString += raw_data;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((line) => {\n return line.trim();\n });\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n/******** Main function*************/\n\nfunction main() {\n var arr = readLine().split(\"\");\n\n var removedDuplicate = [...new Set(arr)];\n\n if (removedDuplicate.length % 2 == 0) {\n console.log(\"CHAT WITH HER!\");\n } else {\n console.log(\"IGNORE HIM!\");\n }\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "dbb9aebd3c332ae3c26c703eea684ec9", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\n// const fs = require('fs');\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n const nd = readLine().split(' ').map(value => parseInt(value));\n const n = nd[0];\n const k = nd[1];\n const arr = readLine().split(' ').map(value => parseInt(value));\n if (arr[0] == 0) {\n console.log(0);\n } else {\n arr.sort((a, b) => b - a);\n var ans = arr.splice(0, k);\n // console.log(ans);\n // console.log(ans[ans.length - 1])\n for (var i = ans.length - 1; i >= 0; i--) {\n if (ans[i] == 0) ans.pop();\n }\n // console.log(ans);\n for (var i = 0; i < arr.length; i++) {\n if (arr[i] === ans[ans.length - 1])\n ans.push(arr[i]);\n }\n console.log(ans.length);\n }\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f3dffd046cc4a5059e0b7ea9e8408920", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "function ProblemSolver() {\n this.HAS_TEST_CASES = false;\n this.INPUT_FILE_NAME = \"test.in\";\n this.OUTPUT_FILE_NAME = \"out.txt\";\n this.DO_OUTPUT_TO_FILE = false;\n this.CLEAR_ARRAY_PER_CASE = false;\n \n this.rec = function( arr , brr , firstFlag , cn ) {\n \tvar res , r1 , newArr , newBrr , fl , sz , i , sz1 , sz2 ;\n \tif( cn > 1000 ) {\n \t\treturn -1 ;\n \t}\n \tif( firstFlag == false && arr.length == this.baseCaseArr.length && brr.length == this.baseCaseBrr.length ) {\n \t\tfl = 1 ;\n \t\tsz = arr.length ;\n \t\tfor( i = 0 ; i < sz ; i++ ) {\n \t\t\tif( arr[ i ] != this.baseCaseArr[ i ] ) {\n \t\t\t\tfl = 0 ;\n \t\t\t\tbreak ;\n \t\t\t}\n \t\t}\n \t\tsz = brr.length ;\n \t\tfor( i = 0 ; i < sz ; i++ ) {\n \t\t\tif( brr[ i ] != this.baseCaseBrr[ i ] ) {\n \t\t\t\tfl = 0 ;\n \t\t\t\tbreak ;\n \t\t\t}\n \t\t}\n \t\tif( fl == 1 ) {\n \t\t\treturn -1 ;\n \t\t}\n \t}\n \tif( arr.length == 0 ) {\n \t\tthis.winner = 2 ;\n \t\treturn 0 ;\n \t}\n \tif( brr.length == 0 ) {\n \t\tthis.winner = 1 ;\n \t\treturn 0 ;\n \t}\n \tnewArr = [] ;\n \tnewBrr = [] ;\n \tsz1 = arr.length ;\n \tsz2 = brr.length ;\n \tfor( i = 1 ; i < sz1 ; i++ ) {\n\t\t\tnewArr.push( arr[ i ] ) ;\n\t\t}\n\t\tfor( i = 1 ; i < sz2 ; i++ ) {\n\t\t\tnewBrr.push( brr[ i ] ) ;\n\t\t}\n \tif( arr[ 0 ] > brr[ 0 ] ) {\n \t\tnewArr.push( brr[ 0 ] ) ;\n \t\tnewArr.push( arr[ 0 ] ) ;\n \t}\n \telse {\n \t\tnewBrr.push( arr[ 0 ] ) ;\n \t\tnewBrr.push( brr[ 0 ] ) ;\n \t}\n \tr1 = this.rec( newArr , newBrr , false , cn + 1 ) ;\n \tif( r1 == -1 ) {\n \t\tres = -1 ;\n \t}\n \telse {\n \t\tres = r1 + 1 ;\n \t}\n \treturn res ;\n } ;\n\n this.solveCase = function() {\n var res , i , j , fl , cn , temp ;\n res = 0 ;\n this.baseCaseArr = [] ;\n for( i = 0 ; i < this.k1 ; i++ ) {\n \tthis.baseCaseArr.push( this.arr[ i ] ) ;\n }\n this.baseCaseBrr = [] ;\n for( i = 0 ; i < this.k2 ; i++ ) {\n \tthis.baseCaseBrr.push( this.brr[ i ] ) ;\n }\n this.winner = -1 ;\n res = this.rec( this.arr , this.brr , true , 0 ) ;\n if( res == -1 ) {\n \tprint( res );\n }\n else {\n \tprint( res + ' ' + this.winner );\n }\n };\n\n this.init = function() {\n this.lim1 = 100010;\n this.lim2 = 110;\n this.cc = 1;\n this.ind = 1;\n this.n = 0;\n this.cn = 0;\n this.declareAndFillArrays();\n };\n\n this.getInput = function( irObj ) {\n var hasMoreInput , i;\n hasMoreInput = true;\n try {\n this.n = irObj.nextInt();\n this.k1 = irObj.nextInt();\n this.arr = [] ;\n for( i = 0 ; i < this.k1 ; i++ ) {\n this.arr.push( irObj.nextInt() ) ;\n }\n this.brr = [] ;\n this.k2 = irObj.nextInt();\n for( i = 0 ; i < this.k2 ; i++ ) {\n this.brr.push( irObj.nextInt() ) ;\n }\n }\n catch( ex ) {\n hasMoreInput = false;\n }\n return hasMoreInput;\n };\n\n this.clearArraysPerCase = function() {\n var i;\n this.arr = new Array();\n this.adj_list = new Array();\n for( i = 0 ; i < this.lim1 ; i++ ) {\n this.arr.push( 0 );\n this.adj_list.push( new Array() );\n }\n };\n\n this.clearPerCase = function() {\n this.cn = 0;\n this.cc++;\n if( this.CLEAR_ARRAY_PER_CASE == true ) {\n this.clearArraysPerCase() ;\n }\n };\n\n this.declareAndFillArrays = function() {\n var i , j;\n this.srr = new Array();\n this.vis = new Array();\n this.arr = new Array();\n this.brr = new Array();\n this.memo = new Array();\n this.done = new Array();\n this.adj_list = new Array();\n for( i = 0 ; i < this.lim1 ; i++ ) {\n this.srr.push( \"\" );\n this.vis.push( 0 );\n this.arr.push( 0 );\n this.brr.push( 0 );\n this.adj_list.push( new Array() );\n }\n for( i = 0 ; i < this.lim2 ; i++ ) {\n this.memo.push( new Array() );\n this.done.push( new Array() );\n for( j = 0 ; j < this.lim2 ; j++ ) {\n this.memo[ i ].push( -1 );\n this.done[ i ].push( 0 );\n }\n }\n };\n\n this.init();\n}\n\nfunction InputReader() {\n var self = this ;\n this.allLines = new Array();\n this.currrentLineNumber = 0;\n this.currrentCharacterIndex = 0;\n this.callBackFunction = null ;\n this.parentContext = null ;\n\n this.readAllLines = function() {\n var singleLine;\n while( true ) {\n try {\n singleLine = readline();\n if( singleLine == null ) {\n break;\n }\n }\n catch( ex ) {\n break;\n }\n this.allLines.push( singleLine );\n }\n };\n \n this.readAllLinesFromRhino = function() {\n var brObj , line ;\n importPackage( java.io ) ;\n importPackage( java.lang ) ;\n brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;\n this.allLines = [] ;\n while( true ) {\n line = brObj.readLine() ;\n if( line == null ) {\n break;\n }\n this.allLines.push( line ) ;\n }\n };\n \n this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {\n self.chunkData += chunk ;\n };\n\n this.readEndFromNodeJsJudgeServer = function() {\n self.parseRawData( self.chunkData ) ;\n self.parentContext.runCases() ;\n };\n \n this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {\n this.parentContext = parentContext ;\n process.stdin.resume() ;\n process.stdin.setEncoding( 'utf8' ) ;\n this.chunkData = '' ;\n process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;\n process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;\n };\n\n this.parseRawData = function( data ) {\n var len , i , currentString;\n len = data.length;\n currentString = \"\";\n this.allLines = [] ;\n for( i = 0 ; i < len ; i++ ) {\n if( data[ i ] == '\\r' ) {\n }\n else if( data[ i ] == '\\n' ) {\n this.allLines.push( currentString );\n currentString = \"\";\n }\n else {\n currentString += data[ i ];\n }\n }\n if( currentString != \"\" ) {\n this.allLines.push( currentString );\n }\n };\n\n this.readAllLinesFromFile = function( inputFileName ) {\n var currentDirectory , fsObj , inputFilePath , rawData;\n fsObj = require( 'fs' );\n currentDirectory = __dirname;\n inputFilePath = currentDirectory + \"\\\\\" + inputFileName;\n rawData = fsObj.readFileSync( inputFilePath , \"utf8\" );\n this.parseRawData( rawData );\n };\n\n this.next = function( flag ) {\n var len , i , startIdx , res , endIdx;\n if( flag == 0 ) {\n if( this.currrentCharacterIndex != 0 ) {\n this.currrentLineNumber++;\n this.currrentCharacterIndex = 0;\n }\n res = \"\";\n len = this.allLines[ this.currrentLineNumber ].length;\n if( typeof( len ) == 'function' ) {\n len = this.allLines[ this.currrentLineNumber ].length() ;\n }\n for( i = this.currrentCharacterIndex ; i < len ; i++ ) {\n res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;\n }\n this.currrentLineNumber++;\n this.currrentCharacterIndex = 0;\n return res;\n }\n while( true ) {\n if( this.currrentLineNumber >= this.allLines.length ) {\n throw new Error( \"No more tokens available!\" );\n }\n startIdx = -1;\n len = this.allLines[ this.currrentLineNumber ].length;\n if( typeof( len ) == 'function' ) {\n len = this.allLines[ this.currrentLineNumber ].length() ;\n }\n for( i = this.currrentCharacterIndex ; i < len ; i++ ) {\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {\n startIdx = i;\n break;\n }\n }\n if( startIdx == -1 ) {\n this.currrentLineNumber++;\n this.currrentCharacterIndex = 0;\n continue;\n }\n res = \"\";\n endIdx = len - 1 ;\n for( i = startIdx ; i < len ; i++ ) {\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {\n endIdx = i;\n break;\n }\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {\n res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;\n }\n else {\n res += '' + this.allLines[ this.currrentLineNumber ].charAt( i );\n }\n }\n this.currrentCharacterIndex = endIdx;\n if( endIdx == len - 1 ) {\n this.currrentLineNumber++;\n this.currrentCharacterIndex = 0;\n }\n return res;\n }\n };\n\n this.nextInt = function() {\n return parseInt( this.next( 1 ) );\n };\n\n this.nextDouble = function() {\n return parseFloat( this.next( 1 ) );\n };\n\n this.nextString = function() {\n return this.next( 1 );\n };\n\n this.nextLine = function() {\n return this.next( 0 );\n };\n}\n\nfunction FileOutputHandler() {\n this.resultantStringArray = new Array();\n\n this.addNewLine = function( newString ) {\n this.resultantStringArray.push( newString );\n };\n\n this.clearPercase = function() {\n this.resultantStringArray = new Array();\n };\n\n this.flushOutOutputToFile = function( outputFileName ) {\n var i , sz , res , currentDirectory , fsObj , outputFilePath;\n res = \"\";\n sz = this.resultantStringArray.length;\n for( i = 0 ; i < sz ; i++ ) {\n if( i != 0 ) {\n res += \"\\n\";\n }\n res += this.resultantStringArray[ i ];\n }\n fsObj = require( 'fs' );\n currentDirectory = __dirname;\n outputFilePath = currentDirectory + \"\\\\\" + outputFileName;\n fsObj.writeFileSync( outputFilePath , res );\n this.clearPercase();\n };\n}\n\nfunction CodeExecutioner() {\n this.irObj = new InputReader();\n this.psObj = new ProblemSolver();\n this.fohObj = new FileOutputHandler();\n\n this.runCases = function() {\n if( this.psObj.HAS_TEST_CASES == true ) {\n testCases = this.irObj.nextInt();\n for( i = 0 ; i < testCases ; i++ ) {\n this.psObj.clearPerCase();\n this.psObj.getInput( this.irObj );\n this.psObj.solveCase();\n }\n }\n else {\n while( true ) {\n this.psObj.clearPerCase();\n hasMoreTestCases = this.psObj.getInput( this.irObj );\n if( hasMoreTestCases == false ) {\n break;\n }\n this.psObj.solveCase();\n }\n }\n if( this.psObj.DO_OUTPUT_TO_FILE == true ) {\n this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );\n }\n };\n\n this.detectEnvironmentType = function() {\n var environmentType = null ;\n try {\n if( importPackage != null ) {\n environmentType = 'rhino' ;\n }\n }\n catch( ex1 ) {\n try {\n //for nodejs local server check\n if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {\n environmentType = 'local-node-js' ;\n }\n }\n catch( ex2 ) {\n try {\n if( readline == null || typeof( readline ) != 'function' ) {\n environmentType = 'server-node-js' ;\n }\n else {\n try {\n if( Map != null ) {\n environmentType = 'spider-monkey' ;\n }\n else {\n environmentType = 'javascript-v8' ;\n }\n }\n catch( ex3 ) {\n environmentType = 'javascript-v8' ;\n }\n }\n }\n catch( ex3 ) {\n environmentType = 'server-node-js' ;\n }\n }\n }\n return environmentType ;\n };\n\n this.configureStreamsAndReadInput = function() {\n var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , environmentType ;\n isNodeJsJudgeServer = false ;\n environmentType = this.detectEnvironmentType() ;\n if( environmentType == 'local-node-js' ) {\n try {\n if( print == null || typeof( print ) != 'function' ) {\n print = console.log;\n }\n }\n catch( ex ) {\n print = console.log;\n }\n if( this.psObj.DO_OUTPUT_TO_FILE == true ) {\n localContext = this.fohObj;\n print = function() {\n localContext.addNewLine.apply( localContext , arguments );\n }\n }\n this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );\n this.runCases() ;\n }\n else if( environmentType == 'server-node-js' ) {\n try {\n if( print == null || typeof( print ) != 'function' ) {\n print = console.log;\n }\n }\n catch( ex ) {\n print = console.log;\n }\n this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;\n }\n else if( environmentType == 'javascript-v8' ) {\n this.irObj.readAllLines();\n this.runCases() ;\n }\n else if( environmentType == 'rhino' ) {\n this.irObj.readAllLinesFromRhino();\n this.runCases() ;\n }\n else if( environmentType == 'spider-monkey' ) {\n this.irObj.readAllLines();\n this.runCases() ;\n }\n };\n \n this.configureStreamsAndReadInput();\n}\n\nnew CodeExecutioner();\n", "lang_cluster": "Javascript", "tags": ["dfs and similar", "brute force", "games"], "code_uid": "6817ffa14db099969ab019ff874e14f0", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "(()=>{\"use strict\";var t={675:(t,e)=>{Object.defineProperty(e,\"__esModule\",{value:!0}),Array.prototype.sortAsc=function(){return this.sort(((t,e)=>t-e))},Array.prototype.sortDesc=function(){return this.sort(((t,e)=>e-t))},Array.prototype.max=function(){return Math.max(...this)},Array.prototype.min=function(){return Math.min(...this)},Array.prototype.sum=function(){let t=0;for(let e=0;e{if(l)return s=o.default.readFileSync(\"input.txt\").toString().trim().split(\"\\n\").map((t=>t.trim())),t(),void o.default.writeFileSync(\"output.txt\",a);process.stdin.resume(),process.stdin.setEncoding(\"utf-8\"),process.stdin.on(\"data\",(t=>{u+=t})),process.stdin.on(\"end\",(e=>{s=u.trim().split(\"\\n\").map((t=>t.trim())),t(),console.log(a)}))};function f(){return s[i++]}function p(){return f().split(\" \").map((t=>parseFloat(t)))}function d(){return f().split(\"\")}e.default={runMain:c,runEachTest:t=>{c((()=>{let[e]=p();for(;e>0;)t(),e--}))},readline:f,nextNumbers:p,nextNumbersMatrix:function(t){let e=[];for(let r=0;rt.join(\" \"))).join(\"\\n\"));break}}}))},747:t=>{t.exports=require(\"fs\")}},e={};!function r(n){if(e[n])return e[n].exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,r),o.exports}(965)})();", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "a1db0a2d7c8fde1aab7e2ef15fff4f90", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n let [n, m] = readLine().split(' ').map(Number);\n let puzzles = readLine().split(' ').map(Number); //[4 4]\n // let sorted = [];\n // for (let i = 0; i < n; i++) {\n // sorted.push(puzzles[i]);\n // }\n // sorted.sort((a, b) => a - b);\n // console.log(sorted[sorted.length - 1] - sorted[0]);\n puzzles.sort((a, b) => a - b);\n\n let min = 10000000000;\n // for (let i = 0; i < puzzles.length; i++) {\n // for (j = 0; j < puzzles.length; j++) {\n // if (i === j) {\n // continue;\n // }\n // let diff = Math.abs(puzzles[i] - puzzles[j]); // puzzles [0+2 -1]\n // if (diff < min) {\n // min = diff;\n // }\n // }\n // }\n for (let i = 0; i <= m - n; i++) {\n min = Math.min(min, puzzles[i + n - 1] - puzzles[i]);\n }\n console.log(min);\n}\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "cffdfbc0d991d34aa0a63651111c2121", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nlet matrix = [];\nrl.on(\"line\",(input)=>{\n let row = input.split(\" \").map(Number)\n matrix.push(row)\n if(matrix[4]){\n rl.close();\n let perfectRow = 3;\n let perfectCol = 3;\n let steps = 0 ;\n let currentRow = null\n let currentCol = null\n matrix.forEach((row,index) => {\n if(row.includes(1)){\n currentRow = index+1; \n row.forEach((col,index)=>{\n if(col==1) currentCol = index+1;\n })\n\n }\n if (currentRow!=perfectRow || currentCol!=perfectCol ) {\n steps = Math.abs(currentCol - perfectCol)+Math.abs(currentRow-perfectRow);\n if (steps === 6) steps = 0\n }\n\n });\n console.log(steps)\n\n }\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "10e9ed30ae45395b93afffc130585236", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n let [area1, area2, area3] = readLine().split(' ').map(Number);\n let a = Math.round(Math.sqrt((area1 * area3) / area2));\n let b = Math.round(Math.sqrt((area1 * area2) / area3));\n let c = Math.round(Math.sqrt((area2 * area3) / area1));\n console.log(4 * (a + b + c));\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "geometry"], "code_uid": "35f5dbb710e2f179c90efc17cfdfa170", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on(\"data\", (d)=>{\n let data = d.toString().split(' ');\n let n = parseInt(data[0]);\n let p = parseInt(data[1]);\n let k = parseInt(data[2]);\n let answer = \"\";\n let left = p - k;\n if(left > 1) answer =\"<< \";\n else left = 1;\n let right = p + k > n ? n : p + k;\n for(let i = left; i < p; i++) answer += `${i} `;\n answer +=`(${p}) `;\n for(let i = p + 1; i <= right; i++) answer +=`${i} `;\n if(p + k < n) answer += \">>\";\n console.log(answer);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e6191cd06a915e9390452a46b3408871", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\n \nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n \nrl.question('', function(line) {\n let [n, k] = line.split(' ').map(x => +x);\n for (let i = 0; i < k; i++) {\n if (n % 10 > 0) {\n n--;\n }\n else {\n n /= 10;\n }\n }\n console.log(n);\n});\n \nrl.on(\"close\", function() {\n process.exit(0);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3bfc58a03cc61ba33b20b934cc34040f", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nfunction game23 (t, s) {\n if (t%s !== 0) return -1\n \n let steps = 0, rem = t/s\n while (rem > 1) {\n if (rem % 2 === 0) {\n rem /= 2\n steps++\n\t\t\tcontinue;\n }\n \n if (rem % 3 === 0) {\n rem /= 3\n steps++\n\t\t\tcontinue;\n }\n\n\t\treturn -1\n }\n \n return steps\n}\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\nrl.question('', answer => {\n const nums = answer.split(' ').map(x => Number(x))\n rl.close()\n console.log(game23(nums[1], nums[0]))\n})\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "68a4340e10d5d97f7fe330fc8d0f02d1", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nlet _inputLines;\nlet _lineNumber = 0;\nlet inputReader = _inputReader ();\n\nfunction _main() {\n\t\n\t_inputLines = _inputData.trim().split('\\n').map((string) => {\n\t\treturn string.trim();\n\t});;\n\tlet n = inputReader.readNumber();\n\tlet result = 1;\n\tfor(let i =2;i {\n let [d, ...arr] = data.split(' ').map(Number).reverse();\n arr.sort((a, b) => a - b);\n let ans = 0;\n let d1 = Math.abs(arr[0] - arr[1]);\n let d2 = Math.abs(arr[1] - arr[2]);\n\n if (d1 < d) {\n ans += d - d1;\n }\n\n if (d2 < d) {\n ans += d - d2;\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "46450c61b94f313c6e39799dc3c89c0f", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const state = { stdin: Buffer.alloc(0) };\nconst consume = (chunk) =>\n (state.stdin = Buffer.concat(\n [state.stdin, chunk],\n state.stdin.length + chunk.length\n ));\nconst commit = (answer) => process.stdout.write(answer);\n//\nconst main = (args) => {\n let data = parseInt(state.stdin.toString(\"utf8\"));\n let solution = \"NO\";\n\n for (let i = 1; i < data; i++) {\n if (i % 2 === 0 && (data - i) % 2 === 0) {\n solution = \"YES\";\n commit(solution);\n return;\n }\n }\n commit(solution);\n};\n\nprocess.stdin.on(\"data\", consume).on(\"end\", main);\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "0ecfd72bf4f7a36fad9b0bf1953c3123", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict'; /*jslint node:true, browser:true, es6:true*/\nconst rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })\nconst print = console.log\nconst lines = []\nrl.on('line', line => {\n lines.push(line);\n});\nrl.on('close', main)\nlet rli = 0;\nfunction readline() {\n return lines[rli++];\n}\n\nfunction query(arr){\n let set = new Set(arr);\n if (set.size==1)\n return print('NO');\n print('YES');\n let left = [], last;\n for (let i=1; i+a);\n query(arr);\n }\n}\n", "lang_cluster": "Javascript", "tags": ["math", "combinatorics"], "code_uid": "342c8a3aac763ca8e279cd5c127715e4", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let data = '';\nprocess.stdin.on('data', c => data += c);\n\nfunction* nextLine() {\n\tlet lines = data.trim().split(/\\n/g);\n\tfor(let l of lines){\n\t\tyield l.trim();\n\t}\n}\n\nlet nl = nextLine();\n\nnl.num = function() {\n\t\treturn Number(this.next().value);\n\t};\nnl.nums = function() {\n\t\treturn this.next().value.split(/\\s/g).map(Number);\n\t};\nnl.line = function() {\n\t\treturn this.next().value;\n\t}\n\t\nconst sol = () => {\n\tlet n = nl.num();\n\tlet ans = [8, 4, 2, 6];\n\tif (n === 0){\n\t\tconsole.log(1);\n\t} else {\n\t\tconsole.log(ans[(n-1)%4]);\n\t}\n\n};\n\nprocess.stdin.on('end', sol);\n", "lang_cluster": "Javascript", "tags": ["math", "implementation", "number theory"], "code_uid": "3482cd12373be24eb04813622c3c54ba", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Solved by RuX\nvar _0x4fdd=['line','exec','index','lastIndex','floor','createInterface','stdin','stdout'];(function(_0x2b23ce,_0x1f3085){var _0x2ac399=function(_0x39796d){while(--_0x39796d){_0x2b23ce['push'](_0x2b23ce['shift']());}};_0x2ac399(++_0x1f3085);}(_0x4fdd,0x1ed));var _0x891b=function(_0x1c3df1,_0x44e524){_0x1c3df1=_0x1c3df1-0x0;var _0x5b31e0=_0x4fdd[_0x1c3df1];return _0x5b31e0;};var readline=require('readline');var rl=readline[_0x891b('0x0')]({'input':process[_0x891b('0x1')],'output':process[_0x891b('0x2')]});var readString='';var ___c=0x0;rl['on'](_0x891b('0x3'),function(_0x56c738){___c+=0x1;if(___c==0x1){readString=_0x56c738;rl['close']();var _0x503784=parse(readString,0x2);console['log'](result(parseInt(_0x503784[0x0]),parseInt(_0x503784[0x1])));}});function parse(_0x2c642c,_0x5b2db2){var _0x50927a=[];var _0x5eda5e=/\\d+/gm;var _0x245740=_0x2c642c;var _0xfb3210;var _0x2940ba=0x0;while((_0xfb3210=_0x5eda5e[_0x891b('0x4')](_0x245740))!==null){if(_0xfb3210[_0x891b('0x5')]===_0x5eda5e['lastIndex']){_0x5eda5e[_0x891b('0x6')]++;}if(_0x2940ba==_0x5b2db2){break;}_0x50927a[_0x2940ba]=_0xfb3210[0x0];_0x2940ba+=0x1;}return _0x50927a;}function result(_0x29a132,_0x1aea3a){var _0x22dd2e=_0x29a132>_0x1aea3a?_0x1aea3a:_0x29a132;_0x22dd2e=_0x29a132>=_0x1aea3a?_0x22dd2e-0x1:_0x22dd2e;var _0x301f27=_0x1aea3a-_0x29a132;_0x301f27=_0x301f27<=0x0?0x1:_0x301f27>=_0x29a132?_0x29a132:_0x301f27;return Math[_0x891b('0x7')]((_0x22dd2e-_0x301f27+0x1)/0x2);}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "1a8fad98e7023b9245e7362cff2cef9e", "src_uid": "98624ab2fcd2a50a75788a29e04999ad", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(str) {\n\n let inputs = str.trim().split(' ').map(num => Number(num)).sort((a, b) => a - b);\n let midFriend = +inputs[1];\n let total = +inputs[2] - midFriend;\n total += midFriend - +inputs[0];\n return total.toString();\n\n}\n\n\n\n\n\n", "lang_cluster": "Javascript", "tags": ["math", "sortings", "implementation"], "code_uid": "85661f7a3a34432e15d93b62ebeab557", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data',c=>{[n,m,a]=c.toString().split(' ');x=Math.ceil;console.log(x(n/a)*x(m/a))})", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "59df12492803f57d03b426157094d039", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n const arr = d.split(' ').map(Number);\n let watchedTime = 15;\n\n for (let i = 0; i < arr.length; i++) {\n if (watchedTime < arr[i]) {\n break;\n }\n else {\n watchedTime = arr[i];\n watchedTime += 15;\n }\n }\n\n console.log(Math.min(watchedTime, 90));\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "4b6ab6d3db37390080ab725e4625e5ad", "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\n/**\n * \n * @param {*} str \n * @param {*} seperator \n */\nfunction splitter(str, seperator = '') {\n return str.trim().split(seperator);\n}\n\n/**\n * \n * @param {*} arr \n */\nfunction strToNumArr(arr = []) {\n return arr.map(num => Number(num));\n}\n\n/**\n * \n * @param {*} num1 \n * @param {*} num2 \n */\nfunction matrixArray(num1, num2) {\n return Array(num1).fill(Array(num2));\n}\n\nlet log = function () {\n return Function.prototype.bind.call(console.log, console, '');\n}();\n\nfunction removeEmptyItem(arr, index) {\n return arr.slice(0, index).concat(arr.slice(index + 1, arr.length));\n}\n\nfunction range(min, max) {\n\n let arr = [];\n for (let index = min; index < max; index++) {\n arr.push(index);\n\n }\n return arr;\n}\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(str) {\n\n let inputs = str.split('\\n');\n let tCard = inputs[0].trim();\n let handCards = inputs[1].trim().split(' ');\n let rank = [2, 3, 4, 5, 6, 7, 8, 9, 'T', 'J', 'Q', 'K', 'A'];\n let suits = ['D', 'C', 'S', 'H'];\n let tCardRank = tCard[0];\n let tCardSuit = tCard[1];\n let msg = 'NO';\n for (let row of handCards) {\n\n // for rank\n if (tCardRank === row[0]) {\n msg = 'YES';\n break;\n\n }\n if (tCardSuit === row[1]) {\n msg = 'YES';\n break;\n }\n }\n\n return msg.toString();\n}\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "68edfbf9a650019badeb71d4543270f8", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let buf='';\r\n\r\nprocess.stdin.on('readable',function(){\r\n let chunk=process.stdin.read();\r\n if(chunk) buf+=chunk.toString();\r\n})\r\n\r\nprocess.stdin.on('end',function(){\r\n let line=buf.split(' ');\r\n let n=parseInt(line[0]),m=parseInt(line[1]);\r\n if(m!==1)\r\n {\r\n let a=BigInt(n);\r\n let b=BigInt(m-1);\r\n let ans=a*b;\r\n console.log(ans.toString());\r\n }\r\n else console.log(n-1);\r\n})", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "81d46ee83384c920323689f76403695a", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n let [n, m] = readLine().split(' ').map(Number);\n let max = Math.max(n, m);\n let loopMax = Math.round(Math.sqrt(max));\n let count = 0;\n for (let i = 0; i <= loopMax; i++) {\n for (let j = 0; j <= loopMax; j++) {\n if (i * i + j === n && j * j + i === m) {\n count++;\n }\n }\n }\n console.log(count);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "d0051362df61aecaec7f40798fb5ecb2", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let lines = [];\nrequire('readline').createInterface({input: process.stdin,output: process.stdout})\n\t\t\t\t.on('line', line => {lines.push(line);})\n\t\t\t\t.on('close', () => {main(lines)});\n\nconst main = (input) => {\n\tinput = parseInt(input);\n\tvar hundreds = Math.floor(input / 100);\n\tvar counter = hundreds;\n\tinput -= hundreds * 100;\n\twhile(input > 0) {\n\t\tcounter++;\n\t\tif (input >= 100) {\n\t\t\tinput -= 100;\n\t\t} else if (input >= 20) {\n\t\t\tinput -= 20;\n\t\t} else if (input >= 10) {\n\t\t\tinput -= 10;\n\t\t} else if (input >= 5) {\n\t\t\tinput -= 5;\n\t\t} else if (input >= 1) {\n\t\t\tinput -= 1;\n\t\t}\n\t}\n\tconsole.log(counter);\n}", "lang_cluster": "Javascript", "tags": ["greedy", "dp"], "code_uid": "5a0700179bfde14e32fd9e3ea42901b6", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function gcd(a, b) {\n if ((a < 0) || (b < 0)) {\n throw Error('both inputs must be non-negative');\n } else if (a === 0) {\n if (b === 0) {\n throw Error('both inputs cannot be zero');\n } else {\n return b;\n }\n } else if (b === 0) {\n return a;\n } else {\n let m = Math.min(a, b);\n for (let i = m; i > 0; i = i - 1) {\n const x = a % i;\n const y = b % i;\n if ((x === 0) && (y === 0)) {\n return i;\n }\n }\n throw Error('this should not happen');\n }\n}\n\nfunction solve(y, w) {\n const num_faces = 6;\n const n = num_faces - Math.max(y, w) + 1;\n const g = gcd(n, num_faces);\n const a = n / g;\n const b = num_faces / g;\n return `${a}/${b}`;\n};\n\nfunction main(lines) {\n const trim_lines = [];\n for (const line of lines) {\n const t = line.trim();\n if (t.length > 0) {\n trim_lines.push(t);\n }\n }\n const [line] = trim_lines;\n const [y, w] = line.split(/\\s+/).map(Number);\n const result = solve(y, w);\n console.log(result);\n};\n\nasync function processLinesFromStream(rs, pf) {\n const content = [];\n rs.setEncoding('utf-8');\n for await (let chunk of rs) {\n content.push(chunk);\n }\n const lines = content.join('').split(/\\n/);\n const result = pf(lines);\n return result;\n};\n\nprocessLinesFromStream(process.stdin, main);\n", "lang_cluster": "Javascript", "tags": ["math", "probabilities"], "code_uid": "b4cd3e4adba3498283b10820039b2f32", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var s = nextCharArray();\n var t = next();\n var check = \"\";\n while(s.length > 0){\n check += s.pop();\n }\n if(check == t){\n myout(\"YES\");\n }else{\n myout(\"NO\");\n }\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "50233e28231e8ace51bb2bbfb4c98150", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction distinct(y) {\n\ty = y.toString(10).split('');\n\tlet { length } = y;\n\n\treturn length === [...new Set(y)].length;\n}\n\nfunction main() {\n\tlet y = readLine() >> 0;\n\ty++;\n\twhile (!distinct(y)) {\n\t\ty++;\n\t}\n\tconsole.log(y);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "6a74c6b81c230346c02ac9d72334c566", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl1 = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nconst canDivide = (aWeight) => {\n if(typeof aWeight === 'number' && aWeight >= 1 && aWeight <= 100) {\n if(aWeight % 2 === 0) {\n const dividedWeight = aWeight/2;\n if(dividedWeight > 1) {\n return 'YES'\n }\n }\n }\n\n return 'NO';\n} \n\nrl1.on('line', (aInput) => {\n let weight = parseInt(aInput);\n console.log(canDivide(weight));\n rl1.close();\n});\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "a2d947d45b60834a8f633accc5e29086", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n//const lineReader = require('fs');\n//const scanner = lineReader.createReadStream('main.in');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n}); \n\nfunction reverse(str) {\n return str.split(\"\").reverse().join(\"\");\n}\n\nrl.on('line', (input) => {\n x = input;\n x = reverse(x);\n let an = 0, one = 0;\n for (let i = 0; i < x.length; i++){\n if (i % 2 === 0)an++;\n if (x.charAt(i) === '1')one++;\n }\n if (one === 1 && x.length % 2 === 1 || one === 0 && x.length % 2 === 1)an--;\n console.log(an);\n rl.close(); \n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "e6e4a635124e16f43b9d826004839909", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.question('', (input) => {\n let x = input.split(' ');\n \n let y = Math.ceil(x[0] / x[2]);\n let z = Math.ceil(x[1] / x[2]);\n\n console.log(y * z);\n\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "1611971a177729ad46afc289e5e9d999", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet stdin = '';\n\nprocess.stdin.on('data', (input) => {\n stdin += input;\n});\n\nprocess.stdin.on('end', () => {\n const data = stdin.split('\\n')[1];\n\n let counter = 0;\n let current;\n\n for (const value of data) {\n if (value === current) counter++;\n else current = value;\n }\n\n process.stdout.write(String(counter));\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "626208ada2fea1c76d4ad77b3d303dd6", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\r\nconst fs = require(\"fs\");\r\n//let filename = \"0.txt\";\r\nlet filename = 0;\r\nconst input = fs.readFileSync(filename, \"utf8\").trim().split(\"\\n\");\r\nlet line = 0;\r\nfunction readline() {\r\n return input[line++];\r\n}\r\nfunction iInpArr() {\r\n return readline()\r\n .trim()\r\n .split(\" \")\r\n .map((cur) => parseInt(cur));\r\n}\r\nfunction BInpArr() {\r\n return readline()\r\n .trim()\r\n .split(\" \")\r\n .map((cur) => BigInt(cur));\r\n}\r\nfunction string() {\r\n return readline().trim();\r\n}\r\nfunction stringArr() {\r\n return readline().trim().split(\"\");\r\n}\r\nfunction getValue() {\r\n return parseInt(readline());\r\n}\r\nlet mod = BigInt(1e9 + 7);\r\nconst solve = () => {\r\n let t = getValue();\r\n while (t--) {\r\n let [n, k] = BInpArr();\r\n const pow = (n, k) => {\r\n if (k === 0n) return 1n;\r\n let x = pow(n, k / 2n);\r\n if (k % 2n) return (n * ((x * x) % mod)) % mod;\r\n else return (x * x) % mod;\r\n };\r\n console.log(pow(n, k) + \"\");\r\n }\r\n};\r\nsolve();\r\n", "lang_cluster": "Javascript", "tags": ["math", "combinatorics", "bitmasks"], "code_uid": "dbd459fd1510800de4f90719f3b6c915", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n\nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n \nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n let [n] = input[0].split(' ').map(x => parseInt(x));\n\n if (n === 1) { console.log(1); return; }\n if (n === 2) { console.log(3); return; }\n \n let sum = n;\n for (let i = 1; i < n; i += 1) {\n sum += (n-i)*i;\n }\n\n console.log(sum);\n});", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "9a0517685f3dc6de78be221bf964f6f5", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const state = { stdin: Buffer.alloc(0) };\nconst consume = (chunk) =>\n (state.stdin = Buffer.concat(\n [state.stdin, chunk],\n state.stdin.length + chunk.length\n ));\nconst commit = (answer) => process.stdout.write(answer);\n//\nconst main = (args) => {\n let data = parseInt(state.stdin.toString(\"utf8\"));\n // let solution = \"NO\";\n // num%2 === 0 ? num/parts+1 : num/parts\n if(data < 3) return commit(\"NO\");\n return data % 2 === 0 && commit(\"YES\") || commit(\"NO\");\n // for (let i = 1; i < data; i++) {\n // if (i % 2 === 0 && (data - i) % 2 === 0) {\n // solution = \"YES\";\n // commit(solution);\n // return;\n // }\n // }\n // commit(solution);\n};\n\nprocess.stdin.on(\"data\", consume).on(\"end\", main);\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "f2995236029637f90ae15154654b90a1", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin\n});\n\nreadline.on('line', line => {\n const [w, h, k] = line.split(' ').map(x => parseInt(x));\n let result = 0;\n for (let i = 1; i <= k; i++)\n result += 2*(w - 4*(i - 1) + h - 4*(i - 1) - 2);\n console.log(result);\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "c71ad2e16069ff3b5c74deb7284fc886", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction print(s) {\n process.stdout.write(`${s}`);\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n // input\n const n = readline();\n const p = readline();\n const m = [\n 'qwertyuiop',\n 'asdfghjkl;',\n 'zxcvbnm,./'\n ];\n let s = [];\n for (let i = 0; i < p.length; i++) {\n for (let j = 0; j < m.length; j++) {\n let idx = m[j].indexOf(p.charAt(i));\n if (idx !== -1) {\n s.push(n === 'R' ? m[j].charAt(idx - 1) : m[j].charAt(idx + 1));\n break;\n }\n }\n }\n print(s.join(''));\n}\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "dcd167c6b51c34c314cde0407b6c30c9", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', (S) => {\n let vowels = ['A', 'E', 'I', 'O', 'U', 'Y', 'a', 'e', 'i', 'o', 'u', 'y'];\n for (let i = S.length - 1; i >= 0; i--) {\n if (S[i] == '?' || S[i] == ' ')\n continue;\n if (vowels.includes(S[i])){\n console.log(\"YES\")\n break;\n }\n else {\n console.log(\"NO\");\n break;\n }\n }\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0e1471b9118709a4410972a8ac6c8aa1", "src_uid": "dea7eb04e086a4c1b3924eff255b9648", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nlet ans = 0;\nlet str1, str2;\nlet count = 0;\n\nrl.on('line', (str) => {\n if (count === 0) {\n str1 = str.toLocaleLowerCase();\n }\n else {\n str2 = str.toLocaleLowerCase();\n }\n\n count++;\n});\n\nrl.on('close', () => {\n if (str1 === str2) {\n ans = 0;\n }\n else if (str1 > str2) {\n ans = 1;\n }\n else {\n ans = -1;\n }\n console.log(ans);\n})\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "20c1d47622ffbb95109a88e8663595c1", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Problem # : 1A\n// Created on : 2019-01-15 00:40:22\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf8\");\n\nvar input = \"\",\n readline,\n print;\n\nprocess.stdin.on(\"data\", function(chunk) {\n input += chunk;\n});\n\nprocess.stdin.on(\"end\", function() {\n input = input.split(/\\r?\\n/);\n print = function(data) {\n process.stdout.write(data + \"\\n\");\n };\n var inputLineIndex = 0;\n readline = function() {\n return inputLineIndex >= input.length ? undefined : input[inputLineIndex++];\n };\n process.exit(main() || 0);\n});\n\nfunction main() {\n // Your code here\n let [n, m, a] = readline().split(\" \");\n\n let x = Math.floor(n / a) + (n % a == 0 ? 0 : 1);\n let y = Math.floor(m / a) + (m % a == 0 ? 0 : 1);\n print(Math.floor(x) * Math.floor(y));\n\n return 0;\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "8e66b9a86d07ede403574fb7ddd25183", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let t = Number(readline())\n while (t--) {\n let key = Number(readline())\n let doors = readline().split(' ').map(v => Number(v))\n let openedDoors = 0\n\n while (key != 0) {\n key = doors[key - 1]\n openedDoors += 1\n }\n\n if (openedDoors == 3) console.log('YES')\n else console.log('NO')\n }\n\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "greedy", "implementation", "math"], "code_uid": "d6440533ece70c6d4c3403e374023929", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })\nconst print = console.log\nconst write = (...args) => {\n process.stdout.write(args.join(' '));\n}\nconst lines = []\nrl.on('line', line => {\n lines.push(line);\n});\nrl.on('close', main)\nlet rli = 0;\nfunction readline() {\n return lines[rli++];\n}\n\nfunction main() {\n var y = +readline() + 1\n const check = (x) => (x + '').length === new Set(x + '').size\n while (!check(y)) y++\n write(y);\n}", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "ea103bc1b976e33cd3ea9b42d3838564", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var N = nextInt();\n var output = 0;\n output += Math.floor(N / 100);\n N %= 100;\n output += Math.floor(N / 20);\n N %= 20;\n output += Math.floor(N / 10);\n N %= 10;\n output += Math.floor(N / 5);\n N %= 5;\n output += N;\n myout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["greedy", "dp"], "code_uid": "3778cb05e08bc769a552c4c2c64b6e29", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n let numberString = readLine();\n // if (numberString.indexOf('4') === -1 && numberString.indexOf('1') === -1) {\n // console.log('NO');\n // return;\n // }\n for (let i = 0; i < numberString.length; i++) {\n if (numberString[i] !== '1' && numberString[i] !== '4') {\n console.log('NO');\n return;\n }\n }\n if (numberString[0] !== '1') {\n console.log('NO');\n return;\n }\n if (numberString.includes('444')) {\n console.log('NO');\n return;\n }\n console.log('YES');\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "greedy"], "code_uid": "4a463acc7fed51a2d33330e85dec34c6", "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n\n// Write your code here\nfunction nameLookUp(str) {\n let weights = str.trim().split(' ');\n\n let limakW = +weights[0];\n let bobW = +weights[1];\n for (var i = 1; i <= 10; i++) {\n\n limakW *= 3;\n bobW *= 2;\n if (limakW > bobW) {\n break;\n }\n }\n\n return i.toString();\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "da7e04792df1ea06286b8c4c346883aa", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(str) {\n let inputs = str.trim().split('\\n');\n let oneNum = inputs[0].trim();\n let twoNum = inputs[1].trim();\n let num = [];\n for (let i = 0; i < oneNum.length; i++) {\n let bit = String(oneNum[i] ^ twoNum[i]);\n num.push(bit);\n }\n\n return num.join('').toString();\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "59e1baa35adf5e533d9f5ceac9999b40", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n \nconst input = [];\nreadLine.on('line', line => input.push(line));\n \nreadLine.on('close', () => {\n\tconst _input = input[0].split(' ')\n\tconst people = parseInt(_input[0], 10)\n\tconst pencil = parseInt(_input[1], 10)\n\tconst notepad = parseInt(_input[2], 10)\n\tlet check = 'No'\n\tif (pencil >= people && notepad >= people)\n\t\tcheck = 'Yes'\n\tconsole.log(check)\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "99f34d80c8198a42d5ddb75bbfaed80a", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet a, b;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n a = +d;\n return;\n }\n\n b = +d;\n const a1 = Math.floor(Math.abs(a - b) / 2);\n const b1 = Math.ceil(Math.abs(a - b) / 2);\n const leftSum = a1 * (a1 + 1) / 2;\n const rigthSum = b1 * (b1 + 1) / 2;\n const ans = leftSum + rigthSum;\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "593078d583a568b566a270fec7ead3d5", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n let [x, y, z] = d.split(' ').map(Number);\n let ans = '?';\n\n if (x > y + z) {\n ans = '+';\n }\n else if (y > x + z) {\n ans = '-';\n }\n else if (x === y && z === 0) {\n ans = '0';\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "8de223fb29beeedcf0e473634e891009", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => string.trim());\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nconst s2i = s => parseInt(s, 10);\n\nfunction main() {\n const k = BigInt(readLine());\n let max = 1n;\n while (max ** 10n < k) max++;\n let nMax = 10n;\n let nMin = 0n;\n while (max ** (nMax - 1n) * (max - 1n) ** (nMin + 1n) >= k) {\n nMax--;\n nMin++;\n }\n\n let result = '';\n const codeforces = 'codeforces'\n for(let i = 0; i < 10; i++) {\n const reps = i < nMax ? max : max - 1n;\n for (let j = 0; j < reps; j++) {\n result += codeforces.charAt(i);\n }\n }\n\n console.log(result)\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "constructive algorithms", "math", "greedy", "strings"], "code_uid": "d3345b215d325b066c288826368f3ca6", "src_uid": "8001a7570766cadcc538217e941b3031", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n\n// Write your code here\nfunction nameLookUp(arr) {\n let nLines = arr.split('\\n');\n let nWeight = nLines[0];\n let quotient = nWeight % 2 === 0 && nWeight > 2 ? 'yes' : 'no';\n return quotient;\n\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "f7abfd0cef2a6e9034c237abfc2dd383", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": " const readline = require('readline');\n \n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n });\n \n rl.question('', (input) => {\n const [n, m, a] = input.split(' ')\n console.log(Math.ceil(n/a) * Math.ceil(m/a));\n rl.close();\n });", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "6279c159d0045d30aa03cad39ed66138", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// https://codeforces.com/problemset/problem/977/B\n// Big O:\n// Time complexity: O(n)\n// Space complexity: O(n)\n\nconst readline = require(\"readline\");\n\n// Read input\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet stringLength;\nrl.on('line', (input) => {\n if (stringLength) {\n console.log(findMostCommonGram(input, stringLength));\n rl.close();\n } else {\n stringLength = input;\n }\n});\n\n// Problem\nfunction findMostCommonGram(string, stringLength) {\n let mostCommonGram = \"\";\n let mostCommonGramOccurrences = 0;\n const gramOccurrences = {};\n\n for (let i = 0; i < stringLength - 1; i++) {\n const twogram = string[i] + string[i + 1];\n const occurrences = gramOccurrences[twogram] ? gramOccurrences[twogram] : 0;\n const currentOcurrences = occurrences + 1;\n if (currentOcurrences > mostCommonGramOccurrences) {\n mostCommonGram = twogram;\n mostCommonGramOccurrences = currentOcurrences;\n }\n\n gramOccurrences[twogram] = currentOcurrences;\n }\n\n return mostCommonGram;\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "b57b296da4fdb0b382dfd4df7e990a64", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data', input => {\n const inputs = input.toString().split('\\n');\n const cutOffIndex = inputs[0].split(' ')[1];\n const test = inputs[1];\n const result = getNumberOfCrossedThreshold(test.split(' '), Number(cutOffIndex) - 1);\n console.log(result);\n});\n\nfunction getNumberOfCrossedThreshold(arr, cutOffIndex) {\n // Check if the cutoff Indey should be less than array length;\n // array length should be of 1 length;\n const cutOff = arr[cutOffIndex];\n return arr.reduce((acc, curr) => {\n // Number should be positive in order to be counted.\n // Minimum cutoff marks 0\n if (Number(curr) >= Number(cutOff) && Number(curr)) {\n ++acc;\n }\n\n return acc;\n }, 0);\n}\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e697ebf6f9981249b30f8a77250c81b9", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n \nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n const balls = input.pop().split(' ').map(x => parseInt(x));\n const params = input.pop().split(' ').map(x => parseInt(x));\n\n const [n, k] = params;\n\n let answer = 0;\n balls.forEach((b, i) => {\n if (b >= balls[k-1] && b > 0) { answer += 1 }\n });\n\n console.log(answer)\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "737cd5225c6dc7c03ce6940501471612", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction isPrime(x) {\n\tlet s = Math.sqrt(x);\n\tlet i = 2;\n\twhile (i <= s) {\n\t\tif (x % i === 0) {\n\t\t\treturn false;\n\t\t}\n\t\ti++;\n\t}\n\treturn true;\n}\n\nfunction main() {\n\tlet prog = readLine().split('');\n\tlet grammar = {\n\t\tH: true,\n\t\tQ: true,\n\t\t9: true,\n\t};\n\n\tlet flag = false;\n\n\tfor (let i = 0, l = prog.length; i < l; ++i) {\n\t\tif (grammar[prog[i]]) {\n\t\t\tflag = true;\n\t\t\tbreak;\n\t\t}\n\t}\n\tflag ? console.log('YES') : console.log('NO');\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "60bc02a99bdc82c3e71d03b27bacc743", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n\nfunction splbsi(line) {\n return line.split(\" \").map((x) => parseInt(x));\n}\n\nconst readLine = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nreadLine.on(\"line\", (line) => {\n input.push(line);\n});\n\nreadLine.on(\"close\", () => {\n const str = input[0];\n\n if (str === str.toUpperCase()) {\n console.log(str.toLowerCase());\n return;\n }\n\n if (\n str[0].toLowerCase() === str[0] &&\n str.slice(1).toUpperCase() === str.slice(1)\n ) {\n console.log(`${str[0].toUpperCase()}${str.slice(1).toLowerCase()}`);\n return;\n }\n\n console.log(str);\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "08619696788828168c6ae24909f51c9b", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const [l, n] = d;\n let ans = 8;\n\n if (l === 'a' || l === 'h' || n === '8' || n === '1') {\n ans = 5;\n }\n\n if (d === 'a1' || d === 'a8' || d === 'h1' || d === 'h8') {\n ans = 3;\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "26f362c5b42a03511097daeb68e1ec1c", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var one = nextIntArray();\n var w = one[0];\n var h = one[1];\n var two = nextIntArray();\n var three = nextIntArray();\n var u1 = two[0];\n var d1 = two[1];\n var u2 = three[0];\n var d2 = three[1];\n for(var i = h; i >= 0; i--){\n w += i;\n if(i == d1){\n w -= u1;\n }\n if(i == d2){\n w -= u2;\n }\n if(w < 0){\n w = 0;\n }\n }\n myout(w);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f68a7c5a7f923971331076927b6f2654", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n let [a, b] = input[0].split(' ').map(x => parseInt(x));\n let answ = a;\n\n let ost = a;\n while (ost >= b) {\n answ += parseInt(ost/b);\n ost = parseInt(ost/b) + (ost % b);\n }\n\n console.log(answ);\n}); \n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "c4c99fe341d73eb330f9f24097da8e84", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const r = require('readline');\nconst rc = r.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrc.on('line', function(i){ \n const e = i % 2 === 0\n console.log((e && i >= 4) ? 'YES' : 'NO')\n})", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "1614e5c18e0b57a22a950ac52a342de4", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "///////////////////////////////// pre-define /////////////////////////////////////\r\nconst pr = console.log;\r\nconst err = console.error;\r\nconst mi = Math.min;\r\nconst mx = Math.max;\r\nconst abs = Math.abs;\r\nconst fl = Math.floor;\r\nconst ce = Math.ceil;\r\nconst sq = Math.sqrt;\r\nconst gcd = (a, b) => b == 0 ? a : gcd(b, a % b);\r\nconst lcm = (a, b) => (a / gcd(a, b)) * b;\r\nconst powmod = (a, b, mod) => {\r\n let r = 1n;\r\n while (b > 0n) {\r\n if (b % 2n == 1) r = r * a % mod;\r\n b >>= 1n;\r\n a = a * a % mod;\r\n }\r\n return r;\r\n};\r\nconst counter = (a_or_s) => {\r\n let map = new Map();\r\n for (const i of a_or_s) map.set(i, map.get(i) + 1 || 1);\r\n return map;\r\n};\r\n///////////////////////////////////////////////////////////////////////////////////\r\n\r\nconst MOD = BigInt(1e9 + 7);\r\nconst solve = (n, k) => {\r\n pr(powmod(n, k, MOD).toString());\r\n};\r\n\r\nconst main = () => {\r\n const readline = require('readline');\r\n const rl = readline.createInterface({\r\n input: process.stdin,\r\n output: process.stdout\r\n });\r\n let input = [];\r\n rl.on('line', (line) => {\r\n input.push(line.split(\" \").map(x => BigInt(x)));\r\n });\r\n rl.on('close', () => {\r\n let t = input[0][0];\r\n let i = 1;\r\n while (t--) {\r\n solve(input[i][0], input[i][1]);\r\n i++;\r\n }\r\n });\r\n};\r\n\r\nmain()", "lang_cluster": "Javascript", "tags": ["math", "combinatorics", "bitmasks"], "code_uid": "f4a5ebfc6cfab18ecfbe28ca4928b6eb", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet inputString = \"\";\nlet currentLine = 0;\n\nprocess.stdin.on(\"data\", (inputStdin) => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((string) => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n const x = readline().split(\" \");\n\n const x2 = readline()\n .split(\" \")\n .map((x) => +x);\n \n fn(x2);\n}\n\nfunction fn(arr) {\n console.log(arr.sort(function(a, b){return a-b}).join(\" \"))\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "c6524b30c8cbaeacc205761618738bf6", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\n\nlet inputs = [];\n\nconst rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n});\n\nrl.on(\"line\", line => inputs.push(line));\n\nrl.on(\"close\", () => console.log(solution(inputs)));\n\nfunction solution(data) {\n [a, b] = data[0].split(\" \").map(Number);\n let ans = 0;\n while (a <= b) {\n ans++;\n a*=3;\n b*=2;\n }\n\treturn ans;\n};\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "49a0bab1b8468503098bea9fa3c90776", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var buffer = '';\n\nprocess.stdin.setEncoding('utf8');\n\nprocess.stdin.on('readable', () => {\n let chunk;\n while ((chunk = process.stdin.read()) !== null) {\n buffer += chunk;\n }\n});\n\nprocess.stdin.on('end', solve);\n\nfunction solve() {\n buffer = buffer.trim();\n let a = 0;\n let other = 0;\n buffer.split('').forEach(element => {\n if (element === 'a'){\n a++;\n }\n else{\n other++;\n }\n });\n\n process.stdout.write('' + (a > other ? a + other : a * 2 - 1));\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "26e4cd193a2034e44c955a2e99d5c43f", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Alternative\n// https://www.npmjs.com/package/competitive-programming-js\n\"use strict\"\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', inputStdin => { inputString += inputStdin; });\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n main();\n});\nfunction input() { return inputString[currentLine++]; }\nconst println = (x = \"\") => process.stdout.write(String(x) + \"\\n\");\nconst print = x => { process.stdout.write(String(x)); }\n// >>>>>>>>>>>>> Main starts here <<<<<<<<<<<<<<\n\nconst createArray = n => {\n let ar = new Array(n).fill(0);\n println(ar);\n ar = ar.map(v => new Array(n).fill(0));\n return ar;\n}\n\nfunction main() {\n let n = parseInt(input());\n let ar = input().split(' ').map(v => parseInt(v));\n let ans = new Array(n).fill(0);\n\n for (let i = n-2; i >= 0; --i) {\n let val = ar[i];\n let minus = 0;\n for (let j = 1; j <= val; ++j) {\n let pos = i + 1;\n // println(\"j: \" + j + \" pos: \" + pos + \" ar[pos]: \" + ar[pos]);\n while (pos < n && ar[pos] < j) {\n pos += 1;\n }\n if (pos != i + 1) {\n pos -= 1;\n // println(\"changed:: j: \" + j + \" pos: \" + pos + \" ar[pos]: \" + ar[pos]);\n ar[i] -= 1;\n ar[pos] += 1;\n // println(ar);\n }\n }\n }\n\n // println(ar);\n ar.forEach(v => print(v + \" \"));\n println();\n\n\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "01b5a57233b2922f10875efe40985e52", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\n// const fs = require('fs');\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n//----------------------------------------------\n\nfunction yourFunction(arr) {\n let squares = arr[0] * arr[1];\n return Math.floor(squares / 2);\n}\n\n//----------------------------------------------\n\nfunction main() {\n\n // const n = parseInt(readLine(), 10);\n\n const arr = readLine().split(' ').map(arrTemp => parseInt(arrTemp, 10));\n // console.log(arr);\n let result = yourFunction(arr);\n\n console.log(result);\n}", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "f992f6a5e2c2375978f6334224743d77", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.setEncoding('utf8');\n\nprocess.stdin.on('readable', () => {\n let input = process.stdin.read();\n input = input.trim();\n\n if (input !== null) {\n let lowerCase = 0;\n let upperCase = 0;\n\n for (let i = 0; i < input.length; i++) {\n if (input[i] == input[i].toUpperCase()) upperCase++;\n else lowerCase++;\n }\n\n if (upperCase > lowerCase) input = input.toUpperCase();\n if (lowerCase > upperCase || lowerCase == upperCase) input = input.toLowerCase();\n\n process.stdout.write(`${input}\\n`);\n process.exit(0);\n }\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "1367acf718ed6e25e197b9b040318d84", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nrl.on('line', (inputString) => {\n let [x, y] = inputString.split(' ').map(v => parseInt(v));\n if (!rl.on.input) rl.on.input = [];\n rl.on.input = rl.on.input.concat([x, y]);\n if (rl.on.input.length == 6) {\n sb.apply(null, rl.on.input);\n process.exit();\n }\n});\n\nfunction sb(w, h, u1, d1, u2, d2) {\n for (; h >= 0; h--) {\n w += h;\n if (h == d1) w -= u1;\n if (h == d2) w -= u2;\n w = Math.max(0, w);\n }\n console.log(w);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f5d4fe755eb316dfccccd73ae6a31426", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "console.log(25)\n\n", "lang_cluster": "Javascript", "tags": ["number theory"], "code_uid": "f10c7a05b40ab86aacaa06bb2765d06f", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf8');\n\nvar input= '', readline, print;\n\nprocess.stdin.on('data', function(chunk) {\n input+=chunk;\n});\n\nprocess.stdin.on('end', function() {\n input = input.split('\\n');\n print = function(data) {process.stdout.write(data+'\\n')};\n var inputLineIndex = 0;\n readline = function(){return inputLineIndex>=input.length?undefined:input[inputLineIndex++]};\n process.exit(main() || 0);\n});\n\nfunction main()\n{\n let line = readline();\n let [n, m, a] = line.split(' ').map((n) => {\n return parseInt(n);\n });\n\n let w = Math.floor(n / a) + (n % a === 0 ? 0 : 1);\n let h = Math.floor(m / a) + (m % a === 0 ? 0 : 1);\n\n print(w * h);\n\n return 0;\n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "e9aaa48f500afcff5ebbd440c19a0f70", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "(()=>{\"use strict\";var t={675:(t,e)=>{Object.defineProperty(e,\"__esModule\",{value:!0}),Array.prototype.sortAsc=function(){return this.sort(((t,e)=>t-e))},Array.prototype.sortDesc=function(){return this.sort(((t,e)=>e-t))},Array.prototype.max=function(){return Math.max(...this)},Array.prototype.min=function(){return Math.min(...this)},Array.prototype.sum=function(){let t=0;for(let e=0;e{if(a)return i=u.default.readFileSync(\"input.txt\").toString().trim().split(\"\\n\").map((t=>t.trim())),t(),void u.default.writeFileSync(\"output.txt\",l);process.stdin.resume(),process.stdin.setEncoding(\"utf-8\"),process.stdin.on(\"data\",(t=>{o+=t})),process.stdin.on(\"end\",(e=>{i=o.trim().split(\"\\n\").map((t=>t.trim())),t(),console.log(l)}))};function c(){return i[s++]}function p(){return c().split(\" \").map((t=>parseFloat(t)))}function d(){return c().split(\"\")}e.default={runMain:f,runEachTest:t=>{f((()=>{let[e]=p();for(;e>0;)t(),e--}))},readline:c,nextNumbers:p,nextNumbersMatrix:function(t){let e=[];for(let r=0;r{for(let u=n;u{t.exports=require(\"fs\")}},e={};!function r(n){if(e[n])return e[n].exports;var u=e[n]={exports:{}};return t[n].call(u.exports,u,u.exports,r),u.exports}(965)})();", "lang_cluster": "Javascript", "tags": ["brute force", "implementation", "number theory"], "code_uid": "774fb7eacaffab85c61a161fdd31f69a", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nlet secondLine = false;\n\n\n// Create readline Interface\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet inputs = [];\n\n\n\nrl.on('line', lineInput => {\n inputs.push(lineInput);\n})\n\n\n// Read Inputs\nrl.on('close', () => {\n const line1 = inputs[0].split(' ');\n const songs = inputs[1].split(' ');\n const D = parseInt(line1[1].split(' ')[0]);\n let spareTime = 0;\n let neededDurationForSongs = 0;\n for (let i = 0; i < songs.length; i++) {\n neededDurationForSongs += parseInt(songs[i]);\n }\n\n spareTime = (songs.length - 1) * 10;\n\n if (neededDurationForSongs + spareTime > D)\n return console.log(-1)\n\n let durationsForJokes = D - neededDurationForSongs;\n\n return console.log(Math.floor(durationsForJokes / 5))\n});", "lang_cluster": "Javascript", "tags": ["greedy", "implementation"], "code_uid": "39b94f87e9c5223f847872365ee06b20", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet inputString = \"\";\nlet currentLine = 0;\n\nprocess.stdin.on(\"data\", (inputStdin) => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = getArray(inputString, '\\n');\n\n main();\n});\n\nfunction getArray(str, delimiter) {\n return str\n .trim()\n .split(delimiter)\n .map((string) => {\n return string.trim();\n });\n}\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction pi(str) {\n return parseInt(str);\n}\n\nfunction main() {\n var n = readLine();\n if (pi(n) %2 === 0 && pi(n) > 2) {\n console.log(\"YES\");\n } else {\n console.log(\"NO\");\n }\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "278cfc9f5ac8b7c445e724e8d5616e09", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar check = function (s) {\n var n = s.length;\n if (n == 0 || n > 16)\n return false;\n //console.log(\"inside function s=%s n=%d\",s,n);\n for (let i = 0; i < n; i++) {\n if (!(s[i] >= 'A' && s[i] <= 'Z' ||\n s[i] >= 'a' && s[i] <= 'z' ||\n s[i] >= '0' && s[i] <= '9' ||\n s[i] == '_'))\n return false;\n }\n return true;\n}\n\nvar CheckHostName = function (HostName) {\n var N = HostName.length\n if (N == 0 || N > 32)\n return false;\n\n var Host = HostName.split(\".\");\n for (let i = 0; i < Host.length; i++) {\n if (!check(Host[i]))\n return false;\n }\n \n /*\n HostName.split('.').forEach(element => {\n if (!check(element))\n return false;\n });\n */\n\n return true;\n}\n\nrl.on('line', (input) => {\n let IsUser = false, IsHost = false, IsResource = false;\n let AtIndex = input.indexOf('@');\n if (AtIndex != -1) {\n var UserName = input.substring(0, AtIndex);\n IsUser = check(UserName);\n var SlashIndex = input.indexOf(\"/\");\n /*\n if (SlashIndex != -1)\n var HostName = input.substring(AtIndex + 1, SlashIndex - AtIndex - 1);\n else\n var HostName = input.substring(AtIndex + 1);\n */\n var HostName = (SlashIndex != -1)? input.substring(AtIndex + 1, SlashIndex): input.substring(AtIndex + 1);\n IsHost = CheckHostName(HostName);\n if (SlashIndex == -1)\n IsResource = true;\n else{\n var Resource = input.substring(SlashIndex + 1);\n IsResource = check(Resource);\n }\n }\n //console.log(\"input=%s IsUser=%s IsHost=%s IsResource=%s\",input, IsUser , IsHost , IsResource)\n console.log((IsUser && IsHost && IsResource) ? \"YES\" : \"NO\");\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "715a4e381793471f7a962e1749f0f8d1", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n var arr=stdin.splice('\\n').map(a => a.split(' '));\n for(let i=0;i Number(num));\n}\n\n/**\n * \n * @param {*} num1 \n * @param {*} num2 \n */\nfunction matrixArray(num1, num2) {\n return Array(num1).fill(Array(num2));\n}\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(str) {\n\n let n = +str.trim();\n let arr = [];\n let max = [1];\n if (n > 1) {\n for (let index1 = 0; index1 < n; index1++) {\n arr[index1] = [];\n for (let index2 = 0; index2 < n; index2++) {\n\n if (index1 == 0 || index2 == 0) {\n arr[index1][index2] = 1;\n\n }\n else {\n let indexItem = arr[index1 - 1][index2] + arr[index1][index2 - 1];\n max.push(indexItem);\n arr[index1][index2] = indexItem;\n }\n\n\n }\n\n }\n }\n return Math.max(...max).toString();\n}\n\n\n\n\n\n\n\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "0aedbbedc834d98bf34655c98e6cc6f9", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nconst readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nreadline.question('', (m) => {\n m = m.split(' ').map(Number);\n\n const ln = m[0];\n\n const slices = m.slice(1);\n\n let res = [];\n\n let x = Math.trunc(ln/slices[0]+1);\n let y = Math.trunc(ln/slices[1]+1);\n\n for (let i=0; i<=x; i++){\n for (let j=0; j<=y; j++){\n let k = (ln-i*slices[0]-j*slices[1])/slices[2];\n if (Number.isInteger(k) && k>=0)\n {\n res.push(k + i + j);\n }\n }\n }\n\n res.sort(function(a, b){return b-a});\n\n console.log(res[0]);\n});\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "dp"], "code_uid": "9f466d47a5bc5ed3b99114a984370744", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n\nfunction splitAndParseInt(line) {\n return line.split(\" \").map((x) => parseInt(x));\n}\n\nconst readLine = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nreadLine.on(\"line\", (line) => {\n input.push(line);\n});\n\nreadLine.on(\"close\", () => {\n const a = parseInt(input[0]);\n const b = parseInt(input[1]);\n const c = parseInt(input[2]);\n\n console.log(\n Math.max(\n a + b + c,\n a * b * c,\n a * (b + c),\n (a + b) * c,\n a * (c + b),\n (a + b) * c\n )\n );\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "87091193f65bedd10bbf81f3c0264926", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\r\nvar rl = readline.createInterface({\r\n input: process.stdin,\r\n output: process.stdout,\r\n terminal: false\r\n});\r\n\r\nlet ls = [];\r\n\r\nfunction solve(){\r\n const len = parseInt(ls[0]);\r\n for (let i = 1; i <= len; i++){\r\n console.log(Math.pow(2, parseInt(ls[i])) - 1);\r\n }\r\n}\r\n\r\nrl.on('line', (l) => ls.push(`${l}`));\r\nrl.on('close', () => solve());", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3795a163936894871d42afbff5539c52", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(str) {\n let inputs = +str.trim();\n // if there is even number then make it half\n // if there is odd number then -(n+1)/2\n let fn = 0;\n if (inputs % 2 === 0) {\n fn = inputs / 2;\n }\n else {\n fn = -(inputs + 1) / 2;\n }\n return fn.toString();\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "1df5fbbf31aa9507e22e17b6298f9172", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const DEBUG = false;\nconst { EOL } = require('os');\nconst fs = require('fs');\n\nlet r = process.stdin;\nif (DEBUG) {\n r = fs.createReadStream('input');\n}\nlet data = '';\nr.on('data', c => (data += c));\nr.on('end', () => {\n const lines = data.split(EOL);\n let arr = [];\n let d;\n [arr[0], arr[1], arr[2], d] = lines[0].split(' ');\n arr[0] = parseInt(arr[0]);\n arr[1] = parseInt(arr[1]);\n arr[2] = parseInt(arr[2]);\n d = parseInt(d);\n arr = arr.sort(function(a, b) {\n return a - b;\n });\n let res = Math.max(0, d - (arr[1] - arr[0]));\n res += Math.max(0, d - (arr[2] - arr[1]));\n console.log(res);\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "76875ce6ac192e033db87d5bc30dae9f", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\nreadline.on('line', (numbers) => {\n [num1, num2] = numbers.split(' ');\n let result = wrongSubstraction(num1, num2);\n console.log(result);\n readline.close()\n})\n\nlet wrongSubstraction = (num1, num2) => {\n // revisar en python si vale comprar dos numeros \n if (num1 <= 0 || num2 <= 0) return;\n\n for(let i = 0; i < num2; i++){\n if(num1%10==0){\n num1 /= 10;\n } else {\n num1 -= 1;\n }\n // console.log(num1);\n }\n\n return num1;\n};", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0b47e4ebea5b2e999006d5eb4ca5748b", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\r\n\r\nprocess.stdin.resume();\r\nprocess.stdin.setEncoding('utf-8');\r\n\r\nlet inputString = '';\r\nlet currentLine = 0;\r\n\r\nprocess.stdin.on('data', inputStdin => {\r\n inputString += inputStdin;\r\n});\r\n\r\nprocess.stdin.on('end', _ => {\r\n inputString = inputString.trim().split('\\n').map(string => {\r\n return string.trim();\r\n });\r\n \r\n main(); \r\n});\r\n\r\nfunction readline() {\r\n return inputString[currentLine++];\r\n}\r\n\r\n\r\nfunction main(){\r\n var tests = parseInt(readline());\r\n for (let t = 0;t < tests; ++t) {\r\n var nm = readline().split(\" \").map(x => parseInt(x));\r\n var mn = readline().split(\" \").map(x => parseInt(x));\r\n let sum = 0;\r\n nm.forEach((x)=> {\r\n sum += x;\r\n })\r\n mn.forEach((x)=> {\r\n sum += x;\r\n })\r\n if (sum == 0) {\r\n console.log(0);\r\n } else if (sum == 4) {\r\n console.log(2);\r\n } else {\r\n console.log(1);\r\n }\r\n }\r\n\r\n}\r\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3b9a296e1374281717c8b1699d723fdf", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n const n = +d;\n const weeks = Math.floor(n / 7);\n const remainder = n % 7;\n const min = weeks * 2 + Math.max(0, remainder - 5);\n const max = (weeks * 2) + Math.min(2, remainder);\n\n console.log(min, max);\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math", "greedy", "constructive algorithms", "brute force"], "code_uid": "cbbe787b23dbeb9fa866d36ef77801af", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var one = nextIntArray();\n var n = one[0];\n var k = one[1];\n var ok = 240 - k;\n var output = 0;\n for(var i = 1; i <= n; i++){\n if(i * 5 <= ok){\n ok -= i * 5;\n output++;\n }else{\n break;\n }\n }\n myout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation", "binary search"], "code_uid": "56d8dded9cdf93029e51c337c78ca569", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n let count_a = 0; [...line].forEach( i => {if(i === 'a') count_a++} );\n if(count_a > line.length - count_a)\n console.log(line.length);\n else\n console.log( line.length - ( line.length-count_a - count_a ) -1)\n});\n\nRL.on('close', () => {\n});\n\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "3533977f343ffb9e8398767f5b5d8a2e", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume()\nprocess.stdin.setEncoding('utf-8')\n\nvar arr = ''\nprocess.stdin.on('data', (i) => {\n arr += i\n})\n\nprocess.stdin.on('end', () => {\n arr = arr.split(' ')\n const n = parseInt(arr[0])\n let k = parseInt(arr[1])\n var num = n\n while(k > 0) {\n if(num % 10 == 0) {\n num = num / 10\n k --\n }\n else {\n num--\n k--\n }\n }\n\n console.log(num)\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "176217b2c281b03f829675a05a152283", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "if (process.env.ANT)\n{\n global.print = this.print ||\n function(){console.log([...arguments].join(' '))} ||\n require('lol-io').print;\n global.debug = function(){console.log('debug:', [...arguments].join(' '))}\n global.write = this.write || require('lol-io').write\n global.readline = this.readline || require('lol-io').readline\n main();\n}\nelse\n{\n const rl = require('readline').createInterface({ input: process.stdin,\n output: process.stdout });\n global.print = console.log\n global.debug = ()=>{};\n global.write = (...args) => {\n process.stdout.write(args.join(' '));\n }\n const lines = []\n rl.on('line', line =>{\n lines.push(line);\n });\n rl.on('close', main)\n let rli = 0;\n global.readline = ()=>lines[rli++];\n}\n\n///////////// CODE\n\nfunction main(){\n let D = [];\n\n let s = readline();\n let t = readline();\n\n function test(i, m)\n {\n debug('test ', i, m)\n let is = 0, it = 0;\n if (is==i)\n is += m;\n while (it {\n if (input > 2 && input % 2 === 0) {\n console.log('YES')\n } else {\n console.log('NO')\n }\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "2c9e194741c1fb6c93ab5bffe241b810", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "console.log(25)", "lang_cluster": "Javascript", "tags": ["number theory"], "code_uid": "722e9e9e51bb7069c471f94451c878f5", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet standardInputString = '';\nlet currentLine = 0;\n\nfunction readLine() {\n return standardInputString[currentLine++];\n}\n\nprocess.stdin.on('data', rawData=> {\n standardInputString += rawData;\n})\n\nprocess.stdin.on('end', _ => {\n standardInputString = standardInputString.trim().split('\\n').map(line=> {\n return line.trim();\n })\n main();\n})\n\nfunction main() {\n let line = '';\n line = readLine().toLowerCase();\n const li = Array.from(line).filter(char=> {\n if(char === 'y' || char === 'o' || char === 'e' || char === 'i' || char === 'a' || char === 'u') {\n return false;\n } else {\n return true;\n }\n })\n console.log(li.map(char=> '.'+char).join(\"\"));\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "a37380dd60823d746504710b41676abd", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function distToCenter(lines) {\n for (var i = 0; i < lines.length; i++) {\n var line = lines[i].split(\" \").join(\"\");\n var j = line.indexOf(\"1\");\n if (j !== -1) {\n return Math.abs(j - 2) + Math.abs(i - 2);\n }\n }\n}\nfunction main(stdin) {\n console.log(distToCenter(stdin.split(\"\\n\")));\n}\nmain(require(\"fs\")\n .readFileSync(0, \"utf-8\")\n .trim());\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "cde499720621d75cb8da61c82a0242ae", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nconst seq = 'qwertyuiopasdfghjkl;zxcvbnm,./';\nlet dir;\n\nrl.on('line', (str) => {\n if (c === 0) {\n dir = str;\n c++;\n return;\n }\n\n let ans = '';\n for (let i = 0; i < str.length; i++) {\n if (dir === 'L') {\n ans += seq[(seq.indexOf(str[i]) + 1) % seq.length];\n }\n else {\n ans += seq[(seq.indexOf(str[i]) - 1 + seq.length) % seq.length];\n }\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "28ec95bd6fafb28cb44ee41faf8f54ee", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\n\n\nrl.on('line', (input) => {\n\n // console.log(`Received: ${input}`);\n\n var temp = input.split(' ');\n var m = parseInt(temp[0]);\n var n = parseInt(temp[1]);\n var a = parseInt(temp[2]);\n\n var x = parseInt(m/a) + !!(m%a);\n var y = parseInt(n/a) + !!(n%a);\n var ans;\n if(a>m && a>n )\n ans = 1;\n else ans =x*y\n console.log(ans);\n rl.close();\n });", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "a1e63578c3fcdec6fd852a7e8b1ba3cf", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction divideEvenWatermelon(weight) {\n if ((weight < 1 && weight > 100) || (weight % 2 !== 0) || weight === 2) return 'NO';\n return \"YES\";\n}\n\nfunction main() {\n const x = +(readline());\n console.log(divideEvenWatermelon(x));\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "4080160540f69fb96d9ea625e932cbf2", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var run = input => (input.split('').filter(function(item, i, ar){ return ar.indexOf(item) === i; }).join('').length % 2 == 0) ? 'CHAT WITH HER!' : 'IGNORE HIM!';\n \nprocess.stdin.setEncoding('utf8');\n \nprocess.stdin.on('readable', () => {\n let input = process.stdin.read();\n input = input.trim();\n \n if (input !== null && typeof input != 'number') {\n process.stdout.write(run(input) + '\\n');\n }\n \n process.exit(0);\n \n});", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "70062c3a9306c7065e49ee799bc87a67", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet currentLine = 0;\nlet inputString = \"\";\n\nprocess.stdin.on(\"data\", (raw_data) => {\n inputString += raw_data;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((line) => {\n return line.trim();\n });\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n/******** Main function*************/\n\nfunction main() {\n var n = +readLine();\n var m = readLine().split(\" \").map(Number);\n\n m.sort((a, b) => a - b);\n console.log(m.join(\" \"));\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "dc12847dcefd19671aecaa65a7ad2f49", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet str1, str2, str3;\n\nrl.on('line', (d) => {\n if (c === 0) {\n str1 = d;\n c++;\n return;\n }\n\n if (c === 1) {\n str2 = d;\n c++;\n return;\n }\n\n str3 = d;\n\n if (str1 === [...str3].reverse().join('') && str2 === [...str2].reverse().join('')) {\n console.log('YES');\n }\n else {\n console.log('NO');\n }\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "4d530234afcf190872ed646565856918", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet a = [];\nlet b = [];\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n const [x, y] = d.split(' ').map(Number);\n a.push(x);\n b.push(y);\n\n c++;\n});\n\nrl.on('close', () => {\n let ans = 0;\n\n for (let i = 0; i < a.length; i++) {\n for (let j = 0; j < b.length; j++) {\n if (a[i] === b[j]) {\n ans++;\n }\n }\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "8c7c4f0e2fb7a477cdc0a12c39e69b77", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.question('', (answer) => {\n if (answer % 2 === 0 && answer != 2) {\n console.log('YES')\n } else {\n console.log('NO')\n }\n rl.close()\n})", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "c650b69cb9282cc1af166478bed9f0b8", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nconst readline=require('readline');\nconst rd=readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\nrd.question('', (s)=>{\n s=s.replace(new RegExp('WUB', 'g'), ' ');\n console.log(s);\n rd.close();\n})", "lang_cluster": "Javascript", "tags": ["strings"], "code_uid": "436b127805f754deeb198439413ce551", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet l = 0;\nrl.on('line', (input) => {\n rl.close();\n let numbers = input.split(' ').map(x=>parseInt(x))\n console.log(Math.min(Math.min(numbers[0]+2,numbers[1]+1),numbers[2])*3-3)\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "9abb6e471e1470dcd7fa0e17770520d9", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n let [Numberofstudents, initialCandyValue] = readLine()\n .split(' ')\n .map(Number);\n // let home = [];\n // let more = [];\n\n let students = readLine().split(' ').map(Number); // [1 3 1 4 2]\n // for (let i = 0; i < students.length; i++) {\n // if (students[i] <= initialCandyValue) {\n // let t = students[i];\n // home[t] = i;\n // } else {\n // let test = students[i];\n // more[test] = i;\n // }\n // }\n // let highest = 0;\n // let vagfol = 0;\n // if (more.length !== 0) {\n // for (let i = 0; i < more.length; i++) {\n // // if (more[i] > highest) {\n // // highest = more[i];\n // // }\n // let iThVagfol = Math.ceil(more[i] / initialCandyValue);\n // if (iThVagfol > vagfol) {\n // vagfol = iThVagfol;\n // } else if (vagfol === iThVagfol) {\n // highest = more[i];\n // }\n // }\n // } else if (more.length === 0) {\n // for (let i = 0; i < home.length; i++) {\n // if (home[i] > highest) {\n // highest = home[i];\n // }\n // }\n // }\n\n let highest = 0;\n let vagfol = 0;\n // if (more.length !== 0) {\n for (let i = 0; i < students.length; i++) {\n // if (more[i] > highest) {\n // highest = more[i];\n // }\n let iThVagfol = Math.ceil(students[i] / initialCandyValue); //100\n if (iThVagfol > vagfol) {\n vagfol = iThVagfol;\n highest = students.lastIndexOf(students[i]);\n } else if (vagfol === iThVagfol) {\n highest = students.lastIndexOf(students[i]);\n }\n }\n console.log(highest + 1);\n // console.log(Math.max.apply(null, more));\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "043b00b9a4e8282efd0f005683da0570", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet inputString = \"\";\nlet currentLine = 0;\n\nprocess.stdin.on(\"data\", (inputStdin) => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((string) => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n const x = readline();\n const y = readline();\n \n colorfulStones(x,y);\n}\n\nfunction colorfulStones(rocks, instructions) {\n let rockPointer = 0;\n\n for (const instruction of instructions) {\n if (instruction === rocks[rockPointer]) rockPointer++;\n }\n console.log(rockPointer + 1);\n\n return rockPointer + 1;\n}\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "feefd6cc32bc99a44c21d3ec84712a6b", "src_uid": "f5a907d6d35390b1fb11c8ce247d0252", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf8');\nlet input= '', readline, cout;\nprocess.stdin.on('data', (chunk) => input+=chunk);\nprocess.stdin.on('end', () => {\n input = input.split('\\n');\n cout = (data) => process.stdout.write(data+'\\n');\n var inputLineIndex = 0;\n readline = function(){return inputLineIndex>=input.length?undefined:input[inputLineIndex++]};\n process.exit(main() || 0);\n});\n\nfunction main(){\n let a = readline();\n if(a > 2 && a % 2 === 0) console.log(\"YES\");\n else console.log(\"NO\")\n return 0;\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "13f7e09ef1ae9586fe55b12d3cacc908", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const rl = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', (line) => {\n let result = \"\";\n for (let i = 0; i < line.length; i++) {\n const char = line[i];\n \n if (isVowel(char)) {\n continue;\n } else {\n result += \".\" + char.toLowerCase()\n }\n }\n\n console.log(result);\n});\n\nconst vowels = [\"a\", \"o\", \"y\", \"e\", \"u\", \"i\"];\nfunction isVowel(c) {\n if (vowels.includes(c.toLowerCase())) {\n return true;\n } else {\n return false;\n }\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "3899810a401b431e34c2c7ca2f5c0ba2", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n// single line input\nreadline.on('line', line => {\n readline.close(), console.log(parseInt(line) % 2 === 0 && parseInt(line) > 2 ? \"YES\" : \"NO\");\n});\n ", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "3eae05c063c401e2cbac781f0dcdc704", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.setEncoding('utf8');\nlet input = [];\nprocess.stdin.on('readable', () => {\n const chunk = process.stdin.read();\n if (chunk !== null) {\n let re = /\\n\\s*| /;\n input = chunk.split(re).slice(0, -1);\n let myinput = input.map(value => parseInt(value));\n console.log(snowball.apply(null, myinput));\n process.exit(0);\n }\n});\n\nfunction snowball(weight, height, u1, d1, u2, d2) {\n let w = weight, h = height;\n for (; h >= 0; h--) {\n w += h;\n if (h == d1) w = (w - u1) > 0 ? (w - u1) : 0;\n if (h == d2) w = (w - u2) > 0 ? (w - u2) : 0;\n }\n return w;\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "b00cab7fd3e71237d2499b2a5ccf95a2", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let number = parseInt(readLine());\n // let number = parseInt(numberString);\n // let n = numberString.length;\n // let result = (2 * (Math.pow(2, n) - 1)) / (2 - 1);\n // if (numberString[n - 1] === '4') {\n // result = result - 1;\n // }\n // let count = 0;\n // for (let i = 4; i <= number; i++) {\n // let iThstring = i.toString();\n // // console.log(iThstring);\n // if (\n // iThstring.includes('1') ||\n // iThstring.includes('2') ||\n // iThstring.includes('3') ||\n // iThstring.includes('5') ||\n // iThstring.includes('6') ||\n // iThstring.includes('8') ||\n // iThstring.includes('9') ||\n // iThstring.includes('0')\n // ) {\n // continue;\n // // console.log(i);\n // // count++;\n // } else {\n // count++;\n // }\n // }\n // console.log(count);\n let limit = 1000000000;\n let luckydigits = [];\n function generate(curr) {\n if (curr > limit) return;\n // if (curr) {\n luckydigits.push(curr);\n // }\n curr = curr * 10;\n generate(curr + 4);\n generate(curr + 7);\n }\n generate(0);\n delete luckydigits[0];\n luckydigits.sort((a, b) => {\n return a - b;\n });\n // generate(7);\n console.log(luckydigits.indexOf(number) + 1);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation", "combinatorics", "bitmasks"], "code_uid": "2d37132c38c14531c5ed99ee7fb22b4f", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.addListener(\"data\", (data)=>{\n var n = parseInt(data.toString().trim());\n if (n > 2 && n % 2 == 0) process.stdout.write(\"YES\");\n else process.stdout.write(\"NO\");\n process.exit();\n})", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "8a967db023265f083623ee2e82f9877f", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n let ans = 0;\n let v = +d;\n let amount = [100, 20, 10, 5, 1];\n\n let idx = 0;\n while (v > 0) {\n while (v >= amount[idx]) {\n ans++;\n v -= amount[idx];\n }\n\n idx++;\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["greedy", "dp"], "code_uid": "fa045342f4cc54a42f4ce0fe1ca4d3c0", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\n\nvar input = [];\n\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar i = 0;\n\nrl.on('line', function(cmd) {\n input.push(cmd);\n\n i++;\n if (i == 2) {\n rl.close();\n }\n});\n\nrl.on('close', function(cmd) {\n var n = parseInt(input[0]);\n var arr = input[1].split(' ').map(Number);\n\n var max = arrayMax(arr);\n var min = arrayMin(arr);\n\n var startIndex = 0;\n var endIndex = 0;\n\n var startCounting = false;\n\n for (var i = 0; i < n; i++) {\n if ((arr[i] == max || arr[i] == min) && !startCounting) {\n startCounting = true;\n startIndex = i;\n i++;\n }\n if ((arr[i] == max || arr[i] == min) && startCounting) {\n\n startCounting = false;\n endIndex = i;\n break;\n }\n }\n\n var maxarr = [];\n maxarr.push(endIndex - startIndex);\n maxarr.push(endIndex);\n maxarr.push(startIndex);\n maxarr.push(arr.length - 1 - startIndex);\n maxarr.push(arr.length - 1 - endIndex);\n\n function arrayMin(array) {\n var len = array.length,\n min = Infinity;\n while (len--) {\n if (array[len] < min) {\n min = array[len];\n }\n }\n return min;\n };\n\n function arrayMax(array) {\n var len = array.length,\n max = -Infinity;\n while (len--) {\n if (array[len] > max) {\n max = array[len];\n }\n }\n return max;\n };\n\n console.log(arrayMax(maxarr));\n process.exit(0);\n});", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation"], "code_uid": "b6c468bc21299a22a894edd2e5d49864", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet inputString = \"\";\nlet currentLine = 0;\n\nprocess.stdin.on(\"data\", (inputStdin) => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((string) => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n const x = readline();\n\n \n nightAtMuseum(x);\n}\n\n\nfunction nightAtMuseum(name) {\n let rotationCount = 0;\n let fixedPointer = \"a\";\n\n var alphabet = [\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 for (let i = 0; i < name.length; i++) {\n let char = name[i];\n let pointerIndex = alphabet.indexOf(fixedPointer);\n let charIndex = alphabet.indexOf(char);\n\n rotationCount += Math.min(\n Math.abs(pointerIndex - charIndex),\n Math.min(pointerIndex, charIndex) -\n 0 +\n (26 - Math.max(pointerIndex, charIndex))\n );\n \n fixedPointer = char;\n }\n console.log(rotationCount);\n\n return rotationCount;\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "83c50c7f0f523136d32ef51afa4ab8de", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let data = '';\nprocess.stdin.on('data', c => data += c);\n\nfunction* nextLine() {\n\tlet lines = data.trim().split(/\\n/g);\n\tfor(let l of lines){\n\t\tyield l.trim();\n\t}\n}\n\nlet nl = nextLine();\n\nnl.num = function() {\n\t\treturn Number(this.next().value);\n\t};\nnl.nums = function() {\n\t\treturn this.next().value.split(/\\s/g).map(Number);\n\t};\nnl.line = function() {\n\t\treturn this.next().value;\n\t}\n\t\nconst sol = () => {\n\tlet str = nl.line();\n\tlet s = str.split('');\n\ts.sort();\n\tlet result = s.filter(x => x === s[s.length - 1]).join('');\n\tconsole.log(result);\n\n};\n\nprocess.stdin.on('end', sol);\n", "lang_cluster": "Javascript", "tags": ["brute force", "binary search", "bitmasks", "greedy", "strings", "implementation"], "code_uid": "dddea16d9a1d9e40da16d13edeefcd94", "src_uid": "9a40e9b122962a1f83b74ddee6246a40", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Input\n'use strict';\n \nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n \nlet inputString = '';\nlet currentLine = 0;\n \nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n \nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n \nfunction readline() {\n return inputString[currentLine++];\n}\n \n//main\nfunction main() {\n var n = parseInt(readline());\n console.log((n<=2 || n%2) ? \"NO\" : \"YES\");\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "5ef4e7961990a132050b38d0a259c5ec", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet n, k, x;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n [n, k, x] = d.split(' ').map(Number);\n return;\n }\n\n const arr = d.split(' ').map(Number);\n\n let idx = arr.length - 1;\n\n while (k > 0) {\n arr[idx] = x;\n idx--;\n k--;\n }\n\n const ans = arr.reduce((a, b) => a + b, 0);\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "cd7c53fbdae71b5275b829349e9ccff2", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "/**\r\n * Author : Fazlul Hoque\r\n * Node.js version : 12.16.3\r\n * command : node fileName.js output.txt\r\n */\r\n\"use strict\";\r\nprocess.stdin.resume();\r\nprocess.stdin.setEncoding(\"utf-8\");\r\nlet inputString = \"\"; //An array of raw inputs (includes 'n,\\r , not usable. need to process before use)\r\nlet currentLine = 0; //input sequence controller variable.\r\n\r\nprocess.stdin.on(\"data\", (inputStdin) => {\r\n inputString += inputStdin;\r\n});\r\nprocess.stdin.on(\"end\", () => {\r\n inputString = inputString.split(\"\\n\");\r\n main(); // after input \r\n});\r\n\r\n/********** Utility Functions Start **********/\r\n/**\r\n * read row Input\r\n * @returns string\r\n */\r\nfunction _readRawLine() {\r\n return inputString[currentLine++];\r\n}\r\nfunction readLine(){\r\n // return _readRawLine().replace(/\\s+$/g, '');\r\n return _readRawLine().replace('\\r', '');\r\n}\r\n\r\nfunction print(x) {\r\n console.log(x);\r\n}\r\n\r\nfunction readSingleInt() {\r\n const p = readLine();\r\n return parseInt(p);\r\n}\r\n\r\nfunction readIntArray() {\r\n return readLine().split(\" \").map((v) => parseInt(v));\r\n}\r\n\r\nfunction readArray() {\r\n return readLine().split(\" \");\r\n}\r\n\r\nfunction int(n) {\r\n return parseInt(n);\r\n}\r\n/********** Utility Functions End **********/\r\n/**\r\n * Don't Touch this fucntion at all , unless you know what are you doing!\r\n */\r\nfunction main() {\r\n solve();\r\n}\r\n\r\n// ********** actual Code Starts from here **********\r\n\r\n\r\nfunction solve() {\r\n let t = readSingleInt();\r\n while(t--){\r\n let n = readSingleInt();\r\n let p = n,k=1;\r\n while(n--){\r\n k=k<<1;\r\n }\r\n console.log(k-1)\r\n }\r\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f60ac7c909f1a99e0c0fe54e4acbba16", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n var num=Number(stdin[0]),n;\n var a=num%100,b=a%20,c=b%10,d=c%5;\n n=Math.floor(num/100)+Math.floor(a/20)+Math.floor(b/10)+Math.floor(c/5)+Math.floor(d/1);\n console.log(n);\n}\n\nconst readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar stdin = [];\nrl.on('line', function (line) {\n stdin.push(line);\n});\nrl.on('close', main);\n", "lang_cluster": "Javascript", "tags": ["greedy", "dp"], "code_uid": "4aaee6c38705695d3c5cdd81feacfbe7", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main(inputString);\n});\n\nfunction log(message){\n if(process.env.NODE_ENV === \"debug\"){\n console.log(message);\n }\n}\n\nfunction main(fileContents) {//input lines as an array\n // console.log(fileContents);\n fileContents.splice(0,1);\n fileContents.forEach(num => {\n num = parseInt(num);\n\n let maxSquare = 0\n let squareCurrent = 0\n\n let maxCube = 0\n let cubeCurrent = 0\n\n const magicNumbers = new Set();\n\n while(maxSquare < num){\n squareCurrent++\n maxSquare = Math.pow(squareCurrent,2)\n\n if(maxSquare > 0 && maxSquare <= num)\n magicNumbers.add(maxSquare)\n }\n\n while(maxCube < num){\n cubeCurrent++\n maxCube = Math.pow(cubeCurrent,3)\n\n if(maxCube > 0 && maxCube <= num)\n magicNumbers.add(maxCube)\n }\n\n // if(magicNumbers.size < 20){\n // console.log(magicNumbers)\n // }\n\n console.log(magicNumbers.size)\n })\n}\n\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "01b7f44ea90322a1ced5bd9551717f0b", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\nvar input = '';\nvar inputResolve;\nvar inputPromise = new Promise(resolve => inputResolve = resolve);\nprocess.stdin.on('data', c => input += c);\nprocess.stdin.on('end', () => {\n inputResolve();\n});\n(async () => {\n // var time = Date.now();\n await inputPromise;\n var inputs = input.split(/\\r?\\n/);\n var n = +inputs[0];\n var s = 0;\n for (let i = 1; i <= 1024; i++) {\n if (+i.toString(2) <= n)\n s++;\n }\n console.log(s);\n})();\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "0c8ce1df5e809b2239509fb047ae3676", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n let k = parseInt(readLine());\n let months = readLine().split(' ').map(Number);\n months.sort((a, b) => b - a);\n if (k === 0) {\n console.log(0);\n return;\n }\n let count = 0;\n let sum = 0;\n for (let i = 0; i < months.length; i++) {\n sum = sum + months[i];\n count++;\n if (sum >= k) {\n break;\n }\n }\n if (sum < k) {\n console.log(-1);\n return;\n }\n console.log(count);\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "8cfa0278cf0ae62e4e9bb95dfe517777", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout,\n\tterminal: false\n});\n\nrl.on(\"line\", (line) => {\n var n = parseInt(line);\n console.log( n > 2 && n % 2 == 0 ? \"YES\" : \"NO\" );\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "ede65343240f86e41e7244206af635b6", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let data = '';\nprocess.stdin.on('data', c => data += c);\nconst sol = () => {\n let lines = data.split(/\\n/g);\n let words = lines[1].split(/\\s/g);\n let m = 0;\n words.forEach(w => {\n let c = 0;\n for(let e of w) {\n if (e >= 'A' && e <= 'Z') {\n c++;\n }\n }\n if (c > m) {\n m = c;\n }\n });\n console.log(m);\n};\nprocess.stdin.on('end', sol);", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "759a54c60d7fd356370fca9cab5972f7", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const [n, m] = readLine()\n .split(\" \")\n .map((n) => parseInt(n));\n if (!isPrime(m)) {\n console.log(\"NO\");\n return;\n } else {\n for (let i = m - 1; i > n; i--) {\n if (isPrime(i)) {\n console.log(\"NO\");\n return;\n }\n }\n console.log(\"YES\");\n }\n}\n\nfunction isPrime(num) {\n const n = Math.floor(Math.sqrt(num));\n for (let i = 2; i <= n; i++) {\n if (num % i === 0) return false;\n }\n return num === 1 ? false : true;\n}\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "b716f83bd37470c194adb6abbe8c8335", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var N = nextInt();\n var output = 0;\n for(var i = 1; i < N; i++){\n if((N - i) % i == 0){\n output++;\n }\n }\n myout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "10e42f0c1111c889c66fc2a06ed22921", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n const arr = d.split(' ');\n const obj = {};\n const ans = [];\n\n for (let i = arr.length - 1; i >= 0; i--) {\n if (!obj[arr[i]]) {\n obj[arr[i]] = true;\n ans.push(arr[i]);\n }\n }\n\n console.log(ans.length);\n console.log(ans.reverse().join(' '));\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e5f2fed00aa2fc921b0543a7f2b07b84", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('ascii');\n \nvar input_stdin = \"\";\nvar input_stdin_array = \"\";\nvar input_currentline = 0;\n \nprocess.stdin.on('data', function (data) {\n input_stdin += data;\n});\n \nprocess.stdin.on('end', function () {\n input_stdin_array = input_stdin.split(\"\\n\");\n main(); \n});\n \nfunction readLine() {\n return input_stdin_array[input_currentline++];\n}\n \nfunction solveMeFirst(a) {\n // Hint: Type return a+b below \n return a > 2 && a % 2 === 0 ? \"YES\" : \"NO\"; \n}\n \n \nfunction main() {\n var a = parseInt(readLine());\n \n var res = solveMeFirst(a);\n console.log(res);\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "373cbb8dd33ee98131734f362c0a627a", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nlet input = [];\nrl.on('line', function (line) {input.push(line);});\nrl.on('close', function() {\n input.forEach((row, index) => {\n input[index] = row.split(' ').map(i => Number(i));\n })\n \n let matrix = [[1,1,1], [1,1,1], [1,1,1]];\n \n \n for(let i = 0; i < input.length; i++) {\n for(let j = 0; j < input[i].length; j++) {\n if (input[i][j] != 0) {\n for (let n = 0; n < input[i][j]; n++) {\n matrix[i][j] = (matrix[i][j]) ? 0 : 1;\n \n // top\n if (matrix[i-1]) matrix[i-1][j] = (matrix[i-1][j]) ? 0 : 1;\n // bottom\n if (matrix[i+1]) matrix[i+1][j] = (matrix[i+1][j]) ? 0 : 1;\n \n // left\n if (matrix[j-1]) matrix[i][j-1] = (matrix[i][j-1]) ? 0 : 1;\n // right\n if (matrix[j+1]) matrix[i][j+1] = (matrix[i][j+1]) ? 0 : 1;\n }\n }\n }\n }\n \n let result = ''\n matrix.forEach((row) => result += row.join('') + '\\n');\n \n console.log(result);\n \n});\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "8e5567e7a3649b9d5f419ccbcf7fef8b", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n let [n, s] = d.split(' ').map(Number);\n let ans = 0;\n\n while (s / n > 0) {\n if (s >= n) {\n ans += Math.floor(s / n);\n s = s % n;\n }\n else {\n n = s;\n }\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["math", "greedy", "implementation"], "code_uid": "1e04d937a51d38a1a730f4bec2e92398", "src_uid": "04c067326ec897091c3dbcf4d134df96", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nfunction GCD(a,b)\n{\n if (b===0) return a; \n\n return GCD (b, a%b);\n}\n\nvar counter = 0;\nvar n = 0;\n\nrl.on(\"line\", input => {\n n = parseInt(input);\n for (var i = 2; i < n; i++) {\n var item = n;\n while (n != 0) {\n counter += n % i;\n n = parseInt(n / i);\n }\n n = item;\n }\n\n var temp = GCD(counter,n-2)\n\n console.log(counter/temp + \"/\" + (n - 2)/temp);\n rl.close();\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "b781ecec575e99c51457d4cdaf3a2241", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n const inputs = readline().split(\" \");\n const output = Math.ceil(inputs[0]/inputs[2])*Math.ceil(inputs[1]/inputs[2]); \n console.log(output);\n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "78c5176b6f1687533eec7be4fef5a260", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\nlet input = []\n\nrl.on('line', line => {\n input = line.split(' ').map(x => parseInt(x))\n const output = solution(input[0], input[1])\n console.log(output)\n})\n\nrl.on('close', () => {\n // console.log(input)\n})\n\n///end of interface\n\n\nvar solution = function(n, k){\n res = n;\n var getLastDigit = function(d){\n last = d%10;\n return +last;\n };\n\n for (i = 0; i < k; i++){\n var lastDigit = getLastDigit(res);\n //if the last digit of the number is non-zero, she decreases the number by one;\n // the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit).\n if (lastDigit !== 0) {\n res--;\n } else {\n res = res/10;\n }\n }\n return res;\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "24a4096efacc500632cf9f5eb4c8645a", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n const desk = input[1];\n let answer = 0;\n\n if (desk.length < 2) { console.log(0); process.exit(); }\n\n for (let i = 1; i < desk.length; i += 1) {\n if (desk[i] === desk[i-1]) answer += 1;\n }\n\n console.log(answer);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "ee14facb8f15086955c5e77eeaee685c", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\r\nconst fs = require(\"fs\");\r\n//let filename = \"0.txt\";\r\nlet filename = 0;\r\nconst input = fs.readFileSync(filename, \"utf8\").trim().split(\"\\n\");\r\nlet line = 0;\r\nfunction readline() {\r\n return input[line++];\r\n}\r\nfunction iInpArr() {\r\n return readline()\r\n .trim()\r\n .split(\" \")\r\n .map((cur) => parseInt(cur));\r\n}\r\nfunction BInpArr() {\r\n return readline()\r\n .trim()\r\n .split(\" \")\r\n .map((cur) => BigInt(cur));\r\n}\r\nfunction string() {\r\n return readline().trim();\r\n}\r\nfunction stringArr() {\r\n return readline().trim().split(\"\");\r\n}\r\n\r\nfunction stringArr1() {\r\n return readline().trim().split(\" \");\r\n}\r\nfunction getValue() {\r\n return parseInt(readline());\r\n}\r\nfunction iInpArr1() {\r\n return readline()\r\n .trim()\r\n .split(\"\")\r\n .map((cur) => parseInt(cur));\r\n}\r\nlet mod = 1e9 + 7;\r\nmod = BigInt(mod);\r\nconst pow = (num, exp, mod) => {\r\n if (exp === BigInt(0)) return BigInt(1);\r\n let x = pow(num, exp / BigInt(2), mod);\r\n if (exp % BigInt(2)) return (((x * x) % mod) * num) % mod;\r\n else return (x * x) % mod;\r\n};\r\nconst inverse = (num, exp) => {\r\n return pow(BigInt(num), BigInt(exp), BigInt(mod));\r\n};\r\nconst sqrt = (n) => {\r\n let low = 1n,\r\n high = n,\r\n ans;\r\n while (low <= high) {\r\n let mid = (low + high) / 2n;\r\n if (mid * mid <= n) {\r\n ans = mid;\r\n low = mid + 1n;\r\n } else high = mid - 1n;\r\n }\r\n return ans;\r\n};\r\n\r\nconst solve = () => {\r\n let t = 1;\r\n while (t--) {\r\n let n = getValue();\r\n let ans = 6n,\r\n k = 4n;\r\n for (let i = 2; i <= n; i++) {\r\n ans = (ans * ((k * k) % mod)) % mod;\r\n k = (k * k) % mod;\r\n }\r\n console.log(ans + \"\");\r\n }\r\n};\r\nsolve();\r\n", "lang_cluster": "Javascript", "tags": ["math", "combinatorics"], "code_uid": "8725009fc9212bb392e27882a5ba390c", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin\n});\n\nrl.on('line', function(line){\n const sp = line.split(' ');\n let lcw = parseInt(sp[0]);\n let bcw = parseInt(sp[1]);\n let y = 0;\n\n while (true) {\n y++;\n lcw *= 3;\n bcw *= 2;\n\n if (lcw > bcw) {\n break;\n }\n }\n\n console.log(y);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "7f2b3a5ec64f9cb54c3d8b2a1b3f1696", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf8');\n\nlet input = [], readline, print;\n\nprocess.stdin.on('data', chunk => {\n input.push(chunk);\n});\n\nprocess.stdin.on('end', () => {\n print = data => {process.stdout.write(data+'\\n')};\n let inputLineIndex = 0;\n readline = () => {\n return inputLineIndex >= input.length && undefined || input[inputLineIndex++]\n };\n process.exit(main() || 0);\n});\n\nfunction main()\n{\n let n = readline().split(' ');\n print(Math.ceil(n[0] / n[2]) * Math.ceil(n[1] / n[2]));\n return 0;\n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "5d40961a9a61b185c3e1b60fc991af49", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\n\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet result = 0;\n\nconst check = (n, m, a) => {\n const x = Math.ceil(n / a);\n const y = Math.ceil(m / a);\n return x * y;\n};\n\nrl.on('line', function (data) {\n const input = data.split(' ');\n const n = Number(input[0]);\n const m = Number(input[1]);\n const a = Number(input[2]);\n \n result = check(n, m, a);\n});\n\nprocess.stdin.on('end', () => { console.log(result); process.exit(0); });\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "e4edfa8f15797a60728b752db976bdcd", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n\n// Write your code here\nfunction nameLookUp(arr) {\n let nLines = arr.trim().split(' ');\n let matrix = nLines.reduce((acc,row)=>{\n return acc * Number(row); \n },1);\n let totalOutput = Math.floor(matrix/2);\n return totalOutput.toString();\n\n}", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "f606f251791b32e0689605ccbde13863", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n let ans = 0;\n let n = +d;\n\n for (let i = 1; i <= n / 2; i++) {\n if (n % i === 0) {\n ans++;\n }\n }\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "c879ae8894d240a1e4ccabe6dc0d947f", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet standardInputString= '';\nlet currentLine = 0;\n\nfunction readLine(){\n return standardInputString[currentLine++];\n}\n\nprocess.stdin.on('data', rawData =>{\n standardInputString += rawData;\n});\n\nprocess.stdin.on('end', _ =>{\n standardInputString= standardInputString.trim().split('\\n').map(line =>{\n return line.trim();\n });\n\n main();\n})\n\nfunction main(){\n\n //first line in input\n let [n] = readLine().split(' ').map(Number);\n\n\n let line = readLine().split('');\n let prev = 0;\n\n let result = '';\n for(let i = 0; i prev){\n prev = counter;\n result = line[i] + line[i+1];\n }\n }\n console.log(result);\n\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "b2d911210636e7c1a6389fc79a665fc7", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\nfunction check(s) {\n let sLen = s.length;\n if (sLen == 0 || sLen > 16)\n return false;\n\n for (let i = 0; i < sLen; i++) {\n if (!(s[i] >= 'a' && s[i] <= 'z' ||\n s[i] >= 'A' && s[i] <= 'Z' ||\n s[i] >= '0' && s[i] <= '9' ||\n s[i] == '_')) return false;\n }\n\n return true;\n}\n\nfunction checkHost(hostName) {\n let hostLen = hostName.length;\n if (hostLen == 0 || hostLen > 32)\n return false;\n var tokens = hostName.split('.');\n for (let i = 0; i < tokens.length; i++)\n if (!check(tokens[i])) return false;\n\n return true;\n}\n\n\n\nvar isUser = false, ishost = false, isResource = false;\nrl.on('line', (input) => {\n\n\n let atIndx = input.indexOf('@');\n if (atIndx != -1) {\n let userName = input.substring(0, atIndx);\n isUser = check(userName);\n let slashIndx = input.indexOf('/');\n let hostName = (slashIndx != -1) ? input.substring(atIndx + 1, slashIndx) : input.substring(atIndx+1);\n ishost = checkHost(hostName);\n\n if (slashIndx == -1) isResource = true;\n else {\n let resource = input.substring(slashIndx + 1);\n isResource = check(resource);\n }\n\n }\n\n //console.log(\"isUser=%s isHost=%s isResource=%s\",isUser,ishost,isResource);\n console.log((isUser && ishost && isResource) ? \"YES\" : \"NO\");\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "f447ec3b446d0460950e243c5dc4f892", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n let string = readLine();\n while (string.includes('WUB')) {\n string = string.replace('WUB', ' ');\n }\n let stringArray = string.split(' ');\n // console.log(stringArray);\n // stringArray.forEach((item) => {\n // if (item === '') {\n // delete item;\n // }\n // });\n for (let i = 0; i < stringArray.length; i++) {\n if (stringArray[i] === '') {\n // stringArray.length--;\n delete stringArray[i];\n }\n }\n let filter = stringArray.filter(Boolean);\n console.log(filter.join(' '));\n}\n", "lang_cluster": "Javascript", "tags": ["strings"], "code_uid": "cca9eb884821dfd36451e3b71577e377", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n// utils\nconst MOD = 1e9 + 7;\nconst mod = (n) => ((n % MOD) + MOD) % MOD;\nconst add = (a, b) => mod(mod(a) + mod(b));\nconst sub = (a, b) => mod(mod(a) - mod(b));\nfunction mul() {\n for (var a = arguments, r = a[0], i = a.length; --i; )\n r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;\n return r;\n}\nfunction inv(b) {\n for (var a = MOD, u = 0, v = 1, t; b; v = t)\n (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);\n u %= MOD;\n return u < 0 ? u + MOD : u;\n}\nfunction pow(base, n) {\n if (n === 0) return 1;\n let p = pow(base, Math.floor(n / 2));\n let res = mul(mod(p), mod(p));\n if (n % 2 === 1) res = mul(mod(res), base);\n return res;\n}\nfunction highestOneBit(i) {\n i |= i >> 1;\n i |= i >> 2;\n i |= i >> 4;\n i |= i >> 8;\n i |= i >> 16;\n return i - (i >>> 1);\n}\nfunction permutation(arr, len, store = \"\", permutations = []) {\n if (store.length === len) {\n permutations.push(store);\n return;\n }\n for (let i = 0; i < arr.length; i++) {\n const newArr = [...arr];\n const newChar = newArr.splice(i, 1);\n permutation(newArr, len, store.concat(newChar), permutations);\n }\n return permutations;\n}\n\nfunction main() {\n const len = +readLine();\n const arr = readLine()\n .split(\" \")\n .map((n) => parseInt(n));\n\n const sum = arr.reduce((total, num) => total + num, 0);\n let found = false;\n\n if (len === 2 && arr[0] === arr[1]) {\n console.log(\"YES\");\n found = true;\n }\n\n for (let i = 0; i < len; i++) {\n if (found) break;\n let total = 0;\n for (let j = 0; j < len - 2; j++) {\n const index = (i + j) % len;\n const nextIndex = (index + 1) % len;\n total += arr[index] + arr[nextIndex];\n if (total === sum - total) {\n found = true;\n console.log(\"YES\");\n break;\n }\n }\n }\n !found && console.log(\"NO\");\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "4f3f14ad1c43fddfd9ff5898ce1f197b", "src_uid": "9679acef82356004e47b1118f8fc836a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// https://codeforces.com/problemset/problem/977/B\n// Big O:\n// Time complexity:\n// Space complexity:\n\nconst readline = require(\"readline\");\n\n// Read input\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet stringLength;\nrl.on('line', (input) => {\n if (stringLength) {\n console.log(findMostCommonGram(input, stringLength));\n rl.close();\n } else {\n stringLength = input;\n }\n});\n\n// Problem\nfunction findMostCommonGram(string, stringLength) {\n let mostCommonGram = \"\";\n let mostCommonGramOccurrences = 0;\n const gramOccurrences = {};\n\n for (let i = 0; i < stringLength - 1; i++) {\n const twogram = string[i] + string[i + 1];\n const occurrences = gramOccurrences[twogram] ? gramOccurrences[twogram] + 1 : 1;\n if (occurrences > mostCommonGramOccurrences) {\n mostCommonGram = twogram;\n mostCommonGramOccurrences = occurrences;\n }\n\n gramOccurrences[twogram] = occurrences;\n }\n\n return mostCommonGram;\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "08889201baa19c7b02f539241ee4cfd1", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\n\nconst runMain = () => {\n inputString = inputString.trim().split('\\n').map(string => string.trim());\n main();\n process.exit();\n}\nconst readLine = () => inputString[currentLine++];\n\nprocess.stdin.on('data', inputStdin => inputString += inputStdin);\nprocess.stdin.on('end', runMain);\nprocess.on('SIGINT', runMain);\n\nfunction main() {\n const a = readLine().split('+').map(num => Number(num)).sort((a, b) => a - b).join('+');\n console.log(a);\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "cc68ebba1ebd40eb5eb7766efc518bbb", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let stdin = process.stdin;\nstdin.setEncoding('utf8');\nstdin.on('data', function (data) {\n let input = data.split('\\n');\n let n = input[0];\n let k = input[1];\n let result = solution(n, k);\n console.log(result);\n});\n\n// End of interface\n\n\nconst solution = (cardOnTable, cardsInHand) => {\n if (cardsInHand.indexOf(cardOnTable[0]) >= 0 || cardsInHand.indexOf(cardOnTable[1]) >= 0){\n\treturn \"YES\";\n } else {\n\treturn \"NO\";\n }\n};", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "63e3fb3a1fde343b92bb5a09e7fca91e", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const stdin = process.openStdin();\n\nprocess.stdin.on('data', function (chunk) {\n lines = chunk.toString().split('\\n');\n lines.map((line, i) => processLine(line, i));\n});\n\nfunction processLine(text, i) {\n if (i === 0) {\n const input = text.toString().trim().toLowerCase();\n let output = '';\n for (let i = 0; i < input.length; i += 1) {\n const char = input.charAt(i);\n if (!['a', 'o', 'u', 'y', 'i', 'e'].includes(char)) {\n output += `.${char}`;\n }\n }\n console.log(output);\n }\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "defaa5df2614c5a69d100d520b452b2a", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n');\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr('time : ' + end + 'ms');\n myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var N = nextInt();\n var s = next();\n var count = 0;\n var output = 0;\n for(var i = 0; i < N; i++){\n if(s[i] == \"x\"){\n count++;\n }else{\n if(count >= 3){\n output += count - 2;\n }\n count = 0;\n }\n }\n if(count >= 3){\n output += count - 2;\n }\n myout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "eecffbd6b716c360f2f14f5794acecbf", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let stdin = process.stdin;\nstdin.setEncoding('utf8');\nstdin.on('data', function (data) {\n let input = data.split('\\n');\n console.log(solution(input[0]));\n});\n\n// End of interface\n\nconst solution = (n) => {\n\tlet intQuotient = Math.floor(n/5);\n\tlet reminder = n % 5;\n\tlet res = intQuotient + (reminder ? 1 : 0);\n\treturn res;\n};\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "2bd73266cf2cb626e4ffc8ddf59367a4", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n \nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n \nrl.question('', (w) => {\n if (w <= 2 || w % 2 !== 0) {\n console.log('NO');\n } else {\n console.log('YES');\n }\n \n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "faaa833f02448e49e30aabfb5ca86bfb", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const state = { stdin: Buffer.alloc(0) };\nconst consume = (chunk) =>\n (state.stdin = Buffer.concat(\n [state.stdin, chunk],\n state.stdin.length + chunk.length\n ));\nconst commit = (answer) => process.stdout.write(answer);\nconst main = (args) => {\n let [n, m, a] = state.stdin\n .toString(\"utf8\")\n .split(\" \")\n .map((e) => parseInt(e));\n let d1 = Math.ceil(n / a);\n let d2 = Math.ceil(m / a);\n let ans = d1 * d2;\n\n commit(ans.toString());\n};\nprocess.stdin.on(\"data\", consume).on(\"end\", main);\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "de2b405cc6c200c2f48e10324ace309a", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nreadline.on('line', line => {\n readline.close(), console.log(capsLocks(line));\n});\nconst capsLocks = (word) => {\n const upperCase = /^[A-ZÑ]+$/g;\n\n if (word.length > 1)\n if (upperCase.test(word))\n return word.toLowerCase();\n else if (upperCase.test(word.slice(1)) && !upperCase.test(word.charAt(0)))\n return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n else\n return word;\n else\n if (!upperCase.test(word))\n return word.toUpperCase();\n else\n return word.toLowerCase();\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "41a93924e760e6f34595788ecc6e1a11", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nconst readLine=()=> inputString[currentLine++];\n/* ================================================ \n Main Solution Starts Here \n===================================================*/\n\nconst main=()=>{\n\tlet set=new Set()\n\tlet numbers = readLine().split(' ').map(n=>+n)\n\tnumbers.forEach(number=>set.add(number))\n\tconsole.log(4-set.size)\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "79f1cdd73017d392b7afb5255865e837", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nconst readline = require ( 'readline' ) ;\n\nconst r = readline.createInterface ( { input : process.stdin , output : process.stdout ,terminal : false } ) ;\n\nr.on ( 'line' , function ( line ) {\n const str = line.toLowerCase() ;\n const bad = 'aouyei' ;\n let ans = '' ;\n for ( let i = 0 ; i < str.length ; i ++ ) {\n if ( bad.indexOf ( str[i] ) < 0 ) {\n ans += '.' + str[i] ;\n }\n }\n console.log ( ans ) ;\n r.close() ;\n}) ;\n\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "937c92148e8bc81a753c086450fa2977", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data', (data) => {\n if (data == 2) {process.stdout.write(\"NO\");}\n else if (data % 2 === 0) {process.stdout.write(\"YES\");}\n else {process.stdout.write(\"NO\");}\n})", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "0b42ebae6c7fec818188091339ae1850", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar countChar = function(s, item) {\n let ans = 0;\n for (let i = 0; i < s.length; i++) {\n ans += (s[i]==item); \n } \n return ans;\n}\n\n/*\nwhile(true){\n input = Console.ReadLine();\n}\n*/\nvar ans = 0, met = false;\n\nrl.on('line', (input) => {\n if (input == \"BBBBBBBB\") \n ans ++;\n else if (!met) {\n met = true;\n ans += countChar(input, 'B');\n } \n \n }).on('close', function() {\n \n console.log(ans);\n });\n /*\n WWWBWWBW\n BBBBBBBB\n WWWBWWBW\n WWWBWWBW\n WWWBWWBW\n WWWBWWBW\n WWWBWWBW\n WWWBWWBW\n */", "lang_cluster": "Javascript", "tags": ["brute force", "constructive algorithms"], "code_uid": "3a281eb01dc0e72e8ace9f0efade268b", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n let row1 = readLine().split(' ').map(Number);\n let row2 = readLine().split(' ').map(Number);\n let row3 = readLine().split(' ').map(Number);\n let row4 = readLine().split(' ').map(Number);\n let row5 = readLine().split(' ').map(Number);\n let finalRowNumber;\n let finalRow;\n if (row1.includes(1)) {\n finalRowNumber = 1;\n finalRow = row1;\n } else if (row2.includes(1)) {\n finalRowNumber = 2;\n finalRow = row2;\n } else if (row3.includes(1)) {\n finalRowNumber = 3;\n finalRow = row3;\n } else if (row4.includes(1)) {\n finalRowNumber = 4;\n finalRow = row4;\n } else if (row5.includes(1)) {\n finalRowNumber = 5;\n finalRow = row5;\n }\n\n let columnNumber;\n\n for (let i = 0; i < finalRow.length; i++) {\n if (finalRow[i] === 1) {\n columnNumber = i + 1;\n }\n }\n\n let result = Math.abs(3 - finalRowNumber) + Math.abs(3 - columnNumber);\n console.log(result);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "8ebd20d5076fca27e1afc8950c680770", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction print(s) {\n process.stdout.write(`${s}`);\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n // input\n const a = readline().split(' ');\n let x = 0;\n const set = new Set();\n for (let i = 0; i < a.length; i++) {\n set.add(a[i]);\n }\n x = a.length - set.size;\n // output\n print(x);\n}\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "7f7e70470ce4c0662d8cb1f293495234", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let data = '';\nprocess.stdin.on('data', c => data += c);\n\nfunction* nextLine() {\n\tlet lines = data.trim().split(/\\n/g);\n\tfor(let l of lines){\n\t\tyield l.trim();\n\t}\n}\n\nlet nl = nextLine();\n\nnl.num = function() {\n\t\treturn Number(this.next().value);\n\t};\nnl.nums = function() {\n\t\treturn this.next().value.split(/\\s/g).map(Number);\n\t};\nnl.line = function() {\n\t\treturn this.next().value;\n\t}\n\t\nconst sol = () => {\n\tlet [m, d] = nl.nums();\n\tlet month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n\tconsole.log(Math.trunc((d - 1 + month[m-1] + 6)/7));\n\n};\n\nprocess.stdin.on('end', sol);\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "82aee4f36d63bf55964e95459d7dca27", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction readAsInt(){\n return parseInt(readline());\n}\n\nfunction readAsIntList(){\n return readline().split(' ').filter(i => i).map(i => parseInt(i));\n}\n\n\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n let [a,b] = readAsIntList();\n for(let i = 1; i <= 10; i++) {\n if((a * 3 ** i) > (b * 2 ** i) ){\n console.log(i);\n return;\n }\n }\n}\n \n\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "631e3e217a4b73b401bee11951c8c14d", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\n \nfunction main() { \n\tminimal(stdin[0])\n}\n \nvar stdin = [];\nrl.on('line', function (line) {stdin.push(line);});\nrl.on('close', main);\n/*\nconst main = async () => {\n await question1()\n rl.close()\n}\n\nmain()\n*/\nfunction minimal(str) {\n\tvar newStr = str.split('+').sort(function(a, b) {\n \treturn a - b\n }).join('+');\n\tconsole.log(newStr)\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "1d72d3b4618c42ba630a59886ef2f287", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n\n let direction = readline();\n let origWord = readline();\n var keyboard = [\n ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p'],\n ['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';'],\n ['z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/']\n ];\n let rowCount = 3, colCount = 10;\n\n /*\n s;;upimrrfod;pbr\n allyouneedislove\n */\n\n if (direction == \"R\") {\n let result = [];\n // shift left\n for (let index = 0; index < origWord.length; index++) {\n const element = origWord[index];\n var loc = findElementLocation(keyboard, element);\n result.push(keyboard[loc.row][loc.col - 1]);\n }\n\n process.stdout.write(result.join(''));\n\n }\n else if (direction == \"L\") {\n // shift right\n let result = [];\n\n for (let index = 0; index < origWord.length; index++) {\n const element = origWord[index];\n var loc = findElementLocation(keyboard, element);\n result.push(keyboard[loc.row][loc.col +1]);\n }\n\n process.stdout.write(result.join(''));\n }\n\n}\n\nfunction findElementLocation(keyboard, element) {\n for (let row = 0; row < 3; row++) {\n const cols = keyboard[row];\n for (let col = 0; col < 10; col++) {\n const colitem = cols[col];\n if (colitem == element) {\n return {\n row: row,\n col: col\n };\n }\n }\n }\n return {\n row: -1,\n col: -1\n };\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "d823836f21887dda6c13c3ba820e83d5", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "var len = readline();\r\nfor(var i=0;i<+len;i++)\r\n{\r\n var inputData = readline();\r\n var count = new Set();\r\nfor(var j=1;j*j<=+inputData;j++)\r\n{\r\n count.add(j*j);\r\n}\r\nfor(var k=1;k*k*k<=+inputData;k++)\r\n{\r\n count.add(k*k*k);\r\n}\r\nprint(count.size);\r\n}\r\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "cd30bc31b49bf8dbc4cbcb640c744aef", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').Interface({\n\tinput: process.stdin,\n\toutput: process.stdout\n});\nconst watermelon = (num) => {\n\tnum = Number(num);\n\tfor (let i = 2; i < num; i += 2) {\n\t\tfor (let j = 2; j < num; j += 2) {\n\t\t\tif (i + j === num) return 'YES';\n\t\t}\n\t}\n\treturn 'NO';\n};\n\nreadline.on('line', (num) => {\n\treadline.close(), console.log(watermelon(num));\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "209974be2d37d1eadc4fc34a668771bf", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let lines = [];\nrequire('readline').createInterface({input: process.stdin,output: process.stdout})\n\t\t\t\t.on('line', line => {lines.push(line);})\n\t\t\t\t.on('close', () => {console.log(main(lines));});\n\nconst main = (input) => {\n\tlet [a, b] = input[0].split(\" \").map(num => parseInt(num));\n\tlet counter = 0;\n\twhile (a <= b) {\n\t\tcounter++;\n\t\ta *= 3;\n\t\tb *= 2;\n\t}\n\treturn counter;\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "03176c03081658b0c7dedb95ca6d4d82", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var line_number = 0;\nconst cs = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nvar lines = {};\ncs.on(\"line\", (input) => {\n if (input == \"\") {\n cs.close();\n }\n lines[line_number] = input.split(\" \");\n line_number += 1;\n}).on(\"close\", () => {\n main();\n process.exit();\n});\n\nfunction isOp(str) {\n return str.length === 1 && str.match(/[<=>]/);\n}\nfunction isChr(str) {\n return str.length === 1 && str.match(/[a-z]/i);\n}\nfunction isInt(str) {\n return str.length === 1 && !isNaN(str);\n}\n\nfunction print(str) {\n console.log(str);\n}\n\nfunction predict(test) {\n let op = \"\";\n let ops = [];\n let opVariables = [];\n let limits = [];\n for (let t of test) {\n // console.log(t);\n for (let i = 0; i < t.length; i++) {\n if (isOp(t[i])) {\n op = t[i];\n if (isOp(t[i + 1])) {\n op += t[i + 1];\n i += 1;\n }\n ops.push(op);\n op = \"\";\n } else if (isChr(t[i])) {\n // console.log(t[i])\n op = t[i];\n for (var j = i + 1; j < t.length; j++) {\n if (isChr(t[j]) || isInt(t[j])) {\n op += t[j];\n i = j;\n } else break;\n }\n opVariables.push(op);\n op = \"\";\n } else {\n if (i == 0 || (i > 0 && isOp(t[i - 1]))) {\n op = t[i];\n let j = i + 1;\n for (; j < t.length; j++) {\n if (isInt(t[j])) {\n op += t[j];\n i = j;\n } else break;\n }\n limits.push(op);\n op = \"\";\n }\n }\n }\n }\n\n let min = limits[0];\n let max = limits[1];\n\n let pvs = ops.map((o, i) => [o, opVariables[i]]);\n\n for (let pv of pvs) {\n if (pv[1] == undefined) {\n pv[1] = max;\n }\n // print(`${min} ${pv[0]} ${pv[1]} ?`)\n if (eval(`${min}${pv[0]}${pv[1]}`)) {\n // print(` ${min} ${pv[0]} ${pv[1]} true`)\n min = pv[1];\n } else {\n print(\"input error\");\n process.exit();\n }\n }\n}\n\nvar n;\nfunction main() {\n for(let r = 0; r < 15; r++) {\n for(let c = 0; c < 15; c++) {\n if (lines[r][c] === '1') {\n print(Math.abs(3-1-r)+Math.abs(3-1-c))\n process.exit()\n }\n }\n }\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "a3f347686d9b0341741b3a6b014ff8af", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const str = readLine();\n let count_4_7 = 0;\n\n str.split(\"\").forEach((char) => {\n if (char === \"4\" || char === \"7\") count_4_7++;\n });\n\n if (count_4_7 === str.length || +str % 4 === 0 || +str % 7 === 0 || +str % 47 === 0 || +str % 74 === 0) {\n console.log(\"YES\");\n } else {\n console.log(\"NO\");\n }\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "number theory"], "code_uid": "866cc110e52577c079a882ebe32eb4f2", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let fs = require('fs')\n\nlet txt = fs.readFileSync(0, \"utf-8\").split(\"\\r\\n\").filter(data => {\n return data.length > 0\n});\nfor (let i = 0; i < txt.length; i ++) {\n doit(txt[i])\n}\n\nfunction doit(str) {\n\n if(str.match(\"H\")!=null || str.match(\"Q\")!=null || str.match(\"/\\+/\")!=null || str.match(\"9\")!=null){\n console.log(\"YES\");\n }else{\n console.log('NO');\n \n }\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "11af632a409e60beda9a7e12e817f7e6", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nlet inputs = [];\n\n// Create readline Interface\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\n\n// Read Inputs\nrl.on('line', lineInput => {\n inputs.push(lineInput)\n})\n\nrl.on('close', () => {\n\n let arr = [];\n let bestPosition = [2, 2];\n\n for (let i = 0; i < inputs.length; i++) {\n const subArr = inputs[i].split(' ');\n arr.push(subArr);\n }\n\n // Get The position of 1\n let currentPositon = [];\n for (let i = 0; i < arr.length; i++) {\n\n for (let j = 0; j < arr[i].length; j++) {\n if (arr[i][j] == 1)\n currentPositon.push(i, j);\n }\n }\n\n // Get the max number that needs minimum steps\n\n let minimumSteps = 0\n\n if (currentPositon.toString() != bestPosition.toString()) {\n const rowSteps = currentPositon[0] - bestPosition[0];\n const colSteps = currentPositon[1] - bestPosition[1];\n minimumSteps = Math.abs(colSteps) + Math.abs(rowSteps);\n }\n\n console.log(minimumSteps);\n\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0d48998802010ff11eca7760ea11c58a", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n \nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n \nlet inputString = '';\nlet currentLine = 0;\n \nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n \nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n \nfunction readline() {\n return inputString[currentLine++];\n}\n \nconst main = () => {\n\tconst input = readline()\n\tlet regex = new RegExp(`.*${'hello'.split('').join('.*')}.*`)\n\tconsole.log(regex.test(input) ? 'YES' : 'NO')\n}\n", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "25573bab6e1005aae257ccd3b7f31bfb", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let word = readLine();\n let target = 'hello';\n let count = 0;\n for (let i = 0; i < word.length; i++) {\n if (count < target.length && word[i] === target[count]) {\n count++;\n }\n }\n if (count === 5) {\n console.log('YES');\n } else {\n console.log('NO');\n }\n}\n", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "808fc270002d9bec4e7d60cc7ba1e393", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n\n// Write your code here\nfunction nameLookUp(str) {\n let nNames = str.trim().split('');\n let dFlag = [...new Set(nNames)].length % 2 === 0 ? 'CHAT WITH HER!' : 'IGNORE HIM!';\n return dFlag.toString();\n\n}", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "f51f3073cc4e4651b8211b615b81dc61", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let readline = require('readline');\nlet rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout,\n\tterminal: false\n});\n\nlet input = [];\nrl.on('line', function(line) {\n\tinput.push(line);\n\tif (input.length === 1) {\n\t\t//n m a\n\t\ttheatreSquare(...input[0].split(' '));\n\t\trl.close();\n\t}\n});\n\nlet theatreSquare = (n, m, a) => {\n\tlet fArg = parseInt(n) / parseInt(a);\n\tlet secArg = parseInt(m) / parseInt(a);\n\tlet result = Math.ceil(fArg) * Math.ceil(secArg);\n\tconsole.log(result);\n};\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "9f79b47cdeec19a95cebc17fa8f3b4ab", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "/* eslint-disable no-continue */\n/* eslint-disable no-param-reassign */\nconst readline = require('readline').createInterface({\n input: process.stdin,\n});\n\nconst values = ['+', '-', '0', '?'];\nconst processLikes = (x, y) => (x === y ? 2 : Number(x < y));\n\nreadline.on('line', (line) => {\n const [x, y, z] = line.split(' ').map(Number);\n\n console.log(\n processLikes(x + z, y) === processLikes(x, y + z)\n ? values[processLikes(x, y)]\n : values[3],\n );\n});\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "fa9879bc24a5142016802dd6fd153ba6", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n \nrl.on('line', (input) => {\n let upper = (input.match(/[A-Z]/g) || []).length;\n let lower = (input.match(/[a-z]/g) || []).length;\n \n if(upper > lower) {\n console.log(input.toUpperCase());\n } else {\n console.log(input.toLowerCase());\n }\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "af1b88b3681087c726a1047066841dc0", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', (name) => {\n let newName = \"\"\n for(let i = 0; i < name.length; i++){\n if(newName.indexOf(name[i]) == -1){\n newName = newName + name[i]\n }\n }\n let message = newName.length % 2 == 0 ? \"CHAT WITH HER!\" : \"IGNORE HIM!\"\n console.log(message)\n rl.close()\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "f07d52112da7d6711fe206886f265a68", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nfunction test(t, k,min = 0, max = 100) {\n// console.log(`t=${t}, k=${k}`)\n if ((t < min || t > max) || (k < min || k > max) || t {\n if (argc == 0) {\n // test(input);\n [n,k] = input.split(' ').map(i => parseInt(i, 10));\n test(n,k,min=1,max=50)\n // console.log(k)\n } else {\n // this my code belong place\n a = input.split(' ').map(i => parseInt(i,10))\n ak = a.filter(x => x >= a[k-1] && x !== 0 )\n// console.log(n)\n }\n\n if (argc == 1) \n {\n // console.log(ak)\n console.log(ak.length)\n readline.close();\n }\n else argc += 1;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "aeb7ed3a23a48347aacfe7fa8fb4e6b3", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nconst readLine=()=> inputString[currentLine++];\n/* ================================================ \n Main Solution Starts Here \n===================================================*/\n\nconst main=()=>{\n\tlet n = +readLine()\n\tlet str = readLine().toLowerCase()\n\tlet pass = true\n\n\tlet alpha={}\n\tfor(let i=65;i<=90;i++)\n\t\talpha[String.fromCharCode(i).toLowerCase()]=0\n\n\tfor(let char of str)\n\t\talpha[char]++\n\n\tfor(let key in alpha){\n\t\tif(alpha[key]===0){\n\t\t\tpass=false\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif(pass)\n\t\tconsole.log('YES')\n\telse console.log('NO')\n\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "08fa25caf4db2a6c1193c98ae223430f", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n}); \n\nrl.on('line', input => {\n console.log(min(input.split(' ')));\n process.exit();\n});\n\nconst min = input => {\n const r = parseInt(input[0]);\n const g = parseInt(input[1]);\n const b = parseInt(input[2]);\n\n return Math.floor(Math.min((r+g+b)/3, (r+b+g)-Math.max(r,g,b)));\n}", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "9b8b228d8d8f962e1b3ff51069f1f650", "src_uid": "bae7cbcde19114451b8712d6361d2b01", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let readline = require('readline');\nlet rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n});\n\nrl.on('line', function(line) {\n\tluckyNum(line);\n\trl.close();\n});\n\nlet luckyNum = (input) => {\n\t// [4,7,44,77,47,74,444,447,474,477,777,774,747,744]\n\tlet luck = [ 4, 7, 44, 77, 47, 74, 444, 447, 474, 477, 777, 774, 747, 744 ];\n\tlet x = luck.filter((el) => {\n\t\tif (input % el === 0) return el;\n\t});\n\tx.length > 0 ? console.log('YES') : console.log('NO');\n};\n", "lang_cluster": "Javascript", "tags": ["brute force", "number theory"], "code_uid": "d010317dd1820fcc8a4fb3eb9d44bb1f", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n let ans = [0, 1, 5];\n let inc = 3;\n\n for (let i = 3; i <= +d; i++) {\n inc += 2;\n\n let sum = 0;\n for (let j = 1; j < inc; j += 2) {\n sum += j;\n }\n\n sum = sum * 2 + inc;\n ans[i] = sum;\n }\n\n console.log(ans[+d]);\n});\n", "lang_cluster": "Javascript", "tags": ["math", "dp", "implementation"], "code_uid": "60a5ee7b92aaec4a78ebf1b4d67b2570", "src_uid": "758d342c1badde6d0b4db81285be780c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet currentLine = 0;\nlet inputString = \"\";\n\nprocess.stdin.on(\"data\", (raw_data) => {\n inputString += raw_data;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((line) => {\n return line.trim();\n });\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n/******** Main function*************/\n\nfunction isLowerCase(str) {\n return str == str.toLowerCase() && str != str.toUpperCase();\n}\n\nfunction main() {\n var str = readLine().split(\"\");\n var string = str.join(\"\");\n var Fstr = str[0];\n var EFstr = str.slice(1);\n\n var count = 0;\n var eFstrCount = 0;\n\n for (var i = 0; i < EFstr.length; i++) {\n if (isLowerCase(EFstr[i]) === false) {\n eFstrCount++;\n }\n }\n\n for (var j = 0; j < str.length; j++) {\n if (isLowerCase(str[j]) === false) {\n count++;\n }\n }\n\n if (eFstrCount == EFstr.length && isLowerCase(Fstr)) {\n console.log(Fstr.toUpperCase() + EFstr.join(\"\").toLowerCase());\n } else if (count === str.length) {\n console.log(string.toLowerCase());\n } else {\n console.log(string);\n }\n}\n\n// either it only contains uppercase letters;\n// or all letters except for the first one are uppercase.\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "388ec1e8f08ff02dfe6ed79c9ecbaa75", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst RL = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n})\n\nRL.on('line', line => {\n let [A, B] = line.split(' ').map(x => parseInt(x))\n let years = 0\n do {\n A *= 3\n B *= 2\n years += 1\n } while ( A <= B)\n console.log(years)\n})\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "34a2b04af4977a695e8c9eda02b80d26", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false,\n});\n\nlet c = 0;\n\nrl.on(\"line\", (str) => {\n if (c === 0) {\n c++;\n return;\n }\n\n let ans = str[0];\n const vowels = {\n a: true,\n e: true,\n i: true,\n o: true,\n u: true,\n y: true,\n };\n\n for (let i = 1; i < str.length; i++) {\n if (vowels[str[i]] && vowels[ans[ans.length - 1]]) {\n continue;\n } else {\n ans += str[i];\n }\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "41430a0e8cbb9b8dea6295b32f31c494", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var N = nextInt();\n if(N % 4 == 2 || N % 4 == 1){\n myout(1);\n }else{\n myout(0);\n }\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "f69fee53dd98c57f747ed92fa92f2c47", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let fs = require('fs');\n\nlet txt = fs.readFileSync(0, \"utf-8\").split(/[\\n\\r]/).filter(data => data.length > 0);\n\nfor (let i = 0; i < txt.length; i++) {\n if (!isNaN(txt[i] * 1)) {\n let arr = [];\n for (let i1 = i + 1; i1 < i + txt[i] * 1 + 1; i1++) {\n arr.push(txt[i1].split(/[ ]/).map(data => data * 1));\n }\n doit(arr);\n }\n\n}\n\nfunction doit(tab) {\n let score = 0;\n for (let i = 0; i < tab.length; i++) {\n for (let i1 = 0; i1 < tab.length; i1++) {\n if (i != i1) {\n if (tab[i][0] == tab[i1][1]) ++score;\n }\n }\n }\n console.log(score);\n\n}", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "5ef96934fc06f52d2bf4b45fd02716a1", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//50A\n//118B\nconst readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nrl.question('', (answer) => {\n rl.close()\n let array = answer.split(\" \")\n let m = array[0]\n let n = array[1]\n let surfaceArea = m * n\n let dieh = Math.floor(surfaceArea / 2)\n console.log(dieh)\n});", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "559d86fbf474fed18403e838d0936828", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction readAsInt(){\n return parseInt(readline());\n}\n\nfunction readAsIntList(){\n return readline().split(' ').filter(i => i).map(i => parseInt(i));\n}\n\n\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n const [m, n] = readAsIntList();\n if (m % 2 === 0) {\n console.log((m / 2) * n);\n } else if (n % 2 === 0) {\n console.log((n / 2) * m);\n } else {\n console.log(((Math.max(n,m) - 1) / 2) * Math.min(n,m) + (Math.min(n,m)-1) / 2);\n }\n}\n\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "b7db9ac40886dc63554e49db103e13fc", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin\n});\n\nlet a, b, c;\nrl.on('line', (line) => {\n [a, b, c] = line.split(' ').map(i => parseInt(i));\n}).on('close', () => {\n console.log(Math.ceil(a / c) * Math.ceil(b / c));\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "6302a544b56bf75096c20f2d814a8bc7", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n console.log(+d - Math.round(+d / 3));\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "e96ca223767ca51cb9fb42ee1e866993", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\r\nprocess.stdin.resume();\r\nprocess.stdin.setEncoding('utf-8');\r\nlet inputString = '', currentLine = 0;\r\nprocess.stdin.on('data', inputStdin => { inputString += inputStdin; });\r\nprocess.stdin.on('end', _ => { \r\n inputString = inputString.trim().split('\\n').map(string => string.trim());\r\n main(); \r\n});\r\nfunction readLine() {\r\n return inputString[currentLine++];\r\n}\r\n \r\nfunction main() {\r\n const t = parseInt(readLine(), 10);\r\n for(let i = 0; i < t; i++){\r\n const x = +readLine();\r\n const arr = readLine().split(' ').map(p => +p);\r\n let result = myFunc(x, arr);\r\n console.log(result);\r\n }\r\n}\r\n \r\n \r\n\r\nfunction myFunc(x, arr){\r\n let cont = 0;\r\n while(arr[x-1] != 0){\r\n x = arr[x-1];\r\n cont++;\r\n }\r\n\r\n return cont > 1 ? 'YES' : 'NO';\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "lang_cluster": "Javascript", "tags": ["brute force", "greedy", "implementation", "math"], "code_uid": "0b851e1100cb8e72d72f36e9cc8786db", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction print(s) {\n process.stdout.write(`${s}`);\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n let n = 0;\n // input\n for (let i = 0; i < 5; i++) {\n const row = readline().split(' ').map(x => parseInt(x));\n const offsetX = row.indexOf(1);\n if (offsetX > -1) {\n n = Math.abs(offsetX - 2) + Math.abs(i - 2);\n }\n }\n\n // output\n print(n);\n}\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "44c3463cc037c7446a90bd10fcd49812", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', inputStd => inputString += inputStd);\nprocess.stdin.on('end', () => {\n inputString = inputString.trim().split('\\n').map(str => str.trim());\n main();\n});\nlet readLine = () => inputString[currentLine++];\n\nfunction solve(){\n let a,b, ans = \"\";\n a = readLine();\n b = readLine();\n for(let i = 0; i < a.length; i++){\n if(a[i] === b[i])\n ans += '0';\n else ans += '1';\n }\n console.log(ans);\n}\n\nfunction main(){\n solve();\n}\n\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "a68e9eac443311dc2da5db7f94d55382", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const n = +readLine();\n const MOD = 1e9 + 7;\n let [fact, twoPow] = [1, 1];\n\n for (let i = 1; i <= n; i++) fact = (fact * i) % MOD;\n\n for (let i = 1; i <= n - 1; i++) twoPow = (twoPow * 2) % MOD;\n\n console.log((fact - twoPow + MOD) % MOD);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "dp", "combinatorics", "graphs"], "code_uid": "165d34985234a6e8dc8a7c2d2bc6a6cc", "src_uid": "3dc1ee09016a25421ae371fa8005fce1", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nlet n;\n\nfunction testCase(n, line) {\n const input_line = line;\n const numbers_string = input_line.split(\" \");\n let sum = 0 ;\n for (cur_number in numbers_string) {\n sum += 4 * cur_number * Number(numbers_string[cur_number]);\n }\n console.log(sum);\n rl.close();\n}\n\nconst program = (line) => {\n if (!n) {\n n = parseInt(line);\n } else {\n testCase(n, line);\n }\n};\n\nrl.on('line', program);\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "445cf6cf3889809ce5967c356f5303bf", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n// HEADER:\nconst print = function(arg){\n let str = arg;\n if (arguments.length>1)\n str = Array.prototype.slice.call(arguments).join(' ');\n process.stdout.write(str+'\\n');\n};\nlet IS_MULTITEST, testN, tests;\nconst pcalc = (testN, toPrint)=>{\n let res = calc(testN);\n if (Array.isArray(res)){\n toPrint.push(res.join(' '));\n } else if (Number.isFinite(res) || typeof res=='string'){\n toPrint.push(res+'');\n }\n if (process.env.DEBUG && toPrint.length){\n let ans = toPrint.pop();\n print(ans);\n let expected = tests[testN-1];\n if (expected){\n if (expected==ans)\n console.log('\\x1b[32m%s\\x1b[0m', 'correct'); \n else {\n console.log('\\x1b[31m%s\\x1b[0m', 'wrong, expected:', expected); \n }\n }\n }\n};\n\nconst main = ()=>{\n let toPrint = [];\n L('\\nSolving:');\n if (IS_MULTITEST){\n let T = +readline()\n for (testN=1; testN<=T; testN++)\n pcalc(testN, toPrint);\n } else {\n pcalc(1, toPrint);\n }\n if (toPrint.length){\n print(toPrint.join('\\n'));\n }\n};\n\nconst lines = [];\nconst rl = require('readline').createInterface({\n input: process.stdin, output: process.stdout});\nrl.on('line', line=>{\n lines.push(line);\n});\nrl.on('close', main);\nlet rli = 0;\nconst readline = ()=>lines[rli++];\nconst L = process.env.DEBUG ? console.log : ()=>{};\nconst LT = obj=>L(`\\nTest #${testN}`, obj);\n\nconst ra = ()=>readline().split(' ').map(a=>+a)\nconst pa = arr=>print(arr.join(' '));\n\ntests = [\n``, // Test #1\n``, // Test #2\n``, // Test #3\n``, // Test #4\n``, // Test #5\n];\n\n// SOLUTION:\nIS_MULTITEST = false;\n \nconst calc = (testN)=>{\n // READING:\n let [n, x] = readline().split(' '); // 10x18\n n = +n;\n LT({n, x});\n // PROCESSING:\n if (n==x.length)\n return 0;\n let queue = [], qi = 0;\n queue.push([x, 0]);\n let visited = new Set([x]);\n while (qin || visited.has(next))\n continue;\n visited.add(next);\n queue.push([next, path+1])\n }\n }\n return -1;\n};\n ", "lang_cluster": "Javascript", "tags": ["brute force", "dfs and similar", "shortest paths", "dp", "data structures"], "code_uid": "5576ea42002622e87ad2d9f4af08e25c", "src_uid": "cedcc3cee864bf8684148df93804d029", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nreadline.on('line', line => {\n var number = parseInt(line);\n console.log(number % 2 === 0 && number > 2 ? \"YES\" : \"NO\");\n readline.close();\n});\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "ab3b1f7a001a6401df641de1d5de239e", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n var arr = readLine().split(\" \").map(Number);\n var arr1 = arr[0];\n var arr2 = arr[1];\n console.log(Math.floor((arr1 * arr2) / 2));\n}\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "b2fd40cb4b606842d7c0a913a6d7bf55", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst rl = readline.createInterface({\n\t input: process.stdin,\n\t output: process.stdout,\n\tterminal : false\n});\n\n\nrl.on(\"line\", (w)=>{\n\tif(w == 2){\n\t \tconsole.log(\"NO\")\n\treturn\n\t}\n\tconst r = w%2 ===0 ? \"YES\" : \"NO\"\n console.log(r)\t\n})\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "31b047c212b8acd560404c2b334d2471", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n const message = input[0].split('');\n const word = [0,0,0,0];\n message.forEach(letter => {\n if (letter === 'h' && word[0] === 0) word[0] += 1;\n if (letter === 'e' && word[0] === 1) word[1] += 1;\n if (letter === 'l' && word[1] >= 1) word[2] += 1;\n if (letter === 'o' && word[2] >= 2) word[3] = 1;\n });\n\n console.log(word[3] === 1 ? \"YES\" : \"NO\"); \n});", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "4943d5237639e5c77ae92992bdf3c649", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var n=0, p=0, q=0;\nconst readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\nreadline.question(``, (n) => {\n \n q= n%4;\n if(n==0) console.log(\"1\");\n else if(q==0) console.log(\"6\");\n else if(q==1) console.log(\"8\");\n else if(q==2) console.log(\"4\");\n else if(q==3) console.log(\"2\");\n readline.close()\n})\n", "lang_cluster": "Javascript", "tags": ["math", "implementation", "number theory"], "code_uid": "bbac6bef0f75a5137c00a0a993a73de7", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\n\nfunction main(){\n let num = parseInt(readline())\n let out ;\n while(true){\n num++;\n let s = new Set(num.toString().split(''))\n \n if(s.size == 4 ){\n out = num\n break;\n } \n }\n console.log(num); \n}", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "6427c076828d6a31b0c4453cdd90adb7", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (str) => {\n const vowels = ['a', 'e', 'i', 'o', 'u', 'y'];\n const newStr = str.replace(/\\s+/g, '').replace(/\\?+/g, '');\n\n if (vowels.includes(newStr[newStr.length - 1].toLowerCase())) {\n console.log('YES');\n }\n else {\n console.log('NO');\n }\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "d28ce6eb14654791f76a9415a7666f40", "src_uid": "dea7eb04e086a4c1b3924eff255b9648", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n// CODE HERE\n\tlet [a, b] = input[0].split(' ').map(x => +x);\n\tfor(let i = 1; i > 0; i++){\n a = 3*a;\n b = 2*b;\n if ( a > b){\n console.log (i);\n break;\n }\n }\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "9a89de682720f4f9587b322c9c48e7a5", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n let n = Number(d);\n let steps = 0;\n let substract = 5;\n\n while (n > 0) {\n while (substract <= n && n !== 0) {\n n -= substract;\n steps++;\n }\n\n substract--;\n }\n\n console.log(steps);\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "e3836b36ce6b3eb16a065b599ed46d7f", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\n\n\nrl.on('line', (input) => {\n\n var splitstr = input.split(\" \")\n var a = parseInt (splitstr[0])\n var b = parseInt (splitstr[1])\n var c = parseInt (splitstr[2])\n var y = Math.ceil(a/c)\n var x = Math.ceil(b/c)\n console.log(x*y)\n \n})\n\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "c035f1d15dc30cdc2788cf10fda3711f", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let store = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}];\n\nfunction checkDigit(n, dig) {\n if (dig === 0 && n === 0) {\n return { count: 0, decrement: 0 };\n }\n return {\n count: 1,\n decrement: Math.max(n, dig) - n\n };\n}\n\nfunction splitNumber(n) {\n const digitsPow = 10 ** Math.floor(Math.log10(n));\n let first = Math.floor(n / digitsPow);\n let tail = n % digitsPow;\n return [first, tail];\n}\n\nfunction solveCore(n, dig = 0) {\n if (store[dig][n]) {\n return store[dig][n];\n }\n if (n < 10) {\n return (store[dig][n] = checkDigit(n, dig));\n }\n\n let rest = n;\n let [first, tail] = splitNumber(rest);\n let count = 0;\n\n while (rest > 0) {\n const r = solveCore(tail, Math.max(first, dig));\n count += r.count;\n rest -= tail + r.decrement;\n [first, tail] = splitNumber(rest);\n }\n\n return (store[dig][n] = { count, decrement: -rest });\n}\nfunction solve(n) {\n store = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}];\n const r = solveCore(n, 0);\n return r.count;\n}\n\nfunction* main() {\n const n = parseInt(yield);\n const r = solve(n);\n console.log(r);\n process.exit(0);\n}\n\nif (!module.parent) {\n (() => {\n const q = main();\n q.next();\n require(\"readline\")\n .createInterface({\n input: process.stdin,\n output: null\n })\n .on(\"line\", line => q.next(line));\n })();\n}\n\nexports.solve = solve;\n", "lang_cluster": "Javascript", "tags": ["dp"], "code_uid": "11c47e00d5f0b3400ccd8fcd558614e2", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume()\nprocess.stdin.setEncoding(\"utf-8\")\nlet inputString = \"\"\nlet lines = []\nlet currentLine = 0\nprocess.stdin.on(\"data\", (inputStdin) => {\n inputString += inputStdin\n})\nprocess.stdin.on(\"end\", (_) => {\n lines = inputString\n .trim()\n .split(\"\\n\")\n .map((string) => {\n return string.trim()\n })\n main()\n})\n\nfunction readline() {\n return lines[currentLine++]\n}\n\nfunction main() {\n const a = readline()\n .split(\" \")\n .map((x) => parseInt(x))\n console.log(Math.ceil(a[0] / a[2]) * Math.ceil(a[1] / a[2]))\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "b02646875d6e5d7775fa0f204e95ee6e", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction multiply(a, b) {\n\ta = a.toString(10).split('').reverse();\n\tb = b.toString(10).split('').reverse();\n\n\tif (a.length < b.length) {\n\t\t[a, b] = [b, a];\n\t}\n\n\tlet res = Array(a.length + b.length).fill(0);\n\tfor (let i = 0, lb = b.length; i < lb; ++i) {\n\t\tlet carry = 0;\n\t\tlet scarry = 0;\n\t\tfor (let j = 0, la = a.length; j < la; ++j) {\n\t\t\tlet m = b[i] * a[j];\n\t\t\tm += carry;\n\n\t\t\tif (m > 9) {\n\t\t\t\tlet [c, d] = m.toString(10).split('');\n\t\t\t\tres[i + j] += (scarry >> 0) + (d >> 0);\n\t\t\t\tcarry = c >> 0;\n\t\t\t} else {\n\t\t\t\tres[i + j] += (scarry >> 0) + m;\n\t\t\t\tcarry = 0;\n\t\t\t}\n\n\t\t\tif (res[i + j] > 9) {\n\t\t\t\tlet [c, d] = res[i + j].toString(10).split('');\n\t\t\t\tres[i + j] = d >> 0;\n\t\t\t\tscarry = c;\n\t\t\t} else {\n\t\t\t\tscarry = 0;\n\t\t\t}\n\t\t}\n\t\tif (carry > 0) res[a.length + i] = carry;\n\t\tif (scarry > 0) res[a.length + i] = scarry;\n\t}\n\n\tres.reverse();\n\tlet mulVal = '';\n\tlet flag = false;\n\tres.forEach(d => {\n\t\tif (!flag && d !== 0) flag = true;\n\t\tif (flag) mulVal += d;\n\t});\n\treturn mulVal;\n}\n\nfunction main() {\n\tlet [s1, s2, s3] = readLine()\n\t\t.split(' ')\n\t\t.map(x => x >> 0);\n\tlet res =\n\t\t4 *\n\t\t(Math.sqrt((s1 * s3) / s2) +\n\t\t\tMath.sqrt((s1 * s2) / s3) +\n\t\t\tMath.sqrt((s2 * s3) / s1));\n\tconsole.log(Math.floor(res));\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "geometry"], "code_uid": "12fbf540420d98432696bcf60bf039bf", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline= require('readline');\nvar rl = readline.createInterface(process.stdin, process.stdout); \nrl.question('', (arg1)=>{\n\trl.question('', (arg2)=>{\t\n\t\tvar c = 0;\n\t\tfor (var i = 0; i < arg1; i++) {\n\t\t\tif(arg2[i]==8){\n\t\t\t\tc++;\n\n\t\t}\n\t}\n\t\targ1=Math.floor(arg1/11);\n\t\tif (c>arg1) {\n\t\tc=arg1;\n\t\t\n\t\t}\n\t\tconsole.log(c);\n\t\trl.close();\n\t});\n\t\n});\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "16ece58cb03e400a775dc2ed9f0f3b7e", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n let curr = 0;\n let n = +d;\n let ans = 'NO';\n\n let inc = 0;\n while (curr <= n) {\n curr = inc * (inc + 1) / 2;\n if (curr === n) {\n ans = 'YES';\n }\n inc++;\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "8e83b5f7ac56a82254679d98b710798a", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var fs = require('fs')\nvar pb = fs.readFileSync(0, {encoding: \"utf8\"}); // STDIN_FILENO = 0\npb = pb.split(\" \").map(x=>x*1);\nconsole.log(Math.ceil(pb[0]/pb[2])*Math.ceil(pb[1]/pb[2]))", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "d3c3bf47570049497708a76adc374952", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\nlet numberOfStones;\nlet arrOfStones;\nlet previousElement;\nlet counter = 0;\nrl.on(\"line\", (input) => {\n if (!numberOfStones) {\n numberOfStones = parseInt(input.split(\" \"))\n // console.log(numberOfStones, typeof (numberOfStones))\n } else {\n arrOfStones = input.split(\" \").toString();\n // console.log(arrOfStones, typeof (arrOfStones))\n for (let i = 0; i < arrOfStones.length; i++) {\n const currentElement = arrOfStones[i];\n if (!previousElement) {\n previousElement = currentElement;\n continue;\n } else {\n previousElement = arrOfStones[i-1];\n if (previousElement == currentElement) {\n counter++\n }\n else continue ;\n\n }\n\n\n } \n console.log(counter)\n rl.close();\n }\n\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "ed8ee363efbde7b995b5f745ae782f7a", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require(\"readline\");\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on(\"line\", function(line){\n\n if (line.indexOf(\"+\") == -1) {\n console.log(line);\n } else {\n var a = line.split(\"+\"); \n i = 0;\n while (i <= a.length){\n for (var j = 0; j< a.length; j++){\n if (a[j]> a[j+1]) {\n var aux = a[j];\n a[j] = a[j+1];\n a[j+1] = aux;\n } \n }\n i++;\n \n } \n var s=\"\";\n for (var j = 0; j< a.length; j++){\n s=s+ a[j] + \"+\"\n }\n console.log(s.slice(0, -1));\n }\n process.exit(0);\n});", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "0de2984f71123b9dc82253cd3eba81a6", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n let [len, targetIndex] = readLine()\n .split(\" \")\n .map((n) => parseInt(n));\n let [leftLen, rightLen] = [0, 0];\n if (len % 2 === 0) [leftLen, rightLen] = [len / 2, len / 2];\n else [leftLen, rightLen] = [Math.floor(len / 2) + 1, len - (Math.floor(len / 2) + 1)];\n\n if (targetIndex <= leftLen) {\n console.log(2 * (targetIndex - 1) + 1);\n } else {\n targetIndex = targetIndex - leftLen;\n console.log(2 * targetIndex);\n }\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "de32c4973b0defcbd197f0969c928c5b", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet l = 0;\nrl.on('line', (input) => {\n rl.close();\n let inp = input.split(\" \").map(x => parseInt(x))\n let res = Math.ceil((inp[0]*8)/inp[1]) + Math.ceil((inp[0]*5)/inp[1]) + Math.ceil((inp[0]*2)/inp[1])\n console.log(res)\n return 0;\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "f7f06a60bb512d35bfd3dcbc178c4bb9", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\n// const fs = require('fs');\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n const arr = readLine().split(' ');\n const k = Number(arr[0]);\n const n = Number(arr[1]);\n const w = Number(arr[2]);\n var total = 0;\n for (var i = 1; i <= w; i++) {\n total += (i * k);\n }\n if (total <= n) {\n console.log(0);\n } else {\n console.log(total - n);\n }\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "304a8586b55cd867e3c282f98454f6d8", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// https://codeforces.com/problemset/problem/977/B\n// Big O:\n// n: string length\n// Time complexity: O(n)\n// Space complexity:\n\nconst readline = require(\"readline\");\n\n// Read input\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet stringLength;\nrl.on('line', (input) => {\n if (stringLength) {\n console.log(findMostCommonGram(input, stringLength));\n rl.close();\n } else {\n stringLength = input;\n }\n});\n\n// Problem\nfunction findMostCommonGram(string, stringLength) {\n let mostCommonGram = \"\";\n let mostCommonGramOccurrences = 0;\n const gramOccurrences = {};\n\n for (let i = 0; i < stringLength - 1; i++) {\n const twogram = string[i] + string[i + 1];\n const occurrences = gramOccurrences[twogram] ? gramOccurrences[twogram] : 0;\n const currentOcurrences = occurrences + 1;\n if (currentOcurrences > mostCommonGramOccurrences) {\n mostCommonGram = twogram;\n mostCommonGramOccurrences = currentOcurrences;\n }\n\n gramOccurrences[twogram] = currentOcurrences;\n }\n\n return mostCommonGram;\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "573167806554b6d47d643e37bba0890f", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = '';\nprocess.stdin.on('data', c => i += c);\nprocess.stdin.on('end', () => {\n const { EOL, } = require('os');\n const weight = i.split(EOL);\n const val = weight[0];\n\n const result = ((val >= 4) && (val % 2 === 0)) ? 'YES' : 'NO';\n\n console.log(result);\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "61f8f60cd8ec9e8837a80562b274bb5d", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function read(cb) {\n let buffer = ''\n process.stdin.on('end', () => cb(buffer))\n process.stdin.on('data', data => buffer += data.toString())\n}\n\nread(input => {\n const [a, b] = input.split(/\\W/).map(Number)\n if (a === b) {\n console.log(1)\n } else {\n console.log(Math.ceil(Math.log(b/a) / (Math.log(3) - Math.log(2))))\n }\n})\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "052ff63044ad8c8a35ac005e8ae80f83", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n let n = parseInt(input[0]);\n let title = input[1];\n\n let flag = false; let count = 0; let answer = 0;\n for(let i = 0; i < n; i++){\n if(title.charAt(i) === 'x' && !flag){\n flag = true; count++;\n } else if(title.charAt(i) === 'x' && flag){\n count++;\n } else if(title.charAt(i) !== 'x' && flag){\n if(count >= 3)\n answer += count-2;\n count = 0;\n flag = false;\n }\n }\n if(flag)\n if(count >= 3)\n answer += count - 2;\n console.log(answer);\n})\n\n", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "f34494f6b2c73dd7fd68eba8d5a5c079", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "/* eslint-disable no-continue */\n/* eslint-disable no-param-reassign */\nconst readline = require('readline').createInterface({\n input: process.stdin,\n});\n\nconst processLikes = ({ x, y, z }) => {\n if (Math.abs(x - y) > z || z === 0) {\n if (x === y) {\n return '0';\n }\n\n if (x > y) {\n return '+';\n }\n\n return '-';\n }\n\n return '?';\n};\n\nreadline.on('line', (line) => {\n const [x, y, z] = line.split(' ').map(Number);\n\n console.log(processLikes({ x, y, z }));\n});\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "54b7d2fab77c7f49a5377694b24dae28", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\n\nconst runMain = () => {\n inputString = inputString.trim().split('\\n').map(string => string.trim());\n main();\n process.exit();\n}\nconst readLine = () => inputString[currentLine++];\n\nprocess.stdin.on('data', inputStdin => inputString += inputStdin);\nprocess.stdin.on('end', runMain);\nprocess.on('SIGINT', runMain);\n\nfunction main() {\n let [n, k] = readLine().split(' ').map(num => Number(num));\n while (k--) {\n if (n % 10 === 0) {\n n /= 10;\n } else {\n n -= 1;\n }\n }\n console.log(n);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "bc324acd90efb6fe2f144bc5d2796f0d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n let [n] = input[0].split(' ').map(x => parseInt(x));\n let left = 0, right = n-1;\n\n let cntOne = 0, cntZero = 0;\n const nums = input[1].split(' ').map(x => parseInt(x));\n nums.forEach(x => x === 0 ? cntZero += 1 : cntOne += 1);\n\n let max = cntZero;\n\n for (let i = 0; i < nums.length; i += 1) {\n let tmpSumZero = 0, tmpSumOne = 0;\n for (let j = i; j < nums.length; j += 1) {\n for (let k = i; k <= j; k += 1)\n nums[k] === 0 ? tmpSumZero += 1 : tmpSumOne += 1;\n \n if (max < cntOne - tmpSumOne + tmpSumZero) max = cntOne - tmpSumOne + tmpSumZero;\n tmpSumZero = 0; tmpSumOne = 0;\n }\n }\n console.log(max);\n}); ", "lang_cluster": "Javascript", "tags": ["brute force", "dp", "implementation"], "code_uid": "bf6d831061f40bf673515d336c40b134", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\n'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\n\nfunction main(){\n\n var n = readline();\n var a = readline().split(\" \").map(x=> parseInt(x));\n a.sort((x,y) => x-y);\n \n let c = 0;\n for(let i=0;i {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let w = readline();\n if(w > 1 && (w-2)>0 && (w-2) %2 == 0 )console.log(\"YES\");\n else console.log(\"NO\");\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "3bfa45f9ddc6cb6cc3da1df8b73735cd", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n const arr = d.split(' ').map(Number);\n arr.sort((a, b) => a - b);\n let ans = 0;\n\n for (let i = 0; i < arr.length; i++) {\n let curr = arr[i];\n if (curr !== 0) {\n arr[i] = 0;\n ans++;\n\n for (let j = i + 1; j < arr.length; j++) {\n if (arr[j] % curr === 0) {\n arr[j] = 0;\n }\n }\n }\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math", "greedy", "implementation"], "code_uid": "c3685ddba799c8db73cafd70d0f1de9a", "src_uid": "63d9b7416aa96129c57d20ec6145e0cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let givenYearNumber = parseInt(readLine());\n while (true) {\n givenYearNumber++;\n let firstDigit = parseInt(givenYearNumber / 1000);\n let SecondDigit = parseInt((givenYearNumber / 100) % 10);\n let ThirdDigit = parseInt((givenYearNumber / 10) % 10);\n let LastDigit = givenYearNumber % 10;\n if (\n firstDigit !== SecondDigit &&\n firstDigit !== ThirdDigit &&\n firstDigit !== LastDigit &&\n SecondDigit !== ThirdDigit &&\n SecondDigit !== LastDigit &&\n ThirdDigit !== LastDigit\n ) {\n break;\n }\n }\n console.log(givenYearNumber);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "93d6af0a9503800d496bf387987f4ff7", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n let [len, time] = readLine()\n .split(\" \")\n .map((n) => parseInt(n));\n let arr = readLine().split(\"\");\n while (time--) {\n for (let i = 0; i < len - 1; i++) {\n if (arr[i] === \"B\" && arr[i + 1] === \"G\") {\n [arr[i], arr[i + 1]] = [arr[i + 1], arr[i]];\n i++;\n }\n }\n }\n console.log(arr.join(\"\"));\n}\n", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "3f9414e7ab8cdd1f1b4c598281ce93af", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst elevatorOrStairs = (data) => {\n let arry = data.split(' ');\n let x = arry[0],\n y = arry[1],\n z = arry[2],\n t1 = arry[3],\n t2 = arry[4],\n t3 = arry[5];\n\n let stairs = Math.abs((x - y) * t1);\n let elevator = Math.abs(x - z) * t2 + 3 * t3 + Math.abs(x - y) * t2;\n\n return elevator <= stairs ? 'YES':'NO';\n}\n\nlet rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (line) => {\n console.log(elevatorOrStairs(line));\n process.exit();\n})\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "fc0d94ab63b10f80ed89d08bea2b1718", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "function ProblemSolver() {\n this.HAS_TEST_CASES = false;\n this.INPUT_FILE_NAME = \"test.in\";\n this.OUTPUT_FILE_NAME = \"out.txt\";\n this.DO_OUTPUT_TO_FILE = false;\n this.CLEAR_ARRAY_PER_CASE = false;\n\n this.solveCase = function() {\n var res , i , j , fl , cn , temp , k , l , str1 , str2 ;\n res = 0 ;\n len = this.s.length ;\n lim = Math.floor( ( len + this.k ) / 2 ) ;\n for( l = 1 ; l <= lim ; l++ ) {\n \tfor( i = 0 ; i < len + this.k ; i++ ) {\n \t\tstr1 = '' ;\n \t\tfor( j = i ; j < i + l && j < len + this.k ; j++ ) {\n \t\t\tif( j >= len ) {\n \t\t\t\tstr1 += 'a' ;\n \t\t\t}\n \t\t\telse {\n \t\t\t\tstr1 += this.s.charAt( j ) ;\n \t\t\t}\n \t\t}\n \t\tif( str1.length == l ) {\n \t\t\tstr2 = '' ;\n\t \t\tfor( j = i + l ; j < i + 2 * l && j < len + this.k ; j++ ) {\n\t \t\t\tif( j >= len ) {\n\t \t\t\t\tif( j - l < len ) {\n\t \t\t\t\t\tstr2 += this.s.charAt( j - l ) ;\n\t \t\t\t\t}\n\t \t\t\t\telse {\n\t \t\t\t\t\tstr2 += 'a' ;\n\t \t\t\t\t}\n\t \t\t\t}\n\t \t\t\telse {\n\t \t\t\t\tstr2 += this.s.charAt( j ) ;\n\t \t\t\t}\n\t \t\t}\n\t \t\tif( str2.length == l && str1 == str2 ) {\n\t \t\t\tres = l * 2 ;\n\t \t\t\tbreak ;\n\t \t\t}\n \t\t}\n \t}\n }\n print( res );\n };\n\n this.init = function() {\n this.lim1 = 100010;\n this.lim2 = 110;\n this.cc = 1;\n this.ind = 1;\n this.n = 0;\n this.cn = 0;\n this.declareAndFillArrays();\n };\n\n this.getInput = function( irObj ) {\n var hasMoreInput , i;\n hasMoreInput = true;\n try {\n this.s = irObj.nextString();\n this.k = irObj.nextInt();\n }\n catch( ex ) {\n hasMoreInput = false;\n }\n return hasMoreInput;\n };\n\n this.clearArraysPerCase = function() {\n var i;\n this.arr = new Array();\n this.adj_list = new Array();\n for( i = 0 ; i < this.lim1 ; i++ ) {\n this.arr.push( 0 );\n this.adj_list.push( new Array() );\n }\n };\n\n this.clearPerCase = function() {\n this.cn = 0;\n this.cc++;\n if( this.CLEAR_ARRAY_PER_CASE == true ) {\n this.clearArraysPerCase() ;\n }\n };\n\n this.declareAndFillArrays = function() {\n var i , j;\n this.srr = new Array();\n this.vis = new Array();\n this.arr = new Array();\n this.brr = new Array();\n this.memo = new Array();\n this.done = new Array();\n this.adj_list = new Array();\n for( i = 0 ; i < this.lim1 ; i++ ) {\n this.srr.push( \"\" );\n this.vis.push( 0 );\n this.arr.push( 0 );\n this.brr.push( 0 );\n this.adj_list.push( new Array() );\n }\n for( i = 0 ; i < this.lim2 ; i++ ) {\n this.memo.push( new Array() );\n this.done.push( new Array() );\n for( j = 0 ; j < this.lim2 ; j++ ) {\n this.memo[ i ].push( -1 );\n this.done[ i ].push( 0 );\n }\n }\n };\n\n this.init();\n}\n\nfunction InputReader() {\n var self = this ;\n this.allLines = new Array();\n this.currrentLineNumber = 0;\n this.currrentCharacterIndex = 0;\n this.callBackFunction = null ;\n this.parentContext = null ;\n\n this.readAllLines = function() {\n var singleLine;\n while( true ) {\n try {\n singleLine = readline();\n if( singleLine == null ) {\n break;\n }\n }\n catch( ex ) {\n break;\n }\n this.allLines.push( singleLine );\n }\n };\n \n this.readAllLinesFromRhino = function() {\n var brObj , line ;\n importPackage( java.io ) ;\n importPackage( java.lang ) ;\n brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;\n this.allLines = [] ;\n while( true ) {\n line = brObj.readLine() ;\n if( line == null ) {\n break;\n }\n this.allLines.push( line ) ;\n }\n };\n \n this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {\n self.chunkData += chunk ;\n };\n\n this.readEndFromNodeJsJudgeServer = function() {\n self.parseRawData( self.chunkData ) ;\n self.parentContext.runCases() ;\n };\n \n this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {\n this.parentContext = parentContext ;\n process.stdin.resume() ;\n process.stdin.setEncoding( 'utf8' ) ;\n this.chunkData = '' ;\n process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;\n process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;\n };\n\n this.parseRawData = function( data ) {\n var len , i , currentString;\n len = data.length;\n currentString = \"\";\n this.allLines = [] ;\n for( i = 0 ; i < len ; i++ ) {\n if( data[ i ] == '\\r' ) {\n }\n else if( data[ i ] == '\\n' ) {\n this.allLines.push( currentString );\n currentString = \"\";\n }\n else {\n currentString += data[ i ];\n }\n }\n if( currentString != \"\" ) {\n this.allLines.push( currentString );\n }\n };\n\n this.readAllLinesFromFile = function( inputFileName ) {\n var currentDirectory , fsObj , inputFilePath , rawData;\n fsObj = require( 'fs' );\n currentDirectory = __dirname;\n inputFilePath = currentDirectory + \"\\\\\" + inputFileName;\n rawData = fsObj.readFileSync( inputFilePath , \"utf8\" );\n this.parseRawData( rawData );\n };\n\n this.next = function( flag ) {\n var len , i , startIdx , res , endIdx;\n if( flag == 0 ) {\n if( this.currrentCharacterIndex != 0 ) {\n this.currrentLineNumber++;\n this.currrentCharacterIndex = 0;\n }\n res = \"\";\n len = this.allLines[ this.currrentLineNumber ].length;\n if( typeof( len ) == 'function' ) {\n len = this.allLines[ this.currrentLineNumber ].length() ;\n }\n for( i = this.currrentCharacterIndex ; i < len ; i++ ) {\n res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;\n }\n this.currrentLineNumber++;\n this.currrentCharacterIndex = 0;\n return res;\n }\n while( true ) {\n if( this.currrentLineNumber >= this.allLines.length ) {\n throw new Error( \"No more tokens available!\" );\n }\n startIdx = -1;\n len = this.allLines[ this.currrentLineNumber ].length;\n if( typeof( len ) == 'function' ) {\n len = this.allLines[ this.currrentLineNumber ].length() ;\n }\n for( i = this.currrentCharacterIndex ; i < len ; i++ ) {\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {\n startIdx = i;\n break;\n }\n }\n if( startIdx == -1 ) {\n this.currrentLineNumber++;\n this.currrentCharacterIndex = 0;\n continue;\n }\n res = \"\";\n endIdx = len - 1 ;\n for( i = startIdx ; i < len ; i++ ) {\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {\n endIdx = i;\n break;\n }\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {\n res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;\n }\n else {\n res += '' + this.allLines[ this.currrentLineNumber ].charAt( i );\n }\n }\n this.currrentCharacterIndex = endIdx;\n if( endIdx == len - 1 ) {\n this.currrentLineNumber++;\n this.currrentCharacterIndex = 0;\n }\n return res;\n }\n };\n\n this.nextInt = function() {\n return parseInt( this.next( 1 ) );\n };\n\n this.nextDouble = function() {\n return parseFloat( this.next( 1 ) );\n };\n\n this.nextString = function() {\n return this.next( 1 );\n };\n\n this.nextLine = function() {\n return this.next( 0 );\n };\n}\n\nfunction FileOutputHandler() {\n this.resultantStringArray = new Array();\n\n this.addNewLine = function( newString ) {\n this.resultantStringArray.push( newString );\n };\n\n this.clearPercase = function() {\n this.resultantStringArray = new Array();\n };\n\n this.flushOutOutputToFile = function( outputFileName ) {\n var i , sz , res , currentDirectory , fsObj , outputFilePath;\n res = \"\";\n sz = this.resultantStringArray.length;\n for( i = 0 ; i < sz ; i++ ) {\n if( i != 0 ) {\n res += \"\\n\";\n }\n res += this.resultantStringArray[ i ];\n }\n fsObj = require( 'fs' );\n currentDirectory = __dirname;\n outputFilePath = currentDirectory + \"\\\\\" + outputFileName;\n fsObj.writeFileSync( outputFilePath , res );\n this.clearPercase();\n };\n}\n\nfunction CodeExecutioner() {\n this.irObj = new InputReader();\n this.psObj = new ProblemSolver();\n this.fohObj = new FileOutputHandler();\n\n this.runCases = function() {\n if( this.psObj.HAS_TEST_CASES == true ) {\n testCases = this.irObj.nextInt();\n for( i = 0 ; i < testCases ; i++ ) {\n this.psObj.clearPerCase();\n this.psObj.getInput( this.irObj );\n this.psObj.solveCase();\n }\n }\n else {\n while( true ) {\n this.psObj.clearPerCase();\n hasMoreTestCases = this.psObj.getInput( this.irObj );\n if( hasMoreTestCases == false ) {\n break;\n }\n this.psObj.solveCase();\n }\n }\n if( this.psObj.DO_OUTPUT_TO_FILE == true ) {\n this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );\n }\n };\n\n this.detectEnvironmentType = function() {\n var environmentType = null ;\n try {\n if( importPackage != null ) {\n environmentType = 'rhino' ;\n }\n }\n catch( ex1 ) {\n try {\n //for nodejs local server check\n if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {\n environmentType = 'local-node-js' ;\n }\n }\n catch( ex2 ) {\n try {\n if( readline == null || typeof( readline ) != 'function' ) {\n environmentType = 'server-node-js' ;\n }\n else {\n try {\n if( Map != null ) {\n environmentType = 'spider-monkey' ;\n }\n else {\n environmentType = 'javascript-v8' ;\n }\n }\n catch( ex3 ) {\n environmentType = 'javascript-v8' ;\n }\n }\n }\n catch( ex3 ) {\n environmentType = 'server-node-js' ;\n }\n }\n }\n return environmentType ;\n };\n\n this.configureStreamsAndReadInput = function() {\n var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , environmentType ;\n isNodeJsJudgeServer = false ;\n environmentType = this.detectEnvironmentType() ;\n if( environmentType == 'local-node-js' ) {\n try {\n if( print == null || typeof( print ) != 'function' ) {\n print = console.log;\n }\n }\n catch( ex ) {\n print = console.log;\n }\n if( this.psObj.DO_OUTPUT_TO_FILE == true ) {\n localContext = this.fohObj;\n print = function() {\n localContext.addNewLine.apply( localContext , arguments );\n }\n }\n this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );\n this.runCases() ;\n }\n else if( environmentType == 'server-node-js' ) {\n try {\n if( print == null || typeof( print ) != 'function' ) {\n print = console.log;\n }\n }\n catch( ex ) {\n print = console.log;\n }\n this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;\n }\n else if( environmentType == 'javascript-v8' ) {\n this.irObj.readAllLines();\n this.runCases() ;\n }\n else if( environmentType == 'rhino' ) {\n this.irObj.readAllLinesFromRhino();\n this.runCases() ;\n }\n else if( environmentType == 'spider-monkey' ) {\n this.irObj.readAllLines();\n this.runCases() ;\n }\n };\n \n this.configureStreamsAndReadInput();\n}\n\nnew CodeExecutioner();\n", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "6c598125946c9f8e37d9f20fea9166a3", "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(str) {\n\n let inputs = str.trim().split(' ');\n let currentShoesIndex = [...new Set(inputs)].length;\n let shoesToBuy = 4 - currentShoesIndex;\n return shoesToBuy.toString();\n}\n\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "5ba0fb0c26ee03293cf7b3c345bfaef7", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst rl = readline.createInterface({\n\t input: process.stdin,\n\t output: process.stdout,\n\tterminal : false\n});\n\n\nrl.on(\"line\", main)\nlet m = 0\nlet n = 0\nfunction main(input){\n\tconst mxn = input.split(' ')\n\t\n\tm = mxn[0]\n\tn = mxn[1]\n\t\n\ta = m*n\n\t\n\tif(a%2 !== 0){\n\t\tconsole.log((a-1)/2)\n\t}\n\telse{\n\t\tconsole.log(a/2)\n\t}\n\t\n\n}\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "65d7f70afaa2c07c5c39d0fc52bd9e58", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = ''\nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os')\n const lines = i.split(EOL) /*your input text, split by lines*/\n let input = lines[0].split(\" \").map(value => {\n return parseInt(value)\n })\n\n let aCount = input[0]\n let bCount = input[1]\n let abCount = input[2]\n\n if (bCount > aCount) {\n let maximumACount = aCount\n let maximumBCount = aCount + 1\n let maximumABCountSeperated = abCount * 2\n let maximumLength = maximumACount + maximumBCount + maximumABCountSeperated\n console.log(maximumLength)\n } else if (bCount < aCount) {\n let maximumACount = bCount + 1\n let maximumBCount = bCount\n let maximumABCountSeperated = abCount * 2\n let maximumLength = maximumACount + maximumBCount + maximumABCountSeperated\n console.log(maximumLength)\n } else if (aCount === bCount) {\n let maximumACount = aCount\n let maximumBCount = bCount\n let maximumABCountSeperated = abCount * 2\n let maximumLength = maximumACount + maximumBCount + maximumABCountSeperated\n console.log(maximumLength)\n }\n})\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "2099c87f391290b24e8bc87ad9e90a96", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const arr = d.split(' ').map(Number);\n let ans = 0;\n const max = Math.max(...arr);\n\n for (let i = 0; i < arr.length - 1; i++) {\n for (let j = i + 1; j < arr.length; j++) {\n if (arr[i] + arr[j] <= max) {\n ans = max - (arr[i] + arr[j]) + 1;\n }\n }\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "geometry"], "code_uid": "5550b7dc34f3eebd2eb14d1e501274b7", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n\tvar one = nextIntArray();\n var A = one[0];\n var B = one[1];\n var output = 0;\n while(A <= B){\n A *= 3;\n B *= 2;\n output++;\n }\n myout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "c4895928f6aefeb80a9195df447b7810", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction print(s) {\n process.stdout.write(`${s}`);\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n // input\n const a = readline();\n const b = readline();\n let result = 0;\n for (let i = 0; i < a.length; i++) {\n const c1 = a.charAt(i).toLowerCase();\n const c2 = b.charAt(i). toLowerCase();\n if (c1 < c2) {\n result = -1;\n break;\n }\n if (c1 > c2) {\n result = 1;\n break;\n }\n }\n // output\n print(result);\n}\n\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "44988ae077b21e3be69b9796ac9391de", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const stdin = process.stdin;\nstdin.setEncoding('UTF-8');\n\nstdin.on('data', (data) => {\n let arr = data.split(' ').map((x)=>{return parseInt(x);});\n console.log(Math.ceil(arr[0]/arr[2])*Math.ceil(arr[1]/arr[2]));\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "a6ffc9a27424c037aa72698dca4a1285", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let nk = readLine().split(' ').map(v => parseInt(v));\n let n = nk[0];\n let k = nk[1];\n let time = 240 - k; //240-222= 18\n let ans = 0;\n let p = 0;\n for (var i = 1; i <= n; i++) {\n p += 5 * i;\n if (p > time) break;\n else ans++;\n\n }\n console.log(ans);\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation", "binary search"], "code_uid": "5ae32ff4068556f5918d6644b59ed0c9", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const stdin = process.openStdin();\nlet n;\nlet i = 0;\nlet output = 0;\n\nprocess.stdin.on('data', function (chunk) {\n lines = chunk.toString().split('\\n');\n lines = lines.map(a => a.trim().toLowerCase());\n if (lines[0] > lines[1]) { console.log('1'); }\n if (lines[0] < lines[1]) { console.log('-1'); }\n if (lines[0] === lines[1]) { console.log('0'); }\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "eb11cf0feb8fe54ea60f47468678d26d", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const solve = (n, m, a) => {\n if (n <= a) {\n if (m <= a) {\n return 1;\n } else {\n return 1 * Math.floor(m / a);\n }\n } else {\n if (m <= a) {\n return 1 * Math.floor(n / a);\n } else {\n let ms, ns;\n if (m % a != 0) {\n ms = Math.ceil(m / a);\n } else {\n ms = m / a;\n }\n if (n % a != 0) {\n ns = Math.ceil(n / a);\n } else {\n ns = n / a;\n }\n return ms * ns;\n }\n }\n};\n\nconst main = () => {\n const readline = require('readline');\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n });\n let input;\n rl.on('line', function (line) {\n input = line.split(\" \").map(x => Number(x));\n console.log(solve(input[0], input[1], input[2]));\n });\n\n};\n\nmain()", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "ea0b75b10b40f6136dce2ff95e3634e1", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n let {0:a, 1:b, 2:c} = {...input[0].split(' ')};\n a = parseInt(a); b = parseInt(b); c = parseInt(c);\n\n let steps = 0;\n while(true){\n if(a+b > c && a+c > b && c+b > a)\n break;\n else {\n if(a > b && a > c && b > c)\n c++;\n else if(a > b && a > c && c >= b)\n b++;\n else if(b > c && b > a && c >= a)\n a++;\n else if(b > c && b > a && a >= c)\n c++;\n else if(c > b && c > a && a >= b)\n b++;\n else if (c > b && c > a && b > a)\n {\n a++;\n }\n steps++;\n }\n }\n console.log(steps);\n});\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "geometry"], "code_uid": "43779c83e9526f8b5ecab5e580306fcf", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let data = '';\nprocess.stdin.on('data', input => data += input);\nprocess.stdin.on('end', () => {\n const score = (arr1, arr2, n) => {\n let x = 0, y = 0;\n for (let i = 0; i < n; i++) {\n if (arr1[i] > arr2[i]) x++;\n if (arr1[i] < arr2[i]) y++;\n }\n if (x === 0) return -1;\n return Math.ceil( (y + 1) / x );\n }\n const inputStrings = data.split('\\n');\n const n = parseInt(inputStrings[0], 10);\n const arr1 = inputStrings[1].split(' ').map(Number);\n const arr2 = inputStrings[2].split(' ').map(Number);\n const answ = score(arr1,arr2,n)+ '\\n';\n process.stdout.write(answ);\n});", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "f9e505b1791174dd123ec60d45fcdc41", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function onlyUnique(value, index, self) { \n return self.indexOf(value) === index;\n}\nlet i = ''\nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os');\n const lines = i.split(EOL);\n //console.log(lines); \n let name = lines[0];\n var unique = Array.from(name).filter(onlyUnique);\n //console.log(unique);\n if(unique.length%2)\n console.log('IGNORE HIM!');\n else\n console.log('CHAT WITH HER!');\n})\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "18730875862ead4754a84b108316217e", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nconst arr = [];\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n arr.push(d.split(' ').map(Number));\n\n c++;\n});\n\nrl.on('close', () => {\n let ans = 0;\n\n for (let i = 0; i < arr.length; i++) {\n for (let j = 0; j < arr.length; j++) {\n ans += arr[i][j];\n }\n }\n\n if (arr.length > 3) {\n ans -= arr[0][1];\n ans -= arr[0][arr.length - 2];\n ans -= arr[arr.length - 1][1];\n ans -= arr[arr.length - 1][arr.length - 2];\n ans -= arr[1][0];\n ans -= arr[1][arr.length - 1];\n ans -= arr[arr.length - 2][0];\n ans -= arr[arr.length - 2][arr.length - 1];\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "bb038eebdb114032e0863668a44363d7", "src_uid": "5ebfad36e56d30c58945c5800139b880", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "/**\n * Problem - http://codeforces.com/contest/1084/problem/A\n */\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf8');\n\nvar input_stdin = '';\nvar input_stdin_array = '';\nvar input_currentline = 0;\n\nprocess.stdin.on('data', function (data) {\n input_stdin += data;\n});\n\nprocess.stdin.on('end', function () {\n input_stdin_array = input_stdin.split('\\n');\n main();\n});\n\nfunction readLine() {\n return input_stdin_array[input_currentline++];\n}\n\nfunction main() {\n let numFloors = Number(readLine());\n let floors = readLine().split(' ').map(Number);\n let minCost = Number.POSITIVE_INFINITY;\n\n for ( let i = 0 ; i < numFloors ; i++ ) {\n let currentX = i;\n let currentCost = 0;\n floors.forEach( function( numPeople, currentFloor ) {\n currentCost = currentCost + numPeople * 2 * ( Math.abs ( currentX - currentFloor ) + Math.abs( currentFloor ) + Math.abs( -currentX ) );\n } );\n if ( currentCost < minCost ) {\n minCost = currentCost;\n }\n }\n process.stdout.write(String(minCost));\n process.exit();\n}", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "f58b3b1d7bd24ee17abe239731c87a88", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const n = +d;\n let sum = 0;\n let ans = 0;\n let c = 1;\n\n while (sum < n) {\n let s = 0;\n for (let j = 1; j <= c; j++) {\n s += j;\n }\n\n sum += s;\n c++;\n\n if (sum > n) {\n break;\n }\n else {\n ans++;\n }\n }\n\n console.log(ans);\n\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "6324106b6c7a0c3a66faa0866938b061", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var s = next();\n var ok = new Set([\"a\",\"e\",\"i\",\"o\",\"u\",\"1\",\"3\",\"5\",\"7\",\"9\"]);\n var count = 0;\n for(var i = 0; i < s.length; i++){\n if(ok.has(s[i])){\n count++;\n }\n }\n myout(count);\n}", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "78144aeffe6c963e518b1bb750c5137e", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// https://codeforces.com/problemset/problem/1091/A\n// Big O:\n// Time complexity:\n// Space complexity:\n\n// Read input\nconst readline = require(\"readline\")\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', (input) => {\n const numbers = input.split(\" \").map(Number);\n const yellow = numbers[0];\n const blue = numbers[1];\n const red = numbers[2];\n console.log(findMaxOrnaments(yellow, blue, red));\n rl.close();\n});\n\nfunction findMaxOrnaments(yellow, blue, red) {\n const isYellowMinimum = yellow <= blue && yellow <= red\n\n if (isYellowMinimum) {\n let solutionFound = false;\n let yellowChosen = yellow;\n let blueChosen = 0;\n let redChosen = 0;\n while (!solutionFound) {\n blueChosen = 1 + yellowChosen;\n redChosen = blueChosen + 1;\n if (blueChosen > blue || redChosen > red) {\n yellowChosen = yellowChosen - 1;\n } else {\n solutionFound = true;\n }\n\n }\n return yellowChosen + blueChosen + redChosen;\n }\n\n const isBlueMinimum = blue <= yellow && blue <= red;\n if (isBlueMinimum) {\n let solutionFound = false;\n let yellowChosen = 0;\n let blueChosen = blue;\n let redChosen = 0;\n while (!solutionFound) {\n yellowChosen = blueChosen - 1;\n redChosen = blueChosen + 1;\n if (yellowChosen > yellow || redChosen > red) {\n blueChosen = blueChosen - 1;\n } else {\n solutionFound = true;\n }\n\n }\n\n return yellowChosen + blueChosen + redChosen;\n }\n\n\n let solutionFound = false;\n let yellowChosen = 0;\n let blueChosen = 0;\n let redChosen = red;\n while (!solutionFound) {\n yellowChosen = redChosen - 2;\n blueChosen = redChosen - 1;\n if (yellowChosen > yellow || blueChosen > blue) {\n redChosen = redChosen - 1;\n } else {\n solutionFound = true;\n }\n\n }\n return yellowChosen + blueChosen + redChosen;\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "72d2ea4a7ffba243ec3ee26d0ac0b839", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n \nconst input = [];\nreadLine.on('line', line => input.push(line));\n \nreadLine.on('close', () => {\n\tconst _input = parseInt(input[0], 10)\n\tif (_input % 2 === 0) {\n\t\tconsole.log('Mahmoud')\n\t} else {\n\t\tconsole.log('Ehab')\n\t}\n})", "lang_cluster": "Javascript", "tags": ["math", "games"], "code_uid": "5e56dc4d0c97813e77d6d24eb47a8ec2", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = '';\nprocess.stdin.on('data', (c) => {\n i += c;\n});\nprocess.stdin.on('end', () => {\n const { EOL } = require('os');\n const lines = i.split(EOL);\n const b = parseInt(lines[0], 10);\n const g = parseInt(lines[1], 10);\n const n = parseInt(lines[2], 10);\n console.log(badges(b, g, n));\n});\n\n\nfunction badges(b, g, n) {\n if (n === b + g) return 1;\n const min = Math.min(b, g);\n const sub = Math.max(b, g) < n ? n - Math.max(b, g) : 0;\n return min >= n ? 1 + n - sub : 1 + min - sub;\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "3c57f6dbb92389371de0e505f29f2db0", "src_uid": "9266a69e767df299569986151852e7b1", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n let w = parseInt(readLine());\n if (w === 2) {\n console.log('NO');\n return;\n }\n if (w % 2 === 0) {\n console.log('YES');\n } else {\n console.log('NO');\n }\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "b6c3f1bc5373045304c23c171862f650", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\n\nlet a, b, c;\nrl.on('line', (line) => {\n [a, b, c] = line.split(' ').map(i => parseInt(i));\n}).on('close', () => {\n process.stdout.write(\"\" + Math.ceil(a / c) * Math.ceil(b / c));\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "ccb92a18efbc30770b5cf498816ad67e", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString\n .trim()\n .split('\\n')\n .map(string => {\n return string.trim();\n });\n\n process.stdout.write(String(main(inputString)));\n process.exit();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nconst main = ([inputString]) => {\n const [height, width, tileSize] = inputString.split(' ');\n const verticalTiles = Math.ceil(height / tileSize); // 2\n\n const horizontalTiles =\n Math.ceil((width - tileSize) / tileSize) * verticalTiles;\n return verticalTiles + horizontalTiles;\n};\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "18b9f2fd133c18b6f8b1c3b55cb00019", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\nconst countFunction = () => {\n let n = +input[0];\n console.log(n % 2 === 0 ? n / 2 : Math.floor(n / 2) - n );\n};\n\nreadLine.on('close', countFunction);\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "64a48fc5fc0765516bd88018eca0a7ed", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let fs = require(\"fs\");\n\nlet txt = fs.readFileSync(0, \"utf-8\").split(\"\\r\\n\").filter(data => {\n return data.length > 0;\n});\nfor (let index = 0; index < txt.length; index++) {\n doit(txt[index]*1);\n}\n\nfunction doit(num) {\n let r=Math.floor(num/5);\n if(num%5!==0){\n ++r;\n }\n console.log(r);\n \n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "5a1dbb1ee3a9ac4fbe0ec02c979e973b", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nvar dp = {};\n\nfunction fibonacci(n) {\n\tif (n === 0) return 0;\n\tif (n === 1) return 1;\n\n\tif (dp[n] !== undefined) return dp[n];\n\tlet result = fibonacci(n - 1) + fibonacci(n - 2);\n\treturn (dp[n] = result);\n}\n\nfunction main() {\n\tlet s = readLine().split('');\n\tlet t = readLine();\n\tif (s.reverse().join('') === t) console.log('YES');\n\telse console.log('NO');\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "9d570e78c300695e0bf3b38d88d1900f", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\n\nconst readline = require(\"readline\");\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.question('', (number) => {\n console.log(cal(parseInt(number))) ; \n rl.close();\n});\n\nrl.on(\"close\", () => {\n process.exit(0);\n}); \n\n\nfunction cal(num){\n let res = [] ; \n for(let i=1 ; i<=Math.ceil(num/2) ; i++) { \n if(num % i === 0) res.push(i) ;\n } \n return res.length ; \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "e8f5b2cd02698eae305bcfb9f4eae55c", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst rl = readline.createInterface({\n input: process.stdin\n})\n\nrl.on('line', line => {\n const [a, b] = line.split(' ').map(v => parseInt(v, 10))\n console.log(solve(a, b))\n})\n\nfunction solve(a, b) {\n let years = 0\n \n while (a <= b) {\n a *= 3\n b *= 2\n years++\n }\n \n return years\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "fefea36412894d03c74c7d149408ed0a", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin\n})\n\nrl.on('line', (l) => {\n let count = 0;\n for (let x = 0; x < l.length; x++) {\n if (l.charAt(x) === 'Q') {\n for (let y = x+1; y < l.length; y++) {\n if (l.charAt(y) === 'A') {\n for (let z = y+1; z < l.length; z++) {\n if (l.charAt(z) === 'Q') {\n count++;\n }\n }\n }\n }\n }\n }\n console.log(count)\n rl.close();\n})\n", "lang_cluster": "Javascript", "tags": ["brute force", "dp"], "code_uid": "7ac9352d205b54f1f9146c8d33a89c24", "src_uid": "8aef4947322438664bd8610632fe0947", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on(\"line\",(name) => {\n const n = parseInt(name)\n \n if(n % 2 == 0 && n > 2 ){\n console.log(\"YES\");\n\n }else{\n console.log(\"NO\")\n }\n process.exit()\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "619a77cf6eef2be6c307c2d24fcfa2c4", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var K = nextInt();\n var L = nextInt();\n var M = nextInt();\n var D = nextInt();\n var N = nextInt();\n var output = 0;\n for(var i = 1; i <= N; i++){\n if(i % K == 0 || i % L == 0 || i % M == 0 || i % D == 0){\n output++;\n }\n }\n myout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "32cbb143cb36af103d50e16930ea47a0", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\n\"use strict\";\nlet input = [];\nconst readline=require('readline');\nconst RL=readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nRL.on('line', (line)=>{\n input.push(line.trim());\n});\nRL.on('close', ()=>{\n const [n, m] = input[0].split(' ').map((str)=>{\n return parseInt(str);\n })\n\n console.log(Math.floor((n*m)/2));\n});\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "2a0609902787ddb4a1dada2a6fe4df9b", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n let n = parseInt(readLine());\n let pagesInWeekDays = readLine().split(' ').map(Number);\n // while (result < 100) {\n // result = result +\n // }\n function recursion(totalpagesPerWeak) {\n // console.log(totalpagesPerWeak);\n // let [\n // monday,\n // tuseday,\n // wednessday,\n // thursday,\n // friday,\n // saturday,\n // sunday,\n // ] = pagesInWeekDays;\n\n for (let i = 0; i < pagesInWeekDays.length; i++) {\n totalpagesPerWeak = totalpagesPerWeak + pagesInWeekDays[i];\n if (totalpagesPerWeak >= n) {\n // console.log(totalpagesPerWeak);\n console.log(i + 1);\n return;\n }\n }\n if (!(totalpagesPerWeak >= n)) {\n // console.log(n);\n // console.log(totalpagesPerWeak);\n // totalpagesPerWeak = n - totalpagesPerWeak; // 1\n recursion(totalpagesPerWeak);\n }\n }\n recursion(0);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "b18ee8d01253d3bc5f4f9bca659d4713", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf8\");\n\n// var getline;\nvar input = \"\";\nvar read;\nvar writeline = (x) => process.stdout.write(x + \"\\n\");\nvar write = (x) => process.stdout.write(x);\n\nprocess.stdin.on(\"data\", (chunk) => input += chunk);\nprocess.stdin.on(\"end\", () => {\n // input = input.split(/\\r?\\n/);\n // getline = () => input.shift();\n input = input.trim().split(/\\s+/);\n read = () => input.shift();\n process.exit(main() || 0);\n});\n\nfunction main() {\n let l;\n while ((l = read()) !== undefined) {\n let x = parseInt(l);\n if (x === 0 || (x > 2 && x % 2 === 0)) {\n writeline('YES')\n } else {\n writeline('NO')\n }\n }\n return 0;\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "45c21682c74a80cd3392c0a79fe89082", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n let {0:n, 1:k} = {...input[0].split(' ')};\n n = parseInt(n); k = parseInt(k);\n //2 red, 5 green, 8 blue\n //k pages \n let n_b = n*8; let n_r = 2*n; let n_g = 5*n;\n let answer = 0;\n answer += Math.ceil(n_b/parseFloat(k));\n answer += Math.ceil(n_r/parseFloat(k));\n answer += Math.ceil(n_g/parseFloat(k));\n\n console.log(answer);\n});\n\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "806d7862e0a294503356cac89ba01988", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const [n, k] = d.split(' ').map(Number);\n const reminder = (n + 1) % k;\n const ans = reminder !== 0 ? k - reminder + n + 1 : n + 1;\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "8533caf317d94bc71cbb731613fab598", "src_uid": "75f3835c969c871a609b978e04476542", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n readline();\n const arr = readline().split(' ').map(x => parseInt(x)).sort((a,b) => a - b)\n console.log(arr.join(' '))\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "d5bc8a83c31240bdb7656f0c1c2a9f04", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let z = '';\nprocess.stdin.on('data', c => z += c);\nprocess.stdin.on('end', () => {\n const {\n EOL\n } = require('os');\n let input = z.split(EOL)[0];\n input = input.split(' ').map(item=>parseInt(item));\n let lengthRes = 0;\n lengthRes += 2*input[2];\n if(input[0]>input[1])\n return console.log((2*(input[1]+input[2]))+1);\n else if(input[0] 0 && +scoresArr[i] >= kScore) {\n count++;\n }\n }\n return count.toString();\n\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "62cfa2562946b69d1279ba46627710b8", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.question('', (numbers) => {\n console.log(doit(numbers.split(' ')));\n rl.close();\n});\n\nrl.on(\"close\", () => {\n process.exit(0);\n});\n\nconst doit = (numbers) => ((+numbers[1] / +numbers[0]) >= 1 && (+numbers[2] / +numbers[0]) >= 1) ? \"Yes\" : \"No\";\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "ef03a38cb158e84dd7e473252af0dd2b", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet l = 0;\nrl.on('line', (input) => {\n rl.close();\n let numbers = input.split(' ').map(x=>parseInt(x))\n console.log(Math.min(Math.min(numbers[0]+2,numbers[1]+1),numbers[2])*3-3)\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "6d4924e2c2745dce6eca010da2072867", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n \nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n \nlet inputString = '';\nlet currentLine = 0;\n \nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n \nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n \nfunction readline() {\n return inputString[currentLine++];\n}\n/**\n4\n22\n9999\n1\n777\n\n\n**/\n\nfunction gcd(a, b) {\n if (!b) {\n return a;\n }\n\n return gcd(b, a % b);\n};\n\nfunction lcm(a, b) {\n return (a / gcd(a, b) * b);\n}\n\nfunction main() { \n let n = Number(readline());\n\n for(let r=0;r data += c);\n\nfunction* nextLine() {\n\tlet lines = data.trim().split(/\\n/g);\n\tfor(let l of lines){\n\t\tyield l.trim();\n\t}\n}\n\nlet nl = nextLine();\n\nnl.elem = function(funParse) {\n\t\treturn funParse(this.next().value);\t\n\t};\n\nnl.array = function(funParse) {\n\t\treturn this.next().value.split(/\\s/g).map(funParse||(x => x));\n\t};\n\t\nnl.num = function() {\n\t\treturn nl.elem(Number);\n\t};\n\t\nnl.nums = function() {\n\t\treturn nl.array(Number);\n\t};\n\t\nnl.line = function() {\n\t\treturn this.next().value;\n\t};\n\t\nconst sol = () => {\n\tlet [x, y] = nl.nums();\n\tif (y%x !== 0){\n\t\tconsole.log(-1);\n\t} else {\n\t\tlet a = y/x;\n\t\tlet cnt = 0;\n\t\twhile(a%2 === 0){\n\t\t\tcnt++;\n\t\t\ta /= 2;\n\t\t}\n\t\twhile(a%3 === 0){\n\t\t\tcnt++;\n\t\t\ta /= 3;\n\t\t}\n\t\tconsole.log((a === 1)?cnt:-1);\n\t}\n\n};\n\nprocess.stdin.on('end', sol);\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "6012d49ffe51edf18cf936e153370f77", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = ''\nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os')\n const lines = i.split(EOL) /*your input text, split by lines*/\n let fileNameLength = lines[0]\n let fileName = lines[1]\n let newFileName = buildNewFileName(fileName)\n let omittedCharactersCount = fileNameLength - newFileName.length\n console.log(omittedCharactersCount)\n})\n\nfunction buildNewFileName(fileName) {\n let explodedName = fileName.split(\"\")\n \n let xCount = 0\n let newFileName = \"\";\n explodedName.forEach(element => {\n if (element === 'x') {\n xCount++;\n } else {\n xCount = 0\n }\n\n if (xCount < 3) {\n newFileName += element\n }\n });\n return newFileName\n}", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "119eb864b763b1202ee9c33bbfab16da", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n let num = parseInt(input[0]);\n\n if (num % 2 === 0) {\n console.log(num/2);\n } else {\n console.log( ((num+1) / 2)*(-1) );\n }\n});", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "f36014c66e270d53abd4a7bbe6e0021a", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\n\n// Create readline Interface\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\n\n// Read Inputs\nrl.on('line', lineInput => {\n check(lineInput)\n})\n\n\nfunction check(num) {\n\n if (parseInt(num) % 7 === 0 || \n parseInt(num) % 4 === 0 || \n parseInt(num) % 47 === 0)\n return console.log(\"YES\")\n else {\n4\n const nums = num.split('');\n\n for (let i = 0; i < nums.length; i++) {\n\n if (nums[i] != 4 && nums[i] != 7)\n return console.log(\"NO\")\n }\n\n return console.log(\"YES\")\n\n }\n\n}", "lang_cluster": "Javascript", "tags": ["brute force", "number theory"], "code_uid": "5023fe38eece5ddcd3f84d14d0b07cb3", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString\n .trim()\n .split('\\n')\n .map(string => {\n return string.trim();\n });\n\n process.stdout.write(main(inputString));\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nconst main = ([inputString]) => {\n const [n, k] = inputString.split(' ');\n let ans = n;\n for (let i = 0; i < k; i += 1) {\n const str = String(ans);\n const endingDigit = str[str.length - 1];\n if (endingDigit === '0') {\n ans = ans / 10;\n } else {\n ans -= 1;\n }\n }\n return String(ans);\n};\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "17c0bfcdb85f0582477f8860ef54b128", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString\n .trim()\n .split('\\n')\n .map(string => {\n return string.trim();\n });\n\n process.stdout.write(String(main(inputString)));\n process.exit();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nconst main = ([inputString]) => {\n let vowelsStripped = inputString\n .toLowerCase()\n .replace(/(a|e|i|o|u|y)/g, '');\n let ans = '';\n for (let i = 0; i < vowelsStripped.length; i += 1) {\n ans += `.${vowelsStripped[i]}`;\n }\n return ans;\n};\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "9fea7709d02e8540019745e15d446be0", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "(()=>{\"use strict\";var t={675:(t,r)=>{Object.defineProperty(r,\"__esModule\",{value:!0}),Array.prototype.sortAsc=function(){return this.sort(((t,r)=>t-r))},Array.prototype.sortDesc=function(){return this.sort(((t,r)=>r-t))},Array.prototype.max=function(){return Math.max(...this)},Array.prototype.min=function(){return Math.min(...this)},Array.prototype.sum=function(){let t=0;for(let r=0;r{if(l)return s=o.default.readFileSync(\"input.txt\").toString().trim().split(\"\\n\").map((t=>t.trim())),t(),void o.default.writeFileSync(\"output.txt\",a);process.stdin.resume(),process.stdin.setEncoding(\"utf-8\"),process.stdin.on(\"data\",(t=>{u+=t})),process.stdin.on(\"end\",(r=>{s=u.trim().split(\"\\n\").map((t=>t.trim())),t(),console.log(a)}))};function f(){return s[i++]}function p(){return f().split(\" \").map((t=>parseFloat(t)))}function d(){return f().split(\"\")}r.default={runMain:c,runEachTest:t=>{c((()=>{let[r]=p();for(;r>0;)t(),r--}))},readline:f,nextNumbers:p,nextNumbersMatrix:function(t){let r=[];for(let e=0;e=n;){if(s-=n,!(s>=u)){i+=u-s;break}s-=u}i+=(t-r)/e,o.default.put(i)}))},747:t=>{t.exports=require(\"fs\")}},r={};!function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{}};return t[n].call(o.exports,o,o.exports,e),o.exports}(965)})();", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "532594cadb0cbc93e5c2acfef3b1a111", "src_uid": "e4a4affb439365c843c9f9828d81b42c", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdout.write(\"\");\n\nprocess.stdin.on('data', function(data) {\n process.stdout.write(data % 2 == 0 && data != 2 ? \"YES\" : \"NO\");\n process.exit();\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "c252acff36e1d770cd8035c2df621e61", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var DEBUG = false;\nvar { EOL } = require('os');\nvar fs = require('fs');\n\nvar r = process.stdin;\nif (DEBUG) {\n r = fs.createReadStream('input');\n}\nvar data = '';\nr.on('data', c => (data += c));\nr.on('end', () => {\n var lines = data.split(EOL);\n var arr = [];\n var d;\n [arr[0], arr[1], arr[2], d] = lines[0].split(' ').map(Number);\n arr.sort(function(a, b) {\n return a - b;\n });\n var res = Math.max(0, d - (arr[1] - arr[0]));\n res += Math.max(0, d - (arr[2] - arr[1]));\n console.log(res);\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "e3688f60ff7e9ba18f35478752fea07e", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nconst petya = () => {\n let a = input[0].toLowerCase();\n let b = input[1].toLowerCase();\n if (a > b) {\n console.log(1);\n }\n else if (b > a) {\n console.log(-1);\n }\n else {\n console.log(0);\n }\n};\n\nreadLine.on('close', petya);", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "e72becbe36fc75f8bb134b478fb5adc3", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nconst can = {\n 0: 1,\n 3: 1,\n 7: 1,\n};\n\nfor (let i = 0; i <= 100; i++) {\n if (can[i]) {\n can[i + 3] = 1;\n can[i + 7] = 1;\n }\n}\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n if (can[+d]) {\n console.log('YES');\n }\n else {\n console.log('NO');\n }\n\n // let n = +d;\n // let ans = 'NO';\n\n // while (n > 0) {\n // if (n % 7 === 0) {\n // ans = 'YES';\n // break;\n // }\n\n // if (n % 3 === 0) {\n // ans = 'YES';\n // break;\n // }\n\n // n -= 7;\n // }\n\n // n = +d;\n // while (n > 0) {\n // if (n % 7 === 0) {\n // ans = 'YES';\n // break;\n // }\n\n // if (n % 3 === 0) {\n // ans = 'YES';\n // break;\n // }\n\n // n -= 3;\n // }\n\n // console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["greedy", "implementation"], "code_uid": "c6d79906adf420b55319bf97826f4193", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n\nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n \nRL.on('line', (line) => {\n input.push(line);\n});\n\nfunction solver(n, m) {\n let first = 0, second = 0, copyN = n;\n let point = (m % 2 === 0) ? m : m + 1;\n\n while (copyN !== point/2) {\n if (copyN > point/2) {\n first += copyN - (point/2);\n copyN = point/2;\n }\n if (copyN < point/2) { copyN *= 2; first += 1; }\n }\n first += (m % 2 === 0) ? 1 : 2;\n\n copyN = n;\n while (copyN !== m) {\n if (copyN < m) copyN *= 2;\n else {\n second += copyN - m;\n break;\n }\n second += 1;\n }\n \n return Math.min(first, second);\n}\n\nRL.on('close', () => {\n let [n, m] = input[0].split(' ').map(x => parseInt(x));\n\n const nums = new Set();\n let arr = [n]; let answ = 0;\n while (true) {\n const data = [];\n for (let i = 0; i < arr.length; i += 1) {\n const x = arr[i];\n\n if (!nums.has(x - 1) && x - 1 >= 1) {\n if (x - 1 === m) { console.log(answ + 1); return; }\n data.push(x-1);\n nums.add(x - 1);\n } \n\n if (!nums.has(x * 2) && x * 2 <= m + 100) {\n if (x * 2 === m) { console.log(answ + 1); return; }\n data.push(x * 2);\n nums.add(x * 2);\n }\n }\n\n arr = data;\n answ += 1;\n }\n});", "lang_cluster": "Javascript", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "14cf22dfdadc9376826fa6138e9aad9c", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\n//////////// LIBS\nObject.defineProperty(exports, \"__esModule\", { value: true });\nclass IO {\n constructor() {\n this.lines = [];\n this.tokens = [];\n this.lines = require('fs').readFileSync(0, 'utf8').split('\\n');\n }\n getTokens() {\n if (!this.tokens.length) {\n this.tokens = this.nextLine().split(' ');\n }\n return this.tokens;\n }\n nextLine() {\n return this.lines.shift().trim();\n }\n nextNum() {\n return Number(this.getTokens().shift());\n }\n nextNumArray(n) {\n let ret = [];\n while (n--) {\n ret.push(this.nextNum());\n }\n return ret;\n }\n}\nfunction solve(n, k) {\n const mod = 1e9 + 7;\n let ret = 1;\n while (k--) {\n ret = (ret * n) % mod;\n }\n console.log(ret);\n}\nfunction main() {\n const io = new IO();\n let t = io.nextNum();\n while (t--) {\n let n = io.nextNum();\n let k = io.nextNum();\n solve(n, k);\n }\n}\nmain();\n", "lang_cluster": "Javascript", "tags": ["math", "combinatorics", "bitmasks"], "code_uid": "f62d23262deac218981ebdc7cfb92fb3", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', inputStd => inputString += inputStd);\nprocess.stdin.on('end', () => {\n inputString = inputString.trim().split('\\n').map(str => str.trim());\n solve();\n});\nlet readLine = () => inputString[currentLine++];\n\nfunction solve(){\n const n = +(readLine());\n let a = [], b = [];\n let suma = 0, sumb = 0;\n for(let i = 0; i < n; i++){\n let line = readLine();\n a.push(+(line[0]));\n b.push(+(line[2]));\n suma += a[i];\n sumb += b[i];\n }\n let check = (s,t) => s%2 == 0 && t%2 == 0;\n let bool = false;\n if(check(suma, sumb)){\n console.log(0);\n return;\n }\n for(let i = 0; i < n; i++){\n let at = suma, bt = sumb;\n at -= a[i];\n bt -= b[i];\n at += b[i];\n bt += a[i];\n if(check(at, bt)){\n console.log(1);\n return;\n }\n }\n console.log(-1);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "d435c170467e601000dba865451b64ed", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet n, m;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n [n, m] = d.split(' ').map(Number);\n return;\n }\n\n const arr = d.split(' ').map(Number);\n arr.sort((a, b) => a - b);\n let ans = Infinity;\n\n for (let i = 0; i <= arr.length - n; i++) {\n let v = arr[i + n - 1] - arr[i];\n ans = Math.min(v, ans);\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "9694bc6e82f7a3aa2a6e426e00374e3f", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "(()=>{\"use strict\";var t={312:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,\"__esModule\",{value:!0});const u=r(n(747));let o=\"\",s=[],i=0,l=\"\";const a=\"local\"===process.argv[2];function c(){return s[i++]}e.default={runMain:t=>{if(a)return s=u.default.readFileSync(\"input.txt\").toString().trim().split(\"\\n\").map((t=>t.trim())),t(),void u.default.writeFileSync(\"output.txt\",l);process.stdin.resume(),process.stdin.setEncoding(\"utf-8\"),process.stdin.on(\"data\",(t=>{o+=t})),process.stdin.on(\"end\",(e=>{s=o.trim().split(\"\\n\").map((t=>t.trim())),t(),console.log(l)}))},readline:c,nextNumbers:function(){return c().split(\" \").map((t=>parseFloat(t)))},put:function(t){l+=t},puts:function(t){l+=t+\"\\n\"},debug:function(t){a&&console.log(t)}}},965:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,\"__esModule\",{value:!0});const u=r(n(312));u.default.runMain((function(){const t=u.default.nextNumbers();u.default.puts(Math.ceil(t[0]/t[2])*Math.ceil(t[1]/t[2]))}))},747:t=>{t.exports=require(\"fs\")}},e={};!function n(r){if(e[r])return e[r].exports;var u=e[r]={exports:{}};return t[r].call(u.exports,u,u.exports,n),u.exports}(965)})();", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "0d0f3e854a2a9e6a208ef7c6b58222fd", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nvar dp = {};\n\nfunction fibonacci(n) {\n\tif (n === 0) return 0;\n\tif (n === 1) return 1;\n\n\tif (dp[n] !== undefined) return dp[n];\n\tlet result = fibonacci(n - 1) + fibonacci(n - 2);\n\treturn (dp[n] = result);\n}\n\nfunction main() {\n\tlet n = readLine() >> 0;\n\tlet m = readLine()\n\t\t.split(' ')\n\t\t.map(x => x >> 0);\n\n\tm.sort((a, b) => b - a);\n\n\tif (n === 0) {\n\t\tconsole.log(0);\n\t\treturn;\n\t}\n\n\tlet c = 0,\n\t\ts = 0;\n\tfor (let i = 0; i < 12; ++i) {\n\t\ts += m[i];\n\t\tif (s >= n) {\n\t\t\tc++;\n\t\t\tbreak;\n\t\t}\n\t\tc++;\n\t}\n\n\tif (s < n) console.log(-1);\n\telse console.log(c);\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "1958e09d4f156cabf30e06c92787b4a1", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n \nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n const set = new Set();\n input[0].split(' ').forEach(x => set.add(x));\n\n console.log(4 - set.size);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "08955b3fc96956b20cf1a9ddbc232102", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet l = 0;\nrl.on('line', (input) => {\n rl.close();\n let inp = input.split(\"\")\n let res = \"\"\n if (inp.length >= 2 && inp.length % 2 === 1) {\n res += inp[Math.floor((inp.length / 2))]\n } else if (inp.length >= 2 && inp.length % 2 === 0) {\n res += inp[Math.floor((inp.length / 2) - 1)]\n }\n let ln = inp.length % 2 === 1 ? inp.length / 2 : inp.length / 2\n ln = Math.floor(ln)\n let inc = inp.length % 2 === 1 ? 0 : 1\n for (let i = 1; i < ln; i++) {\n res += inp[ln + i - inc]\n res += inp[ln - i - inc]\n }\n res += inp[inp.length - 1]\n if (inp.length > 1 && inp.length % 2 == 1) {\n res += inp[0]\n }\n console.log(res)\n return 0;\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "300edb177c22510e8fc07451b9b983cc", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction checkBeautifullYear(y) {\n let k = String(y);\n let arr = k.split('').map(value => parseInt(value));\n let p;\n for (var i = 0; i < arr.length; i++) {\n if (arr.indexOf(arr[i]) == i) {\n p = 0;\n } else {\n p = 1;\n break;\n }\n }\n if (p == 0) {\n return true;\n } else return false;\n}\n\nfunction main() {\n let y = readLine();\n let ans = parseInt(y) + 1;\n while (true) {\n if (checkBeautifullYear(ans) == true) {\n break;\n } else {\n ans += 1;\n }\n }\n console.log(ans);\n}", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "d1e367338cdd0153031317827a731a27", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const str1 = readLine();\n const str2 = readLine();\n\n if (str1.split(\"\").reverse().join(\"\") === str2) {\n console.log(\"YES\");\n } else {\n console.log(\"NO\");\n }\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "8208922aa9f6364df1d5678ce29d27f0", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet inputString = \"\";\nlet currentLine = 0;\n\nprocess.stdin.on(\"data\", (inputStdin) => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .replace(/\\s*$/, \"\")\n .split(\"\\n\")\n .map((str) => str.replace(/\\s*$/, \"\"));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n const nd = readLine().split(\" \");\n const length = parseInt(nd[0], 10);\n const array = readLine()\n .split(\" \")\n .map((aTemp) => parseInt(aTemp, 10));\n\n let count = 0;\n for (let i = 0; i < length - 1; i++) {\n for (let j = 1; j < length; j++) {\n if (array[j - 1] > array[j]) {\n [array[j - 1], array[j]] = [array[j], array[j - 1]];\n }\n }\n }\n for (let g = 0; g < array.length; g += 2) {\n if (array[g + 1] > array[g]) {\n count += array[g + 1] - array[g];\n }\n }\n console.log(count);\n}\n\n// sortTeams(length, students);\n\n// const input = prompt(\"Friends\");\n\n// const meetFriends = () => {\n// let friends = input.split(\" \");\n// let distance = 0;\n\n// for (let i = 1; i < friends.length; i++) {\n// let current = friends[i];\n\n// let index = i;\n\n// while (index >= 0 && current < friends[index - 1]) {\n// friends[index] = friends[index - 1];\n// index--;\n// }\n// friends[index] = current;\n// }\n// distance = friends[2] - friends[0];\n// console.log(distance);\n// };\n\n// meetFriends(input);\n\n// const input1 = parseInt(prompt(\"First length\"))\n// const input2 = prompt(\"First text\")\n// const input3 = parseInt(prompt(\"Second length\"))\n// const input4 = prompt(\"Second text\")\n\n// const chooseTwoNumbers = () => {\n// let first = input2.split(\" \");\n// let second = input4.split(\" \");\n\n// for (let i = 1; i < input1; i++) {\n// let current = first[i];\n\n// let index = i;\n\n// while (index >= 0 && current < first[index - 1]) {\n// first[index] = first[index - 1];\n// index--;\n// }\n// first[index] = current;\n// }\n// for (let i = 1; i < input3; i++) {\n// let current = second[i];\n\n// let index = i;\n\n// while (index >= 0 && current < second[index - 1]) {\n// second[index] = second[index - 1];\n// index--;\n// }\n// second[index] = current;\n// }\n\n// if (\n// first[input1 - 1] >= second[input3 - 1] &&\n// first[0] >= second[input3 - 1]\n// ) {\n// console.log(\"YES\");\n// } else if (first[input1 - 1] <= second[0] && first[0] <= second[0]) {\n// console.log(\"YES\");\n// } else {\n// console.log(\"NO\");\n// }\n// };\n\n// chooseTwoNumbers();\n", "lang_cluster": "Javascript", "tags": ["sortings"], "code_uid": "8a3913446e2e73c5c2a95fa811c5360c", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data', function(data) {\n let [n, k] = data.toString().trim().split(' ').map(Number);\n for (let i = 0; i < k; i++) {\n if (n.toString().endsWith('0')) {\n n = parseInt(n / 10);\n } else {\n n = n - 1;\n }\n }\n console.log(n);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "ae93bc03e716b1491347070cf4ce9047", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n const nn = readline().split(' ');\n var n = nn[0];\n let arr = nn.slice(1); \n n = parseInt(n);\n \n arr = arr.map(ele => parseInt(ele))\n \n console.log(cutRibbon(n, arr));\n}\n\n\nfunction cutRibbon(ribbon, piecesLength) {\n let cuts = new Array(ribbon + 1).fill(0);\n cuts[0] = 0;\n piecesLength.forEach(ele => {\n cuts[ele] = 1;\n });\n\n for(let i = 1; i <= ribbon; i ++) {\n let cur = cuts[i]; \n for(let piece of piecesLength){\n\n \tif(piece <= i){\n \t if(cuts[i - piece] > 0){\n cur = Math.max(cur, 1 + cuts[i - piece]);\t\n \t }\n \t}\n } \n \n cuts[i] = cur;\n } \n return cuts[ribbon];\n\n}\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "dp"], "code_uid": "e096f7e2c3a8cd579bcd5f27b7fdfd23", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let _inputLines;\nlet _lineNumber = 0;\nlet inputReader = _inputReader ();\n \nfunction _main() {\n \n\t_inputLines = _inputData.trim().split('\\n').map((string) => {\n\t\treturn string.trim();\n\t});;\n\tvar t = inputReader.readNumber();\n\tfunction print(x) { console.log(x); }\n\twhile (t--) {\n\t var n = inputReader.readNumber();\n\t var cnt = 0;\n\t var f = 0;\n\t for (var i = 1; i <= 9; ++i) {\n\t for (var j = i, time = 1; j < 10000+1; j = j * 10 + i, ++time) {\n\t cnt += time;\n\t if (j == n) {\n\t f = 1;\n\t break;\n\t }\n\t }\n\t if (f) break;\n\t }\n\t print(cnt);\n\t}\n \n}\n \nvar _inputData = '';\nfunction cacheInput(data) {\n\t_inputData += data;\n}\n \nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf8');\nprocess.stdin.on('data', cacheInput).on('end', _main);\n \nfunction _inputReader ( ) {\n\tfunction readNumber(){\n\t\treturn Number(_inputLines[_lineNumber++]);\n\t}\n \n \n\treturn {\n\t\treadNumber,\n\t}\n}", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "2f787d3117a692a100c52774aab98921", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', function(line){\n console.log(+line % 2 === 0 && line > 2 ? \"YES\" : \"NO\");\n})", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "163b9a0f6cefa90145333d7363f20f18", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\n \nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nvar lines = [];\nrl.on('line', function(input) {\n lines.push(input);\n});\nrl.on('close', function() {\n var l = 0;\n var t = +lines[l++]\n for (var i = 0; i < t; i++) {\n var arr = lines[l++].trim().split(' ').map(Number)\n console.log(solve(arr) ? 'YES' : 'NO')\n }\n});\n\nfunction solve([n, m, k]) {\n if (n & 1) {\n const least = m / 2\n if (k < least) return false\n\n if (n === 1) return true\n const r = (k - least) % (n - 1)\n // console.log(n, m, k, r)\n return !(r & 1)\n } else {\n if (m & 1) {\n const side = n / 2\n return !(k & 1) && k <= (n * m / 2 - side)\n } else {\n return !(k & 1)\n }\n }\n}\n", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms"], "code_uid": "34ebedde8c6fa5844bdec55cfd6d2468", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function generateAlphabets() {\n var alphabets = [];\n var start = 'a'.charCodeAt(0);\n var last = 'z'.charCodeAt(0);\n for (var i = start; i <= last; ++i) {\n alphabets.push(String.fromCharCode(i));\n }\n\n return alphabets;\n}\n\nconst seq = generateAlphabets();\n\n\n\n\nconst processData = (lines) => {\n const s = lines[1].split('').map(x => x.charCodeAt(0))\n let sum = 0\n const set = Array.from(new Set(s)).sort((a, b) => a - b).reverse()\n for (const l of set) {\n const target = l - 1;\n for (let j =0; j i += c)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os')\n const lines = i.split(EOL) /*your input text, split by lines*/\n processData(lines)\n})\n", "lang_cluster": "Javascript", "tags": ["brute force", "greedy", "strings", "constructive algorithms"], "code_uid": "afd78d837fe00fa1613ba81aeaf380c6", "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction print(s) {\n process.stdout.write(`${s}`);\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n // input\n let a = readline().split('+').map(x => parseInt(x));\n a.sort((m, n) => m - n);\n print(a.join('+'));\n}\n\n", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "619ee3b924e9eaf7da5b5911a5d09298", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\n\n// Create readline Interface\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\n\n// Read Inputs\nrl.on('line', lineInput => {\n check(lineInput)\n})\n\n\nfunction check(word) {\n const base = ['h', 'e', 'l', 'l', 'o'];\n let counter = 0;\n let next = 0;\n let temp = 0;\n\n\n contains(base[0])\n\n function contains(letter) {\n\n for (let i = temp; i < word.length; i++) {\n\n if (word[i] == letter) {\n counter++;\n temp = i + 1;\n next++;\n if (counter < 5)\n return contains(base[next])\n }\n\n if (counter == 5) {\n return console.log(\"YES\")\n }\n }\n\n return console.log(\"NO\")\n\n }\n\n}", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "8281240219fd8dd2353eb5ab2ab56201", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// https://codeforces.com/problemset/problem/263/A\n\nfunction main(stdin) {\n const matrix = stdin.map(row => row.split(' ').map(Number))\n let y = 0; let x = 0\n\n while(matrix[y][x] !== 1)\n if(x < 5) { x++ }\n else { x = 0; y++ }\n\n process.stdout.write(Math.abs(y - 2) + Math.abs(x - 2) + '')\n}\n\n// Handle standard input\nprocess.stdin.resume()\nprocess.stdin.setEncoding('utf-8')\n\nlet inputString = ''\n\nprocess.stdin.on('data', (inputStdin) => inputString += inputStdin)\nprocess.stdin.on('end', () =>\n main(inputString.trim().split('\\n').map(s => s.trim())))\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "08c7e82c2036d0f2f888befe7abcb038", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function helpfulMaths(str) {\n let arr = str.split(\"+\");\n arr.sort(function (a, b) {\n return a - b;\n });\n return console.log(arr.join(\"+\"));\n}\n\n// read file\nconst readline = require(\"readline\");\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nlet input = \"\";\n// read each line\nrl.on(\"line\", (lineInput) => {\n input = lineInput;\n});\n\n// when all file readed\nrl.on(\"close\", () => {\n helpfulMaths(input);\n});\n", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "8689455e426ce8fed0a0950c7af7ef8a", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nlet ans = 0;\nlet count = 0;\nrl.on('line', (d) => {\n if (count === 0) {\n count++;\n return;\n }\n\n let prevStone = d[0];\n for (let i = 1; i < d.length; i++) {\n if (d[i] === prevStone) {\n ans++;\n }\n\n prevStone = d[i];\n }\n\n count++;\n});\n\nrl.on('close', () => {\n console.log(ans);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "aeaedc3c7325db76dc7c9711eaa7ec18", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nvar dp = {};\n\nfunction fibonacci(n) {\n\tif (n === 0) return 0;\n\tif (n === 1) return 1;\n\n\tif (dp[n] !== undefined) return dp[n];\n\tlet result = fibonacci(n - 1) + fibonacci(n - 2);\n\treturn (dp[n] = result);\n}\n\nfunction main() {\n\tlet [n, m] = readLine()\n\t\t.split(' ')\n\t\t.map(x => x >> 0);\n\n\tlet c = 0;\n\tfor (let i = 0; i <= n; i++) {\n\t\tfor (let j = 0; j <= m; j++) {\n\t\t\tif (i * i + j === n && i + j * j === m) c++;\n\t\t}\n\t}\n\n\tconsole.log(c);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "bb0852516886d2372ec790d73e696e93", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nlet count = 0;\nlet n = t = 0;\n\nrl.on('line', (d) => {\n if (count === 0) {\n [n, t] = d.split(' ').map(Number);\n count++;\n return;\n }\n\n let str = d.split('');\n let isSwap = 0;\n\n while (isSwap < t) {\n for (let j = 1; j <= n; j++) {\n let prev = str[j - 1];\n let curr = str[j];\n\n if (prev === 'B' && curr === 'G') {\n str[j - 1] = curr;\n str[j] = prev;\n j++;\n }\n }\n\n isSwap++;\n }\n\n console.log(str.join(''));\n\n count++;\n});\n", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "607f1e5be25db55e56ba12246ba12b1f", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Input\n'use strict';\n \nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n \nlet inputString = '';\nlet currentLine = 0;\n \nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n \nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n \nfunction readline() {\n return inputString[currentLine++];\n}\n \n//main\nfunction main() {\n var s = readline();\n var currentValue, currentLength=0;\n for (var i=0 ; i {\n let [n1, n2, k1, k2] = d.split(' ').map(Number);\n\n if (n1 > n2) {\n console.log('First');\n }\n else {\n console.log('Second');\n }\n});\n", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms"], "code_uid": "04bd322e7cf25958ee473e4a3f808830", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const [ab, bc, ac] = readLine()\n .split(\" \")\n .map((n) => parseInt(n));\n\n const b = Math.sqrt((ab * bc) / ac);\n const a = ab / b;\n const c = bc / b;\n\n console.log(4 * (a + b + c));\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "geometry"], "code_uid": "5ffcea2852cb5852f32f4f59070d81e3", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n let [n, k] = d.split(' ').map(Number);\n const mid = Math.ceil(n / 2);\n\n if (mid >= k) {\n console.log(k * 2 - 1);\n }\n else {\n console.log((k - mid) * 2);\n }\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "7aa909bd8007127e232779f571dc3bf5", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input ='';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nprocess.stdin.on('data',(data)=>input+=data)\nprocess.stdin.on('end',()=>{\n let arr = input.split(' ').sort((a,b)=>+b - +a);\n \n console.log(arr[0]-arr[2])\n})", "lang_cluster": "Javascript", "tags": ["math", "sortings", "implementation"], "code_uid": "babe74dc890d64442b406b5e4214ae98", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet l = 0;\nrl.on('line', (input) => {\n if (l === 0) { l++ }\n else {\n rl.close();\n let arr = input.split(\" \").map(x => parseInt(x))\n let sum = 0\n for (let i = 0; i < arr.length; i++) {\n sum += arr[i]*2*(2*(Math.max((i+1),1)-1))\n }\n\n console.log(sum)\n return 0;\n }\n})\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "9c91ed373f7b407d0156cd7bf35deba0", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\")\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet shovelPrice;\nlet unlimitedBudget = 10;\nlet r = 0;\nlet flag = true;\nlet counter = 1;\n\nrl.on(\"line\", (input) => {\n if (!shovelPrice) {\n let tempArr = input.split(\" \").map(Number)\n shovelPrice = tempArr[0]\n r = tempArr[1]\n }\n if (shovelPrice) {\n // if (shovelPrice === r) {\n // console.log(counter)\n // flag = false\n // rl.close();\n // }\n while (flag) {\n if ((shovelPrice * counter) % unlimitedBudget === 0 || shovelPrice * counter % 10 === r) {\n console.log(counter)\n flag = false\n rl.close();\n break;\n }\n counter++\n }\n }\n\n\n})", "lang_cluster": "Javascript", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "f0d352d00c3ebb400351052e523fd397", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nconst daysInMonth = (month) => new Date(2017, month, 0).getDate();\n\nrl.on('line', (data) => {\n const [m, d] = data.split(' ').map(Number);\n const days = daysInMonth(m);\n const ans = Math.ceil((days + (d - 1)) / 7);\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "98927ded1594d8aceaa5d59f7a83cfec", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nconst gcd = (a, b) => {\n while (b !== 0) {\n const temp = a;\n a = b;\n b = temp % b;\n }\n\n return a;\n}\n\nconst factorial = (n) => {\n let prev = 1;\n let r = prev;\n\n for (let i = 2; i <= n; i++) {\n r = prev * i;\n prev = r;\n }\n\n return r;\n}\n\nrl.on('line', (d) => {\n const [a, b] = d.split(' ').map(Number);\n let ans = 1;\n\n for (let i = 1; i <= Math.min(a, b); i++) {\n ans *= i;\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation", "number theory"], "code_uid": "7b1da6297fa29c1353167f5e7c1da2a8", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n var arr = stdin[0].split(' ').map(Number);\n var fashion = Math.min(...arr);\n var temp = Math.max(...arr) - fashion;\n var pair = 0;\n if (temp % 2 !== temp) {\n pair = Math.floor(temp / 2);\n }\n console.log(fashion + ' ' + pair);\n}\n\nconst readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar stdin = [];\nrl.on('line', function (line) {\n stdin.push(line);\n});\nrl.on('close', main);", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "3e3dbc23421b2e066af05575ccba5282", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false,\n});\n\nlet c = 0;\n\nrl.on(\"line\", (str) => {\n if (c === 0) {\n c++;\n return;\n }\n\n let ans = 0;\n\n for (let i = 0; i < str.length; i++) {\n if (str[i] === \"+\") {\n ans++;\n } else {\n ans = Math.max(0, --ans);\n }\n }\n\n console.log(ans);\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "7f4fb4ab3e6d1b0061a6a93b139ce7c9", "src_uid": "a593016e4992f695be7c7cd3c920d1ed", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\nrl.question('', ans => {\n rl.close()\n\n let n = Number(ans)\n\n function nirvana(num) {\n const str = String(num)\n \n function mult(str) {\n return Number(str) === 0 ? 1 : str.split('').map(x => Number(x)).reduce((i, acc = 1) => i * acc)\n }\n \n let l = mult(str)\n for (let i = str.length - 1; i > 0; i--) {\n \t\tnines = str.length -1 - i + 1\n \t\tlet tMult = mult(String(Number(str.substr(0, i)) - 1))\n \t\ttMult = tMult * (9 ** nines)\n \t\t\n \t\tif (tMult > l) l = tMult\n }\n \t\n \treturn l\n }\n\n console.log(nirvana(n))\n})", "lang_cluster": "Javascript", "tags": ["brute force", "math", "number theory"], "code_uid": "7876dec60600d404549aa163e5a94559", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n const nums = input[0].split(' ').map(x => parseInt(x));\n let [a, b] = nums;\n let answer = 0;\n\n if (a === b) { console.log(1); return }\n\n while (a <= b) {\n a *= 3;\n b *= 2;\n answer += 1;\n }\n\n console.log(answer);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3a3c499fa5f38783c56a0a2fbdd84a36", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.setEncoding(\"ascii\");\n\nlet input = \"\";\n\nprocess.stdin.on(\"data\", data => { input += data; });\nprocess.stdin.on(\"end\", () => {\n const [[n, m], T] = input.trim().split(\"\\n\").map(x => x.trim().split(\" \").map(Number));\n const sum = [0, ...T];\n for (let i = 1; i < sum.length; i++)\n sum[i] += sum[i - 1];\n sum.shift();\n process.stdout.write(\"0 \");\n for (let i = 1; i < sum.length; i++) {\n const pred = T.slice(0, i);\n pred.sort((a, b) => b - a);\n let currentSum = sum[i];\n let count = 0;\n while (currentSum > m) {\n count++;\n currentSum -= pred.shift();\n }\n process.stdout.write(count + \" \");\n }\n});", "lang_cluster": "Javascript", "tags": ["sortings", "greedy"], "code_uid": "429b1f48d99a472818af0bf37a3d4ca8", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString='';\nlet currentLine=0;\nprocess.stdin.on('data',inputStdin=>{\n\tinputString+=inputStdin;\n});\nprocess.stdin.on('end',_=>{\n\tinputString=inputString.trim().split(\"\\n\").map(string=>{\n\t\treturn string.trim();\n\t});\n\tmain();\n});\nfunction readLine()\n{\n\treturn inputString[currentLine++]; \n}\nfunction rec(t,i,x,pre)\n{\n\tif(i==t.length)\n\t\treturn ((pre===x)?1:0);\n\tif(t[i]=='+')\n\t\treturn rec(t,i+1,x,pre+1);\n\telse if(t[i]=='-')\n\t\treturn rec(t,i+1,x,pre-1);\n\telse\n\t\treturn (rec(t,i+1,x,pre-1)+rec(t,i+1,x,pre+1));\n}\nfunction main()\n{\n\tvar s=readLine().trim();\n\tvar t=readLine().trim();\n\tvar x=0,po=0;\n\tfor(let i=0;i {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(str => str.trim());\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction sol(n, m, a) {\n\tlet width = n;\n\tlet height = m;\n\n\tlet wCount = 0;\n\t\n\twhile (width > a) {\n\t\twCount += parseInt(width / a);\n\t\twidth = width % a;\n\t}\n\n\tif (width > 0) {\n\t\twCount++;\n\t}\n\t\n\tlet hCount = 1;\n\theight = height - a;\n\n\twhile (height > a) {\n\t\thCount += parseInt(height / a);\n\t\theight = height % a;\n\t}\n\n\tif (height > 0) {\n\t\thCount++;\n\t}\n\n\t// console.log(wCount * hCount);\n\treturn wCount * hCount;\n\n}\n\n// sol(12,12,4)\n\nfunction main() {\n\n\t\tconst inputArr = readLine().split(' ');;\n\t\t\n\t\tconst n = parseInt(inputArr[0], 10);\n\n\t\tconst m = parseInt(inputArr[1], 10);\n\n\t\tconst a = parseInt(inputArr[2], 10);\n\n\t\tconst ans = sol(n, m, a);\n\n\t\tconsole.log(ans);\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "9d259931ad5cdc277e9a2e65d809c6fb", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar idx = 0;\n\nvar line1 = \"\";\nvar line2 = \"\";\n\nrl.on(\"line\", (theLine) => {\n if (idx == 0)\n line1 = theLine.toString().toUpperCase()\n else \n line2 = theLine.toString().toUpperCase();\n idx++\n if (idx > 1)\n {\n rl.close();\n console.log(line1 < line2 ? \"-1\":(line1 === line2 ? \"0\": \"1\"));\n }\n }\n);", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "1fe7256bd60de678659aab5139aa53d7", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet first = true;\nlet n, t, s;\n\n\nrl.on('line', (line) => {\n if (first) {\n // We're getting the numbers\n const input = line.split(' ');\n input.forEach(char => Number(char));\n n = input[0], t = input[1];\n first = false;\n return;\n } else {\n // We're getting the string\n s = line;\n }\n\n console.log(solution(n, t, s));\n});\n\n\nfunction solution(numberOfChildren, seconds, arrangement) {\n const q = arrangement.split('');\n for (let i = 0; i < seconds; i++) {\n for (let j = 0; j < q.length - 1; j++) {\n if (q[j] === 'B' && q[j + 1] === 'G') {s\n q[j] = 'G', q[j + 1] = 'B';\n j += 1;\n }\n }\n }\n return q.join('');\n}", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "c4f85db96dd54282ef28a86faa654b25", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const name = readLine();\n const map = name.split(\"\").reduce((obj, char) => {\n if (!obj[char]) obj[char] = 1;\n return obj;\n }, {});\n if (Object.keys(map).length % 2 === 0) console.log(\"CHAT WITH HER!\");\n else console.log(\"IGNORE HIM!\");\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "b485cbcf240e88645599b2068ad35c6b", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let q = '';\nprocess.stdin.on('data', c => q += c);\nprocess.stdin.on('end', () => {\n const {EOL} = require('os');\n const lines = q.split(EOL);\n var t = lines[0];\n for(j = 1; j <= t; j++){\n var s = 0;\n var n = lines[j];\n for(k = 0; k < n; k++){\n s += s + 1;\n }\n console.log(s);\n }\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "b037d6bb12dab67537cc25433e1fefd8", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf8\");\n\nlet s = \"\";\n\nprocess.stdin.on(\"data\", function(chunk) {\n s += chunk;\n});\n\nprocess.stdin.on(\"end\", function() {\n console.log(solve(s));\n});\n\nfunction solve(s) {\n const [x, y, z] = s.split(\" \").map(Number);\n\n if (x - y == 0 && z == 0) {\n return '0';\n }\n if (Math.abs(x - y) <= z) {\n return '?';\n }\n if (x - y > 0) {\n return '+';\n }\n if (x - y < 0) {\n return '-';\n }\n}\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "b74f4f6d957735007ad0f571a8739b90", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', inputStd => inputString += inputStd);\nprocess.stdin.on('end', () => {\n inputString = inputString.trim().split('\\n').map(str => str.trim());\n solve();\n});\nlet readLine = () => inputString[currentLine++];\n\nfunction solve(){\n const n = +(readLine());\n let str = readLine();\n let arr = [], arr2 = [];\n\n for(let i = 0; i < 2*n; i++){\n if(i < n)\n arr.push(+(str[i]));\n else\n arr2.push(+(str[i]));\n }\n arr.sort((a, b) => a-b);\n arr2.sort((a, b) => a-b);\n let a = true, b = true;\n\n for(let i = 0; i < n; i++){\n if(arr[i] <= arr2[i])\n a = false;\n if(arr[i] >= arr2[i])\n b = false;\n }\n console.log(a ^ b ? \"YES\" : \"NO\");\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "greedy"], "code_uid": "7d6f36b87408787b363dd22b0ad6eb94", "src_uid": "e4419bca9d605dbd63f7884377e28769", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (str) => {\n const obj = {};\n\n [...str].forEach(s => {\n if (!obj[s]) {\n obj[s] = s;\n }\n });\n\n if(Object.keys(obj).length % 2 === 0) {\n console.log('CHAT WITH HER!');\n }\n else {\n console.log('IGNORE HIM!');\n }\n});", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "bc313a4afd5e93fa951e114ba4afee92", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst r1= readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n})\nr1.on('line', (line) => {\n\twatermelon(+line);\n\tr1.close();\n})\n\nfunction watermelon(kg) {\n\tlet max = 4;\n\twhile (max <= kg) {\n\t\tif (max=== kg) {\n\t\t\tconsole.log('YES')\n\t\t\treturn;\n\t\t}\n\t\tmax += 2\n\t}\n\tconsole.log('NO')\n}\n\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "1265be27dbbc511de40068e5f70c2524", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n \nconst input = [];\nreadLine.on('line', line => input.push(line));\n \nreadLine.on('close', () => {\n let [n, k] = input[0].split(' ').map(x => +x);\n for (let i = 0; i < k; i++) {\n if (n % 10 == 0) {\n n /= 10;\n }\n else {\n n--;\n }\n }\n console.log(n);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "7571349f82ab47411cf5d37e84f3bbca", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let str = readLine().split(\" \")\n str[0] = parseInt(str[0])\n str[1] = parseInt(str[1])\n str[2] = parseInt(str[2])\n \n let tot = 0, res = 0\n for (let i = 1; i < str[2]+1; i++) {\n tot += (i * str[0])\n }\n \n res = tot - str[1]\n \n if (res < 0) console.log(0)\n else console.log(res)\n \n}", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "f569ea342b0dbcad0921e9aeb4c2bf83", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n const bills = [ 1, 5, 10, 20, 100 ].reverse();\n\n let n = parseInt(readline());\n let i = 0;\n while (n > 0) {\n //console.log(n, bills.find(b => n >= b));\n n -= bills.find(b => n >= b);\n i++;\n }\n console.log(i);\n}\n", "lang_cluster": "Javascript", "tags": ["greedy", "dp"], "code_uid": "b17c1aeec6fdd7b630853690a17dffa0", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "async function solve() {\n let s = await line()\n const vk = (s.match(/VK/g) || []).length\n s = s.split('VK').join('X')\n const vv = (s.match(/VV/g) || []).length > 0\n const kk = (s.match(/KK/g) || []).length > 0\n\n print(vk + (vv || kk ? 1 : 0))\n}\n\n// read the input\nconst readline = require('readline')\nconst _lines = []\nlet _lineIndex = 0\nlet _ended = false\nconst _rl = readline.createInterface(process.stdin)\n_rl.on('line', line => _lines.push(line))\n_rl.on('end', () => (ended = true))\nconst wait = ms => new Promise(resolve => setTimeout(resolve, ms))\nconst line = async () => {\n while (!_ended && _lines.length <= _lineIndex) await wait(10)\n const result = _lines[_lineIndex].trim()\n _lines[_lineIndex] = null\n _lineIndex++\n return result\n}\nconst words = async () => (await line()).split(' ')\nconst chars = async () => (await line()).split('')\nconst int = async () => parseInt(await line())\nconst ints = async () => (await words()).map(x => parseInt(x))\nconst big = async () => BigInt(await line())\nconst bigs = async () => (await words()).map(x => BigInt(x))\n\nconst print = console.log\n\nsolve()\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "c35bf16b98c23fbeca8dbc0b6feba138", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\n\nlet inputs = [];\nconst chars = [\n 'a', 'b', 'c', 'd',\n 'e', 'f', 'g', 'h',\n 'i', 'j', 'k', 'l',\n 'm', 'n', 'o', 'p',\n 'q', 'r', 's', 't',\n 'u', 'v', 'w', 'x',\n 'y', 'z'\n];\n\n\n\n// Create readline Interface\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\n\n// Read Inputs\nrl.on('line', lineInput => {\n inputs.push(lineInput);\n})\n\n\n// Excute algorithm\nrl.on('close', () => {\n let firstWord = inputs[0];\n let secondWord = inputs[1];\n\n recognize(firstWord, secondWord)\n\n})\n\n\n/*\n ****************************\n * Devide & Conquer functions\n ****************************\n */\n\n \n// Return the charcter position\nfunction charPosition(char) {\n let low = 0\n let high = chars.length - 1\n let mid = Math.floor((low + high) / 2)\n\n\n while (low <= high) {\n mid = Math.floor((low + high) / 2)\n if (chars.indexOf(char) > mid)\n low = mid + 1\n else if (chars.indexOf(char) < mid)\n high = mid - 1\n else\n return mid\n }\n\n return -1\n}\n\n// Recognize which one's order is greater than the other\nfunction recognize(fWord, sWord) {\n\n for (let i = 0; i < fWord.length; i++) {\n const char1 = fWord[i].toLowerCase();\n const char2 = sWord[i].toLowerCase();\n\n if (charPosition(char1) > charPosition(char2))\n return console.log(1);\n else if (charPosition(char1) < charPosition(char2))\n return console.log(-1);\n }\n\n\n return console.log(0)\n}\n\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "ebb84f9b6b993f3bc798cc5da8b9a302", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n const x = readline().split(\" \");\n \n bearAndBigBrother(x[0],x[1]);\n }\n \nfunction bearAndBigBrother(a, b) {\n let counter = 0;\n a = parseInt(a);\n b = parseInt(b);\n\n while (a <= b) {\n a *= 3;\n b *= 2;\n counter++;\n }\n \n console.log(counter)\n\n return counter;\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "d8b65a2e64d15a74f1a0f84320b32e3e", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const [n, k, t] = d.split(' ').map(Number);\n let ans = k;\n let max = n + k;\n\n if (t < k) {\n ans = t;\n }\n else if (t > max - k) {\n ans = max - t;\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "7a2b4aee6757a68260987d94066df4b0", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data', data => {\n process.stdout.write(parseInt(data.toString().trim()) > 2 ? ((parseInt(data.toString().trim()) - 2) % 2 === 0 ? \"YES\" : \"NO\") : \"NO\");\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "198dd0eb2466f31026eab2186eda8c34", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction isPrime(x) {\n\tlet s = Math.sqrt(x);\n\tlet i = 2;\n\twhile (i <= s) {\n\t\tif (x % i === 0) {\n\t\t\treturn false;\n\t\t}\n\t\ti++;\n\t}\n\treturn true;\n}\n\nfunction main() {\n\tlet [n, m] = readLine()\n\t\t.split(' ')\n\t\t.map(x => x >> 0);\n\tn++;\n\n\tlet next = false;\n\n\twhile (n <= m) {\n\t\tif (isPrime(n)) {\n\t\t\tif (n === m) {\n\t\t\t\tnext = true;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tn++;\n\t}\n\n\tnext ? console.log('YES') : console.log('NO');\n}\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "e9744446c4b97a990ddb46181ec9066e", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\r\n\r\nfunction solve(n, m, k) {\r\n if (n & 1) {\r\n if (k < m / 2) return 'NO';\r\n n--;\r\n k -= m / 2;\r\n }\r\n if (k & 1) return 'NO';\r\n if (k > n * Math.floor(m / 2)) return 'NO';\r\n return 'YES';\r\n}\r\n\r\nasync function main(read) {\r\n try {\r\n let t = Number(await read());\r\n let res = new Array(t);\r\n for (let i = 0; i < t; i++) {\r\n const [n, m, k] = (await read()).split(' ').map(Number);\r\n res[i] = solve(n, m, k);\r\n }\r\n return res.join('\\n');\r\n } catch (error) {\r\n console.log(error);\r\n }\r\n}\r\n\r\nlet inputs,\r\n str = '';\r\nfunction read() {\r\n return inputs.next().value.trim();\r\n}\r\nprocess.stdin.resume();\r\nprocess.stdin.setEncoding('utf8');\r\nprocess.stdin.on('data', input => str += input);\r\nprocess.stdin.on('end', async () => {\r\n inputs = str.split('\\n').values();\r\n const output = await main(read);\r\n process.stdout.write(output);\r\n});\r\n", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms"], "code_uid": "2c8594d3114dc58711000ccf1f5d8370", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\nasync function getData() {\n\treturn new Promise((res,rej)=>{\n\t\trl.question('',answer=>res(answer))\t\n\t})\n\t\n}\nfunction counted(limak,bob){\n\tlet years = 0\n\t\n\tlimak = parseInt(limak,10)\n\tbob = parseInt(bob,10)\n\n\twhile(limak <= bob){\n\n\t\tyears++\n\t\tlimak *= 3\n\t\tbob *= 2\n\t}\n\tconsole.info(years)\n}\n\nasync function main(){\n\n\tlet data = await getData()\n\trl.close()\n\tdata = data.trim().split(' ')\n\n\tcounted(...data)\n}\n\nmain()", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "81a7daad147d53d6b2df5560ff1b2896", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\n\nconst runMain = () => {\n inputString = inputString.trim().split('\\n').map(string => string.trim());\n main();\n process.exit();\n}\nconst readLine = () => inputString[currentLine++];\n\nprocess.stdin.on('data', inputStdin => inputString += inputStdin);\nprocess.stdin.on('end', runMain);\nprocess.on('SIGINT', runMain);\n\nfunction main() {\n let n = Number(readLine()) + 1;\n let res = false;\n while (!res) {\n const a = Array.from(n.toString());\n res = true;\n a.forEach(_a => {\n if (a.filter(__a => __a !== _a).length !== 3) {\n res = false;\n }\n });\n n++;\n }\n console.log(--n);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "a88ad54c1af8cb139b0094ca000bf3a2", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n var str = stdin[0].split(' ').map(x=>parseInt(x));\n var L = str[0];\n var P = str[1];\n var N = str[2];\n var M = ((N+P)%L+L)%L;\n console.log(M>0?M:L);\n}\n\nconst readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar stdin = [];\nrl.on('line', function (line) {stdin.push(line);});\nrl.on('close', main);", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "7db6b2b8a2b148648a2af403e91f4603", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n');\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr('time : ' + end + 'ms');\n myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var one = nextIntArray();\n var a = one[0];\n var b = one[1];\n var n = one[2];\n var turn = true;\n while(true){\n \tif(turn){\n \t\tvar minus = gcd(a, n);\n \t\tif(n < minus){\n \t\t\tmyout(\"1\");\n \t\t\treturn;\n \t\t}\n \t\tn -= minus;\n \t\tturn = false;\n \t}else{\n \t\tvar minus = gcd(b, n);\n \t\tif(n < minus){\n \t\t\tmyout(\"0\");\n \t\t\treturn;\n \t\t}\n \t\tn -= minus;\n \t\tturn = true;\n \t}\n }\n}\nfunction gcd(m, n) {return n != 0 ? gcd(n, m % n) : m;}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "d3794c30e1166c25dbb4a047c4b03135", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = '';\nprocess.stdin.on('data', (c) => {\n i += c;\n});\nprocess.stdin.on('end', () => {\n const { EOL } = require('os');\n const lines = i.split(EOL);\n let nums = lines[1].split(' ');\n nums = nums.map(num => parseInt(num, 10));\n const k = lines[0].split(' ')[1];\n console.log(minOperations(nums, parseInt(k, 10)));\n});\n\nfunction minOperations(nums, k) {\n if (nums.length === 1) return 0;\n let totalMin = Number.MAX_VALUE;\n\n for (const num of nums) {\n let currNum = num;\n while (currNum > 0) {\n let arr = [];\n for (let i = 0; i < nums.length; i++) {\n let temp = nums[i];\n let operations = 0;\n while (temp > currNum) {\n temp = Math.floor(temp / 2);\n operations++;\n }\n if (temp === currNum) arr.push(operations);\n }\n if (arr.length < k) {\n currNum = Math.floor(currNum / 2);\n continue;\n } else {\n arr = arr.sort((a, b) => a - b);\n let minSum = 0;\n for (let j = 0; j < k; j++) {\n minSum += arr[j];\n }\n totalMin = Math.min(minSum, totalMin);\n currNum = Math.floor(currNum / 2);\n }\n }\n }\n\n if (totalMin === Number.MAX_VALUE) {\n return 0;\n }\n return totalMin;\n}\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "4ea30a328519f17185e20d808b77d790", "src_uid": "ed1a2ae733121af6486568e528fe2d84", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var stdin = process.openStdin();\n\nstdin.addListener(\"data\", function(d) {\n // note: d is an object, and when converted to a string it will\n // end with a linefeed. so we (rather crudely) account for that \n // with toString() and then trim() \n d = d.toString().trim();\n var arr = d.split('WUB');\n for( var i = 0; i < arr.length; i++){ \n if ( arr[i] === '') {\n arr.splice(i, 1); \n i--;\n }\n }\n \n console.log(arr.join(' '));\n \n });", "lang_cluster": "Javascript", "tags": ["strings"], "code_uid": "66b0b2a42323ed0557d92ae00a58f2cd", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function lexicographically(str1, str2) {\n for (let i = 0; i < str1.length; i++) {\n if (\n str1[i].toLocaleLowerCase().charAt(0) >\n str2[i].toLocaleLowerCase().charAt(0)\n ) {\n return console.log(1);\n } else if (\n str1[i].toLocaleLowerCase().charAt(0) <\n str2[i].toLocaleLowerCase().charAt(0)\n ) {\n return console.log(-1);\n } else {\n continue;\n }\n }\n return console.log(0);\n}\n\nconst readline = require(\"readline\");\n// Create readline Interface\nlet inputs = [];\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nrl.on(\"line\", (lineInput) => {\n inputs.push(lineInput);\n});\nrl.on(\"close\", () => {\n let firstWord = inputs[0];\n let secondWord = inputs[1];\n lexicographically(firstWord, secondWord);\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "5a2898bebc050d44c7d196033f81a5ce", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// https://codeforces.com/problemset/problem/1091/A\n// Big O:\n// Time complexity: O(1)\n// Space complexity: O(1)\n\n// Read input\nconst readline = require(\"readline\")\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', (input) => {\n const numbers = input.split(\" \").map(Number);\n const yellow = numbers[0];\n const blue = numbers[1];\n const red = numbers[2];\n console.log(findMaxOrnaments(yellow, blue, red));\n rl.close();\n});\n\nfunction findMaxOrnaments(yellow, blue, red) {\n const minimum = Math.min(yellow, blue, red)\n\n if (minimum == yellow) {\n return findMaxWithYellowMinimum(yellow, blue, red);\n }\n\n if (minimum == blue) {\n return findMaxWithBlueMinimum(yellow, blue, red);\n }\n\n return findMaxWithRedMinimum(yellow, blue, red);\n}\n\nfunction findMaxWithYellowMinimum(yellow, blue, red) {\n let solutionFound = false;\n\n let yellowChosen = yellow;\n let blueChosen = 0;\n let redChosen = 0;\n\n while (!solutionFound) {\n blueChosen = 1 + yellowChosen;\n redChosen = 2 + yellowChosen;\n if (blueChosen > blue || redChosen > red) {\n yellowChosen = yellowChosen - 1;\n } else {\n solutionFound = true;\n }\n\n }\n return yellowChosen + blueChosen + redChosen;\n}\n\nfunction findMaxWithBlueMinimum(yellow, blue, red) {\n let solutionFound = false;\n\n let yellowChosen = 0;\n let blueChosen = blue;\n let redChosen = 0;\n\n while (!solutionFound) {\n yellowChosen = blueChosen - 1;\n redChosen = blueChosen + 1;\n if (yellowChosen > yellow || redChosen > red) {\n blueChosen = blueChosen - 1;\n } else {\n solutionFound = true;\n }\n\n }\n\n return yellowChosen + blueChosen + redChosen;\n}\n\nfunction findMaxWithRedMinimum(yellow, blue, red) {\n let solutionFound = false;\n\n let yellowChosen = 0;\n let blueChosen = 0;\n let redChosen = red;\n\n while (!solutionFound) {\n yellowChosen = redChosen - 2;\n blueChosen = redChosen - 1;\n if (yellowChosen > yellow || blueChosen > blue) {\n redChosen = redChosen - 1;\n } else {\n solutionFound = true;\n }\n\n }\n return yellowChosen + blueChosen + redChosen;\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "258f54d5f659b1affcfef917b4780fab", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction readint() {\n let line = readline().split(' ').map(function(num) {\n return parseInt(num);\n });\n return line;\n}\n\nfunction readfloat() {\n let line = readline().split(' ').map(function(num) {\n return parseFloat(num);\n });\n return line;\n}\n\nfunction print(x) {\n console.log(x);\n}\n\nfunction write(x) {\n process.stdout.write(x);\n}\nfunction main() {\n let [n,t,k,d] = readint(); \n let times = parseInt(d / t) + 1;\n let qoldi = n - k * times;\n if(qoldi > 0 ) {\n print(\"YES\");\n } else {\n print(\"NO\");\n }\n\n \n\n\n}", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "c3fc7babe3f1655f18135103a2d44fe8", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline'),\n rl = readline.createInterface(process.stdin, process.stdout);\n\n\nrl.on('line', function (line) {\n\n var n = line.split(' ')\n //n%2==0 && n!=2 ? console.log(\"YES\") : console.log(\"NO\");\n console.log(n % 2 == 0 && n != 2 ? \"YES\" : \"NO\");\n rl.close();\n\n}).on('close', function () {\n\n process.exit(0);\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "02167792fbc550be76466ba6379d9711", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', function(line) {\n let arr = line.split(' ').map(el => +el);\n console.log(func(arr));\n});\n\nconst func = ([moves, sweetsLeft]) => {\n let tempMove = 0;\n let tempSweets = 0;\n let lastAddition = 0;\n while (tempMove < moves && (tempSweets - (moves - tempMove) != sweetsLeft)) {\n lastAddition++;\n tempSweets += lastAddition;\n tempMove++;\n }\n return moves - tempMove;\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math", "binary search"], "code_uid": "713a509ad08db6007e71ab54833c832c", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const str = readLine();\n let countPlus = 0;\n const nums = str.split(\"\").reduce((obj, char) => {\n if (char - char === 0) obj[char] = char;\n return obj;\n }, {});\n\n for (let i = 0; i < str.length; i++) {\n if (str[i] === \"+\") countPlus++;\n }\n\n Object.keys(nums).forEach((key) => {\n nums[key] = +nums[key] + countPlus;\n });\n\n if (str.includes(\"H\") || str.includes(\"Q\") || str.includes(\"9\")) {\n console.log(\"YES\");\n } else {\n console.log(\"NO\");\n }\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "c7b4b78aaf1edb9344a19b561b455648", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.setEncoding('utf8');\n\nprocess.stdin.on('readable', () => {\n let input = process.stdin.read();\n input = parseInt(input.trim());\n\n console.log(Math.ceil(input / 5));\n process.exit(0);\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "cc4e5b5f53a3b4af86b03763de514e39", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst rl = readline.createInterface({\n\t input: process.stdin,\n\t output: process.stdout,\n\tterminal : false\n});\n\n\nrl.on(\"line\", main)\nlet i = 0;\nlet n = 0;\nlet x = 0;\nlet s1, s2 = \"\"\nconst arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' ,'k', 'l', 'm', 'n', 'o','p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] \n\nfunction main(input){\n\t\n\tif(i == 0){\n\t\ts1 = input\n\t\ti++\n\t\treturn\n\t}\n\tif(i == 1){\n\t\ts2 = input\n\t\ti++\n\t}\n\n\t//let x = 0\n\t//let y = 0\n\t\n\tlet r = 0;\n\tfor(var j = 0 ; j < s1.length ; j++){\n\t\n\t\tlet v = arr.indexOf(s1[j].toLowerCase())\n\t\tlet w = arr.indexOf(s2[j].toLowerCase())\n\n\t\tif(v > w){\n\t\t\tr = 1\n\t\t\tbreak;\n\t\t}\n\t\tif(v < w){\n\t\t\tr = -1\n\t\t\tbreak\n\t\t}\n\n\t}\n\n\t\n\tconsole.log(r)\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "c12e9526a56e5aff22db37b21ebce7d6", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet a = [];\nlet b = [];\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n const [x, y] = d.split(' ').map(Number);\n a.push(x);\n b.push(y);\n\n c++;\n});\n\nrl.on('close', () => {\n let ans = 0;\n let aCount = {};\n let bCount = {};\n\n for (let i = 0; i < a.length; i++) {\n if (aCount.hasOwnProperty(a[i])) {\n aCount[a[i]] += 1;\n }\n else {\n aCount[a[i]] = 1;\n }\n\n if (bCount.hasOwnProperty(b[i])) {\n bCount[b[i]] += 1;\n }\n else {\n bCount[b[i]] = 1;\n }\n }\n\n for (let x in aCount) {\n if (bCount.hasOwnProperty(x)) {\n ans += aCount[x] * bCount[x];\n }\n }\n\n // for (let i = 0; i < a.length; i++) {\n // for (let j = 0; j < b.length; j++) {\n // if (a[i] === b[j]) {\n // ans++;\n // }\n // }\n // }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "edf2498fdcfa38bc65a81a2d89394c2f", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input ='';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nprocess.stdin.on('data',(data)=>input+=data)\nprocess.stdin.on('end',()=>{\n let count = 0;\n let tmp = input.split('\\n');\n let arr = tmp[1].split(' ').map((val)=>+val).sort((a,b)=>a-b);\n \n for(let i = 0; i < arr.length; i+=2){\n count+=Math.abs(arr[i]-arr[i+1])\n }\n console.log(count)\n})\n", "lang_cluster": "Javascript", "tags": ["sortings"], "code_uid": "532d4d5ee4daff287df6aa86a4b8dd7e", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var one = nextIntArray().sort(function(a,b){return a - b;});\n var x1 = one[0];\n var x2 = one[1];\n var x3 = one[2];\n var output = 300;\n for(var i = 1; i <= 100; i++){\n var check = Math.abs(i - x1);\n check += Math.abs(i - x2);\n check += Math.abs(i - x3);\n output = Math.min(output, check);\n }\n myout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "sortings", "implementation"], "code_uid": "772ac666df38a304eaec42c1cd0097f9", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.setEncoding('utf8');\nprocess.stdin.on('readable', () => {\n const chunk = process.stdin.read();\n if (chunk !== null) {\n let re = /\\n\\s*| /;\n let input = chunk.split(re).slice(0, -1);\n console.log(snowball.apply(null, input.map(value => parseInt(value))));\n process.exit(0);\n }\n});\n\nfunction snowball(w, h, u1, d1, u2, d2) {\n for (; h >= 0; h--) {\n w += h;\n if (h == d1) w -= u1;\n if (h == d2) w -= u2;\n w = Math.max(w, 0);\n }\n return w;\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "308e32e70cb8675a5bda19d6556f3d11", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nconst matrix = [];\n\nrl.on('line', (d) => {\n matrix.push(d.split(' ').map(Number));\n c++;\n});\n\nrl.on('close', () => {\n const states = new Array(3).fill(0).map(x => new Array(3).fill(1));\n\n for (let i = 0; i < matrix.length; i++) {\n for (let j = 0; j < matrix[i].length; j++) {\n if (matrix[i][j] % 2) {\n states[i][j] = +!states[i][j];\n\n let up = i - 1;\n let down = i + 1;\n let left = j - 1;\n let right = j + 1;\n\n if (up > -1) {\n states[up][j] = +!states[up][j];\n }\n\n if (down < 3) {\n states[down][j] = +!states[down][j];\n }\n\n if (left > -1) {\n states[i][left] = +!states[i][left];\n }\n\n if (right < 3) {\n states[i][right] = +!states[i][right];\n }\n }\n }\n }\n\n states.forEach(x => console.log(x.join('')));\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "60274335830750ca05ef221492cc0b99", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\n\nconst runMain = () => {\n inputString = inputString.trim().split('\\n').map(string => string.trim());\n main();\n process.exit();\n}\nconst readLine = () => inputString[currentLine++];\n\nprocess.stdin.on('data', inputStdin => inputString += inputStdin);\nprocess.stdin.on('end', runMain);\nprocess.on('SIGINT', runMain);\n\nfunction main() {\n const [k, n, w] = readLine().split(' ').map(num => Number(num));\n const sum = w * (w + 1) * k / 2 - n;\n console.log(sum > 0 ? sum : 0);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "2bb7cb163e1be4c411a9e6272c52898d", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet inputString = \"\";\nlet currentLine = 0;\n\nprocess.stdin.on(\"data\", (inputStdin) => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((string) => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n const x = readline();\n\n fn(x);\n}\n\nfunction fn(str) {\n console.log(\n new Set(str.split(\"\")).size % 2 ? \"IGNORE HIM!\":\"CHAT WITH HER!\"\n );\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "21e1a7b67a65673b80aa4fca4a4656e6", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Generated by CoffeeScript 2.5.1\nvar find, lines, mainAux, numMoves, print, readline, rl, rli, sum, write;\n\nrl = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nprint = console.log;\n\nwrite = function(...args) {\n return process.stdout.write(args.join(' '));\n};\n\nlines = [];\n\nrl.on('line', function(line) {\n return lines.push(line);\n});\n\nrl.on('close', main);\n\nrli = 0;\n\nreadline = function() {\n return lines[rli++];\n};\n\nsum = function(items) {\n return items.reduce((function(a, b) {\n return a + b;\n }), 0);\n};\n\nfind = function(input) {\n return [\n input.find((inp) => {\n return inp.includes('1');\n }).split(' ').findIndex((str) => {\n return str === '1';\n }),\n input.findIndex((inp) => {\n return inp.includes('1');\n })\n ];\n};\n\nnumMoves = function(v) {\n return Math.abs(2 - v);\n};\n\nmainAux = function() {\n var input;\n input = [];\n input.push(readline());\n input.push(readline());\n input.push(readline());\n input.push(readline());\n input.push(readline());\n return print(sum(find(input).map(function(v) {\n return numMoves(v);\n })));\n};\n\n\n function main() {\n return mainAux();\n }\n;\n\n//# sourceMappingURL=matrix.js.map\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "c6bb6d1f7744358361a04fe1ec193037", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet standardInputString = '';\nlet currentLine = 0;\n\nfunction readLine() {\n return standardInputString[currentLine++];\n}\n\nprocess.stdin.on('data', rawData=> {\n standardInputString += rawData;\n})\n\nprocess.stdin.on('end', _ => {\n standardInputString = standardInputString.trim().split('\\n').map(line=> {\n return line.trim();\n })\n main();\n})\n\nfunction main() {\n const line1 = readLine().toLowerCase();\n const line2 = readLine().toLowerCase();\n if(line1 < line2) {\n console.log(-1);\n } else if(line1 > line2) {\n console.log(1);\n } else if(line1 === line2) {\n console.log(0);\n }\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "7774b5cbf68913d6ed93df2336df5efb", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const state = { stdin: Buffer.alloc(0) };\nconst consume = (chunk) =>\n (state.stdin = Buffer.concat(\n [state.stdin, chunk],\n state.stdin.length + chunk.length\n ));\nconst commit = (answer) => process.stdout.write(answer);\n//\nconst main = (args) => {\n let data = parseInt(state.stdin.toString(\"utf8\"));\n let solution = \"NO\";\n if (data < 1 || data > 100) return commit(solution);\n\n // divide the watermelon into two parts,\n // each of them weighing even (%2==0) number of kilos;\n\n for (let i = 1; i < data; i++) {\n let part = (data - i) % 2 ===0;\n if (i % 2 === 0 && part) {\n solution = \"YES\";\n // console.log(data, partOne, partTwo)\n commit(solution);\n return;\n }\n }\n commit(solution);\n};\n\nprocess.stdin.on(\"data\", consume).on(\"end\", main);\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "4cb67a32df765094e604156511cde2fd", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const rl = require('readline')\n\nconst readline = rl.createInterface({input: process.stdin})\n\nreadline.on('line', line => {\n\tconst [y, b, r] = line.split(' ').map(Number)\n\tlet u = 0, v = 0, w = 0\n\tif (b >= y + 1 && r >= y + 2) u = 3 * y + 3\n\tif (y >= b - 1 && r >= b + 1) v = 3 * b\n\tif (b >= r - 1 && y >= r - 2) w = 3 * r - 3\n\tconsole.log(Math.max(u, v, w))\n})", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "f24f83690ac06357522811f7e64a676b", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nreadline.on('line', hay => {\n const needle = 'hello';\n\n let found = false;\n let needleP = 0;\n let hayP = 0;\n\n while (hayP < hay.length) {\n // console.log(needleP, hayP, needle[needleP], hay[hayP]);\n if (hay[hayP] === needle[needleP]) {\n needleP++;\n // console.log(needle[needleP - 1], needle[needle.length - 1]);\n if (\n needleP === needle.length &&\n needle[needleP - 1] === needle[needle.length - 1]\n ) {\n found = true;\n break;\n }\n } else if (hay[hayP] === needle[needleP - 1]) {\n }\n hayP++;\n }\n\n console.log(found ? 'YES' : 'NO');\n});", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "73f3d63f2a24c6643f4c442db217f01f", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let fs = require('fs');\n\nlet txt = fs.readFileSync(0, \"utf-8\").split(\"\\r\\n\").filter(data => {\n return data.length > 0;\n});\n\nfor (let i = 0; i < txt.length; i++) {\n doit(txt[i]*1);\n}\n\nfunction doit(n) {\n if(n%2===0){\n console.log(n/2);\n }else{\n console.log((n+1)/2*-1);\n }\n \n}", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "1809951593c9cd9d5ed9c1619fbabd4b", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "var n = +readline();\nvar a = readline().split(' ').map(Number);\nvar d1 = a.indexOf(1);\nif (n - 1 - d1 > d1) d1 = n-1-d1;\nvar dn = a.indexOf(n);\nif (n - 1 - dn > dn) dn = n-1-dn;\nprint(d1 > dn ? d1 : dn);\n", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation"], "code_uid": "0b09829a304ef05d2cf0ee662f69408f", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', (inputStdin) => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', (_) => {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((string) => {\n return string.trim();\n });\n\n driver();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction driver() {\n const x = readline();\n main(x);\n}\n\nfunction main(string) {\n if (!string.includes('+')) {\n console.log(string);\n return;\n }\n\n string = string\n .split('+')\n .sort((a, b) => a - b)\n .join('+');\n\n console.log(string);\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "95e103095f04d6a7fc7e13f9583ee667", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n let [n, m] = input[0].split(' ').map(x => parseInt(x));\n const set = new Set();\n\n for (let i = 1; i <= 100; i += 1) {\n set.add(m*i);\n }\n\n let day = 0;\n while (n > 0) {\n n -= 1;\n day += 1;\n if (set.has(day)) n += 1;\n }\n\n console.log(day);\n}); \n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "d913ae2eb74af37d7f984d5285edce17", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (str) => {\n let letters = 'abcdefghijklmnopqrstuvwxyz';\n let ans = 0;\n\n for (let i = 0; i < str.length; i++) {\n let c = str[i];\n\n let idx = 0;\n while (letters[idx] !== c) {\n idx = (idx + 1) % 26;\n\n if (letters[idx] === c) {\n ans += Math.min(idx, 26 - idx);\n break;\n }\n }\n\n letters = letters.slice(idx) + letters.slice(0, idx);\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "c14fe36dff9bef1afb529e189a25bcf0", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let data = '';\nprocess.stdin.on('data', c => data += c);\n\nfunction* nextLine() {\n\tlet lines = data.trim().split(/\\n/g);\n\tfor(let l of lines){\n\t\tyield l.trim();\n\t}\n}\n\nlet nl = nextLine();\n\nnl.elem = function(funParse) {\n\t\treturn funParse(this.next().value);\t\n\t};\n\nnl.array = function(funParse) {\n\t\treturn this.next().value.split(/\\s/g).map(funParse||(x => x));\n\t};\n\t\nnl.num = function() {\n\t\treturn nl.elem(Number);\n\t};\n\t\nnl.nums = function() {\n\t\treturn nl.array(Number);\n\t};\n\t\nnl.line = function() {\n\t\treturn this.next().value;\n\t};\n\t\nconst sol = () => {\n\tlet [n, m] = nl.nums();\n\tlet max = Math.max(n,m);\n\tlet cnt = 0;\n\tfor(let a = 0; a <= max; a++){\n\t\tfor(let b = 0; b <= max - a; b++){\n\t\t\tif (a*a + b === n && a + b*b === m){\n\t\t\t\tcnt++;\n\t\t\t}\n\t\t}\n\t}\n\tconsole.log(cnt);\n\n};\n\nprocess.stdin.on('end', sol);\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "b3ebad4d47371ac487befbaabd49b05e", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = '';\nprocess.stdin.on('data', (c) => {\n i += c;\n});\nprocess.stdin.on('end', () => {\n const { EOL } = require('os');\n const lines = i.split(EOL);\n canSplitEqually(parseInt(lines, 10)) ? console.log('YES') : console.log('NO');\n});\n\nfunction canSplitEqually(w) {\n return w !== 2 && w % 2 === 0;\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "4287227b465af3ff91b56f607c11a06a", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', line => {\n var [m, n] = line.split(' ');\n \n if (n == 1) {\n console.log(0);\n rl.close();\n return;\n }\n\n var result = parseInt(n/2) * m;\n\n if (n%2 === 1) {\n result += parseInt(m/2);\n }\n\n console.log(result);\n\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "9c8224473388c7e765a67695a87d0efd", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nrl.on('line', (inputString) => {\n let numberOfSquares = parseInt(inputString);\n console.log(findTheNumberOfLinesForLady(numberOfSquares));\n});\n\nfunction findTheNumberOfLinesForLady(forTheNumberOfSquaress) {\n let a = Math.sqrt(forTheNumberOfSquaress);\n let b = Math.trunc(a);\n if (a == b) return 2 * a;\n if (b * (b + 1) >= forTheNumberOfSquaress) return 2 * b + 1;\n return 2 * b + 2;\n}", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms", "binary search"], "code_uid": "3b3dd5f2bccf3d30f5d7aac2b794ff24", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf8');\nlet input= '', cin, cout;\nprocess.stdin.on('data', (chunk) => input+=chunk);\nprocess.stdin.on('end', () => {\n input = input.split('\\n');\n cout = (data) => process.stdout.write(data+'\\n');\n var inputLineIndex = 0;\n cin = function(){return inputLineIndex>=input.length?undefined:input[inputLineIndex++]};\n process.exit(main() || 0);\n});\n\nfunction main(){\n let a = cin();\n if(a > 2 && a % 2 === 0) cout(\"YES\");\n else cout(\"NO\");\n return 0;\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "8b2ccc7e2a68788c7d4a0f11264b12cf", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nconst solution = (input) => {\n const vowels = [\"A\", \"O\", \"Y\", \"E\", \"U\", \"I\"];\n\n const consonants = Array.from(input).filter((item) => {\n return !(vowels.includes(item.toLowerCase()) || vowels.includes(item.toUpperCase()));\n }).map((item) => {\n return item.toLowerCase();\n });\n\n console.log(`.${consonants.join('.')}`);\n\n rl.close();\n}\n\nrl.question('', (input) => {\n solution(input);\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "2dfbb4370fb785e9318e5c30edb42590", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n var strArr = readLine().split(\" \").map(Number);\n var k = strArr[0];\n var n = strArr[1];\n var w = strArr[2];\n var result = 0;\n for (let i = 1; i <= w; i++) {\n result += k * i;\n }\n if (result > n) {\n console.log(result - n);\n } else {\n console.log(0);\n }\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "48d31aa4184d38a8dcf0e80d89bb3e69", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "'use strict';\n\nvar data = [];\n\ndata.push(readline())\n\nfunction sum(n) {\n return n.split('').map(function (d) {\n return parseInt(d);\n }).reduce(function (s, d) {\n return s + d;\n });\n}\n\nfunction minus1(s, i) {\n if (!s) return '';\n if (s[i] === '0') {\n return rem0(minus1(s.substring(0, i), i - 1) + '9' + '9'.repeat(s.substring(i + 1).length));\n } else {\n return rem0(s.substring(0, i) + String(parseInt(s[i]) - 1) + '9'.repeat(s.substring(i + 1).length));\n }\n}\nfunction rem0(s) {\n var i = 0;\n while (s[i] === '0') {\n i++;\n }\n return s.substring(i);\n}\n\nfunction solve() {\n var n1 = data[0];\n if (n1.length === 1) {\n return print(n1);\n }\n var s1 = sum(n1);\n var s2 = 0;\n var n2 = void 0;\n for (var i = 0; i < n1.length - 1; i++) {\n var s9 = minus1(n1, i);\n var s9s = sum(s9);\n if (s9s >= s2) {\n s2 = s9s;\n n2 = s9;\n }\n }\n\n print(s2 > s1 ? n2 : n1);\n}\n\nsolve();", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "bc59ee2755b82d15c0c29384c91c0a11", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const word = readLine();\n let [lowerCount, upperCount] = [0, 0];\n const isLowerCase = (char) => {\n return char.charCodeAt(0) >= 97 && char.charCodeAt(0) <= 122;\n };\n const convertTo = (word, type = \"lower\") => {\n const result = [];\n if (type === \"upper\") {\n for (let i = 0; i < word.length; i++) {\n const char = word[i];\n if (isLowerCase(char)) {\n let charCode = char.charCodeAt(0);\n result.push(String.fromCharCode(charCode - 32));\n } else {\n result.push(char);\n }\n }\n } else {\n for (let i = 0; i < word.length; i++) {\n const char = word[i];\n if (!isLowerCase(char)) {\n let charCode = char.charCodeAt(0);\n result.push(String.fromCharCode(charCode + 32));\n } else {\n result.push(char);\n }\n }\n }\n return result.join(\"\");\n };\n for (let i = 0; i < word.length; i++) {\n if (isLowerCase(word[i])) lowerCount++;\n else upperCount++;\n }\n if (lowerCount >= upperCount) {\n console.log(convertTo(word));\n } else {\n console.log(convertTo(word, \"upper\"));\n }\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "e2adcd5b1f64347e53ad4309d7292f6a", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nfunction processData(input) {\n //Enter your code here\n let res=input.split(\"\\n\"), n=+(res[0]),\n arr=res[1].split(\"\").filter((x)=>x!==\"\"),\n cnt=dvsr(n);\n //console.log(cnt,arr)\n cnt.forEach((d)=>{\n ////console.log(arr,d)\n let temp=\"\";\n while(d>0){\n temp+=arr.shift();\n d--\n }\n //console.log(arr,temp)\n temp=[...temp].reverse();\n arr=[...temp,...arr];\n \n })\n console.log(arr.reverse().join(\"\"))\n} \n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"ascii\");\n_input = \"\";\nprocess.stdin.on(\"data\", function (input) {\n _input += input;\n});\n\nprocess.stdin.on(\"end\", function () {\n processData(_input);\n});\nfunction dvsr(n){\n let v=Math.sqrt(n),set=new Set()\nfor(let i=2;i<=v;i++){\n if(n%i===0){\n set.add(i);\n set.add(n/i)\n }\n // cnt.push(i)\n}\n let cnt=[...set]\nreturn cnt.sort((a,b)=>a-b)\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "d4ea2e2fc0473c1d318575611d967f9c", "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const len = +readLine();\n const str = readLine();\n let count = 0;\n for (let i = 0; i < len - 1; i++) {\n if (str[i] === str[i + 1]) count++;\n }\n console.log(count);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "b1090aad0697ca60b74d88b99db41bbb", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var read = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\nvar obj;\nvar inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n var returnObj = {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){\n if(!this.hasNext()){\n\n throw \"ArrayIndexOutOfBoundsException これ以上ないよ\";\n }\n else{\n var returnInput = this.list[this.index];\n this.index++;\n return returnInput;\n }\n }};\n return returnObj;\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n //[no]要素の扱い。数値型\n //不明値、異常時:引数そのまま返す 1:数値へ変換\n //2:半角SPで分割 4:半角SPで分割し、数値配列へ\n //6:1文字で分割 7:1文字で分割し、数値配列へ\n //8:半角SPで結合 9:改行で結合 0:文字なしで結合\nfunction myconv(i,no){\n try{\n switch(no){\n case 1:return parseInt(i);\n case 2:return i.split(\" \");\n case 4:return i.split(\" \").map(Number);\n case 6:return i.split(\"\");\n case 7:return i.split(\"\").map(Number);\n case 8:return i.join(\" \");\n case 9:return i.join(\"\\n\");\n case 0:return i.join(\"\");\n default:return i;\n }\n }\n catch(e){\n return i;\n }\n}\nfunction Main(){\n var output = [];\n\n var ul = next();\n var arr = nextIntArray() ;\n var brr = nextIntArray() ; \n arr.sort() ;\n brr.sort();\n var crr = arr.filter(x=>brr.includes(x));\n if(crr.length > 0) {\n myout(crr[0]) ;\n }\n else {\n var l = Math.min(arr[0],brr[0]) ;\n var h = Math.max(arr[0],brr[0]) ;\n myout(l+\"\"+h)\n }\n \n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "179eb6fac52ce0768ef441bb02411202", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n const arr = d.split(' ').map(Number);\n let ans = 0;\n const coins = {};\n\n for (let i = 0; i < arr.length; i++) {\n if (coins.hasOwnProperty(arr[i])) {\n coins[arr[i]]++;\n }\n else {\n coins[arr[i]] = 1;\n }\n\n ans = Math.max(ans, coins[arr[i]]);\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e3efbda3c2c05b9671360f77c3c530cd", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\nvar z = readline.createInterfrace\n\nvar r = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nr.on('line', function (line) {\n r.close();\n bain(line);\n\n});\nfunction bain(line){\n let b= line.split(\" \");\n let n = b[0];\n let m = b[1];\n let a = b[2];\n let z = Math.ceil(n/a);\n let y = Math.ceil(m/a);\n console.log(z*y);\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "d22dbb775fbdff54b60d20b30a4dc138", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (str) => {\n let ans = 0;\n const obj = {\n a: true,\n e: true,\n i: true,\n o: true,\n u: true,\n 1: true,\n 3: true,\n 5: true,\n 7: true,\n 9: true\n };\n\n for (let i = 0; i < str.length; i++) {\n if (obj[str[i]]) {\n ans++;\n }\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "43e1255825ec8cb4b1d390d5d6f510de", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function solve(n) {\n let rest = n;\n let count = 0;\n while (rest > 0) {\n rest -= Math.max(...rest.toString().split(\"\"));\n count += 1;\n }\n return count;\n}\n\nfunction* main() {\n const n = parseInt(yield);\n const r = solve(n);\n console.log(r);\n process.exit(0);\n}\n\nif (!module.parent) {\n (() => {\n const q = main();\n q.next();\n require(\"readline\")\n .createInterface({\n input: process.stdin,\n output: null\n })\n .on(\"line\", line => q.next(line));\n })();\n}\n\nexports.solve = solve;\n", "lang_cluster": "Javascript", "tags": ["dp"], "code_uid": "8ac4196ea3c5c26786bcc44187bba097", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction readAsInt(){\n return parseInt(readline());\n}\n\nfunction readAsIntList(){\n return readline().split(' ').filter(i => i).map(i => parseInt(i));\n}\n\n\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n let [n, k] = readAsIntList();\n for(let i = 1; i <= k; i++) {\n if(n % 10 === 0) {\n n = n / 10;\n } else {\n n = n - 1;\n }\n }\n console.log(n);\n}\n \n\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "37516f52c369456b59549dd67ad04e2b", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({input: process.stdin})\nlet lines = [];\nreadline.on(\"line\", line => {\n lines.push(line);\n}).on(\"close\", () => {\n \n let myArray = lines[0].split('+');\n myArray.sort();\n console.log(myArray.join('+'));\n \n});\n", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "dfcb34bce6c4c95d45a05e957e41c654", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nconst isCapitalize = ch => ch === ch.toUpperCase();\n\nreadLine.on('close', () => {\n const str = input[0];\n let flag = true;\n\n if (str.length === 1) { \n if (!isCapitalize(str[0]))\n console.log(str.toUpperCase()); \n else \n console.log(str.toLowerCase());\n return \n }\n\n for (let i = 1; i < str.length; i += 1) if(!isCapitalize(str[i])) flag = false;\n \n if (flag) {\n if (isCapitalize(str[0]))\n console.log(str[0].toLowerCase() + str.slice(1).toLowerCase());\n else\n console.log(str[0].toUpperCase() + str.slice(1).toLowerCase());\n return;\n }\n \n console.log(str);\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "e55a81b95d2ae72077bbafb0e62458a3", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const arr = d.split(' ').map(Number);\n const max = Math.max(...arr);\n const min = Math.min(...arr);\n const point = arr.find((x) => x !== max && x !== min, 0);\n let ans = 0;\n\n for (let i = 0; i < arr.length; i++) {\n ans += Math.abs(point - arr[i]);\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["math", "sortings", "implementation"], "code_uid": "a861d7c82ff9891ab5494ffae1294c81", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => { \n solveWrap(inputString); \n});\n\nfunction solve(n){\n\tconst bills = [1, 5, 10, 20, 100].reverse();\n\tlet sum = 0;\n\tlet acc = 0;\n\tlet current = n;\n\tfor (let el of bills) {\n\t\twhile(el<=current){\n\t\t\tcurrent-=el;\n\t\t\tacc++;\n\t\t}\n\t}\n\treturn acc;\n}\n\n\nfunction solveWrap(input) {\n let n = input.trim().split('\\n');\n\tconsole.log(solve(+n));\n}\n", "lang_cluster": "Javascript", "tags": ["greedy", "dp"], "code_uid": "e979d5dc877f2eb2be376bdc84c802f4", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n let num = readLine()\n .split(\"\")\n .map((n) => parseInt(n));\n const map = {};\n for (let i = 0; i < num.length; i++) {\n if (!map[num[i]]) map[num[i]] = 1;\n else map[num[i]]++;\n }\n function isLucky(num) {\n if (!num) return false;\n while (num) {\n if (num % 10 !== 4 && num % 10 !== 7) return false;\n num = parseInt(num / 10);\n }\n return true;\n }\n let [four, seven] = [map[\"4\"] || 0, map[7] || 0];\n const total = four + seven;\n if (isLucky(total)) console.log(\"YES\");\n else console.log(\"NO\");\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "dcf92df5c2d8883558f0a6259835d713", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n let [n, m, z] = d.split(' ').map(Number);\n let ans = 0;\n\n for (let i = m; i <= z; i += m) {\n if (i % n === 0) {\n ans++;\n }\n }\n\n console.log(ans);\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "035f12a9240a5b1322dfa4a6915d2800", "src_uid": "e7ad55ce26fc8610639323af1de36c2d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Word\n\nconst {EOL} = require('os');\n\nlet inp = '';\n\nprocess.stdin.on('data', c => inp += c);\n\nprocess.stdin.on('end', () => {\n const lines = inp.split(EOL)[0].trim();\n \n let small = 0;\n for(let i = 0; i < lines.length; i++) {\n \tif(lines[i] >= 'a' && lines[i] <= 'z') {\n \t\tsmall++;\n \t\tif(small > lines.length / 2) {\n \t\t\tbreak;\n \t\t}\n \t}\n }\n\n if(small >= lines.length / 2) {\n \tprocess.stdout.write(lines.toLowerCase());\n } else {\n \tprocess.stdout.write(lines.toUpperCase());\n }\n\n return;\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "248f02fa01fb6ff6201b4a45fb194607", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n var T = readLine();\n var Tarr = T.split(\" \");\n var t1 = parseInt(Tarr[0]);\n var t2 = parseInt(Tarr[1]);\n var count = 0;\n var scores = readLine();\n var scoresArr = scores.split(\" \");\n scoresArr = scoresArr.map(Number);\n var passScore = scoresArr[t2 - 1];\n for (let i = 0; i < t1; i++) {\n if (scoresArr[i] >= passScore && scoresArr[i] > 0) {\n count++;\n }\n }\n console.log(count);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "5466dabeb7430e3c99fe57ee5754a17d", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n const training = {\n chest: 0,\n biceps: 0,\n back: 0\n };\n\n const arr = d.split(' ').map(Number);\n\n arr.forEach((x, idx) => {\n if (idx % 3 === 0) {\n training.chest += x;\n }\n\n if (idx % 3 === 1) {\n training.biceps += x;\n }\n\n if (idx % 3 === 2) {\n training.back += x;\n }\n });\n\n if (training.chest > training.biceps && training.chest > training.back) {\n console.log('chest');\n }\n else if (training.biceps > training.chest && training.biceps > training.back) {\n console.log('biceps');\n }\n else if (training.back > training.chest && training.back > training.biceps) {\n console.log('back');\n }\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e604525f6291aca4248bf00a4767224c", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = ''\n\nprocess.stdin.on('data',c => {\n i += c\n})\n\nprocess.stdin.on('end', () => {\n const { EOL } = require('os')\n const lines = i.split(EOL) /*your input text, split by lines*/\n\n let teamsCount = parseInt(lines[0])\n\n let homeKitColors = Array(teamsCount)\n let awayKitColors = Array(teamsCount)\n\n for (i = 1; i <= teamsCount; i++) {\n let teamKits = lines[i].split(\" \").map(value => {\n return parseInt(value)\n })\n \n homeKitColors[i-1] = teamKits[0]\n awayKitColors[i-1] = teamKits[1]\n\n }\n\n let overlappingKitCount = 0\n for(i = 0; i < teamsCount; i++) {\n for(j = 0; j < teamsCount; j++) { \n if (j === i) { continue }\n if (homeKitColors[i] === awayKitColors[j]) { \n overlappingKitCount++\n }\n }\n }\n\n console.log(overlappingKitCount)\n})", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "fd6bf106ee71ae11b2ff20d3c662b7bb", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar check = function (x, y, z) {\n if (x + y > z && x + z > y && y + z > x) return 'T';\n if (x + y == z || x + z == y || y + z == x) return 'S';\n return 'I';\n};\n\nrl.on('line', (input) => {\n\n var cont = input.split(' ').map(item => parseInt(item));\n var a = cont[0],\n b = cont[1],\n c = cont[2],\n d = cont[3];\n if (check(a, b, c) == 'T' ||\n check(a, b, d) == 'T' ||\n check(a, d, c) == 'T' ||\n check(d, b, c) == 'T') console.log(\"TRIANGLE\");\n else if (check(a, b, c) == 'S' ||\n check(a, b, d) == 'S' ||\n check(a, d, c) == 'S' ||\n check(d, b, c) == 'S') console.log(\"SEGMENT\");\n else console.log(\"IMPOSSIBLE\");\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["brute force", "geometry"], "code_uid": "c5a476868e86a0766dae9a121f0e0b74", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n // if(Array.isArray(inputString)) inputString = inputString.join('\\n');\n inputString += inputStdin;\n // inputString = inputString.trim().split('\\n').map(string => {\n // return string.trim();\n // });\n \n // main(); \n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction readAsInt(){\n return parseInt(readline());\n}\n\nfunction readAsIntList(){\n return readline().trim().split(' ').filter(i => i).map(i => parseInt(i));\n}\n\n\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n let n = readAsInt();\n console.log(n % 2 === 0 ? ( n + n*-1/2 ) : ( (n + 1)*-1/2));\n}\n \n\n\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "3e0d9507aa9da01d5c1861731635f220", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n var T = readLine();\n var result = readLine()\n .split(\" \")\n .map(Number)\n .sort((a, b) => a - b)\n .join(\" \");\n console.log(result);\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "acded0ee8f5e683f0192ee35cbe763db", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst reader = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet lines = [];\n\nreader.on('line', line => {\n lines.push(line);\n});\n\nreader.on('close', () => {\n\t//Code goes here. Input is in lines\n\tvar [n, m, a] = lines[0].split(\" \");\n\tvar ans = Math.ceil(n/a) *Math.ceil(m/a);\n\tconsole.log(ans);\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "4fce80ea1b239249e95c94c276ebbfe7", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet inputString = \"\";\nlet currentLine = 0;\n\nprocess.stdin.on(\"data\", (inputStdin) => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((string) => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n const x = readline();\n console.log(x.split('+').sort().join('+'));\n}\nfunction foo(x) {\n process.stdout.write(\"hello: \"); // without auto '\\n' (newline)\n console.log(x); // with auto '\\n' (newline)\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "90ec8f64028a740f13d98b5f5ebf0a89", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var t = next();\n var list = nextStrArray();\n for(var i = 0; i < list.length; i++){\n \tif(list[i].indexOf(t[0]) != -1 || list[i].indexOf(t[1]) != -1){\n myout(\"YES\");\n return;\n }\n }\n myout(\"NO\");\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "79ecda18618d5fde12a7cc7518242dce", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nreadline.on('line', input => {\n let n = input;\n const div = [4, 7, 47, 74, 444, 447, 474, 744, 477, 747, 774, 777];\n\n console.log(div.some(lucky => n % lucky === 0) ? 'YES' : 'NO');\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "number theory"], "code_uid": "e2e03435b46dd2298b693c462698f9c1", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function solve(n, str) {\n str = str.toLowerCase();\n let m = {};\n for (let c = 'a'.charCodeAt(0); c <= 'z'.charCodeAt(0); c++) {\n m[c] = false;\n }\n str.split('').forEach(letter => {\n m[letter.charCodeAt(0)] = true;\n });\n for (var key in m) {\n if (m.hasOwnProperty(key) && m[key] === false) {\n return \"NO\\n\";\n }\n }\n return \"YES\\n\";\n}\n\nlet i = ''\nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os');\n const lines = i.split(EOL);\n console.log(solve(lines[0], lines[1]));\n})\n\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "1e08440fde5a9fc90f95eec97e8e8d1e", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n})\nlet line\nlet c = 0\nrl.on('line', (cmd) => {\n\tline = cmd\n\trl.close()\n})\nrl.on('close', () => {\n\tprocess.stdout.write(test(line.split(\" \")))\n})\nfunction test(list) {\n\tlet cost = 0\n\tfor (let i = 1; i <= list[2]; i++) {\n\t\tcost += i * list[0]\n\t}\n\treturn cost - list[1] > 0 ? String(cost - list[1]) : \"0\"\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "3da57d9775b9926897880824f96b56d3", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nisT = true;\n\nreadLine.on(\"line\", line => {\n if (isT) {\n isT = false;\n } else {\n countPress(line);\n }\n});\n\nfunction countPress(num) {\n let str = num;\n num = parseInt(num);\n let count = str.length;\n let sum = 0;\n let flag = false;\n for(let i = 1; i <= num%10; i++) {\n for (let j = 1; j <= 4; j++) {\n if(i == num%10 && j == count) {\n //sum += count;\n sum += j;\n flag = true;\n break;\n }\n sum += j;\n }\n if (flag) {\n break;\n }\n }\n console.log(sum);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "caccc1c2751c64a00175ecb04e7d8cb5", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var dataitr;\r\nvar stdin_input = \"\";\r\nprocess.stdin.resume();\r\nprocess.stdin.setEncoding(\"ascii\");\r\nprocess.stdin.on(\"data\", function (input) { stdin_input += input; });\r\nprocess.stdin.on(\"end\", function () { dataitr = stdin_input.split('\\n').values(); main(); });\r\n\r\nconst rl = () => dataitr.next().value.trim();\r\nconst rn = () => Number(rl());\r\nconst ra = () => rl().split(' ');\r\nconst rna = () => ra().map(x => Number(x));\r\n\r\nfunction main () {\r\n\tlet T = rn();\r\n\twhile (T--) {\r\n\t\tconst [n, m, k] = rna();\r\n\r\n\t\tfunction check (n, m, k) {\r\n\t\t\tif (k < 0) return false;\r\n\t\t\tif (k > n*m/2) return false;\r\n\t\t\tif (k%2 == 0) return true;\r\n\t\t\telse false;\r\n\t\t}\r\n\r\n\t\tlet ans;\r\n\t\tif (n%2 == 0 && m%2 == 0) \r\n\t\t\tans = check(n, m, k);\r\n\t\telse if (n%2 == 0) {\r\n\t\t\tans = check(n, m - 1, k);\r\n\t\t} else {\r\n\t\t\tans = check(n - 1, m, k - m/2);\r\n\t\t}\r\n\r\n\t\tconsole.log(ans ? 'YES' : 'NO');\r\n\t}\r\n}\r\n\r\n", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms"], "code_uid": "6e9b2a96ab50842fa9bdb3b6115a0a77", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const stdin = process.openStdin();\nstdin.addListener('data', text => {\n const numbers = text.toString().split(' ');\n console.log(Math.ceil(numbers[0] / numbers[2]) * Math.ceil(numbers[1] / numbers[2]));\n stdin.pause();\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "dbd8765d848800843d88310c628ff999", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet n, h, m;\nlet arr;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n [n, h, m] = d.split(' ').map(Number);\n arr = new Array(n).fill(h);\n return;\n }\n\n const [l, r, x] = d.split(' ').map(Number);\n\n for (let i = l - 1; i <= r - 1; i++) {\n if (x < arr[i]) {\n arr[i] = x;\n }\n }\n\n c++;\n});\n\nrl.on('close', () => {\n let ans = 0;\n\n for (let i = 0; i < arr.length; i++) {\n ans += arr[i]**2;\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "84f31a397f527a7586596e9f4a90878f", "src_uid": "f22b6dab443f63fb8d2d288b702f20ad", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet days, toSF = toSea = 0;\n\nrl.on('line', n => {\n if (!days) { days = n } else {\n n.toLowerCase().split('')\n .forEach((letter, i, arr) =>\n letter !== arr[i - 1] && i !== 0 && (letter === 'f' ? toSF++ : toSea++));\n console.log(toSF > toSea ? 'YES' : 'NO');\n rl.close();\n }\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "425904718de8d2c8ab47f6aa83fcb26e", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const state = { stdin: Buffer.alloc(0) };\nconst consume = (chunk) =>\n (state.stdin = Buffer.concat(\n [state.stdin, chunk],\n state.stdin.length + chunk.length\n ));\nconst commit = (answer) => process.stdout.write(answer);\nconst main = (args) => {\n let [n, m, a] = state.stdin\n .toString(\"utf8\")\n .split(\" \")\n .map((e) => parseInt(e));\n let d1 = Math.ceil(n / a);\n let d2 = Math.ceil(m / a);\n let ans = d1 * d2;\n\n commit(ans.toString());\n};\nprocess.stdin.on(\"data\", consume).on(\"end\", main);\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "ad6e32e4bf2e2a8a2d4964c37e723dd9", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const [n] = [d].map(BigInt);\n const total = n * (n + 1n) / 2n;\n\n console.log((total % 2n).toString());\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "a9993fa99c2eb96a2542bda5451e0f97", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet currentLine = 0;\nlet inputString = \"\";\n\nprocess.stdin.on(\"data\", (raw_data) => {\n inputString += raw_data;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((line) => {\n return line.trim();\n });\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n/******** Main function*************/\n\nfunction main() {\n var str = readLine().split(\" \");\n var firstName = str[0];\n var lastName = str[1];\n\n var first = firstName[0];\n\n for (var i = 1; i < 10; i++) {\n if (firstName[i] < lastName[0]) {\n first += firstName[i];\n } else {\n break;\n }\n }\n console.log(first + lastName[0]);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "sortings", "greedy"], "code_uid": "e9e61582eb5107584dd1bffc45c61319", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n const [n] = input[0].split(' ').map(x => parseInt(x));\n\n const people = {\n 1: 'Sheldon',\n 2: 'Leonard',\n 3: 'Penny',\n 4: 'Rajesh',\n 5: 'Howard',\n };\n\n if (n <= 5) console.log(people[n]);\n else {\n let left = 5;\n let boundary = 15;\n let count = 2;\n\n while (true) {\n if (n >= left && n <= boundary) \n break;\n left = boundary;\n count = count * 2;\n boundary = count * 5 + left;\n }\n\n //console.log(`people = ${count}; left = ${left}; right = ${boundary}`);\n let s = 1;\n for (let i = left; i <= boundary; i += count) {\n if (i <= n && i+count >= n) {\n console.log(people[s]); break;\n }\n s += 1;\n }\n }\n}); ", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "7ad5afd23b48222ce0c577d20312d1bf", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n let [n, t] = input[0].split(' ').map(x => parseInt(x));\n const queue = input[1].split('');\n\n while (t > 0) {\n for (let i = 1; i < queue.length; i += 1) {\n if (queue[i] === 'G' && queue[i-1] === 'B') {\n queue[i] = 'B'; queue[i-1] = 'G'; i += 1;\n }\n }\n t--;\n } \n \n console.log(queue.join(''));\n});", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "0c4420a513ad4f35f73685fa58e6b338", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\n\"use strict\";\nlet input = [];\nconst readline=require('readline');\nconst RL=readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nRL.on('line', (line)=>{\n input.push(line.trim());\n});\nRL.on('close', ()=>{\n const vowels=['a', 'o', 'y', 'e', 'u', 'i'];\n const arr=input[0].toLowerCase().split('');\n let answer=arr.map((ch) => {\n if(vowels.includes(ch)){\n return \"\";\n }\n\n return \".\"+ch;\n });\n\n console.log(answer.join(''));\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "afe8965ee3904ababab7f36c0eb1a1a0", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nconst dominos = () =>{\n const [n, k] = input[0].split(' ').map(x => +x);\n let s = n * k;\n let q = Math.floor(s / 2);\n console.log(q);\n};\n\nreadLine.on('close', dominos);", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "ef357cfbd9e8c430f8cb1cffc59ba363", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let data = '';\nprocess.stdin.on('data', c => data += c);\nconst sol = () => {\n let num = Number(data.split(/\\n/g)[0]);\n let result = [];\n let flag = true;\n while (num > 0 || flag) {\n let d = num%10;\n num = Math.trunc(num/10);\n result.push(((d >= 5)?'-O':'O-') + \n '|' +\n ['-OOOO', 'O-OOO', 'OO-OO', 'OOO-O', 'OOOO-'][d%5]);\n flag = false;\n }\n console.log(result.join('\\n'));\n};\nprocess.stdin.on('end', sol);", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "89d41cab1234bf67ea44688462dfe86b", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n const arr = d.split(' ').map(Number);\n const sum = arr.reduce((a, b) => a + b, 0);\n let max = Math.max(...arr);\n let r = 0;\n\n for (let i = 0; i < arr.length; i++) {\n r += max - arr[i];\n }\n\n // while (r <= sum) {\n // r += arr.length;\n // max++;\n // }\n\n if (sum - r >= 0) {\n max += Math.floor((sum - r) / arr.length) + 1;\n }\n\n console.log(max);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "e499aa0cca922ecff52d0788939939fd", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "/* scheme2js generated file Fri, 16 Oct 2020 16:24:07 +0800 */\nconst rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })\nconst print = console.log\nconst write = (...args) => {\n process.stdout.write(args.join(' '));\n}\nconst lines = []\nrl.on('line', line => {\n lines.push(line);\n});\nrl.on('close', main)\nlet rli = 0;\nfunction readline() {\n return lines[rli++];\n}\n\n\nfunction main() {\nvar BGl_rze21ze2zzscm2js1008z00;\nvar BGl_mze22ze2zzscm2js1008z00;\nvar BGl_nze23ze2zzscm2js1008z00;\nvar num = readline().split(\" \").map(x => parseInt(x));\nBGl_nze23ze2zzscm2js1008z00 = num[0];\nBGl_mze22ze2zzscm2js1008z00 = num[1];\nBGl_rze21ze2zzscm2js1008z00 = num[2];\n(print(((((parseInt((BGl_nze23ze2zzscm2js1008z00+BGl_rze21ze2zzscm2js1008z00-1)/BGl_rze21ze2zzscm2js1008z00)))*((parseInt((BGl_mze22ze2zzscm2js1008z00+BGl_rze21ze2zzscm2js1008z00-1)/BGl_rze21ze2zzscm2js1008z00)))))));\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "942def177cab1f9d09de41678f85dff0", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n}); \nfunction sort(array) {\n // use custom compare function that sorts numbers ascending\n alert(ary.sort(function(a, b) {\n return a - b;\n }));\n}\n\n\nvar array =[];\nvar newarr = [];\nrl.question(``, (count) => {\n var a = '';\n for (let index = 0; index < count.length; index++) {\n if(count[index]!='+'){\n a =a+count[index];\n }else{\n array.push(a);\n a='';\n }\n if(count.length-index == 1){\n array.push(a);\n }\n\n }\n array = array.sort(function(a, b) {\n return a - b;\n });\n console.log(array.join('+'));\n rl.close();\n })\n\n\n\n", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "022c0a094d9aea01164907b47687915a", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input.push(parseInt(line));\n});\n\nRL.on('close', () => {\n let n = input[0];\n let count_v = 1;\n\n\n for(let i = 2; i < n/2+1; i++){\n if( (n-i) % i == 0){\n count_v ++; \n }\n }\n\n console.log(count_v);\n});\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "7afdaea9c97b0fda10363963f458d9eb", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let fs = require(\"fs\");\n\nlet txt = fs.readFileSync(0, \"utf-8\").split(\"\\r\\n\").filter(data => {\n return data.length > 0;\n});\nfor (let i = 0; i < txt.length; i ++) {\n doit(txt[i]);\n\n}\n\nfunction doit(str) {\n let tab =str.split(\"\").filter(data=>{return data.length>0});\n let stab=[]\n tab.forEach(data => {\n if(data.charCodeAt()<97){\n stab.push(\"U\");\n }else{\n stab.push(\"L\")\n }\n });\n let r=stab.filter(data=>{return data==\"L\"}).length\n if(r==0 ||(r==1 && stab[0]==\"L\")){\n tab.forEach((data,index)=>{\n if(data.charCodeAt()<97){\n stab[index]=data.toLowerCase()\n }else{\n stab[index]=data.toUpperCase()\n }\n })\n console.log(stab.join(\"\"));\n \n }else{\n console.log(str);\n \n }\n \n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "f24c8626fbe390af66562386c647301f", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nlet q = {};\n\nrl.on(\"line\", (input) => {\n for (c of input) {\n q[c] = true;\n }\n\n if (Object.keys(q).length % 2) {\n console.log(\"IGNORE HIM!\");\n } else {\n console.log(\"CHAT WITH HER!\");\n }\n rl.close();\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "ada8ca5efae080e07d3280e8fce83f4b", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let stdin = process.stdin;\nstdin.setEncoding('utf8');\nstdin.on('data', function (data) {\n let input = data.split('\\n');\n console.log(solution(input[0], input[1]));\n});\n\nconst solution = (cardOnTable, cardsInHand) => {\n if (cardsInHand.indexOf(cardOnTable[0]) >= 0 || cardsInHand.indexOf(cardOnTable[1]) >= 0){\n\treturn \"YES\";\n } else {\n\treturn \"NO\";\n }\n};\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "274a441c15ef7d3d46996fbc44d269f9", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\n\nrl.on('line', (str) => {\n console.log(str.split('+').sort((a, b) => a - b).join('+'));\n});", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "ade1ce5ae89f7bbca10302b5a5689af2", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n let n = +d;\n\n const soroban = {\n 0: 'O-|-OOOO',\n 1: 'O-|O-OOO',\n 2: 'O-|OO-OO',\n 3: 'O-|OOO-O',\n 4: 'O-|OOOO-',\n 5: '-O|-OOOO',\n 6: '-O|O-OOO',\n 7: '-O|OO-OO',\n 8: '-O|OOO-O',\n 9: '-O|OOOO-',\n };\n\n if (n === 0) {\n console.log(soroban[0]);\n return;\n }\n\n while (n > 0) {\n const digit = n % 10;\n n = Math.floor(n / 10);\n\n console.log(soroban[digit]);\n }\n\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "89f140fb226ef4d2eae212b8bf7f599a", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet cups = 0;\nlet medals = 0;\nlet n = 0;\n\nlet cMax = 5;\nlet mMax = 10;\n\nrl.on('line', (d) => {\n if (c === 0) {\n cups = d.split(' ').map(Number).reduce((a, b) => a + b, 0);\n }\n\n if (c === 1) {\n medals = d.split(' ').map(Number).reduce((a, b) => a + b, 0);\n }\n\n if (c === 2) {\n n = +d;\n }\n\n c++;\n});\n\nrl.on('close', () => {\n let ans = 0;\n\n ans += Math.ceil(cups / cMax);\n ans += Math.ceil(medals / mMax);\n\n if (ans > n) {\n console.log('NO');\n }\n else {\n console.log('YES');\n }\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "190f6ce5436aa38ae1d75017814dc485", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet inputString = \"\";\nlet currentLine = 0;\n\nprocess.stdin.on(\"data\", inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on(\"end\", function() {\n inputString = inputString\n .replace(/\\s*$/, \"\")\n .split(\"\\n\")\n .map(str => str.replace(/\\s*$/, \"\"));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n const firstLine = readLine();\n const weight = parseInt(firstLine, 10);\n // const a = readLine().split(' ').map(aTemp => parseInt(aTemp, 10));\n\n console.log(watermelon(weight));\n}\n\nfunction watermelon(weight) {\n for (let i = 2; i <= weight / 2; i += 2) {\n if ((weight - i) % 2 === 0) {\n return \"YES\";\n }\n }\n return \"NO\";\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "816dbefffd22e15e1d055b1b58c59e43", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet currentLine = 0;\nlet inputString = \"\";\n\nprocess.stdin.on(\"data\", (raw_data) => {\n inputString += raw_data;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((line) => {\n return line.trim();\n });\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n/******** Main function*************/\n\nfunction main() {\n var arr = [];\n for (var k = 0; k < 5; k++) {\n var inp = readLine().split(\" \").map(Number);\n arr.push(inp);\n }\n\n var m, n;\n for (var i = 0; i < 5; i++) {\n for (var j = 0; j < 5; j++) {\n if (arr[i][j] == 1) {\n m = i;\n n = j;\n }\n }\n }\n\n var sum;\n\n sum = Math.abs(m - 2) + Math.abs(n - 2);\n\n console.log(sum);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0c5b13d7909a71f43644331ac21b8bef", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data', function(chunk){\n\tvar lns = chunk.toString().replace(/\\r/g, \"\").split(/\\n/);\n\tvar hs = '', gs = '', r = 0;\n\tfor(var i = 0, l = lns.splice(0, 1)[0]; i\"|\" + e + \"|\");\n\t\tr += (hs.split(ln[1]).length - 1) + (gs.split(ln[0]).length - 1);\n\t\ths += ln[0];\n\t\tgs += ln[1];\n\t}\n\tconsole.log(r);\n});", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "572e17e5bf2b6f3d4a681ef76a892769", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n});\n\nvar str;\n\nfunction main() {\n\trl.question('', (answer) => {\n\t\tif (answer.length) {\n\t\t\tstr = answer;\n\t\t\trl.close();\n\t\t\tsolve();\n\t\t}\n\t});\n}\nfunction solve() {\n\tvar a = [];\n\tfor(var i=0; i sLen / 2 ? sLen : aLen*2-1);\n}\n\nconst readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar stdin = [];\nrl.on('line', function (line) {\n stdin.push(line);\n});\nrl.on('close', main);\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "cd6177f91b66fca79992e07a276ca107", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let input1 = readline().split(' ');\n let m = parseInt(input1[0]);\n let n = parseInt(input1[1]);\n \n maxNumDominoes(m, n)\n};\n\nfunction maxNumDominoes(n, m){\n\n console.log(Math.floor((n * m) / 2));\n}", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "55f98e3c0a147b340252248ce03f0e32", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', (inputStdin) => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', (_) => {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((string) => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let lines = 5;\n\n let matrix = [];\n\n while (lines-- > 0) {\n let array = readline()\n .split(' ')\n .map((int) => parseInt(int));\n\n matrix.push(array);\n }\n\n let x;\n let y;\n\n for (let i = 0; i < 5; i++) {\n for (let j = 0; j < 5; j++) {\n if (matrix[i][j] === 1) {\n x = i + 1;\n y = j + 1;\n }\n }\n }\n\n console.log(Math.abs(3 - x) + Math.abs(3 - y));\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "be93d2d6267056121d26bd0dcb78b4c6", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf8');\nvar input= '', readline, cout;\nprocess.stdin.on('data', function(chunk) {\n input+=chunk;\n});\nprocess.stdin.on('end', function() {\n input = input.split('\\n');\n cout = function(data) {process.stdout.write(data+'\\n')};\n var inputLineIndex = 0;\n readline = function(){return inputLineIndex>=input.length?undefined:input[inputLineIndex++]};\n process.exit(main() || 0);\n});\n\nfunction main()\n{\n let a = readline();\n if(a > 2 && a % 2 === 0) console.log(\"YES\");\n else console.log(\"NO\")\n return 0;\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "8f28aeacf40043ea331204543ea976d4", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\nrl.on('line', (input) => {\n rl.close();\n console.log(solve(input));\n});\n\n\nconst solve = (word) => {\n let moves = 0;\n let currentChar = 'a';\n const alphapet = {\n a: 1,\n b: 2,\n c: 3,\n d: 4,\n e: 5,\n f: 6,\n g: 7,\n h: 8,\n i: 9,\n j: 10,\n k: 11,\n l: 12,\n m: 13,\n n: 14,\n o: 15,\n p: 16,\n q: 17,\n r: 18,\n s: 19,\n t: 20,\n u: 21,\n v: 22,\n w: 23,\n x: 24,\n y: 25,\n z: 26\n }\n\n for (let i = 0; i < word.length; i++) {\n let char = word[i];\n let clockWise = Math.abs(alphapet[currentChar] - alphapet[char]);\n let antiClockWise = 26 - clockWise;\n moves += clockWise < antiClockWise ? clockWise : antiClockWise;\n currentChar = char;\n }\n\n return moves;\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "93234c3dbe7562cf376a44fe85512408", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var line_number = 0;\nconst cs = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nvar lines = {};\ncs.on(\"line\", (input) => {\n if (input == \"\") {\n cs.close();\n }\n lines[line_number] = input.split(\" \");\n line_number += 1;\n}).on(\"close\", () => {\n main();\n process.exit();\n});\n\nfunction isOp(str) {\n return str.length === 1 && str.match(/[<=>]/);\n}\nfunction isChr(str) {\n return str.length === 1 && str.match(/[a-z]/i);\n}\nfunction isInt(str) {\n return str.length === 1 && !isNaN(str);\n}\n\nfunction print(str) {\n console.log(str);\n}\n\nfunction predict(test) {\n let op = \"\";\n let ops = [];\n let opVariables = [];\n let limits = [];\n for (let t of test) {\n // console.log(t);\n for (let i = 0; i < t.length; i++) {\n if (isOp(t[i])) {\n op = t[i];\n if (isOp(t[i + 1])) {\n op += t[i + 1];\n i += 1;\n }\n ops.push(op);\n op = \"\";\n } else if (isChr(t[i])) {\n // console.log(t[i])\n op = t[i];\n for (var j = i + 1; j < t.length; j++) {\n if (isChr(t[j]) || isInt(t[j])) {\n op += t[j];\n i = j;\n } else break;\n }\n opVariables.push(op);\n op = \"\";\n } else {\n if (i == 0 || (i > 0 && isOp(t[i - 1]))) {\n op = t[i];\n let j = i + 1;\n for (; j < t.length; j++) {\n if (isInt(t[j])) {\n op += t[j];\n i = j;\n } else break;\n }\n limits.push(op);\n op = \"\";\n }\n }\n }\n }\n\n let min = limits[0];\n let max = limits[1];\n\n let pvs = ops.map((o, i) => [o, opVariables[i]]);\n\n for (let pv of pvs) {\n if (pv[1] == undefined) {\n pv[1] = max;\n }\n // print(`${min} ${pv[0]} ${pv[1]} ?`)\n if (eval(`${min}${pv[0]}${pv[1]}`)) {\n // print(` ${min} ${pv[0]} ${pv[1]} true`)\n min = pv[1];\n } else {\n print(\"input error\");\n process.exit();\n }\n }\n}\n\nvar n;\nfunction main() {\n let str1 = lines[0][0].toLowerCase();\n let str2 = lines[1][0].toLowerCase();\n if (str1 > str2)\n print(1)\n else if (str1 < str2)\n print(-1)\n else\n print(0)\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "9dc1a76985024650ad1d2e22f515f067", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n// read each line\nrl.on(\"line\", (lineInput) => {\n let params = lineInput.split(\" \");\n console.log(Math.floor((params[0] * params[1]) / 2));\n});\n\n// when all file readed\nrl.on(\"close\", () => {});\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "283a731b60d269f8e1030ac2e97e700f", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction readint() {\n let line = readline().split(' ').map(function(num) {\n return parseInt(num);\n });\n return line;\n}\n\nfunction readfloat() {\n let line = readline().split(' ').map(function(num) {\n return parseFloat(num);\n });\n return line;\n}\n\nfunction print(x) {\n console.log(x);\n}\n\nfunction write(x) {\n process.stdout.write(x);\n}\nfunction main() {\n let line = readline();\n let arr = [];\n for(let i = 0; i < line.length; i+=2) {\n arr.push(line[i]);\n }\n let len = arr.length;\n arr.sort((a, b) => (a - b));\n arr.forEach((v,i) => {\n if(i != len - 1) write(v +=\"+\"); \n else write(v);\n });\n}", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "9f6bcc97ec6e8cab227876e5281d9e69", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nrl.question('',(val)=>{\n if(val>2 && val%2==0){\n console.log('YES');\n }else{\n console.log('NO');\n }\n rl.close();\n})\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "11f49a2329b7cc5cbfd468f2a0fe2d6d", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main(){\n var inp = readLine();\n var n = parseInt(inp.split(\" \")[0]);\n var m = parseInt(inp.split(\" \")[1]);\n var a = parseInt(inp.split(\" \")[2]);\n var res = 0;\n res+= Math.ceil(n/a) * Math.ceil(m/a);\n\nconsole.log(res);\n\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "4d60bfbffb93762a0fc4f95c597c5314", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nrl.on(\"line\", (input) => {\n const [m, n, a] = input.split(/\\s+/).map((n) => parseInt(n));\n //\n const rows = Math.ceil(m / a);\n const columns = Math.ceil(n / a);\n const total = rows * columns;\n //\n console.log(total);\n process.exit();\n //\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "46d14373e1c5c945940b6cf3bd5ffe72", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n removeDups = (string) => {\n return string\n .split('')\n .filter((item, pos, self) =>{\n return self.indexOf(item) == pos;\n })\n .join('');\n }\n\nlet userName = \" \" ;\nrl.on(\"line\",(input)=>{\n userName = removeDups((input)) \n // console.log(userName) \n if(userName.length % 2 == 0 )\n {\n console.log(\"CHAT WITH HER!\") ;\n rl.close();\n }\n else\n {\n console.log(\"IGNORE HIM!\" )\n rl.close();\n }\n \n})", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "f887592d9c1155f5c15744c71fa59523", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', (inputStdin) => {\n\tinputString += inputStdin;\n});\n\nprocess.stdin.on('end', (_) => {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map((string) => {\n\t\t\treturn string.trim();\n\t\t});\n\n\tmain();\n});\n\nfunction readline() {\n\treturn inputString[currentLine++];\n}\n\nfunction main() {\n\tconst str = readline();\n\tlet result = 0;\n\tlet diff = 0;\n\n\tdiff = Math.abs('a'.charCodeAt() - str[0].charCodeAt());\n\tresult += 26 - diff < diff ? 26 - diff : diff;\n\tfor (let i = 0; i < str.length - 1; i++) {\n\t\tdiff = Math.abs(str[i].charCodeAt() - str[i + 1].charCodeAt());\n\t\tresult += 26 - diff < diff ? 26 - diff : diff;\n\t}\n\n\tconsole.log(result);\n\treturn;\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "bada4b4a34ee500cc30af273090e8c78", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout,\n\tterminal: false\n});\n\nrl.on('line', function(line){\n\tlet [a, b, c] = line.split(' ').map(i => parseInt(i));\n\ta = a % c !== 0 ? Math.floor(a / c) + 1 : a / c;\n\tb = b % c !== 0 ? Math.floor(b / c) + 1 : b / c;\n\tconsole.log(a * b);\n\trl.close();\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "50af7988e90118751e7a22ca8b8fbfbb", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet stdin = '';\n\nprocess.stdin.on('data', (input) => {\n stdin += input;\n});\n\nprocess.stdin.on('end', () => {\n const data = stdin.split('\\n')[1];\n\n let counter = 0;\n let current;\n\n data.split('').forEach((value) => {\n if (value === current) counter++;\n else current = value;\n });\n\n process.stdout.write(`${counter}`);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f1d0722b919b8d9b144474fb775536cd", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n \nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n const n = [...input[0]];\n if (parseInt(n) >= 0) console.log(n.join(''))\n else {\n let modify = [...n];\n modify.pop();\n let t = [...n];\n t.splice(n.length-2, 1);\n\n if (parseInt(modify.join('')) > parseInt(t.join(''))) {\n console.log(parseInt(modify.join('')) === 0 ? 0 : parseInt(modify.join('')))\n } else {\n console.log(parseInt(t.join('')) === 0 ? 0 : parseInt(t.join('')));\n }\n }\n});", "lang_cluster": "Javascript", "tags": ["implementation", "number theory"], "code_uid": "3191092816e3ce7ce6bf6df1e698a757", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\n// NYAN NYAN\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n// ░░░░░░░░░░▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄░░░░░░░░░\n// ░░░░░░░░▄▀░░░░░░░░░░░░▄░░░░░░░▀▄░░░░░░░\n// ░░░░░░░░█░░▄░░░░▄░░░░░░░░░░░░░░█░░░░░░░\n// ░░░░░░░░█░░░░░░░░░░░░▄█▄▄░░▄░░░█░▄▄▄░░░\n// ░▄▄▄▄▄░░█░░░░░░▀░░░░▀█░░▀▄░░░░░█▀▀░██░░\n// ░██▄▀██▄█░░░▄░░░░░░░██░░░░▀▀▀▀▀░░░░██░░\n// ░░▀██▄▀██░░░░░░░░▀░██▀░░░░░░░░░░░░░▀██░\n// ░░░░▀████░▀░░░░▄░░░██░░░▄█░░░░▄░▄█░░██░\n// ░░░░░░░▀█░░░░▄░░░░░██░░░░▄░░░▄░░▄░░░██░\n// ░░░░░░░▄█▄░░░░░░░░░░░▀▄░░▀▀▀▀▀▀▀▀░░▄▀░░\n// ░░░░░░█▀▀█████████▀▀▀▀████████████▀░░░░\n// ░░░░░░████▀░░███▀░░░░░░▀███░░▀██▀░░░░░░\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\nconst CODEFORCES_NODE = \"cf\";\nconst CODEFORCES_V8 = \"cf-v8\";\nconst BEAKJOON = \"bj\";\nconst TEST = \"test\";\nconst PROGRAMMERS = \"ps\";\nvar SITE = CODEFORCES_NODE;\n// var SITE = CODEFORCES_NODE;\n// var SITE = PROGRAMMERS;\nvar DEBUG = false;\nif (SITE == BEAKJOON) {\n if (!String.prototype.startsWith) {\n String.prototype.startsWith = function (search, pos) {\n return this.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;\n };\n }\n if (!String.prototype.endsWith) {\n String.prototype.endsWith = function (search, this_len) {\n if (this_len === undefined || this_len > this.length) {\n this_len = this.length;\n }\n return this.substring(this_len - search.length, this_len) === search;\n };\n }\n if (!String.prototype.repeat) {\n String.prototype.repeat = function (count) {\n 'use strict';\n if (this == null) {\n throw new TypeError('can\\'t convert ' + this + ' to object');\n }\n var str = '' + this;\n count = +count;\n if (count != count) {\n count = 0;\n }\n if (count < 0) {\n throw new RangeError('repeat count must be non-negative');\n }\n if (count == Infinity) {\n throw new RangeError('repeat count must be less than infinity');\n }\n count = Math.floor(count);\n if (str.length == 0 || count == 0) {\n return '';\n }\n // Ensuring count is a 31-bit integer allows us to heavily optimize the\n // main part. But anyway, most current (August 2014) browsers can't handle\n // strings 1 << 28 chars or longer, so:\n if (str.length * count >= 1 << 28) {\n throw new RangeError('repeat count must not overflow maximum string size');\n }\n var maxCount = str.length * count;\n count = Math.floor(Math.log(count) / Math.log(2));\n while (count) {\n str += str;\n count--;\n }\n str += str.substring(0, maxCount - str.length);\n return str;\n };\n }\n}\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ HELPER ALGORITHMS/POLYFILLS ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\nfunction getCombinations2(n) {\n let ret = [];\n for (let start = 0; start < n; start++) {\n for (let k = start + 1; k < n; k++) {\n let s = new Set();\n s.add(start);\n s.add(k);\n ret.push(s);\n }\n }\n return ret;\n}\n\nfunction getSubbits(n) {\n let ret = [];\n for (var subset = n; subset; subset = (subset - 1) & n) {\n ret.push(subset);\n }\n return ret;\n}\nString.prototype.replaceAt = function (index, replacement) {\n return this.substr(0, index) + replacement + this.substr(index + replacement.length);\n};\nFunction.prototype.repeat = function (times, callback = undefined) {\n for (let i = 0; i < times; i++) {\n this();\n }\n return callback ? callback() : null;\n};\nArray.prototype.getMaxConsecutiveSum = function (defaultValue = -Infinity) {\n const N = this.length;\n let maxsum = defaultValue;\n let cursum = defaultValue;\n let cur;\n for (var ii = 0; ii < N; ii++) {\n cur = this[ii];\n if (cursum + cur > 0) {\n if (cur > cursum + cur) {\n cursum = cur;\n } else\n cursum += cur;\n } else {\n cursum = cur;\n if (maxsum < cursum) {\n maxsum = cursum;\n }\n }\n if (maxsum < cursum) {\n maxsum = cursum;\n }\n }\n this.maxConsecutiveSum = maxsum;\n return maxsum;\n};\ntry {\n require('manakin').global;\n // require (\"babel-polyfill\");\n} catch (error) {}\ntry {\n process.argv.forEach(function (val, index, array) {\n if (val.startsWith(\"site\")) {\n switch (val.split(\"=\")[1]) {\n case \"test\":\n // console.log('change site to test')\n SITE = TEST;\n break;\n case \"cf-node\":\n // console.log('change site to cf')\n SITE = CODEFORCES_NODE;\n break;\n case \"cf\":\n // console.log('change site to cf')\n SITE = CODEFORCES_NODE;\n break;\n case \"cf-v8\":\n // console.log('change site to cf')\n SITE = CODEFORCES_V8;\n break;\n case \"bj\":\n // console.log('change site to bj')\n SITE = BEAKJOON;\n break;\n }\n }\n if (val.startsWith(\"debug\")) {\n switch (val.split(\"=\")[1]) {\n case \"true\":\n DEBUG = true;\n break;\n case \"false\":\n DEBUG = false;\n break;\n }\n }\n });\n} catch (error) {}\nlet inputFilePath = '';\nswitch (SITE) {\n case TEST:\n const config = require('config');\n var fs = require(\"fs\");\n var path = require('path');\n inputFilePath = config.get('INPUTFILEPATH') || path.resolve(__dirname, \"input.txt\");\n break;\n default:\n inputFilePath = './input.txt';\n break;\n}\nconst INPUTFILEPATH = inputFilePath;\n// if (!String.prototype.endsWith) {\n// \tString.prototype.endsWith = function(search, this_len) {\n// \t\tif (this_len === undefined || this_len > this.length) {\n// \t\t\tthis_len = this.length;\n// \t\t}\n// \t\treturn this.substring(this_len - search.length, this_len) === search;\n// \t};\n// }\n// if (!Array.prototype.includes) {\n// Array.prototype.includes = function (target) {\n// return this.indexOf(target) !== -1\n// }\n// }\nif (!Array.prototype.sortNumber) {\n /**\n * @memberof Array\n * @summary sorts array by number\n */\n Array.prototype.sortNumber = function (order = 'asc') {\n return this.sort((a, b) => ((order == 'asc') ? 1 : -1) * (+a - +b));\n };\n}\nconst newLine = '\\n';\nvar ans;\nvar inputText = \"\";\nvar lineCount = 0;\nvar lines;\nvar input;\n/**\n * @type {(trim?=true)=>string}\n */\nvar readline;\nvar getlines;\nvar lineOpen = false;\nvar readingLine = '';\nvar clockStart;\nvar clock;\n/**\n * @type {typeof import('glob')}\n */\nvar glob;\nvar customFilesPattern = 'inputs/**/*.in';\nvar customFiles = [];\nvar print;\nprint = console.log;\nvar it;\nvar step;\n\nfunction EnableLogging() {\n it = console.info;\n step = console.success;\n}\n\nfunction DisableLogging() {\n it = function it(params) {\n return 0;\n };\n step = it;\n}\n\nfunction RunCustomTests() {\n // glob = require('glob');\n // it(process.cwd());\n // it(process.cwd() + customFilesPattern);\n // glob(customFilesPattern, (er,files)=>{\n // console.log('files count: ' + files.length);\n // files.forEach(file=>{\n // console.log(`custom test case files : ${file}`);\n // customFiles.push(file);\n // })\n // });\n // var path2 = process.cwd().replace(/\\\\/g, \"/\");\n // path = require('path');\n // glob(\"*.js\", (er,files)=>{\n // console.log('files count: ' + files.length);\n // files.forEach(file=>{\n // console.log(`custom test case files : ${file}`);\n // })\n // });\n // customFiles.forEach(file=>{\n // const filePath = process.cwd() + file;\n // console.info(filePath);\n // })\n}\nif (DEBUG) {\n EnableLogging();\n clock = function (start) {\n if (!start)\n return process.hrtime();\n var end = process.hrtime(start);\n return Math.round((end[0] * 1000) + (end[1] / 1000000));\n };\n} else {\n DisableLogging();\n}\n// prepares test data. to replace line input, assign arrays to lines variable.\nfunction prepareTestData() {\n // it(lines);\n // lines = ['custom line 1', 'custom line 2'];\n}\n// executes exactly once for both test and run. execution time will be included to elapsed time. \nconst prepareSolve = () => {};\n\nfunction power(x, y) {\n let ret = 1;\n while (y > 0) {\n if (y % 2) {\n ret *= x;\n ret %= P;\n }\n x *= x;\n x %= P;\n y /= 2;\n }\n return ret;\n}\n\nfunction createArray(lengths) {\n var arr = new Array(lengths || 0),\n i = lengths;\n if (arguments.length > 1) {\n var args = Array.prototype.slice.call(arguments, 1);\n while (i--)\n arr[lengths - 1 - i] = createArray.apply(this, args);\n }\n return arr;\n}\n\nfunction numericSortList(list) {\n list.sort((a, b) => a - b);\n}\n\nfunction getRectangleIntersection(r1, r2) {\n if (r1.x > r2.x + r2.w)\n return null;\n if (r1.x + r1.w < r2.x)\n return null;\n if (r1.y > r2.y + r2.h)\n return null;\n if (r1.y + r1.h < r2.y)\n return null;\n var rect = {};\n rect.x = Math.max(r1.x, r2.x);\n rect.y = Math.max(r1.y, r2.y);\n rect.w = Math.min(r1.x + r1.w, r2.x + r2.w) - rect.x;\n rect.h = Math.min(r1.y + r1.h, r2.y + r2.h) - rect.y;\n return rect;\n}\n\nfunction getRandomNumber(to, from) {\n if (from == undefined) {\n return Math.floor(Math.random() * to + 1);\n }\n return Math.floor(Math.random() * (to - from) + from);\n}\n/**\n * a queue that will be stop working someday.\n */\nclass TerminallyIllQueue {\n constructor() {\n this.data = {};\n this.head = 0;\n this.tail = 1;\n }\n length() {\n return this.tail - this.head - 1;\n }\n enqueue(v) {\n this.data[this.tail - 1] = v;\n this.tail++;\n }\n dequeue() {\n const v = this.data[this.head];\n this.head++;\n return v;\n }\n}\n/**\n * @template T\n * @type {TwoDimensionalMap}\n */\nclass TwoDimensionalMap {\n constructor() {\n this.data = {};\n }\n /**\n * @memberof TwoDimensionalMap\n * @public\n * @param {number} x\n * @param {number} y\n * @returns {T}\n */\n getPosition(x, y) {\n return this.data[`${x}.${y}`];\n }\n /**\n * @memberof TwoDimensionalMap\n * @public\n * @param {number} x\n * @param {number} y\n * @param {T} value\n */\n setPosition(x, y, value) {\n this.data[`${x}.${y}`] = value;\n }\n}\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ MAIN SOLVE FUNCTION ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\nfunction solve() {\n const [h1,m1] = readline().split(':').map(x=>+x);\n const [h2,m2] = readline().split(':').map(x=>+x);\n const mm1 = h1*60 + m1;\n const mm2 = h2*60 + m2;\n const avgm = (mm1+mm2)/2;\n let h = (avgm - avgm%60)/60;\n // h =(h1+h2)/2;\n if(h<10) h = '0'+h;\n let m = avgm%60;\n // m = (m1+m2)/2;\n if(m<10) m = '0'+m;\n print(`${h}:${m}`);\n}\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\nfunction resetRead() {\n lineCount = 0;\n}\n\nfunction checkMemoryUsage() {\n it(process.memoryUsage());\n}\n\nfunction readOne(separator = ' ') {\n if (lineOpen && readingLine != null) {\n // if(lineOpen){\n // it(readingLine);\n let splitPos = readingLine.search(separator);\n let ret = readingLine.slice(0, splitPos);\n if (splitPos == -1) {\n // it('close');\n ret = readingLine;\n readingLine = '';\n lineOpen = false;\n }\n readingLine = readingLine.substr(splitPos + 1);\n // it(ret, readingLine, splitPos);\n if (ret == '' || ret == separator) {\n return readOne(separator);\n } else {\n return ret;\n }\n } else {\n readingLine = readline();\n lineOpen = true;\n if (readingLine == null)\n return '';\n return readOne(separator);\n }\n}\n\nfunction ri() {\n return +readOne();\n}\n\nfunction ria() {\n return readInts();\n}\n/**\n * @return {string}\n */\nfunction rs() {\n return readOne();\n}\n/**\n * @return {string[]}\n */\nfunction rsa() {\n return readline().split(' ');\n}\n/**\n * @returns {number[]}\n */\nfunction readInts() {\n try {\n lineOpen = false;\n return readline()\n .split(\" \")\n .map(x => parseInt(x));\n } catch (error) {\n console.error(error);\n return null;\n }\n}\nlet inputListener;\nlet readlines;\nswitch (SITE) {\n case TEST:\n var fs = require(\"fs\");\n var path = require('path');\n // input = fs.createReadStream(path.resolve(__dirname, \"input.txt\"), {\n // encoding: \"utf8\"\n // });\n input = fs.createReadStream(INPUTFILEPATH, {\n encoding: \"utf8\"\n });\n inputListener = (line) => {\n console.log(line);\n if (line.startsWith('end')) {\n console.log('end');\n closing();\n }\n if (!line) {\n closing();\n }\n lineCount++;\n inputText += line + \"\\r\\n\";\n };\n readlines = () => {\n const readline = require(\"readline\");\n const rl = readline.createInterface({\n input,\n output: process.stdout,\n terminal: false\n });\n rl.on(\"line\", inputListener);\n rl.on('close', closing);\n };\n getlines = function* (inputText) {\n var lines = inputText.split(/\\r?\\n/);\n for (let line of lines) {\n yield line + newLine;\n }\n };\n readline = function (trim = true) {\n const lineval = lines.next().value;\n return trim ? lineval.trim() : lineval;\n };\n readlines();\n break;\n case CODEFORCES_NODE:\n input = process.stdin;\n inputListener = (line) => {\n if (!line) {\n closing();\n }\n lineCount++;\n inputText += line + \"\\r\\n\";\n };\n readlines = () => {\n const readline = require(\"readline\");\n const rl = readline.createInterface({\n input,\n output: process.stdout,\n terminal: false\n });\n rl.on(\"line\", inputListener);\n rl.on('close', closing);\n };\n getlines = function* (inputText) {\n var lines = inputText.split(/\\r?\\n/);\n for (let line of lines) {\n yield line + newLine;\n }\n };\n readline = function (trim = true) {\n const lineval = lines.next().value;\n return trim ? lineval.trim() : lineval;\n };\n readlines();\n break;\n case BEAKJOON:\n var fs = require('fs');\n if (DEBUG) {\n // input = fs.readFileSync('./input.txt').toString();\n inputText = fs.readFileSync(INPUTFILEPATH).toString();\n } else {\n inputText = fs.readFileSync('/dev/stdin').toString();\n }\n readline = function (trim = true) {\n lineCount++;\n let line = lines[lineCount - 1];\n if (line)\n return trim ? lines[lineCount - 1].trim() : lines[lineCount - 1];\n else\n return null;\n };\n getlines = function (inputText) {\n lineCount = 0;\n return inputText.split(/\\r?\\n/);\n };\n // lines = getlines(input);\n closing();\n break;\n case PROGRAMMERS:\n //자체 함수를 실행할 것이므로 아무것도 하지 않는다.\n default:\n break;\n}\n\nfunction closing() {\n if (DEBUG) {\n DisableLogging();\n const prepareClock = clock();\n lines = getlines(inputText);\n prepareSolve();\n const prepareClockElapsedTime = clock(prepareClock);\n EnableLogging();\n prepareTestData();\n solve();\n console.warn('done. running custom tests');\n RunCustomTests();\n resetRead();\n console.warn('performance check');\n DisableLogging();\n clockStart = clock();\n // lines = getlines(inputText);\n solve();\n console.warn(`${clock(clockStart) + prepareClockElapsedTime} ms`);\n EnableLogging();\n process.exit();\n } else {\n lines = getlines(inputText);\n prepareSolve();\n solve();\n process.exit();\n }\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "da4ceaca119b11a50f40caa4c8e53369", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\n\nconst runMain = () => {\n inputString = inputString.trim().split('\\n').map(string => string.trim());\n main();\n process.exit();\n}\nconst readLine = () => inputString[currentLine++];\n\nprocess.stdin.on('data', inputStdin => inputString += inputStdin);\nprocess.stdin.on('end', runMain);\nprocess.on('SIGINT', runMain);\n\nfunction main() {\n const [n, k] = readLine().split(' ');\n const arr = readLine().split(' ').map(num => Number(num));\n console.log(arr.filter(a => a > 0 && a >= arr[k - 1]).length);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "1c877fbf76ecdd6c7279f82a9c6645a9", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction main() {\n\tlet [a, b] = readLine()\n\t\t.split(' ')\n\t\t.map(x => parseInt(x));\n\tlet s = a;\n\tlet hours = 0;\n\n\twhile (Math.floor(a / b) > 0) {\n\t\thours += Math.floor(a / b);\n\t\ta = Math.floor(a / b) + (a % b);\n\t}\n\n\tconsole.log(Math.round(s + hours));\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3508bc01d71b526c23d0773de1e4c23a", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "(()=>{\"use strict\";var t={675:(t,e)=>{Object.defineProperty(e,\"__esModule\",{value:!0}),Array.numbersMatrix=(t,e,r)=>{let n=[];null==t&&(e=t),null==r&&(r=0);for(let i=0;it-e))},Array.prototype.sortDesc=function(){return this.sort(((t,e)=>e-t))},Array.prototype.max=function(){if(0==this.length)return 0;let t=this[0];for(let e=1;e{if(p){if(s=i.default.readFileSync(\"input.txt\").toString().trim().split(\"\\n\").map((t=>t.trim())),t(),i.default.writeFileSync(\"output.txt\",l),console.log(l),i.default.readFileSync(\"expected.txt\").toString().trim()==l.trim()){const{exec:t}=r(129);t(\"osascript -e 'display notification \\\"✅ AC!!\\\"'\")}}else process.stdin.resume(),process.stdin.setEncoding(\"utf-8\"),process.stdin.on(\"data\",(t=>{o+=t})),process.stdin.on(\"end\",(e=>{s=o.trim().split(\"\\n\").map((t=>t.trim())),t(),console.log(l)}))};function h(){return s[u++]}function f(){return h().split(\" \").map((t=>parseFloat(t)))}function c(){return h().split(\"\")}e.default={runMain:a,runEachTest:t=>{a((()=>{let[e]=f();for(;e>0;)t(),e--}))},readline:h,nextNumbers:f,nextBigNumbers:function(){return h().split(\" \").map((t=>BigInt(t)))},nextNumbersMatrix:function(t){let e=[];for(let r=0;r{t.exports=require(\"child_process\")},747:t=>{t.exports=require(\"fs\")}},e={};!function r(n){if(e[n])return e[n].exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}(965)})();\n\n// Solution written in typescript and compiled via webpack. Original source code below\n// Happy Hacking 😜\n\n\n// import './array'\n// \n// import io from './io'\n// \n// function main() {\n// let [n] = io.nextNumbers()\n// \n// let res = 0\n// \n// for (let i = 2; i < n; ++i) {\n// res += i * (i + 1)\n// }\n// \n// io.puts(res)\n// }\n// \n// // io.runEachTest(main)\n// io.runMain(main)", "lang_cluster": "Javascript", "tags": ["math", "greedy", "dp"], "code_uid": "cceb81ece2b21c36341249177eb2e3e8", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n let n = parseInt(readLine());\n let pagesInWeekDays = readLine().split(' ').map(Number);\n // while (result < 100) {\n // result = result +\n // }\n function recursion(totalpagesPerWeak) {\n // console.log(totalpagesPerWeak);\n // let [\n // monday,\n // tuseday,\n // wednessday,\n // thursday,\n // friday,\n // saturday,\n // sunday,\n // ] = pagesInWeekDays;\n\n for (let i = 0; i < pagesInWeekDays.length; i++) {\n totalpagesPerWeak = totalpagesPerWeak + pagesInWeekDays[i];\n if (totalpagesPerWeak >= n) {\n console.log(i + 1);\n return;\n }\n }\n if (!(totalpagesPerWeak >= n)) {\n // console.log(n);\n // console.log(totalpagesPerWeak);\n // totalpagesPerWeak = n - totalpagesPerWeak; // 1\n recursion(totalpagesPerWeak);\n }\n }\n recursion(0);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "633cd37f53d6c3dfbcc9b4b76949478e", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n B();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction pi(a) {\n return parseInt(a);\n}\n\nfunction ti(a){\n for(let i = 0; i < a.length; i++)\n a[i] = pi(a[i]);\n\n return a;\n}\n\nfunction A(){\n let t = pi(readline());\n while(t > 0){\n t--;\n let n = pi(readline());\n let ans = '';\n for(let i = 0; i < n; i++){\n ans += '1 ';\n }\n console.log(ans);\n }\n}\n\nfunction B(){\n let t = pi(readline());\n while(t > 0){\n t--;\n let n = pi(readline());\n\n if(n%2===0){\n console.log(n/2, n/2);\n continue;\n }\n\n let sq = Math.floor(Math.sqrt(n));\n let min = 999999999999999;\n let minPair = [];\n for(let i = 1; i <= sq; i++){\n if(n % i === 0){\n let j = n/i;\n let x = n-i;\n let y = n-j;\n\n if(x % i === 0){\n if(min > Math.max(x,i)){\n min = Math.max(x,i);\n minPair = [i,x]\n }\n }\n\n if(y % j === 0){\n if(min > Math.max(j,y)){\n min = Math.max(j,y);\n minPair = [j,y]\n }\n }\n }\n }\n console.log(minPair[0], minPair[1]);\n }\n}\n\nfunction C(){\n let t = pi(readline());\n while(t > 0){\n t--;\n let n = pi(readline());\n let a = ti(readline().split(' '));\n let map = new Array(600000);\n\n let b = JSON.parse(JSON.stringify(a));\n b.sort((a,b) => a-b);\n for(let i = 0; i < n; i++)\n map[b[i]] = i;\n\n let preCount = 0;\n let count = 0;\n let flag = false;\n for(let i = 0; i < n; i++){\n if(i === map[a[i]]){\n if(preCount === 1){\n if(!flag)\n count += 1;\n flag = true;\n }else if(preCount !== 0){\n count += 1;\n preCount = 0;\n }\n }else{\n preCount += 1;\n flag = false;\n }\n }\n console.log(count);\n }\n}\n", "lang_cluster": "Javascript", "tags": ["math", "greedy", "number theory"], "code_uid": "30f36c9a7e5c4431e147401189fa012b", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nrl.on('line', (line) => {\n var [n,m,a]=line.split(' ');\n var ans=Math.ceil(n/a)*Math.ceil(m/a);\n console.log(ans);\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "4a335b196fb0cafde4b1fa7320b21770", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.question('', (answer) => {\n // TODO: Log the answer in a database\n let vals = answer.split(\" \");\n if(Math.log(vals[0])/vals[0] === Math.log(vals[1])/vals[1]){\n console.log(\"=\");\n }else if(Math.log(vals[0])/vals[0] > Math.log(vals[1])/vals[1]){\n console.log(\">\");\n }else {\n console.log(\"<\");\n }\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "2084455db7b665343b804b8aa99446bb", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var n;\n\nvar readline = require('readline');\n\nconst myInterface = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n });\n\n\nmyInterface.on('line', function (line) {\n n = parseInt(line);\n}).on('close', () => {\n main();\n process.exit(0);\n})\n\nfunction main() {\n\n \n if(kt()==1)\n console.log(\"YES\");\n\t\telse\n console.log(\"NO\");\n }\n \n function kt(){\n for(var i=2; i {\n\tinputString += inputStd;\n});\nprocess.stdin.on('end', _ => {\n\tinputString = inputString.trim().split('\\n').map( str => {\n\t\treturn str.trim();\n\t});\n\tmain();\n});\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\nfunction main() {\n\tconst n = +(readLine());\n\tconst res = (n / 5) + ((n % 5) === 0 ? 0 : 1);\n\tconsole.log(parseInt(res));\n}\n\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "e7b1fe393e69a9978eccfb8b1afc75ae", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Insomnia cure\n\nconst {EOL} = require('os');\n\nlet inp = '';\n\nprocess.stdin.on('data', c => inp += c);\n\nprocess.stdin.on('end', () => {\n let lines = inp.split(EOL).map(c => +c);\n \n let gcd = (a, b) => {\n \tif(b == 0) {\n \t\treturn a;\n \t}\n \treturn gcd(b, a % b);\n };\n\n let lcm = (a, b) => (a * b) / gcd(a, b);\n\n let thr = lines.slice(0, 4);\n\n let flg = true;\n for(let i in thr) {\n if(thr[i] <= lines[4]) {\n flg = false;\n break;\n }\n }\n if(flg) {\n process.stdout.write('0');\n return;\n }\n\n let thrx = [];\n\n for(let i = 0; i < thr.length; i++) {\n \tlet addflg = true;\n \tfor(let j = 0; j < thrx.length; j++) {\n \t\tif(thr[i] % thrx[j] == 0) {\n \t\t\taddflg = false;\n \t\t\tbreak;\n \t\t}\n \t\tif(thrx[j] % thr[i] == 0) {\n \t\t\tthrx[j] = thr[i];\n \t\t\taddflg = true;\n \t\t\tbreak;\n \t\t}\n \t}\n\t\tif(addflg) {\n\t\t\tthrx.push(thr[i]);\n\t\t}\n }\n\n let thrf = [thrx, [], [], []];\n for(let i = 0; i < thrx.length; i++) {\n \tfor(let j = i + 1; j < thrx.length; j++) {\n \t\tlet l1 = lcm(thrx[i], thrx[j]);\n \t\tfor(let k = j + 1; k < thrx.length; k++) {\n \t\t\tlet l2 = lcm(l1, thrx[k]);\n \t\t\tfor(let l = k + 1; l < thrx.length; l++) {\n \t\t\t\tthrf[3].push(lcm(l2, thrx[l]));\n \t\t\t}\n \t\t\tthrf[2].push(l2);\n \t\t}\n \t\tthrf[1].push(l1);\n \t}\n }\n\n let calc = (i) => Math.floor(lines[4] / i);\n\n let res = 0;\n\n for(let i = 0; i < thrf.length; i++) {\n \tlet sum = 0;\n \tfor(let j in thrf[i]) {\n \t\tsum += calc(thrf[i][j]);\n \t}\n \tres += (1 - ((i % 2) * 2)) * sum;\n }\n\n process.stdout.write(res + '');\n\n return;\n});", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "b01a613d4668faae25c7a5e5362a695b", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nrl.on('line', n => {\n let [participants, pens, notebooks] = n.split(' ').map(number => Number(number));\n participants <= pens && participants <= notebooks ? console.log('Yes') : console.log('No');\n return rl.close();\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "68a4c33d0f014be09869351c12139dd9", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const rl = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\n\nfunction solve(n) {\n marked = new Array(n+1, false);\n count = 0;\n for(i = 1; i*i <= n; ++i) { \n if(i*i*i <= n) {\n marked[i*i*i] = true;\n count++;\n }\n if(!marked[i*i]) {\n count++;\n }\n }\n return count; \n}\n\nrl.once('line', (_) => { \n \n rl.on('line', (txt) => {\n // console.log(txt);\n\n console.log(solve(parseInt(txt)));\n });\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "f3f02ee40dc36a52bc100de39a87f192", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet input = '';\nprocess.stdin.on('data', (line) => {\n input += line;\n});\nprocess.stdin.on('end', () => {\n const lines = input.split('\\n');\n const k = BigInt(lines.shift());\n const occur = Array(10).fill(1n);\n let count = 1n;\n let index = 0;\n while (count < k) {\n count /= occur[index];\n occur[index]++;\n count *= occur[index];\n index++;\n if (index === 10) {\n index = 0;\n }\n }\n const word = \"codeforces\";\n const ans = occur\n .map((value, index) => word[index].repeat(Number(value)))\n .join('');\n console.log(ans);\n});\n// input helper\nfunction lineToNumArray(line) {\n return line.split(' ').map(element => parseInt(element, 10));\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "constructive algorithms", "math", "greedy", "strings"], "code_uid": "433821f3537f150a8f291f7f18230af7", "src_uid": "8001a7570766cadcc538217e941b3031", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Stones on the Table\n\nconst {EOL} = require('os');\n\nlet inp = '';\n\nprocess.stdin.on('data', c => inp += c);\n\nprocess.stdin.on('end', () => {\n let lines = inp.split(EOL);\n \n let n = +lines.shift();\n\n let s = lines[0], dup = 0;\n for(let i = 0; i < s.length - 1; i++) {\n \tif(s[i] == s[i + 1]) {\n \t\tdup++;\n \t}\n }\n\n process.stdout.write(dup + '');\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "d34ed0158b91c1b86b494d6e34d53de3", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n let year = +readLine();\n\n while (year++) {\n const map = `${year}`.split(\"\").reduce((obj, n) => {\n if (!obj[n]) obj[n] = 1;\n else obj[n]++;\n return obj;\n }, {});\n const values = Object.values(map);\n let unique = true;\n for (let i = 0; i < values.length; i++) {\n if (values[i] > 1) unique = false;\n }\n if (unique) {\n console.log(year);\n return;\n }\n }\n}\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "2da225d3c9e099c3eec5d7440065cea3", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n const word = input[1].toLowerCase();\n const letters = new Set();\n if (word.length < 26) { console.log('NO'); return; }\n for (let i = 0; i < word.length; i += 1) \n letters.add(word[i]);\n\n if (letters.size === 26) console.log('YES');\n else console.log('NO');\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "adf33d69dc1fc49b3eb7321c44abc025", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet limak = 0;\nlet bob = 0;\nlet years = 0;\nrl.on(\"line\",(input)=>{\n const array = input.split(\" \").map(Number);\n\n limak = array[0];\n bob = array[1];\n while(limak<=bob){\n bob*=2\n limak*=3\n years++\n }\n console.log(years)\n rl.close();\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "5c053ccec80e1eb197ab96ab3ded3be6", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nlet readline = require('readline');\nlet rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n});\n \nrl.on('line', function(line) {\n\tchatRoom(line);\n\trl.close();\n});\n \n//M N\nlet chatRoom = (input) => {\n\t//hello\n\tlet word = [ 'h', 'e', 'l', 'l', 'o' ];\n\tlet count = 0;\n\tfor (let i = 0; i < input.length; i++) {\n\t\tif (input.charAt(i) === word[count]) {\n\t\t\tcount++;\n\t\t}\n\t}\n\tcount === 5 ? console.log('YES') : console.log('NO');\n};", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "43c6a2b80ca3318ba7c2e178eecf03e9", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\nlet input = []\n\nrl.on('line', line => {\n input = line.split(' ').map(x => parseInt(x))\n const output = solution(...input)\n console.log(output)\n})\n\nrl.on('close', () => {\n // console.log(input)\n})\n\nfunction solution(num, times) {\n let numStr = num.toString()\n for (let i=0; i {\n return inp.includes('1');\n }).split(' ').findIndex((str) => {\n return str === '1';\n }),\n input.findIndex((inp) => {\n return inp.includes('1');\n })\n ];\n};\n\nmainAux = function() {\n var input;\n input = [];\n input.push(readline());\n input.push(readline());\n input.push(readline());\n input.push(readline());\n input.push(readline());\n return print(sum(find(input).map(function(v) {\n return Math.abs(2 - v);\n })));\n};\n\n\n function main() {\n return mainAux();\n }\n;\n\n//# sourceMappingURL=matrix.js.map\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "638c91191abe5a3bb34c3b72b0270b94", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function giaiBai(data) {\n let temp = 0\n for(var i = 0; i < data.length; i++) {\n let count = 0\n if(i === 0) {\n count = Math.abs(data.charCodeAt(0) - 97)\n } else {\n count = Math.abs(data.charCodeAt(i) - data.charCodeAt(i - 1))\n }\n if (count > 13) {\n count = 26 - count\n }\n temp = temp + count\n }\n console.log(temp)\n}\n\n// Get process.stdin as the standard input object.\nvar standard_input = process.stdin;\n\n// Set input character encoding.\nstandard_input.setEncoding('utf-8');\n\n// Prompt user to input data in console.\n// console.log(\"Please input text in command line.\");\n\n// When user input data and click enter key.\nstandard_input.on('data', function (data) {\n\n // User input exit.\n if(data === 'exit\\n'){\n // Program exit.\n console.log(\"User input complete, program exit.\");\n process.exit();\n }else\n {\n // Print user input in console.\n data = data.trim()\n giaiBai(data)\n process.exit();\n }\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "a691f75a70adc4a57cf751810336ce4b", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar input = [];\nrl.on('line', function (line) {input.push(line);});\nrl.on('close', function() {\n const [n, t] = input[0].split(' '); \n var a = input[1].split('');\n \n for (let j = 0; j < t; j++) {\n for (let i = 0; i < a.length; i= i + 1) {\n if (a[i] === 'B' && a[i+1] === 'G') {\n let temp = a[i];\n a[i] = a[i+1];\n a[i+1] = temp;\n i++;\n }\n }\n }\n //GBGGB\n console.log(a.join(''));\n});", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "e9cccece206c4b8e7287a34573ed2826", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n↑入力 ↓出力');\n Main();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var one = nextIntArray();\n var H = one[0];\n var W = one[1];\n var output = 0;\n var list = new Array(H);\n for(var i = 0; i < H; i++){\n list[i] = nextCharArray();\n }\n for(var i = 0; i < H; i++){\n var isOK = true;\n for(var j = 0; j < W; j++){\n if(list[i][j] == \"S\"){\n isOK = false;\n }\n }\n if(isOK){\n for(var j = 0; j < W; j++){\n list[i][j] = \"X\";\n output++;\n }\n }\n }\n for(var i = 0; i < W; i++){\n var isOK = true;\n for(var j = 0; j < H; j++){\n if(list[j][i] == \"S\"){\n isOK = false;\n }\n }\n if(isOK){\n for(var j = 0; j < H; j++){\n if(list[j][i] == \".\"){\n output++;\n }\n }\n }\n }\n myout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "c490ccd55ae395cfac8db43e1229524a", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n\tinput: process.stdin,\n\t//output: process.stdout,\n\tterminal: false\n});\n\nrl\n .on('line', function(line){\n console.log(main(line));\n rl.close();\n })\n .on('close', () => {\n \n })\n \nconst main = (n) => {\n const denominations = [100,20,10,5,1];\n let count = 0;\n denominations.forEach((denom) => {\n while (n >= denom) {\n n -= denom;\n count++;\n }\n })\n return count;\n}\n", "lang_cluster": "Javascript", "tags": ["greedy", "dp"], "code_uid": "f038d2026a6e11b9f6d18d2e863357d2", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction readAsInt(){\n return parseInt(readline());\n}\n\nfunction readAsIntList(){\n return readline().split(' ').filter(i => i).map(i => parseInt(i));\n}\n\n\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n const [n, k] = readAsIntList();\n const list = readAsIntList().filter(x => x > 0);\n console.log(list.slice(k).filter(x => x === list[k-1]).length + list.slice(0, k).length);\n}\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3e747d6c5f928f3bd3f61f85e0368d06", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\r\nprocess.stdin.setEncoding(\"utf-8\");\r\nvar arr = \"\";\r\nprocess.stdin.on(\"data\", function (chunk) {\r\n arr += chunk;\r\n});\r\n\r\nprocess.stdin.on(\"end\", function () {\r\n arr = arr.split(\"\\n\");\r\n const testcases = parseInt(arr.shift());\r\n\r\n for (let t = 0; t < 2 * testcases; ) {\r\n const [a, b] = arr[t++].split(\" \").map((el) => parseInt(el));\r\n const [c, d] = arr[t++].split(\" \").map((el) => parseInt(el));\r\n\r\n let count = 0;\r\n\r\n if (a === 1) count++;\r\n if (b === 1) count++;\r\n if (c === 1) count++;\r\n if (d === 1) count++;\r\n\r\n if (count === 0) console.log(0);\r\n else if (count === 1) console.log(1);\r\n else if (count === 2) console.log(1);\r\n else if (count === 3) console.log(1);\r\n else if (count === 4) console.log(2);\r\n }\r\n});\r\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "90601b37b0859bf98a5a11f15d906fe5", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n let data = input[0].split(' ');\n let s = parseInt(data[0]);\n let v1 = parseInt(data[1]);\n let v2 = parseInt(data[2]);\n let t1 = parseInt(data[3]);\n let t2 = parseInt(data[4]);\n\n let first = (v1*s)+(t1*2);\n let second = (v2*s)+(t2*2);\n\n if(first > second)\n console.log('Second');\n else if(second > first)\n console.log('First');\n else \n console.log('Friendship');\n});\n\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "7bcace5864ae0f1ea9bc49d1d715fe24", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\n\nconst runMain = () => {\n inputString = inputString.trim().split('\\n').map(string => string.trim());\n main();\n process.exit();\n}\nconst readLine = () => inputString[currentLine++];\n\nprocess.stdin.on('data', inputStdin => inputString += inputStdin);\nprocess.stdin.on('end', runMain);\nprocess.on('SIGINT', runMain);\n\nfunction main() {\n let s = readLine().split('');\n let n = 0;\n s.forEach(el => {\n if (el === '4' || el === '7') {\n n++;\n }\n });\n console.log(n === 4 || n === 7 ? 'YES' : 'NO');\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "a465f6d4ed415ef80b4229fac0d03f0e", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nconst readLine=()=> inputString[currentLine++];\n/* ================================================ \n Main Solution Starts Here \n===================================================*/\n\nconst main=()=>{\n\tlet newNumber=''\n\tlet firstNumber = readLine()\n\tlet secondNummber = readLine()\n\tlet length = firstNumber.length\n\tfor(let i=0;i input.push(line));\n\nreadLine.on('close', () => {\n const a = parseInt(input[0]);\n const b = parseInt(input[1]);\n const c = parseInt(input[2]);\n\n let max = a + b + c;\n if (a * b * c > max) max = a * b * c;\n if ( (a + b) * c > max) max = (a + b) * c;\n if ( a * (b + c) > max) max = a * (b + c);\n\n console.log(max);\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "e2d39c7bdd886b255c6208c691349d2a", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nconst readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n// single line input\nreadline.on('line', line => {\n readline.close();\n const arr = line.split(' ').map(Number);\n let n = arr[0];\n let k = arr[1];\n while (k--) {\n const rem = n % 10;\n if (rem != 0) { \n --n; \n } else {\n n /= 10;\n }\n }\n console.log(n);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3699ffc7f12c755e0ee9b6a64bbb6ac9", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function _defineProperties(t,e){for(var r=0;rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}var fs=require(\"fs\"),configPath=\"./compe.config.json\";function proc(t,e){if(global.MOD_=998244353,global.MOD_CUT=444595123,fs.existsSync(configPath)){if(!fs.existsSync(e))return void console.log(\"Input directory does not exist\");var r=fs.readFileSync(e,{encoding:\"utf-8\"}),n=0;r=r.split(/ |\\n|\\r/g);for(var i,o=[],s=_createForOfIteratorHelperLoose(r);!(i=s()).done;){var a=i.value;a.length>0&&o.push(a)}global.rnum=function(t){return t?o.slice(n,n+=t).map((function(t){return+t})):+o[n++]},global.rstr=function(t){return t?o.slice(n,n+=t):o[n++]},global.rbig=function(t){return t?o.slice(n,n+=t).map((function(t){return BigInt(t)})):BigInt(o[n++])},global.print=function(){for(var t=arguments.length,e=new Array(t),r=0;r0&&n.push(o)}global.rnum=function(t){return t?n.slice(e,e+=t).map((function(t){return+t})):+n[e++]},global.rstr=function(t){return t?n.slice(e,e+=t):n[e++]},global.rbig=function(t){return t?n.slice(e,e+=t).map((function(t){return BigInt(t)})):BigInt(n[e++])};var s=\"\";global.print=function(){for(var t=arguments.length,e=new Array(t),r=0;rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}Object.defineProperty(exports,\"__esModule\",{value:!0});var ErrorGenerator,ForOfAdaptor=function(t){function e(t,e){this.it_=t,this.last_=e}var r=e.prototype;return r.next=function(){if(this.it_.equals(this.last_))return{done:!0,value:void 0};var t=this.it_;return this.it_=this.it_.next(),{done:!1,value:t.value}},r[t]=function(){return this},e}(Symbol.iterator),Container=function(t){function e(){}var r=e.prototype;return r.empty=function(){return 0===this.size()},r.rbegin=function(){return this.end().reverse()},r.rend=function(){return this.begin().reverse()},r[t]=function(){return new ForOfAdaptor(this.begin(),this.end())},r.toJSON=function(){for(var t,e=[],r=_createForOfIteratorHelperLoose$1(this);!(t=r()).done;){var n=t.value;e.push(n)}return e},e}(Symbol.iterator),NativeArrayIterator=function(){function t(t,e){this.data_=t,this.index_=e}var e=t.prototype;return e.index=function(){return this.index_},e.prev=function(){return--this.index_,this},e.next=function(){return++this.index_,this},e.advance=function(t){return this.index_+=t,this},e.equals=function(t){return this.data_===t.data_&&this.index_===t.index_},e.swap=function(t){var e=[t.data_,this.data_];this.data_=e[0],t.data_=e[1];var r=[t.index_,this.index_];this.index_=r[0],t.index_=r[1]},_createClass$1(t,[{key:\"value\",get:function(){return this.data_[this.index_]}}]),t}(),SetContainer=function(t){function e(e){var r;return(r=t.call(this)||this).data_=e(_assertThisInitialized(r)),r}_inheritsLoose$1(e,t);var r=e.prototype;return r.assign=function(t,e){this.clear(),this.insert(t,e)},r.clear=function(){this.data_.clear()},r.begin=function(){return this.data_.begin()},r.end=function(){return this.data_.end()},r.has=function(t){return!this.find(t).equals(this.end())},r.size=function(){return this.data_.size()},r.push=function(){for(var t=arguments.length,e=new Array(t),r=0;r (index = \"+n+\").\")},t.excessive_index=function(t,r,n,i){return new OutOfRange(\"Error on \"+e(t)+\".\"+r+\"(): parametric index is equal or greater than size -> (index = \"+n+\", size: \"+i+\").\")},t.not_my_iterator=function(t,r){return new InvalidArgument(\"Error on \"+e(t)+\".\"+r+\"(): parametric iterator is not this container's own.\")},t.erased_iterator=function(t,r){return new InvalidArgument(\"Error on \"+e(t)+\".\"+r+\"(): parametric iterator, it already has been erased.\")},t.negative_iterator=function(t,r,n){return new OutOfRange(\"Error on \"+e(t)+\".\"+r+\"(): parametric iterator is directing negative position -> (index = \"+n+\").\")},t.iterator_end_value=function(t,r){void 0===r&&(r=\"end\");var n=e(t);return new OutOfRange(\"Error on \"+n+\".Iterator.value: cannot access to the \"+n+\".\"+r+\"().value.\")},t.key_nout_found=function(t,r,n){throw new OutOfRange(\"Error on \"+e(t)+\".\"+r+\"(): unable to find the matched key -> \"+n)}}(ErrorGenerator||(ErrorGenerator={}));var IAssociativeContainer,UniqueSet=function(t){function e(){return t.apply(this,arguments)||this}_inheritsLoose$1(e,t);var r=e.prototype;return r.count=function(t){return this.find(t).equals(this.end())?0:1},r.insert=function(){for(var e,r=arguments.length,n=new Array(r),i=0;i1?e-1:0),n=1;n=1&&r[0]instanceof Array?(i=function(){var e=r[0];t.push.apply(t,e)},o=r.slice(1)):r.length>=2&&r[0].next instanceof Function&&r[1].next instanceof Function?(i=function(){var e=r[0],n=r[1];t.assign(e,n)},o=r.slice(2)):(i=null,o=r),{ramda:i,tail:o}}}(IAssociativeContainer||(IAssociativeContainer={}));var is_node_=null;function is_node(){return null===is_node_&&(is_node_=\"object\"==typeof global&&\"object\"==typeof global.process&&\"object\"==typeof global.process.versions&&void 0!==global.process.versions.node),is_node_}function _Get_root(){return null===__s_pRoot&&void 0===(__s_pRoot=is_node()?global:self).__s_iUID&&(__s_pRoot.__s_iUID=0),__s_pRoot}var ITreeContainer,__s_pRoot=null;function get_uid(t){if(t instanceof Object){if(!1===t.hasOwnProperty(\"__get_m_iUID\")){var e=++_Get_root().__s_iUID;Object.defineProperty(t,\"__get_m_iUID\",{value:function(){return e}})}return t.__get_m_iUID()}return void 0===t?-1:0}function equal_to(t,e){return t=t?t.valueOf():t,e=e?e.valueOf():e,t instanceof Object&&t.equals instanceof Function?t.equals(e):t===e}function less(t,e){return t=t.valueOf(),e=e.valueOf(),t instanceof Object?t.less instanceof Function?t.less(e):get_uid(t)3?o-3:0),a=3;a=1&&(i=h.tail[0])}r(i),null!==n&&n()},t.emplacable=function(t,e,r){var n=e.prev(),i=n.equals(t.end())||t.value_comp()(n.value,r);return i=i&&(e.equals(t.end())||t.value_comp()(r,e.value))}}(ITreeContainer||(ITreeContainer={}));var INIT_VALUE=2166136261,MULTIPLIER=16777619,Pair=function(){function t(t,e){this.first=t,this.second=e}var e=t.prototype;return e.equals=function(t){return equal_to(this.first,t.first)&&equal_to(this.second,t.second)},e.less=function(t){return!1===equal_to(this.first,t.first)?less(this.first,t.first):less(this.second,t.second)},e.hashCode=function(){return hash(this.first,this.second)},t}(),UniqueTreeSet=function(t){function e(){return t.apply(this,arguments)||this}_inheritsLoose$1(e,t);var r=e.prototype;return r.find=function(t){var e=this.lower_bound(t);return!e.equals(this.end())&&this._Key_eq(t,e.value)?e:this.end()},r.equal_range=function(t){var e=this.lower_bound(t);return new Pair(e,!e.equals(this.end())&&this._Key_eq(t,e.value)?e.next():e)},r.value_comp=function(){return this.key_comp()},r._Key_eq=function(t,e){return!this.key_comp()(t,e)&&!this.key_comp()(e,t)},r._Insert_by_key=function(t){var e=this.lower_bound(t);return!e.equals(this.end())&&this._Key_eq(e.value,t)?new Pair(e,!1):(e=this.data_.insert(e,t),this._Handle_insert(e,e.next()),new Pair(e,!0))},r._Insert_by_hint=function(t,e){if(ITreeContainer.emplacable(this,t,e)){var r=this.data_.insert(t,e);return this._Handle_insert(r,r.next()),r}return this._Insert_by_key(e).first},e}(UniqueSet),ListIterator=function(){function t(t,e,r){this.prev_=t,this.next_=e,this.value_=r}t._Set_prev=function(t,e){t.prev_=e},t._Set_next=function(t,e){t.next_=e};var e=t.prototype;return e.prev=function(){return this.prev_},e.next=function(){return this.next_},e._Try_value=function(){if(void 0===this.value_&&!0===this.equals(this.source().end()))throw ErrorGenerator.iterator_end_value(this.source())},e.equals=function(t){return this===t},_createClass$1(t,[{key:\"value\",get:function(){return this._Try_value(),this.value_}}]),t}(),Repeater=function(){function t(t,e){this.index_=t,this.value_=e}var e=t.prototype;return e.index=function(){return this.index_},e.next=function(){return++this.index_,this},e.equals=function(t){return this.index_===t.index_},_createClass$1(t,[{key:\"value\",get:function(){return this.value_}}]),t}();function advance(t,e){if(0===e)return t;if(t.advance instanceof Function)return t.advance(e);var r;if(e<0){if(!(t.prev instanceof Function))throw new InvalidArgument(\"Error on std.advance(): parametric iterator is not a bi-directional iterator, thus advancing to negative direction is not possible.\");r=function(t){return t.prev()},e=-e}else r=function(t){return t.next()};for(;e-- >0;)t=r(t);return t}var ListContainer=function(t){function e(){var e;return(e=t.call(this)||this).end_=e._Create_iterator(null,null),e.clear(),e}_inheritsLoose$1(e,t);var r=e.prototype;return r.assign=function(t,e){this.clear(),this.insert(this.end(),t,e)},r.clear=function(){ListIterator._Set_prev(this.end_,this.end_),ListIterator._Set_next(this.end_,this.end_),this.begin_=this.end_,this.size_=0},r.resize=function(t){var e=t-this.size();e>0?this.insert(this.end(),e,void 0):e<0&&this.erase(advance(this.end(),-e),this.end())},r.begin=function(){return this.begin_},r.end=function(){return this.end_},r.size=function(){return this.size_},r.push_front=function(t){this.insert(this.begin_,t)},r.push_back=function(t){this.insert(this.end_,t)},r.pop_front=function(){if(!0===this.empty())throw ErrorGenerator.empty(this.end_.source().constructor.name,\"pop_front\");this.erase(this.begin_)},r.pop_back=function(){if(!0===this.empty())throw ErrorGenerator.empty(this.end_.source().constructor.name,\"pop_back\");this.erase(this.end_.prev())},r.push=function(){for(var t=arguments.length,e=new Array(t),r=0;r=0;--o){var s=this.tryEntries[o],a=s.completion;if(\"root\"===s.tryLoc)return i(\"end\");if(s.tryLoc<=this.prev){var u=n.call(s,\"catchLoc\"),h=n.call(s,\"finallyLoc\");if(u&&h){if(this.prev=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,\"finallyLoc\")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if(\"throw\"===n.type){var i=n.arg;k(r)}return i}}throw new Error(\"illegal catch attempt\")},delegateYield:function(t,r,n){return this.delegate={iterator:z(t),resultName:r,nextLoc:n},\"next\"===this.method&&(this.arg=e),v}},t}(t.exports);try{regeneratorRuntime=e}catch(t){\"object\"==typeof globalThis?globalThis.regeneratorRuntime=e:Function(\"r\",\"regeneratorRuntime = r\")(e)}})),Deque=function(t){function e(t){this.head=0,this.tail=0,this.mask=1,this.list=new Array(2),t&&this.extend(t)}var r=e.prototype;return r.extend=function(t){for(var e,r=_createForOfIteratorHelperLoose(t);!(e=r()).done;){var n=e.value;this.push(n)}return this},r.extendFront=function(t){for(var e,r=_createForOfIteratorHelperLoose(t);!(e=r()).done;){var n=e.value;this.pushFront(n)}return this},r._resize=function(t,e){var r=this.head,n=this.mask;if(this.head=0,this.tail=t,this.mask=e-1,0!==r){for(var i=new Array(e),o=0;o=r||t<-r)throw new RangeError(\"deque index out of range\");return i[(t>=0?e:n)+t&this.mask]},r.indexOf=function(t,e){void 0===e&&(e=0);for(var r=this.head,n=this.list,i=this.size,o=this.mask,s=e>=0?e:e<-i?0:i+e;s>>1&&this._resize(this.size,this.list.length>>>1),t},r.popFront=function(){if(this.head===this.tail)throw new RangeError(\"pop from an empty deque\");var t=this.list[this.head];return this.list[this.head]=void 0,this.head=this.head+1&this.mask,this.size>>1&&this._resize(this.size,this.list.length>>>1),t},r.delete=function(t){if(t>=this.size||t<0)throw new RangeError(\"deque index out of range\");for(var e=this.head+t&this.mask;e!==this.tail;){var r=e+1&this.mask;this.list[e]=this.list[r],e=r}return this.tail=this.tail-1&this.mask,this.size>>1&&this._resize(this.size,this.list.length>>>1),this},r.reverse=function(){for(var t=this.head,e=this.tail,r=this.size,n=this.mask,i=0;i<~~(r/2);i++){var o=e-i-1&n,s=t+i&n,a=this.list[o];this.list[o]=this.list[s],this.list[s]=a}return this},r.rotate=function(t){void 0===t&&(t=1);var e=this.head,r=this.tail;if(0===t||e===r)return this;if(this.head=e-t&this.mask,this.tail=r-t&this.mask,t>0)for(var n=1;n<=t;n++){var i=e-n&this.mask,o=r-n&this.mask;this.list[i]=this.list[o],this.list[o]=void 0}else for(var s=0;s>t;s--){var a=r-s&this.mask,u=e-s&this.mask;this.list[a]=this.list[u],this.list[u]=void 0}return this},r.entries=runtime_1.mark((function t(){var e,r,n,i,o;return runtime_1.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=this.head,r=this.size,n=this.list,i=this.mask,o=0;case 2:if(!(o=1){var e;if(\"object\"==typeof t)throw new Error(\"The value can not be object\");var r=[t,[]],n=0,i=1;r[0]=new Array((e=(arguments.length<=1?0:arguments.length-1)-1+1)<1||arguments.length<=e?void 0:arguments[e]);for(var o=0;o=0;s--){if(!Number.isInteger(s+1<1||arguments.length<=s+1?void 0:arguments[s+1]))throw new Error(\"Please pass integer arguments for array size\");r[i]=new Array(s+1<1||arguments.length<=s+1?void 0:arguments[s+1]);for(var a=0;a<(s+1<1||arguments.length<=s+1?void 0:arguments[s+1]);a++)r[i][a]=r[n].slice();var u=[i,n];n=u[0],i=u[1]}return r[n]}},vectorArray=function(t){for(var e=new Array(t),r=0;rthis.p[e]){var r=[e,t];t=r[0],e=r[1]}return this.p[t]+=this.p[e],this.p[e]=t,!0},e.size=function(t){return t=this.group(t),-this.p[t]},t}(),PriorityQueue=function(){function t(t){this.comparator=t||function(t,e){return t0&&(r=e>>1,!this.comparator(this.elem[e],this.elem[r]));)this.swap(e,r),e=r},e.pop=function(){var t=this.top,e=this.elem.pop(),r=this.size;if(0==r)return t;this.elem[0]=e;for(var n=0,i=0,o=0,s=0;n=0;t=(t&t+1)-1)e=this.updateMethod(e,this.cont[t]);return e},e.update=function(t,e){for(;t<=this.elemCount;t|=t+1)this.cont[t]=this.updateMethod(this.cont[t],e)},t}(),SegmentTree=function(){function t(t,e,r,n){if(void 0===n&&(n=null),this.identityValue=e,this.merger=r,this.elemCount=t,this.log=Math.ceil(Math.log2(t)),this.size=1<=1;o--)this.internalUpdate(o)}}var e=t.prototype;return e.internalUpdate=function(t){this.cont[t]=this.merger(this.cont[t<<1],this.cont[t<<1|1])},e.set=function(t,e){t+=this.size,this.cont[t]=e;for(var r=1;r<=this.log;r++)this.internalUpdate(t>>r)},e.get=function(t){return t?this.cont[t+this.size]:this.cont.slice(this.size,this.size+this.elemCount)},e.query=function(t,e){void 0===t&&(t=0),void 0===e&&(e=this.elemCount-1),e++;var r=this.identityValue,n=this.identityValue;for(t+=this.size,e+=this.size;t>=1,e>>=1;return this.merger(r,n)},e.all=function(){return this.cont[1]},t}(),LazySegmentTree=function(){function t(t,e,r,n,i,o,s){if(void 0===s&&(s=null),this.identityValue=e,this.merger=r,this.identityLazy=n,this.pusher=i,this.modifier=o,this.log=Math.ceil(Math.log2(t)),this.size=1<=1;u--)this.internalUpdate(u)}}var e=t.prototype;return e.internalUpdate=function(t){this.cont[t]=this.merger(this.cont[t<<1],this.cont[t<<1|1])},e.internalModify=function(t,e){e!==this.identityLazy&&(this.cont[t]=this.modifier(this.cont[t],e),t=1;r--)this.internalPush(t>>r);this.cont[t]=e;for(var n=1;n<=this.log;n++)this.internalUpdate(t>>n)},e.get=function(t){t+=this.size;for(var e=this.log;e>=1;e--)this.internalPush(t>>e);return this.cont[t]},e.query=function(t,e){e++,t+=this.size,e+=this.size;for(var r=this.log;r>=1;r--)t>>r<>r),e>>r<>r);for(var n=this.identityValue,i=this.identityValue;t>=1,e>>=1;return this.merger(n,i)},e.all=function(){return this.cont[1]},e.update=function(t,e,r){e++,t+=this.size,e+=this.size;for(var n=this.log;n>=1;n--)t>>n<>n),e>>n<>n);for(var i=t,o=e;t>=1,e>>=1;t=i,e=o;for(var s=1;s<=this.log;s++)t>>s<>s),e>>s<>s)},t}(),defaultComparator=function(t,e){return t>>1)],e)?r=o+1:n=o;return r},upperBound=function(t,e,r,n,i){var o;for(void 0===r&&(r=0),void 0===n&&(n=0),void 0===i&&(i=defaultComparator),n||(n=t.length);r>>1)])?n=o:r=o+1;return r},binarySearch=function(t,e,r){for(var n,i=null;t<=e;)r(n=t+e>>1)?(i=n,e=n-1):t=n+1;return i},ternarySearch=function(t,e,r,n,i){var o,s;if(void 0===n&&(n=!1),void 0===i&&(i=200),n)for(;i--;)s=e-(e-t)/3,r(o=t+(e-t)/3)>1),r(i-1)>1),r(a-1)>u?(h=u,t=a+1):e=a-1;return h},Graph=function(){function t(t){this.g=vectorArray(t+1),this.vis=multiArray(!1,t+1),this.par=multiArray(-1,t+1)}var e=t.prototype;return e.addEdge=function(t,e,r){this.g[t].push({to:e,prop:r})},e.addBiEdge=function(t,e,r){this.addEdge(t,e,r),this.addEdge(e,t,r)},e.reset=function(){this.vis=multiArray(!1,this.g.length),this.par=multiArray(-1,this.g.length)},t}(),dfs=function(t,e,r,n){var i=new Deque;for(i.push(e);i.size;){var o=i.back;if(t.vis[o])n(o,t),i.pop();else{t.vis[o]=!0,r(o,t);for(var s,a=_createForOfIteratorHelperLoose(t.g[o]);!(s=a()).done;){var u=s.value;t.vis[u.to]||(t.par[u.to]=o,i.push(u.to))}}}},bfs=function(t,e,r){var n=new Deque;if(n.push(e),Array.isArray(e))for(var i,o=_createForOfIteratorHelperLoose(e);!(i=o()).done;){var s=i.value;t.vis[s]=!0,n.push(s)}else t.vis[e]=!0,n.push(e);for(;n.size;){var a=n.pop();r(a,t);for(var u,h=_createForOfIteratorHelperLoose(t.g[a]);!(u=h()).done;){var l=u.value;t.vis[l.to]||(t.par[l.to]=a,n.push(l.to),t.vis[l.to]=!0)}}},mst=function(t){for(var e=0,r=[],n=[],i=0;ii[r]+f.prop.weight&&(i[f.to]=i[r]+f.prop.weight,t.par[f.to]=r,o[f.to]||(o[f.to]=!0,s.push(f.to)))}}return{parArray:t.par,distArray:i}},dijkstra=function(t,e){t.reset();var r=new PriorityQueue((function(t,e){return t.dist>e.dist})),n=Number.MAX_SAFE_INTEGER,i=multiArray(n,t.g.length);if(Array.isArray(e))for(var o,s=_createForOfIteratorHelperLoose(e);!(o=s()).done;){var a=o.value;r.push({node:a,dist:0}),i[a]=0}else r.push({node:e,dist:0}),i[e]=0;for(;r.size;){var u=r.pop();if(i[u.node]===u.dist)for(var h,l=_createForOfIteratorHelperLoose(t.g[u.node]);!(h=l()).done;){var c=h.value;i[c.to]>i[u.node]+c.prop.weight&&(i[c.to]=i[u.node]+c.prop.weight,t.par[c.to]=u.node,r.push({node:c.to,dist:i[c.to]}))}}return{parArray:t.par,distArray:i}},setMod=function(t){global.MOD_=t,global.MOD_CUT=1099511627776%t},add=function(){for(var t=arguments.length,e=new Array(t),r=0;r=1;n--)e[0]+=e[n],e[0]=e[0]>=global.MOD_?e[0]-global.MOD_:e[0];return e[0]},sub=function(t,e){return(t+=global.MOD_-e)>=global.MOD_?t-global.MOD_:t},mul=function(){for(var t=arguments.length<=0?void 0:arguments[0],e=1;e>20)*((e<0||arguments.length<=e?void 0:arguments[e])>>20)*global.MOD_CUT+(4293918720&t)*(1048575&(e<0||arguments.length<=e?void 0:arguments[e]))+(1048575&t)*(e<0||arguments.length<=e?void 0:arguments[e]))%global.MOD_;return t},pow=function(t,e){for(var r=1;e;)1&e&&(r=mul(r,t)),t=mul(t,t),e>>>=1;return r},inv=function(t){for(var e,r=1,n=0,i=global.MOD_;i;n=(o=[r,n-e*r])[0],r=o[1],o){var o,s;i=(s=[t,i-(e=i/t|0)*t])[0],t=s[1]}return r<0?r+global.MOD_:r},factSetup=function(t){void 0===t&&(t=2e5),global.factorial=Array(t+1).fill(1),global.invFactorial=Array(t+1).fill(1);for(var e=1;e<=t;e++)global.factorial[e]=mul(global.factorial[e-1],e);global.invFactorial[t]=inv(global.factorial[t]);for(var r=t-1;r>=1;r--)global.invFactorial[r]=mul(global.invFactorial[r+1],r+1)},binom=function(t,e){return e>t?0:mul(global.factorial[t],global.invFactorial[e],global.invFactorial[t-e])},fact=function(t){return global.factorial[t]},Tree=function(t){function e(e,r){var n;return(n=t.call(this,e)||this).root=1,n.root=r,n.childCount=Array(e+1).fill(1),n.distRoot=Array(e+1).fill(0),n.distance=Array(e+1).fill(0),n}_inheritsLoose(e,t);var r=e.prototype;return r.setupDist=function(){var t=this;dfs(this,this.root,(function(e,r){for(var n,i=_createForOfIteratorHelperLoose(r.g[e]);!(n=i()).done;){var o=n.value;o.to!=r.par[e]&&(o.prop&&(t.distance[o.to]=t.distance[e]+o.prop.weight),t.distRoot[o.to]=t.distRoot[e]+1)}}),(function(e,r){for(var n,i=_createForOfIteratorHelperLoose(r.g[e]);!(n=i()).done;){var o=n.value;o.to!=r.par[e]&&(t.childCount[e]+=t.childCount[o.to])}}))},r.setupLCA=function(){this.setupDist();var t=31-Math.clz32(this.g.length);this.log=t,this.parentLift=Array(t+1),this.parentLift[0]=this.par;for(var e=1;e<=t;e++){this.parentLift[e]=Array(this.g.length).fill(-1);for(var r=0;r=0;n--)this.distRoot[t]-(1<=this.distRoot[e]&&(t=this.parentLift[n][t]);if(t===e)return t;for(var i=this.log;i>=0;i--)this.parentLift[i][t]!=this.parentLift[i][e]&&(t=this.parentLift[i][t],e=this.parentLift[i][e]);return this.parentLift[0][t]},e}(Graph);\r\n\r\nfunction main() {\r\n // write your code from here\r\n let [n, x] = rnum(2);\r\n let dp = multiArray(0, n + 1, x + 1);\r\n let p = multiArray(0, n + 1, x + 1);\r\n dp[0][0] = 1;\r\n for (let i = 0; i <= n; i ++) {\r\n for (let j = 1; j <= x; j ++) {\r\n p[i][j] = pow(j, i);\r\n }\r\n }\r\n factSetup();\r\n for (let i = 2; i <= n; i ++) {\r\n for (let j = 1; j < i; j ++) {\r\n dp[i][j] = mul(binom(n, i), sub(p[i][j], p[i][j - 1]));\r\n }\r\n }\r\n for (let i = 2; i <= n; i ++) {\r\n for (let j = 1; j <= x; j ++) {\r\n for (let k = 0; i + k <= n && i + j + k - 1 <= x; k ++) {\r\n dp[i + k][i + j + k - 1] = add(dp[i + k][i + j + k - 1], mul(dp[i][j], binom(n - i, k), p[k][i + k - 1]));\r\n }\r\n }\r\n }\r\n let ans = 0;\r\n for (let i = 1; i <= x; i ++)\r\n ans = add(ans, dp[n][i]);\r\n print(ans);\r\n}\r\nproc(main, 'input.txt');\r\n\r\n\r\n// Generated with compe.js - https://github.com/polarity-cf/compe.js", "lang_cluster": "Javascript", "tags": ["math", "dp", "combinatorics"], "code_uid": "ce2b2b5f49b95742e8b3a4660ff03e47", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\n\nconst rl = readline.createInterface(process.stdin, process.stdout);\n\nrl.on(\"line\", (value) => {\n console.log(getAnswer(+value));\n rl.close();\n});\n\nfunction getAnswer(weight) {\n if (weight < 4 || weight > 100 || weight % 2 !== 0) {\n return \"NO\";\n }\n\n return \"YES\";\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "6c27f887f54de161d9ec7b422258d8c1", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (str) => {\n if (c === 0) {\n c++;\n return;\n }\n\n let a = 0;\n let b = 0;\n\n for (let i = 1; i < str.length; i++) {\n if (str[i - 1] === 'S' && str[i] === 'F') {\n a++;\n }\n\n if (str[i - 1] === 'F' && str[i] === 'S') {\n b++;\n }\n }\n\n if (a > b) {\n console.log('YES');\n }\n else {\n console.log('NO');\n }\n\n c++;\n});\n\nrl.on('close', () => {\n\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e3a96622e81f4c9ce478a7d993a7e272", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Panoramix's Prediction\n\nconst {EOL} = require('os');\n\nlet inp = '';\n\nprocess.stdin.on('data', c => inp += c);\n\nprocess.stdin.on('end', () => {\n let ns = inp.split(EOL)[0].split(' ').map(c => +c);\n \t\n let prime = n => {\n \tfor(let i = 2; i <= Math.sqrt(n); i++) {\n \t\tif(n % i == 0) {\n \t\t\treturn false;\n \t\t}\n \t}\n \treturn true;\n }\n\n \tlet nxt = ns[0];\n \tif(nxt % 2 == 0) {\n \t\tnxt += 1;\n \t} else {\n \t\tnxt += 2;\n \t}\n\n \tfor(; nxt < ns[1]; nxt += 2) {\n \t\tif(prime(nxt)) {\n \t\t\tprocess.stdout.write(\"NO\");\n \t\t\treturn;\n \t\t}\n \t}\n\n \tprocess.stdout.write((prime(ns[1])) ? \"YES\" : \"NO\");\n\n return;\n});", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "55af8595b507d242258403dba7bc3a71", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\n// listCount = new Array(1001).fill(0);\nconst obj = {};\nlet a;\nlet b;\nlet c;\n\nfunction solve(n) {\n if (n < 0) {\n return -10000;\n }\n if (n === 0) {\n return 0;\n }\n if (n < a && n < b && n < c) {\n obj[n] = -10000;\n return -10000;\n }\n if (obj[n]) {\n return obj[n];\n }\n obj[n] = Math.max(solve(n - a) + 1, solve(n - b) + 1, solve(n - c) + 1);\n return obj[n];\n}\n\nrl.on('line', (line) => {\n const [n, aa, bb, cc] = line.split(' ').map(Number);\n a = aa;\n b = bb;\n c = cc;\n solve(n);\n console.log(obj[n]);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "dp"], "code_uid": "ca1d733516075cf6f6ebb6fbc53154c9", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nfunction main(x) {\n console.log(x % 2 == 0 && x > 3 ? 'YES' : 'NO');\n}\n\nlet a;\n\n// single line input\nreadline.on('line', line => {\n a = line;\n main(a);\n readline.close();\n});\n\n// multi line input\n// readline.on('line', line => {\n// console.log(line);\n// });\n\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "adfb4c1dc7fc5a043798c77764fe05df", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let readline = require('readline');\nlet intInput = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n});\nlet num;\n\nintInput.on('line', (line) => {\n\tnum = Number(line)\n});\nintInput.on('close', () => {\n\tlet result = 'Ehab';\n\tif (num % 2 == 0){\n\t\tresult = 'Mahmoud'\n\t}\n\tconsole.log(result);\n})", "lang_cluster": "Javascript", "tags": ["math", "games"], "code_uid": "1d9ed5096dd5d4be5d49fd1b11a05d66", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n let [x, y] = d.split(' ').map(Number);\n let inc = 1;\n\n while (x >= 0 && y >= 0) {\n if (inc % 2 === 0) {\n y -= inc;\n }\n else {\n x -= inc;\n }\n\n inc++;\n }\n\n if (x < 0) {\n console.log('Vladik');\n }\n else {\n console.log('Valera');\n }\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "50c02aeeb390e6025604b390780f9873", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const DEBUG = false;\nconst { EOL } = require('os');\nconst fs = require('fs');\n\nlet r = process.stdin;\nif (DEBUG) {\n r = fs.createReadStream('input');\n}\nlet data = '';\nr.on('data', c => (data += c));\nr.on('end', () => {\n const lines = data.split(EOL);\n const arr = [];\n const x = [];\n let d;\n [arr[0], arr[1], arr[2], d] = lines[0].split(' ');\n x[0] = parseInt(arr[0]);\n x[1] = parseInt(arr[1]);\n x[2] = parseInt(arr[2]);\n d = parseInt(d);\n x.sort(function(a, b) {\n return a - b;\n });\n let res = Math.max(0, d - (x[1] - x[0]));\n res += Math.max(0, d - (x[2] - x[1]));\n console.log(res);\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "8c35d2ac6b382afb135fa6005bbe3a80", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nlet _inputLines;\nlet _lineNumber = 0;\nlet inputReader = _inputReader ();\n\nfunction _main() {\n\t\n\t_inputLines = _inputData.trim().split('\\n').map((string) => {\n\t\treturn string.trim();\n\t});;\n\tlet n = inputReader.readNumber();\n\tlet str = inputReader.readLine();\n\tlet sf = 0,fs=0;\n\tfor(let i=1;i0){\n\t\tconsole.log(\"YES\");\n\t}\n\telse{\n\t\tconsole.log(\"NO\");\n\t}\n\n}\n\nvar _inputData = '';\nfunction cacheInput(data) {\n\t_inputData += data;\n}\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf8');\nprocess.stdin.on('data', cacheInput).on('end', _main);\n\nfunction _inputReader () {\n\tfunction readNumber(){\n\t\treturn Number(_inputLines[_lineNumber++]);\n\t}\n\t\t\n\tfunction readLine(){\n\t\treturn _inputLines[_lineNumber++];\n\t}\n\t\t\n\t\n\treturn {\n\t\treadNumber,\n\t\treadLine,\n\t}\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "a8806d71e4a7633b94bb664edb4e3a14", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', line => {\n const arr = line.split(' ');\n const res = func(arr[0], arr[1], arr[2]);\n console.log(res);\n});\n\nfunction func(n, m, a) {\n return Math.ceil(n / a) * Math.ceil(m / a);\n}\n\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "ad44a991e883edc1909549ef6ed700ba", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const start=(main, readlineFun, printFun) => {\n if (readlineFun && printFun) {\n main(readlineFun, printFun);\n return;\n }\n\n process.stdin.resume();\n process.stdin.setEncoding('utf8');\n\n let input = '',\n readline,\n print;\n\n process.stdin.on('data', function(chunk) {\n input += chunk;\n });\n\n process.stdin.on('end', function() {\n input = input.split('\\n');\n print = function(data) {\n process.stdout.write(data + '\\n');\n };\n let inputLineIndex = 0;\n readline = function() {\n return inputLineIndex >= input.length ? undefined : input[inputLineIndex++];\n };\n process.exit(main(readline, print) || 0);\n });\n} \n function main(readline, print) {\n const a = parseInt(readline());\n const b = parseInt(readline());\n const c = parseInt(readline());\n\n let max = Math.max(a + b + c, (a + b) * c, a + b * c, a * b + c, a * (b + c), a * b * c);\n\n print(max);\n} \n start(main);", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "ef9b35312242b044d39e98dc91c3bb80", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let fs = require('fs')\n\nlet txt = fs.readFileSync(0, \"utf-8\").split(\"\\r\\n\").filter((data) => {\n return data.length > 0;\n});\n// txt.shift()\n\nfor (let index = 0; index < txt.length; index++) {\n let info=txt[index].split(\" \")\n square(info[0]*1,info[1]*1)\n}\n\nfunction square(m,n) {\n let count=Math.floor(m/2)*n\n if(m%2==1){\n count+=Math.floor(n/2)\n }\n console.log(count);\n \n}", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "42539ecbd5cc7d93a23cd6e1bdfea768", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let nd = readLine().split(' ');\n let n = parseInt(nd[0]);\n let k = parseInt(nd[1]);\n for (let i = 0; i < k; i++) {\n if (n % 10 == 0) {\n n /= 10;\n } else n -= 1;\n }\n console.log(n);\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "c5fdd84139089fbf263e8345101c990c", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.question(\"\", function(input) {\n arrOfInp = input.split(' ')\n console.log(calculateMinDis([Number(arrOfInp[0]), Number(arrOfInp[1]), Number(arrOfInp[2])]));\n rl.close();\n});\n\nrl.on(\"close\", function() {\n process.exit(0);\n});\n\nfunction calculateMinDis(a) {\n miniCor = a[0] + a[1]\n mid = a[2] > miniCor ? miniCor : a[2]\n firstSol = miniCor + mid\n secSol = 2*a[2] + 2*a[0]\n thirdSol = 2*a[2] + 2*a[1]\n return Math.min(firstSol, secSol, thirdSol)\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f21c84dcc6c8796d2cdc4ceda1b85a2e", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\n\nreadLine.on('close', () => {\n const [c1, c2, c3, c4, c5] = input[0].split(' ').map(x => parseInt(x));\n const answ = c1 + c2 + c3 + c4 + c5;\n\n console.log(\n (answ) % 5 === 0 && answ !== 0 ? answ/5 : -1\n );\n}); ", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "00a87c4c86d97d1fdf1f1c2c1d471694", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function isValid(input) {\n var hello = 'hello'.split('');\n var word = input.split('');\n let letter = 0;\n for (let i = 0; i < word.length; i ++) {\n if (word[i] == hello[letter] && letter < 5) {\n letter += 1;\n }\n if (letter == 5) {\n return 'YES';\n }\n }\n return 'NO';\n}\n\nfunction processData(input) {\n console.log(isValid(input));\n}\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"ascii\");\n_input = \"\";\nprocess.stdin.on(\"data\", function (input) {\n _input += input;\n});\n\nprocess.stdin.on(\"end\", function () {\n processData(_input);\n});", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "23441a6b1f536500d50d20b79ac9123f", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = '';\nprocess.stdin.on('data', (c) => {\n i += c;\n});\nprocess.stdin.on('end', () => {\n const { EOL } = require('os');\n const lines = i.split(EOL);\n getMaxMinMath(...lines[0].split(' '));\n});\n\nfunction getMaxMinMath(n, l, r) {\n n = parseInt(n, 10);\n l = parseInt(l, 10);\n r = parseInt(r, 10);\n\n const max = Math.pow(2, r - 1) * (n - r + 1) + Math.pow(2, r - 1) - 1;\n const min = Math.pow(2, l) - 1 + (n - l);\n console.log(`${min} ${max}`);\n}", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "ca27ce33efd5dd050ae884900b1c07cd", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nfunction main() {\n const is = new Scanner();\n const n = is.nextInt();\n const numbers = is.nextArray();\n for (let i = 0; i < n; i += 1)\n numbers[i] = parseInt(numbers[i], 10);\n const repeat = new Map();\n numbers.forEach((element) => {\n if (!repeat.has(element))\n repeat.set(element, 1);\n else\n repeat.set(element, repeat.get(element) + 1);\n });\n\n let answer = 0;\n repeat.forEach((element) => { answer = Math.max(answer, element); });\n console.log(answer);\n}\n\n/*\n * api stdin\n */\n\nclass Scanner {\n constructor() {\n this.index = 0;\n this.lines = stdinInput.trim().split('\\n');\n }\n\n nextLine() {\n return this.lines[this.index++];\n }\n\n nextInt() {\n return parseInt(this.nextLine(), 10);\n }\n\n nextDouble() {\n return parseFloat(this.nextLine());\n }\n\n nextArray() {\n return this.nextLine().split(' ');\n }\n\n hasNext() {\n return this.index < this.lines.length;\n }\n}\n\nlet stdinInput = '';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nprocess.stdin.on('data', input => { stdinInput += input; });\nprocess.stdin.on('end', () => { main(); });\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "a0d9379fa0e9423fac4701f3742dd516", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let s = readLine().split('');\n s = [...new Set(s)];\n if (s.length % 2 == 0) {\n console.log('CHAT WITH HER!');\n } else console.log('IGNORE HIM!');\n}", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "ddd936266358a35c0022e5ab4fc8f3aa", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst rl = readline.createInterface({\n\t input: process.stdin,\n\t output: process.stdout,\n\tterminal : false\n});\n\n\nrl.on(\"line\", main)\nlet s = \"\" \nfunction main(input){\n\tlet arr = input.split(' ')\n\n\tlet k = arr[0]\n\tlet n = arr[1]\n\tlet w = arr[2]\n\n\tlet c = 0\n\tfor(var i = 0; i < w; i++){\n\t\tif( i == 0 ){\n\t\t\tn = n - k\n\t\t}\n\t\telse{\n\t\t\tn = n - ((i+1)*k)\n\t\t}\n\t}\n\t\n\tif(n >= 0){\n\t\tconsole.log(\"0\")\n\t}\n\telse{\n\t\tconsole.log(Math.abs(n))\n\t}\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "51659fce6442492d0d3c5eab59cba303", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let readline = require('readline');\nlet rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout,\n\tterminal: false\n});\n\nrl.on('line', function(line) {\n\tstringTask(line);\n\n\trl.close();\n});\n\n//\"A\", \"O\", \"Y\", \"E\", \"U\", \"I\",\nlet stringTask = (line) => {\n\tlet vowels = [ 'a', 'o', 'y', 'e', 'u', 'i' ];\n\tlet lowerStr = line.toLowerCase();\n\tlet result = lowerStr.split('').map((el) => {\n\t\tif (vowels.includes(el)) {\n\t\t\treturn '';\n\t\t} else {\n\t\t\treturn `.${el}`;\n\t\t}\n\t});\n\tconsole.log(result.join(''));\n};\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "ada686711c979d8a1897860f6d0529db", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n\tvar one = nextIntArray();\n\tvar N = one[0];\n\tvar M = one[1];\n\tvar xlist = nextIntArray();\n\tvar ylist = nextIntArray();\n\tvar set = new Set(ylist);\n\tvar output = [];\n\tfor(var i = 0; i < N; i++){\n\t\tif(set.has(xlist[i])){\n\t\t\tset.delete(xlist[i]);\n\t\t\toutput.push(xlist[i]);\n\t\t}\n\t}\n\tmyout(myconv(output, 8));\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "2743d698c449e55138cb65dd5a4743b1", "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let readline = require('readline');\nlet rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout,\n\tterminal: false\n});\n\nlet input = [];\nrl.on('line', function(line) {\n\tinput.push(line);\n\tif (input.length === 1) {\n\t\twaterMelon(parseInt(input[0]));\n\t\trl.close();\n\t}\n});\n\nlet waterMelon = (input) => {\n\tlet start = 1;\n\tlet end = input - 1;\n\tlet result = 'NO';\n\tfor (let i = start; i <= end; i++) {\n\t\tif (i % 2 === 0 && end % 2 === 0) {\n\t\t\tresult = 'YES';\n\t\t}\n\t\tend--;\n\t}\n\tconsole.log(result);\n};\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "95bd5e55594682eea720146e22c838c5", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const DEBUG = false;\nconst { EOL } = require('os');\nconst fs = require('fs');\n\nlet r = process.stdin;\nif (DEBUG) {\n r = fs.createReadStream('input');\n}\nlet data = '';\nr.on('data', c => (data += c));\nr.on('end', () => {\n const lines = data.split(EOL);\n const arr = [];\n let d;\n [arr[0], arr[1], arr[2], d] = lines[0].split(' ').map(Number);\n arr.sort(function(a, b) {\n return a - b;\n });\n let res = Math.max(0, d - (arr[1] - arr[0]));\n res += Math.max(0, d - (arr[2] - arr[1]));\n console.log(res);\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "b249d04733a99c226620bd06f76cae85", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nprocess.stdin.on('data', (input) => {\n const danger = input.match(/(0000000|1111111)/g);\n\n process.stdout.write(danger && danger.length ? 'YES' : 'NO');\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "23f18ba3d6e0d48197b577e910d7555c", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nreadline.on(\"line\", (line) => {\n const string = line.split(\" \")[0];\n readline.close();\n main(string);\n return;\n});\n\nconst main = (inputStr) => {\n const arr = [...inputStr];\n let count = 0;\n let current = arr[0];\n for (let val of arr) {\n if (val === current) {\n count++;\n }\n if (val !== current) {\n current = val;\n count = 1;\n }\n if (count === 7) {\n console.log(\"YES\");\n return;\n }\n }\n console.log(\"NO\");\n};\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "af8b0bddaab421e0b2854e689c043cde", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nlet input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n const all = input[0].split(' ')\n let red = parseInt(all[0], 10)\n let blue = parseInt(all[1], 10)\n let multi = 0\n if (red > blue) {\n multi = blue\n red -= blue\n blue = 0\n } else if (red < blue) {\n multi = red\n blue -= red\n red = 0\n } else if (red === blue) {\n multi = red\n red = 0\n blue = 0\n }\n if (red > 0)\n multi += ` ${Math.floor(red / 2)}`\n else if (blue > 0)\n multi += ` ${Math.floor(blue / 2)}`\n else \n multi += ' 0'\n console.log(multi)\n})", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "9fbd1fd1fef2ddaf39e97884d4b45c7c", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var read = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\nvar obj;\nvar inLine = [];\nread.on('line', function (input) { inLine.push(input); });\nread.on('close', function () {\n obj = init(inLine);\n myerr(\"-----start-----\");\n var start = new Date();\n Main();\n var end = new Date() - start;\n myerr(\"----- end -----\");\n myerr(\"Time: \" + (end) + \"ms\");\n myerr(\"Memory: \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction nextInt() { return myconv(next(), 1); }\nfunction nextStrArray() { return myconv(next(), 2); }\nfunction nextIntArray() { return myconv(next(), 4); }\nfunction nextCharArray() { return myconv(next(), 6); }\nfunction next() { return obj.next(); }\nfunction hasNext() { return obj.hasNext(); }\nfunction init(input) {\n var returnObj = {\n list: input, index: 0, max: input.length,\n hasNext: function () { return (this.index < this.max); },\n next: function () { if (!this.hasNext()) { throw \"ArrayIndexOutOfBoundsException\"; } else { var returnInput = this.list[this.index]; this.index++; return returnInput; } }\n };\n return returnObj;\n}\nfunction myout(s) { console.log(s); }\nfunction myerr(s) { console.error(\"debug:\" + require(\"util\").inspect(s, false, null)); }\nfunction myconv(i, no) { try { switch (no) { case 1: return parseInt(i); case 2: return i.split(\" \"); case 4: return i.split(\" \").map(Number); case 6: return i.split(\"\"); case 7: return i.split(\"\").map(Number); case 8: return i.join(\" \"); case 9: return i.join(\"\\n\"); case 0: return i.join(\"\"); default: return i; } } catch (e) { return i; } }\n\n\nfunction Main() {\n var str1 = next().toLowerCase();\n var str2 = next().toLowerCase();\n\n myout(str1.localeCompare(str2));\n \n} // Use Terminal to debug, not Debug Console!", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "566437c4a39ca251e2a9d96ee7bfe16c", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const [n, m, a] = String(require('fs').readFileSync(0)).trim().split(' ').map(Number);\nconsole.log(Math.ceil(n / a) * Math.ceil(m / a));\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "cd912882251371229853e358ce19b109", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n\n\nfunction main() {\n \n \n const friends = readLine().split(' ').map(aTemp => parseInt(aTemp, 10));\n \n let distance = 0;\n\n for (let i = 1; i < friends.length; i++) {\n let current = friends[i];\n\n let index = i;\n\n while (index >= 0 && current < friends[index - 1]) {\n friends[index] = friends[index - 1];\n index--\n \n }\n friends[index] = current;\n }\n distance = friends[2] - friends[0];\n console.log(distance);\n\n \n}", "lang_cluster": "Javascript", "tags": ["math", "sortings", "implementation"], "code_uid": "44edc41945e6d10138f77cb937221756", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n\nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n \nRL.on('line', line => input.push(line));\n\nRL.on('close', () => {\n const [n, m, k] = input[0].split(' ').map(x => parseInt(x));\n console.log( Math.min(m, k) >= n ? \"YES\" : \"NO\" );\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "6cd2c744f8b404b49d1b3e8eb17da942", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst { parse } = require('path');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', line => {\n const inputs = line.split(' ');\n solution(inputs[0]);\n});\n\nfunction solution(line) {\n console.log(line.split('+')\n .map(item => parseInt(item))\n .sort((a, b) => a - b)\n .join('+'));\n return;\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "1504ecb2aba9f48d90ee28eef8f5817b", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n \nrl.on('line', (input) => {\n lucky = 0;\n for(let i = 0; i < input.length; i++) {\n if(input[i] == 4 || input[i] == 7) {\n lucky +=1;\n }\n }\n if(lucky == 4 || lucky == 7) {\n console.log('YES');\n } else {\n console.log('NO');\n }\n \n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f71b6da27d8ad6212290875e6443847f", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n let theNum = readline();\n\n let result = isTrue(theNum);\n\n if(result) {\n console.log('YES');\n } else {\n console.log('NO');\n }\n}\n\nfunction isTrue(theNum) {\n if(theNum == 2) {\n return false;\n }\n let secondNum = theNum - 2;\n for(let i = 2; i <= theNum; i+=2, secondNum-=2) {\n if(i + secondNum == theNum) {\n if(i % 2 == 0 && secondNum % 2 == 0) {\n return true;\n }\n }\n }\n return false;\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "a85ff907b53692621e9be965ad6970d6", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n const n=Number(stdin[0]);\n var str=stdin[1];\n var arr=[];\n for(let i=0,j=0;i {\n const [m, n] = d.split(' ').map(Number);\n\n console.log(Math.floor(m*n/2));\n});\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "8740100c3a181af82e6b9faf77ea3e4b", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict'; /*jslint node:true, browser:true, es6:true*/\nconst print = console.log\nconst E = {};\nconst lines = []\nif (!process.env.JEST_WORKER_ID){\n const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })\n rl.on('line', line => {\n lines.push(line);\n });\n rl.on('close', main)\n}\nlet rli = 0;\nfunction readline() {\n return lines[rli++];\n}\n\nmodule.exports = E;\n\nconst ra = ()=>readline().split(' ').map(a=>+a)\n\nconst EPS = 1e-6;\n\nconst calc = n=>{\n return (1< {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction readAsInt(){\n return parseInt(readline());\n}\n\nfunction readAsIntList(){\n return readline().split(' ').filter(i => i).map(i => parseInt(i));\n}\n\n\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n let s1 = readline().toLowerCase();\n let s2 = readline().toLowerCase();\n console.log( s1.split('').reverse().join('') === s2 ? 'YES' : 'NO' );\n}\n \n\n\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "eb62e972f000de7aeeff3de0816e3355", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// 58A - Chat room\n// http://codeforces.com/problemset/problem/58/A\n\nfunction main() {\n let s = read();\n if (s.match(/.*h.*e.*l.*l.*o.*/))\n writeline(\"YES\");\n else\n writeline(\"NO\");\n return 0;\n}\n\nvar input = \"\";\nvar read;\nvar writeline = (x) => process.stdout.write(x + \"\\n\");\nvar write = (x) => process.stdout.write(x);\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf8\");\nprocess.stdin.on(\"data\", (chunk) => input += chunk);\nprocess.stdin.on(\"end\", () => {\n input = input.trim().split(/\\s+/);\n read = () => input.shift();\n process.exit(main() || 0);\n});\n", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "a588652cde71906076e46dbef2b0f28e", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\n// multi line input read nodejs function\nreadline.on('line', line => {\n let number = line\n console.log(matchs(number))\n})\n\n//it's a main function \nfunction matchs(n) {\n return n.split(/\\+/g).sort().join('+')\n}", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "42ba10400719d31c752e4258ef2b6e34", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nconst readLine=()=> inputString[currentLine++];\n/* ================================================ \n Main Solution Starts Here \n===================================================*/\n\nconst main=()=>{\n\tlet x=parseInt(readLine())\n\tlet blocks=readLine().split(\" \").map(n=>+n)\n\tblocks.sort((a,b)=>a-b)\n\tconsole.log(...blocks)\n}", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "5c1679e35e2bd3c66282a8e8cf842919", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use-strict'\r\n\r\nprocess.stdin.resume();\r\nprocess.stdin.setEncoding('utf8');\r\n\r\nlet data = '';\r\nlet currentLine = 0;\r\n\r\nprocess.stdin.on('data', chunk => {\r\ndata += chunk;\r\n});\r\n\r\nprocess.stdin.on('end', () =>{\r\ndata = data.replace(/\\s*$/, '')\r\n.split('\\n')\r\n.map(str => str.replace(/\\s*$/, ''));\r\n\r\nlet testCases = parseInt(data.shift());\r\n\r\nwhile(testCases--) {\r\n\r\nconst num = parseInt(readLine());\r\nconst res = a(num);\r\nconsole.log(res)\r\n}\r\n});\r\n\r\nfunction readLine() { \r\nreturn data[currentLine++];\r\n}\r\n\r\nfunction a(s){\r\n let ans = 0;\r\n for(let i = 0; i*i <= s ; i++) ans++;\r\n for(let i = 0; i*i*i <= s ; i++) ans++;\r\n for(let i = 0; i*i*i*i*i*i <= s ; i++) ans--;\r\n return ans - 1;\r\n}\r\n\r\nmodule.exports = a;\r\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "d0a54a795645d1a80f3872db3fe388f8", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n const nk = stdin[0].split(' ').map(Number);\n var i = 0,\n sum = 0;\n while (nk[0] > 0) {\n nk[0]--;\n i++;\n sum += i;\n if (sum >= nk[1] && nk[0] === sum - nk[1]) {\n break;\n }\n }\n console.log(nk[0]);\n}\n\nconst readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar stdin = [];\nrl.on('line', function (line) {\n stdin.push(line);\n});\nrl.on('close', main);", "lang_cluster": "Javascript", "tags": ["brute force", "math", "binary search"], "code_uid": "fedaef76edefb7024e388752bdaafaa9", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const [w1, h1, w2, h2] = d.split(' ').map(Number);\n const ans = ((w1 + 2) * 2 + (h1 + h2 + 2) * 2) - 4;\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "f38672924e477b921f2b4ea4d6e7ff6a", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\nconst substract = () => {\n let [n,k] = input[0].split(' ').map(x => +x);\n let count = 0;\n while (count < k) {\n let last = n % 10;\n if (last !== 0) {\n n--;\n }\n else {\n n /= 10;\n }\n count++;\n }\n console.log(n);\n\n};\n\n\n\n\nreadLine.on('close', substract);", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "03f876e3356f4bab2b8c39f41fed1aba", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputNum = 0;\nconst readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\nfunction tanyaEraser(number, iterations){\n while (iterations != 0) {\n if (number % 10 == 0){\n number /= 10;\n //console.log(number, typeof number);\n } else {\n number--;\n }\n iterations--;\n }\n //console.log(`number is ${number} and typeof number is ${typeof number}`);\n console.log(number);\n \n}\n\nrl.on('line', (line) => {\n [inputNum, iterations] = line.split(' ', 2).map(Number);\n //console.log('inputNum', inputNum, typeof inputNum, iterations, typeof iterations);\n tanyaEraser(inputNum, iterations);\n process.exit();\n});\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3d9220261fd6c91107c3ab71ef00e916", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nlet inputs = [];\n\n// Create readline Interface\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\n// Read Inputs\nrl.on('line', inputLine => {\n let seq = [];\n const n = parseInt(inputLine.split(' ')[0]);\n const k = parseInt(inputLine.split(' ')[1]);\n const evens = Math.floor((n / 2));\n\n\n if (n % 2 === 0) {\n const base = ((k - 1) * 2);\n if (k <= (n / 2)) {\n return console.log(base + 1);\n } else if (k > (n / 2) && k <= n) {\n return console.log((base + 2) - n);\n }\n }\n else {\n const lastOdd = evens + 1;\n const base = ((k - 1) * 2);\n\n if (k <= lastOdd) {\n return console.log(base + 1);\n } else if (k > lastOdd && k <= n) { \n return console.log((base + 2) - n - 1);\n }\n\n }\n\n});\n\n\n\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "16259c428b7cdd3f528ec0020e3936d8", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input.push(line);\n});\n\n\nRL.on('close', () => {\n let n = parseInt(input[0]);\n let a = n%4, b = (n+1)%4, c = (n+2)%4;\n //console.log(`a = ${a}; b = ${b}; c = ${c}`);\n if(a == 1){\n console.log('0 A');\n } else if(a != 1 && (b == 1 || b == 3)){\n console.log('1 '+(b===1 ? 'A' : (b === 2) ? 'C' : (b === 3) ? 'B' : 'D'));\n } else {\n console.log('2 '+(c===1 ? 'A' : (c === 2) ? 'C' : (c === 3) ? 'B' : 'D'));\n }\n});\n\n\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "9f9d82d7f9271f328f91c505aff29e3a", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n \nRL.on('line', (line) => {\n input.push(line.split(' ').map(x => parseInt(x)));\n});\n\nRL.on('close', () => {\n const [n, m, a] = input[0];\n \n console.log( parseInt(Math.ceil(m/a) * Math.ceil(n/a)) );\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "adc4e176bb0586db1be83cbfdaafa6ec", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main(stdin) {\n const [n, m, a] = stdin.split(\" \").map(v => parseInt(v));\n console.log(Math.ceil(n / a) * Math.ceil(m / a));\n}\n\nmain(\n require(\"fs\")\n .readFileSync(0, \"utf-8\")\n .trim()\n);\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "e1a4c85adb5b7732a1875671e85b9190", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const main = data => {\n const n = data[0];\n const winnerArr = data[1].split(' ');\n const looserArr = data[2].split(' ');\n\n const winCount = winnerArr.filter((x, i) => looserArr[i] !== x && +x !== 0).length;\n const looseCount = looserArr.filter((x, i) => winnerArr[i] !== x && +x !== 0).length;\n\n if (winCount === 0) {\n console.log('-1')\n } else {\n let i = 1;\n while (winCount * i <= looseCount) {\n i++\n }\n console.log(i);\n }\n};\n\nlet data = '';\n\nprocess.stdin.on('data', input => data += input);\nprocess.stdin.on('end', () => {\n data = data.split('\\n');\n\n main(data);\n});", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "1f37c2283c2103d9a47cff8fb3733d0e", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\r\nconst fs = require(\"fs\");\r\n//let filename = \"0.txt\";\r\nlet filename = 0;\r\nconst input = fs.readFileSync(filename, \"utf8\").trim().split(\"\\n\");\r\nlet line = 0;\r\nfunction readline() {\r\n return input[line++];\r\n}\r\nconst solve = () => {\r\n let t = parseInt(readline());\r\n while (t--) {\r\n let n = parseInt(readline());\r\n let arr = readline()\r\n .trim()\r\n .split(\" \")\r\n .map((cur) => parseInt(cur));\r\n let ans = true;\r\n if (arr[n - 1] !== 0) {\r\n if (arr[arr[n - 1] - 1] === 0) ans = false;\r\n } else ans = false;\r\n console.log(`${ans === true ? \"YES\" : \"NO\"}`);\r\n }\r\n};\r\nsolve();\r\n", "lang_cluster": "Javascript", "tags": ["brute force", "greedy", "implementation", "math"], "code_uid": "a7efad24fc23ec6fbd9adbbbc5f97d14", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = ''\nprocess.stdin.on('data', c => input += c)\nprocess.stdin.on('end', () => {\nconst { EOL } = require('os')\nconst lines = input.split(EOL)\ns = lines[0]\nright = s.length - 1\nleft = 0\nans = \"\"\nif (s.length %2 == 1){\n ans += s[left]\n left += 1\n}\nwhile (left < right){\n ans += s[right]\n ans += s[left]\n right -= 1\n left += 1\n}\nfinalans = \"\"\nfor (i = ans.length-1; i>= 0; i--){\n finalans += ans[i]\n}\nconsole.log(finalans)\n})", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "8213554dfa2c91d4536e00e0f0384784", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n let [n, len] = readLine()\n .split(\" \")\n .map((n) => parseInt(n));\n const arr = readLine()\n .split(\" \")\n .map((n) => parseInt(n));\n arr.sort((a, b) => a - b);\n let min = Number.MAX_SAFE_INTEGER;\n\n for (let i = 0; i <= len - n; i++) {\n const [low, high] = [arr[i], arr[i + n - 1]];\n min = Math.min(min, high - low);\n }\n\n console.log(min);\n}\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "78e02495eded9bd83fdfa697c7e91242", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nfunction readLines(number, cb) {\n const lines = [];\n rl.on('line', function(line) {\n lines.push(line);\n if (lines.length === number) {\n rl.close();\n cb(lines);\n }\n });\n};\n\n\nfunction doIt(lines) {\n const n = parseInt(lines[0]);\n if (n === 0)\n console.log(n)\n else\n console.log(calc(n, 1));\n}\n\nfunction calc(next, acc) {\n if (next === 0)\n return acc;\n let unit1 = next%10;\n let rest1 = Math.floor(next/10);\n let ret1 = calc(rest1, unit1*acc);\n let ret2 = 0;\n if (unit1 < 9 && rest1>0) {\n let unit2 = 9;\n let rest2 = Math.floor(next/10) -1;\n\n ret2 = calc(rest2, unit2*acc);\n }\n return Math.max(ret1, ret2);\n}\n\nreadLines(1, doIt);", "lang_cluster": "Javascript", "tags": ["brute force", "math", "number theory"], "code_uid": "a4efb16792169844d0045f74f0d1c287", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume()\r\nprocess.stdin.setEncoding('utf-8')\r\n\r\nlet currentLine = 0\r\nlet inputString = ''\r\n\r\nprocess.stdin.on('data', raw_data => {\r\n inputString += raw_data\r\n})\r\n\r\nprocess.stdin.on('end', _ => {\r\n inputString = inputString.trim().split('\\n').map(line => {\r\n return line.trim()\r\n })\r\n main()\r\n})\r\n\r\nfunction readLine() {\r\n return inputString[currentLine++]\r\n}\r\n\r\n\r\n// function main() {\r\n// /**\r\n// * INPUT TECHNIQUES\r\n// */\r\n\r\n// // Simple String Input\r\n// const strInput = readLine()\r\n\r\n// // Array Input\r\n// const arrInput = readLine().split(' ')\r\n\r\n// // Array Destructuring and Three variable input from a single line, separated by a space\r\n// const [a, b, c] = readLine.split(' ')\r\n\r\n// // If you need number separated by space just map each element of the array this way\r\n// const [x, y, z] = readLine.split(' ').map(Number)\r\n\r\n\r\n// /**\r\n// * OUTPUT TECHNIQUES\r\n// */\r\n\r\n// // End by a new line \"\\n\"\r\n// console.log(\"Hi\")\r\n\r\n// // Don't end by new line character \"\\n\"\r\n// process.stdout.write(\"Hi\")\r\n\r\n// }\r\n\r\nfunction main() {\r\n let t = readLine();\r\n t = parseInt(t);\r\n\r\n while (t--) {\r\n solve()\r\n }\r\n}\r\n\r\nfunction solve() {\r\n let N = readLine();\r\n N = parseInt(N);\r\n\r\n let res = ((Math.floor(Math.sqrt(N)) + Math.floor(Math.cbrt(N))) - Math.floor(Math.sqrt(Math.floor(Math.cbrt(N)))));\r\n console.log(res);\r\n}", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "ce050fcc0076f9d0451ed0cab2d8babf", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nlet count = 0;\nlet r, c;\nlet matrix = [];\nconst cake = [];\n\nconst makeRowPoison = (c, cake) => {\n for (let i = 0; i < matrix.length; i++) {\n let safe = 1;\n for (let j = 0; j < matrix[i].length; j++) {\n if(cake[i][j] === 'S') {\n safe = 0;\n }\n }\n\n if (!safe) {\n matrix[i][c] = 0;\n }\n }\n}\n\nconst makeColPoison = (r, cake) => {\n for (let i = 0; i < matrix[r].length; i++) {\n let safe = 1;\n for (let j = 0; j < matrix.length; j++) {\n if (cake[j][i] === 'S') {\n safe = 0;\n }\n }\n\n if (!safe) {\n matrix[r][i] = 0;\n }\n }\n}\n\nrl.on('line', (d) => {\n if (count === 0) {\n count++;\n [r, c] = d.split(' ').map(Number);\n matrix = new Array(r).fill(1).map(x => new Array(c).fill(1));\n return;\n }\n\n const cakeLine = d.split('');\n cake.push(cakeLine);\n\n count++;\n});\n\nrl.on('close', () => {\n let ans = 0;\n\n for (let row = 0; row < cake.length; row++) {\n for (let col = 0; col < cake[row].length; col++) {\n if (cake[row][col] === 'S') {\n makeRowPoison(col, cake);\n makeColPoison(row, cake);\n }\n }\n }\n\n for (let i = 0; i < matrix.length; i++) {\n for (let j = 0; j < matrix[i].length; j++) {\n if (matrix[i][j]) {\n ans++;\n }\n }\n }\n\n console.log(ans);\n});", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "eb69f77cb7d697c12b25824a38e3f7b9", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(str) {\n\n let inputs = str.trim().split(' ');\n let questions = +inputs[0];\n let minutesToTake = +inputs[1];\n let totalHours = 240;\n\n for (var index = 1; index <= questions; index++) {\n\n let mul = 5 * index;\n let diff = totalHours - mul;\n\n if (diff < minutesToTake) {\n index--;\n break;\n }\n else if (diff == minutesToTake) {\n break;\n }\n totalHours = diff;\n }\n\n if (index > questions) {\n index--;\n }\n\n\n return index.toString();\n}\n\n\n\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation", "binary search"], "code_uid": "9469d9529b4f9b77f31a17b372b3cb9c", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\n'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\n\nfunction main() {\n let place = [];\n\n for (let row = 0; row < 5; row++) {\n let found = readline().split(\" \").indexOf('1');\n if (found > -1) {\n place = [row, found];\n break;\n }\n\n }\n\n let num1 = Math.abs(2- place[0]) >= 0 ? Math.abs(2- place[0]) : 0;\n let num2 = Math.abs(2- place[1]) >= 0 ? Math.abs(2- place[1]) : 0;\n console.log(num1 + num2);\n\n return;\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "20d69544a3f6accaebf242f446eb2813", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nconst ans = (text) => {\n console.log(text);\n};\n\nrl.on('line', function (w) {\n if (w < 3) {\n ans('NO');\n }\n else if (w % 2 === 0) {\n ans('YES');\n }\n else {\n ans('NO');\n }\n})\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "d716de4f524f70cb6f6471b41ecd987b", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nreadline.on('line', s => {\n let i = 0;\n\n const n = s.length;\n\n while (i < n) {\n if (s[i] == 'h') {\n i++;\n while (i < n) {\n if (s[i] == 'e') {\n i++;\n while (i < n) {\n if (s[i] == 'l') {\n i++;\n while (i < n) {\n if (s[i] == 'l') {\n i++;\n while (i < n) {\n if (s[i] == 'o') {\n console.log('YES');\n return;\n }\n i++;\n }\n }\n i++;\n }\n }\n i++;\n }\n }\n i++;\n }\n }\n i++;\n }\n\n console.log('NO');\n});", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "3ff21b0ebe6dd8607603cbb326e1b9bb", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const [s, v1, v2, t1, t2] = d.split(' ').map(Number);\n const p1 = 2 * t1 + s * v1;\n const p2 = 2 * t2 + s * v2;\n\n if (p1 < p2) {\n console.log('First');\n }\n else if (p1 > p2) {\n console.log('Second');\n }\n else {\n console.log('Friendship');\n }\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "cfba3a4e7a9d9522c7c5aa5f6e317fd2", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n const matrix = [];\n let minNumOfSwap;\n for( let i = 0 ; i < 5 ; i++){\n matrix[i] = readline().split(' ').map(x => parseInt(x))\n }\n\n\n for (let i=0 ; i <5 ;i++){\n for (let j =0 ; j < 5 ; j++){\n if (matrix[i][j] === 1 ){\n minNumOfSwap = Math.abs( i - 2) + Math.abs(j -2);\n break;\n }\n }\n if (minNumOfSwap > 0) break;\n }\n console.log(minNumOfSwap)\n\n}\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "d784382cd899598455b70d8c8f054fd6", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function solve() {\n var k = BigInt(read());\n var str = 'codeforces';\n var n = str.length;\n \n var step = 0;\n var mul = 0n;\n\n while (mul <= k) {\n step++;\n mul = st(step, n);\n }\n\n step--;\n mul = st(step, n);\n var c = 0;\n\n while(mul < k) {\n c++;\n mul += mul / BigInt(step);\n }\n\n var ans = '';\n for (var i = 0; i < n; ++i) {\n ans += str[i].repeat(i < c ? step + 1 : step);\n }\n write(ans);\n}\n\nfunction st(n, k) {\n n = BigInt(n);\n var p = BigInt(1);\n for (var i = 0; i < k; ++i) {\n p *= n;\n }\n return p;\n}\n\n\nvar isNode = typeof console !== 'undefined';\nvar MEMORY = [];\nvar MEMORY_INDEX = 0;\nif (isNode) {\n var fs = require('fs');\n var path = require('path');\n \n var inTextName;\n var outTextName;\n if (process.argv.length === 5) {\n inTextName = process.argv[3];\n outTextName = process.argv[4];\n }\n \n if (inTextName) {\n fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {\n MEMORY = data.split('\\r\\n');\n solve();\n });\n } else {\n var RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n });\n \n RL.on('line', (line) => {\n MEMORY.push(line);\n });\n \n RL.on('close', solve);\n }\n} else {\n solve();\n}\n \nfunction write(value) {\n isNode ? console.log(value) : print(value);\n}\nfunction read() {\n return isNode ? MEMORY[MEMORY_INDEX++] : readline();\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "constructive algorithms", "math", "greedy", "strings"], "code_uid": "6bddd036dbbfb566b371034c550f7cb0", "src_uid": "8001a7570766cadcc538217e941b3031", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n console.log(+d / 2 * 3);\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math", "number theory"], "code_uid": "7579907974328660da325872b1cab49f", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n const arr = d.split(' ').map(Number);\n arr.sort((a, b) => a - b);\n\n console.log(arr.join(' '));\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "b7c65a975d3725eeb741d09736bd9544", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\nlet input = []\nrl.on('line', line => {\n input = line.split(' ').map(x => parseInt(x))\n const output = solution(input[0], input[1])\n console.log(output)\n})\nrl.on('close', () => {\n \n})\n\n\nconst solution = (n) => {\n\tlet intQuotient = Math.floor(n/5);\n\tlet reminder = n % 5;\n\tlet res = intQuotient + (reminder ? 1 : 0);\n\treturn res;\n};", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "10e5cd2423df084bc59f827e3b894781", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n\tvar one = nextIntArray();\n var n = one[0];\n var k = one[1];\n for(var i = 0; i < k; i++){\n if(n % 10 == 0){\n n /= 10;\n }else{\n n--;\n }\n }\n myout(n);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "74864dabd794b6783113994b6cf14df5", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = ''\n \nfunction main(n,m,a) {\n if( (1 <= n && n <= Math.pow(10,9)) && ( 1 <= m && m <= Math.pow(10,9)) && (1 <= a && a <= Math.pow(10,9)) ){\n let x = n/a;\n let y = m/a;\n let num = 0;\n if(n == 1 && m == 1 && a == 1 ){\n console.log(1);\n }\n else if(n == 1 || m == 1){\n let x = Math.ceil((n * m) / a);\n console.log(x);\n }\n else if(x <= 1 && y <= 1){\n console.log(1);\n }\n else if(x < 1){\n console.log(Math.ceil(y));\n }\n else if(y < 1){\n console.log(Math.ceil(x));\n }\n else{\n let x = Math.ceil(n/a) ;\n let y = Math.ceil(m/a);\n num = x*y;\n console.log(num);\n }\n }\n \n}\n// main(1000000000,1000000000,1);\n \n \nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os')\n const lines = i.split(EOL)\n const line1Array = lines[0].split(' ').map(x => parseInt(x))\n const n = line1Array[0];\n const m = line1Array[1];\n const a = line1Array[2];\n main(n,m,a);\n})", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "180159985b380f33427df3be07c00b10", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet currentLine = 0;\nlet inputString = \"\";\n\nprocess.stdin.on(\"data\", (raw_data) => {\n inputString += raw_data;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((line) => {\n return line.trim();\n });\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n/******** Main function*************/\n\nfunction main() {\n var s = readLine().split(\"\").map(Number);\n\n var count = 0;\n for (var i = 0; i < s.length; i++) {\n if (s[i] === 7 || s[i] === 4) {\n count++;\n }\n }\n if (count == 4 || count == 7) {\n console.log(\"YES\");\n } else {\n console.log(\"NO\");\n }\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "bfdca137c020cd53f2f8848118ceb3ff", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet stdin = '';\n\nprocess.stdin.on('data', (input) => {\n stdin += input;\n});\n\nprocess.stdin.on('end', () => {\n const data = stdin.split('\\n')[1];\n\n let counter = 0;\n let current;\n\n for (let i = 0; i < data.length; i++) {\n if (data[i] === current) counter++;\n else current = data[i];\n }\n\n process.stdout.write(String(counter));\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "98db5ea5db9781b3b1c75fe42773dfc4", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let data = '';\nprocess.stdin.on('data', c => data += c);\nconst sol = () => {\n\tlet x = Number(data);\n\twhile(x%10 === 0) x /= 10;\n\tlet a = x, b = 0;\n\twhile(x > 0){\n\t\tb *= 10;\n\t\tb += x%10;\n\t\tx = Math.trunc(x/10);\n\t}\n\tconsole.log(a === b?'YES':'NO');\n};\nprocess.stdin.on('end', sol);\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "1d04458f3440c83e221b6b76964ff012", "src_uid": "d82278932881e3aa997086c909f29051", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n let [t, s, x] = d.split(' ').map(Number);\n let ans = 'NO';\n let val = t;\n\n if (val === x) {\n ans = 'YES';\n }\n\n let idx = 1;\n while (val <= x) {\n val = t + (idx * s);\n\n if (val === x) {\n ans = 'YES';\n break;\n }\n\n val = t + (idx * s) + 1;\n\n if (val === x) {\n ans = 'YES';\n break;\n }\n\n idx++;\n }\n\n console.log(ans);\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "6bfb307c2eef1364be2d291648466442", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data', async data => {\n\tlet result = 0\n\tconst dataarr = data.toString().trim().split('');\n\tawait Promise.all(dataarr.reverse().map(datum => new Promise(resolve => {\n\t\tresult += (10 - (+datum + 1)%10)%10;\n\t\tresolve()\n\t})))\n\tif (dataarr.reverse()[0] == 0) result+=10\n\tresult += +dataarr[0] + +!!(dataarr.length-1)\n\tconsole.log(result)\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "ad118e97bc728ca33a88aceb20e26447", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = '';\nprocess.stdin.on('data', c => i += c);\nprocess.stdin.on('end', () => {\n const {EOL} = require('os');\n const lines = i.split(EOL);/*your input text, split by lines*/\n\n const tableCard = lines[0];\n const handCards = lines[1].trim().split(' ');\n\n for (const card of handCards) {\n if (tableCard[0] === card[0] || tableCard[1] === card[1]) {\n console.log('YES');\n return;\n }\n }\n\n console.log('No');\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "6d4704338692fd069662b6c264c9b74b", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nprocess.stdin.resume()\nprocess.stdin.setEncoding('utf-8')\n\nlet input = ''\nlet ptr = 0\nprocess.stdin.on('data', (i) => {\n input += i\n})\n\n\nprocess.stdin.on('end', () => {\n input = input.split('\\n').map(a => a.replace(/(\\r\\n|\\n|\\r)/gm, ''))\n main()\n})\n\nfunction wr(...x) {\n console.log(...x)\n}\n\nfunction sort(a, inc = true) {\n if(inc) a.sort((a, b) => a - b)\n else a.sort((a, b) => b - a)\n}\n\nfunction readInt() {\n return parseInt(input[ptr++])\n}\n\nfunction readString() {\n return input[ptr++]\n}\n\nfunction readStrings() {\n return input[ptr++].split(' ')\n}\n\nfunction readInts() {\n return input[ptr++].split(' ').map(a => parseInt(a))\n}\n\nfunction main() {\n const l = readInt()\n let s = readString()\n let max = 0\n let count = 0\n let len = l\n for(let c = 1; c < l; c++) { // l -1 times\n let f = false\n for(let i = 1; i < len; i++) {\n if(s[i] > s[max]) max = i\n }\n // console.log(s, max, s[max], count)\n if(max !== 0 && s.charCodeAt(max) - 1 === s.charCodeAt(max - 1)) {\n s = cut(max)\n len--\n count++\n f = true\n }\n else {\n for(let x = max; x < len - 1; x++) {\n if(s[x] === s[max] && s.charCodeAt(x) - 1 === s.charCodeAt(x + 1)) {\n // console.log('x', x, s[x])\n s = cut(x)\n len--\n count++\n f = true\n break\n }\n }\n }\n if(!f) s = put(max)\n max = 0\n }\n\n wr(count)\n\n function cut(i) {\n i++\n return s.substring(0, i - 1) + s.substring(i)\n }\n function put(i) {\n i++\n return s.substring(0, i - 1) + 'A' + s.substring(i)\n\n }\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "greedy", "strings", "constructive algorithms"], "code_uid": "ba5f2a879d78d252accc69ea922b0603", "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n↑入力 ↓出力');\n Main();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var one = nextIntArray();\n var x = one[0];\n var y = one[1];\n var z = one[2];\n one = nextIntArray();\n var a = one[0];\n var c = one[1];\n var b = one[2];\n if(a < x){\n myout(\"NO\");\n return;\n }\n a -= x;\n if(a + c < y){\n myout(\"NO\");\n return;\n }\n var ac = a + c;\n ac -= y;\n if(ac + b < z){\n myout(\"NO\");\n return;\n }else{\n myout(\"YES\");\n return;\n }\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "greedy", "implementation"], "code_uid": "5d122c2e01179b2b6d423a1a66215a0d", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet first = true;\n\nrl.on('line', line => {\n if (first) {\n first = false;\n } else {\n solution(line);\n }\n});\n\nfunction solution(line) {\n let previous = line[0];\n let repeat = 0;\n for (let i = 1; i < line.length; i++) {\n while (line[i] === previous) {\n repeat++;\n i++;\n }\n previous = line[i];\n }\n\n console.log(repeat);\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3a519d20f9640d8163bc55967d5420c5", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = ''\nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os')\n const lines = i.split(EOL) /*your input text, split by lines*/\n getMinNumber(lines[0])\n})\n\nfunction getMinNumber(input) {\n let avaialbleBankNotes = [1, 5, 10, 20, 100];\n let output = 0;\n let bankNotesCount = 0;\n let reaminingInput = input\n\n avaialbleBankNotes.reverse().forEach(element => {\n if (input === element) {\n // console.log('Input === Element');\n output = element;\n bankNotesCount = 1;\n return;\n }\n\n if (reaminingInput >= element) {\n do {\n output = output + element;\n reaminingInput = reaminingInput - element;\n bankNotesCount = bankNotesCount + 1;\n\n // console.log(\"Bank Note used: \" + element);\n // console.log(\"Remaining Amount:\" + reaminingInput);\n // console.log(\"Current Output: \" + output);\n } while(output + element <= input)\n }\n });\n // console.log('Final Output is: ' + output);\n console.log(bankNotesCount);\n}", "lang_cluster": "Javascript", "tags": ["greedy", "dp"], "code_uid": "2d56aeebc0b7b27e37beb90693ebe1a2", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet l = 0;\nrl.on('line', (input) => {\n if (l === 0) { l++ }\n else {\n rl.close();\n let arr = input.split(\" \").map(x => parseInt(x))\n let sum = 0\n for (let i = 0; i < arr.length; i++) {\n sum += arr[i]*2*(2*(Math.max((i+1),1)-1))\n }\n\n console.log(sum)\n return 0;\n }\n})\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "ad6c56dada025c0f9a0dc71774cc0d05", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": " process.stdin.resume();\n process.stdin.setEncoding('utf-8');\n \n process.stdin.on('data', inputStdin => {\n if (inputStdin % 2 === 0 && inputStdin > 2) {\n console.log('YES');\n } else console.log('NO');\n });", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "36b0f916660c633acbb465f77607f9c4", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nreadline.on('line',main);\n\nfunction main(line) {\n const str = line.split(' ');\n const n = str[0];\n const m = str[1];\n const a = str[2];\n\n console.log(\n Math.ceil(n / a) * Math.ceil(m / a)\n )\n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "f33f266ba7cc89d6893a41d2275c023e", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nconst teams = () => {\n const n = +input.shift();\n let ar1 = [];\n let ar2 = [];\n let count = 0;\n for (const x of input) {\n let [z,y] = x.split(' ').map(x => +x);\n ar1.push(z);\n ar2.push(y);\n }\n for (const k of ar1) {\n for (const s of ar2) {\n if (k === s) {\n count++\n }\n }\n\n }\n\n console.log(count);\n};\nreadLine.on('close', teams);", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "9c6d0346f2807e003d2e14d36b01d5e6", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction print(s) {\n process.stdout.write(`${s}`);\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n // input\n const n = readline();\n let result = 0;\n let t = [];\n for (let i = 0; i < n; i++) {\n const c = readline().split(' ');\n t.push(c);\n }\n for (let i = 0; i< n; i++) {\n const [h,] = t[i];\n for (let j = 0; j < n; j++) {\n if (j === i) {\n continue;\n }\n const [,a] = t[j];\n if (h === a) {\n result++;\n }\n }\n }\n // output\n print(result);\n}\n\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "42df06a880b0795f9e4becf316595e66", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({input: process.stdin})\nlet lines = [];\nreadline.on(\"line\", line => {\n lines.push(line);\n}).on(\"close\", () => {\n \n let first = lines[0].toLowerCase();\n let second = lines[1].toLowerCase();\n let flag = true;\n \n for (let i = 0; i < lines[0].length; i++) {\n if (first[i] < second[i]) {\n flag = false;\n console.log('-1');\n break;\n } else if (first[i] > second[i]) {\n flag = false;\n console.log('1');\n break;\n }\n }\n \n if (flag) {\n console.log('0');\n }\n\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "525d1a3889051bac9ab73de4e17eeb4b", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar check = function (x, y, z) {\n if (x + y > z && x + z > y && y + z > x)\n return 'T';\n if (x + y == z || x + z == y || y + z == x)\n return 'S';\n\n return 'I';\n}\n\nrl.on('line', (input) => {\n var cont = input.split(' ').map(item=>parseInt(item));\n \n var a = cont[0], b = cont[1], c = cont[2], d = cont[3];\n if (check(a, b, c) == 'T' ||\n check(a, b, d) == 'T' ||\n check(a, d, c) == 'T' ||\n check(d, b, c) == 'T')\n console.log(\"TRIANGLE\")\n else if (check(a, b, c) == 'S' ||\n check(a, b, d) == 'S' ||\n check(a, d, c) == 'S' ||\n check(d, b, c) == 'S')\n console.log(\"SEGMENT\");\n else\n console.log(\"IMPOSSIBLE\");\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["brute force", "geometry"], "code_uid": "1d27b7e5af1eccf450c703d09c695208", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function nextInt() {\n return parseInt(nextString());\n}\n\nfunction nextFloat() {\n return parseFloat(nextString());\n}\n\nlet input_stdin = \"\";\nlet input_cursor = 0;\n\nfunction nextString() {\n let next_string = \"\";\n clearWhitespaces();\n while (input_cursor < input_stdin.length && !isWhitespace(input_stdin[input_cursor])) {\n next_string += input_stdin[input_cursor];\n input_cursor += 1;\n }\n return next_string;\n}\n\nfunction nextChar() {\n clearWhitespaces();\n if (input_cursor < input_stdin.length) {\n return input_stdin[input_cursor++];\n } else {\n return '\\0';\n }\n}\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('ascii');\nprocess.stdin.on('data', function (data) { input_stdin += data; });\nprocess.stdin.on('end', function () { main(); });\n\nfunction isWhitespace(character) {\n return ' \\t\\n\\r\\v'.indexOf(character) > -1;\n}\n\nfunction clearWhitespaces() {\n while (input_cursor < input_stdin.length && isWhitespace(input_stdin[input_cursor])) {\n input_cursor += 1;\n } \n}\n\nfunction main() {\n let x = nextInt();\n if (x % 2 === 1 || x === 2)console.log(\"NO\"); else console.log(\"YES\");\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "8548278da62c7e54f1208531361e7c33", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\nrl.on('line', line => {\n const input = line.split(' ').map(char => Number(char)); // Array of two numbers\n console.log(solution(input[0], input[1]));\n});\n\n// If n % 10 !== 0 (n is not divisible by 10) then n = n - 1 (subtract 1)\n// If n % 10 === 0 (n is divisble by 10) then then n = n / 10 (divide by 10)\n\n// There are k operation\n// [?] Does dividing by 10 count as an operation?\nfunction solution(n, k) {\n let num = n;\n let numberOfOperations = k;\n for (let i = 0; i < numberOfOperations; i ++) {\n if (num % 10 !== 0) {\n num -= 1\n } else {\n num = num / 10;\n }\n }\n\n return num;\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "c7d00191ff8d19038a2aadbc60521706", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\n'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\n\nfunction main() {\n const str1= readline();\n const str2= readline();\n let result =0;\n for (let i=0;i str2[i].toLowerCase()){\n result=1;\n break;\n }\n else if (str1[i].toLowerCase() < str2[i].toLowerCase()){\n result=-1;\n break;\n }\n }\n\n console.log(result);\n return;\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "fefdc68a4c3c7def2adda6e8179e084f", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "readline = require('readline')\nlet stdinInput = '';\n\n// //file\n// var fs = require('fs');\n// const inputfile = '_in.txt';\n// const outputfile = '_out.txt';\n// fs.writeFileSync(outputfile, '');\n// var myInterface = readline.createInterface({\n// input: fs.createReadStream(inputfile),\n// });\n// myInterface.on('line', function (line) {\n// stdinInput += line+'\\n';\n// }).on('close', () => {\n// main(); \n// process.exit(0);\n// })\n /*\n * Api Scanner\n */\n class Scanner {\n constructor() {\n this.index = -1;\n this.lines = stdinInput.trim().split('\\n'); // eslint-disable-line\n }\n \n nextLine() {\n this.index += 1;\n return this.lines[this.index].trim();\n }\n nextArray(fn) {\n const array = this.nextLine().split(' ');\n return fn === String ? array : array.map(fn);\n }\n \n hasNext() {\n return this.index < this.lines.length;\n }\n }\n \n process.stdin.resume();\n process.stdin.setEncoding('utf-8');\n process.stdin.on('data', (input) => { stdinInput += input; });\n process.stdin.on('end', () => { main(); });\n\nvar n;\nfunction main() {\n const is = new Scanner();\n \n // const s = is.nextArray(Number);\n // const t = is.nextArray(Number);\n // // const k = is.nextArray();\n\n n = parseInt(is.nextLine());\n // console.log(n);\n if(kt()==1)\n console.log(\"YES\");\n\t\telse\n console.log(\"NO\");\n }\n \n function kt(){\n for(var i=2; i input.push(line));\n\nreadLine.on('close', () => {\n let [n] = input[0].split(' ').map(x => parseInt(x));\n let prev = 0;\n\n if (n === 1) { console.log(1); return; }\n\n for (let i = 1; i < 1000; i += 1) {\n let sum = (i*(i+1))/2;\n prev += sum;\n\n if (prev > n) {\n console.log(i-1); return;\n }\n }\n}); \n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "cb1a3f424dd266d94eb16b19564e8723", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n \nlet stdinInput = '';\n \nprocess.stdin.on('data', input => {\n stdinInput += input;\n})\n \nprocess.stdin.on('end', () => {\n main(stdinInput);\n})\n \nfunction main(data) {\n data = data.split('\\n');\n let count = 0;\n let idx = 0;\n let i;\n for (i = 0; i < data.length; i += 1) {\n idx = data[i].indexOf(1);\n if (idx >= 0) { \n idx /= 2;\n break;\n }\n }\n count = Math.abs(idx - 2) + Math.abs(i - 2);\n process.stdout.write(count + '');\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "81ac95edccf6056833d9ef3540a0d2f2", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict'\n\nconst {EOL} = require('os')\n\nlet ipt = ''\nprocess.stdin.on('data', s => ipt += s)\nprocess.stdin.on('end', () => {\n const [ils] = ipt.split(EOL).slice(0, -1)\n const [a, b, c, d, e, f] = ils.split(' ')\n\n let r = 1\n let g1, g2\n\n const cast = (r, a, b) => {\n if (a == 0 && b == 0) {\n return 0\n }\n else if (a == 0) {\n return Infinity\n }\n return r / a * b\n }\n\n r = cast(r, a, b)\n r = cast(r, c, d)\n g1 = r\n r = cast(r, e, f)\n r = cast(r, a, b)\n r = cast(r, c, d)\n g2 = r\n\n console.log(g2 == Infinity || g2 > g1 ? 'Ron' : 'Hermione')\n})", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "8489b32a49a858e1c39c3d64e2faba0b", "src_uid": "44d608de3e1447f89070e707ba550150", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nlet total_input = 6;\nlet cur_input = 0;\nlet data = [];\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf8');\nlet inputString = '';\nlet currentLine = 0;\n\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n data_get(inputString);\n});\n\nfunction data_get(data) {\n data = data.trim().split('\\n').map(string => {\n return string.trim();\n });\n data.forEach((d,i) => {\n data[i] = parseInt(d)\n });\n if (data[4] > data[5]){\n s1 = Math.min(data[0],data[3]);\n data[3] -= s1;\n s2 = Math.min(data[1],data[2],data[3]);\n } // tie first\n else {\n s2 = Math.min(Math.min(data[1],data[2]),data[3]);\n data[3] -= s2;\n s1 = Math.min(data[0],data[3]);\n }\n\n console.log(s1* data[4] + s2*data[5])\n}", "lang_cluster": "Javascript", "tags": ["math", "greedy", "brute force"], "code_uid": "56afc3554d42b71bc456e5bbfea685db", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet matrix = [], location = [];\n\nrl.on('line', n => {\n matrix.push(n.split(' ').map(Number));\n if (matrix.length === 5) {\n for (let i = 0; i < matrix.length; i++) {\n if (matrix[i].includes(1)) {\n location.push(i, matrix[i].indexOf(1));\n break;\n }\n }\n\n console.log(Math.abs(location[0] - 2) + Math.abs(location[1] - 2));\n rl.close();\n }\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e82c1b642fc67754fa4ccdcd75415518", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\r\n\r\nvar fs = require('fs');\r\n\r\nfunction _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }\r\n\r\nvar fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);\r\n\r\nfunction solve(read) {\r\n const [rn, rb, rns, re, rbs] = convertInput(read);\r\n const n = rn(),\r\n k = rn();\r\n const MOD = 10 ** 9 + 7;\r\n const f = new Array(n);\r\n f[0] = f[1] = 1;\r\n for (let i = 2; i <= n; i++) {\r\n f[i] = mul(f[i - 1], i);\r\n }\r\n const g = new Array(n);\r\n g[n] = power(f[n], MOD - 2);\r\n g[0] = 1;\r\n for (let i = n; i >= 2; i--) {\r\n g[i - 1] = mul(g[i], i);\r\n }\r\n let res = 0,\r\n max = Math.min(n, k);\r\n for (let i = 0; i <= max; i++) {\r\n res = (res + mul(f[n], g[i], g[n - i])) % MOD;\r\n }\r\n return res;\r\n}\r\nconst MOD = 10 ** 9 + 7;\r\nfunction power(a, b) {\r\n let res = 1;\r\n while (b) {\r\n if (b & 1) res = mul(res, a);\r\n a = mul(a, a);\r\n b = b >> 1;\r\n }\r\n return res;\r\n}\r\nfunction mul(...args) {\r\n if (args.length === 0) throw new Error('参数不能为空');\r\n if (args.length === 1) return args[0];\r\n const [a, b] = args;\r\n if (args.length > 2) return mul(mul(a, b), ...args.slice(2));\r\n return (Math.floor(a / 65536) * b % MOD * 65536 + (a & 65535) * b) % MOD;\r\n}\r\nfunction convertInput(read) {\r\n const rn = () => Number(read());\r\n const rb = () => BigInt(read());\r\n const rns = n => {\r\n let res = new Array(n);\r\n for (let i = 0; i < n; i++) res[i] = rn();\r\n return res;\r\n };\r\n const re = n => {\r\n let res = new Array(n);\r\n for (let i = 0; i < n; i++) res[i] = rn() - 1;\r\n return res;\r\n };\r\n const rbs = n => {\r\n let res = new Array(n);\r\n for (let i = 0; i < n; i++) res[i] = rb();\r\n return res;\r\n };\r\n return [rn, rb, rns, re, rbs];\r\n}\r\nfunction main(r) {\r\n try {\r\n let t = 1;\r\n let res = new Array(t);\r\n let limit = 100;\r\n for (let i = 0; i < t; i++) {\r\n var _solve;\r\n const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';\r\n if (t < limit) {\r\n process.stdout.write(s.toString());\r\n process.stdout.write('\\n');\r\n }\r\n }\r\n if (t >= limit) ; else {\r\n return '';\r\n }\r\n } catch (error) {\r\n console.log(error);\r\n }\r\n}\r\n\r\nconst inputs = fs__default[\"default\"].readFileSync(0, 'utf-8').split(/\\s+/);\r\nvoid function () {\r\n const read = ((i = 0) => () => inputs[i++])();\r\n const output = main(read);\r\n process.stdout.write(output);\r\n}();\r\n", "lang_cluster": "Javascript", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "d8ac29e3a60cc4b4cdcb575ac5087ad4", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet count = 0;\nlet a, b, c;\n\nconst solve = () => {\n let ans = 0;\n let hasFruits = true;\n\n while (hasFruits) {\n a -= 1;\n b -= 2;\n c -= 4;\n\n if (a > -1 && b > -1 & c > -1) {\n ans += 7;\n }\n else {\n hasFruits = false;\n }\n }\n\n console.log(ans);\n};\n\nrl.on('line', (d) => {\n if (count === 0) {\n a = +d;\n }\n else if (count === 1) {\n b = +d;\n }\n else {\n c = +d;\n\n solve();\n }\n\n count++;\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "aee1bb8abaf45e105d1314898ca1e206", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict'\n\nconst {EOL} = require('os')\n\nlet ipt = ''\nprocess.stdin.on('data', s => ipt += s)\nprocess.stdin.on('end', () => {\n let [p1, p2, p3, p4, a, b] = ipt.split(EOL)[0].split(' ').map(v => parseInt(v))\n let c = 0\n for (let i = a; i <= b; i++) {\n i % p4 % p3 % p2 % p1 == i && c++\n }\n\n console.log(c)\n})", "lang_cluster": "Javascript", "tags": ["implementation", "number theory"], "code_uid": "ccd915fc2f46e3dd6492c9f5337897a3", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n const nn = readline();\n var n = nn[0];\n let arr = readline().split(' '); \n n = parseInt(n);\n \n arr = arr.map(ele => parseInt(ele))\n \n console.log(flip(n, arr));\n}\n\n\nfunction flip (n, arr) {\n let total = 0;\n for(let i = 0; i < arr.length; i ++){\n total += arr[i];\n }\n\n let max = 0;\n \n for (let i = 0; i < arr.length; i++) {\n for (let j = arr.length -1; j >= i; j--) {\n let sub = arr.slice(i, j + 1);\n let subSum = 0;\n for(let k = 0; k < sub.length; k++) {\n subSum += sub[k] === 0 ? 1 : -1;\n }\n let subRes = total + subSum;\n max = Math.max(max, subRes);\n }\n }\n return max;\n}", "lang_cluster": "Javascript", "tags": ["brute force", "dp", "implementation"], "code_uid": "deedefe7798860045c722cceac10fd93", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction getArray(str) {\n return str.split(' ').map(x => Number(x));\n}\n\nfunction getInt(str) {\n return Number(str);\n}\n\nfunction getStrArray(str) {\n return str.split(' ').map(x => x);\n}\n// ---------------------------------------\n\n\n\nfunction main() {\n let t = getInt(readline());\n let dp = [];\n dp[0] = 1;\n dp[1] = 0;\n for(let i=2; i<=t; i++) {\n dp[i] = 2* dp[i-2];\n }\n console.log(dp[t]);\n}", "lang_cluster": "Javascript", "tags": ["math", "dp"], "code_uid": "ec35c22d613ae7db2ed0c5122dd664fa", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadline.on('line', line => input.push(line));\n\nreadline.on('close', () => {\n const [word, drow] = input;\n if (word == drow.split('').reverse().join('')) console.log('YES');\n else console.log('NO');\n})", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "0257fbd4101e56b3b5e7249b5777b083", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "var n = parseInt(readline());\nvar arr = readline().split(' ').map(Number);\n\nvar max = arrayMax(arr);\nvar min = arrayMin(arr);\n\nvar startIndex = 0;\nvar endIndex = 0;\n\n\tvar startCounting = false;\n\n\tfor (var i = 0; i < n; i++) {\n\t\tif ((arr[i] == max || arr[i] == min) && !startCounting)\n\t\t{\n\t\t\tstartCounting = true;\n\t\t\tstartIndex = i;\n\t\t\ti++;\n\t\t}\n\t\tif ((arr[i] == max || arr[i] == min) && startCounting)\n\t\t{\n\n\t\t\tstartCounting = false;\n\t\t\tendIndex = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\nvar maxarr = [];\nmaxarr.push(endIndex - startIndex);\nmaxarr.push(endIndex);\nmaxarr.push(startIndex);\nmaxarr.push(arr.length - 1 - startIndex);\nmaxarr.push(arr.length - 1 - endIndex);\n\nfunction arrayMin(array) {\n var len = array.length, min = Infinity;\n while (len--) {\n if (array[len] < min) {\n min = array[len];\n }\n }\n return min;\n};\n\nfunction arrayMax(array) {\n var len = array.length, max = -Infinity;\n while (len--) {\n if (array[len] > max) {\n max = array[len];\n }\n }\n return max;\n};\n\nprint(arrayMax(maxarr));", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation"], "code_uid": "74c9798b59c0a293b6f13bd451fe02ab", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n readline();\n let s = readline();\n let n = 0;\n for (let i = 0 , c = s.length -1 ; i {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let firstNumberString = readLine();\n let secondNumberString = readLine();\n let finalStringArray = [];\n for (let i = 0; i < firstNumberString.length; i++) {\n if (firstNumberString[i] !== secondNumberString[i]) {\n finalStringArray.push('1');\n } else {\n finalStringArray.push('0');\n }\n }\n let finalString = finalStringArray.map(Number);\n let finalNumber = finalString.join('');\n console.log(finalNumber);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0fae4575fc150eb1dad2b6102710a296", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Nearly Lucky Number\n\nconst {EOL} = require('os');\n\nlet inp = '';\n\nprocess.stdin.on('data', c => inp += c);\n\nprocess.stdin.on('end', () => {\n let lines = inp.split(EOL)[0].trim();\n\n let count = 0;\n for(let i in lines) {\n \tif((lines[i] == '4') || (lines[i] == '7')) {\n \t\tcount++;\n \t}\n }\n\n count += '';\n for(let i in count) {\n \tif(!((count[i] == '4') || (count[i] == '7'))) {\n \t\tprocess.stdout.write(\"NO\");\n \t\treturn;\n \t}\n }\n\n process.stdout.write(\"YES\");\n return;\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "c710655e82e3eff34a600bd59663c65c", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nfunction main() {\n const is = new Scanner();\n const [n, m] = is.nextArray().map(Number);\n const word = is.nextLine().split('');\n word.forEach((item, index, array) => {\n array[index] = item.charCodeAt() - 'a'.charCodeAt() + 1;\n });\n word.sort((a, b) => a - b);\n\n let answer = word[0];\n let pre = 0;\n let number = 1;\n for (let i = 1; i < n; i += 1) {\n if (number === m)\n break;\n if (word[i] - word[pre] >= 2) {\n answer += word[i];\n pre = i;\n number += 1;\n }\n }\n\n console.log(number !== m ? -1 : answer);\n}\n\n/*\n * Api Scanner\n */\n\nclass Scanner {\n constructor() {\n this.index = 0;\n this.lines = stdinInput.trim().split('\\n'); // eslint-disable-line\n }\n\n nextLine() {\n return this.lines[this.index++]; // eslint-disable-line\n }\n\n nextInt() {\n return parseInt(this.nextLine(), 10);\n }\n\n nextDouble() {\n return parseFloat(this.nextLine());\n }\n\n nextArray() {\n return this.nextLine().split(' ');\n }\n\n hasNext() {\n return this.index < this.lines.length;\n }\n}\n\nlet stdinInput = '';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nprocess.stdin.on('data', (input) => { stdinInput += input; });\nprocess.stdin.on('end', () => { main(); });\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "934a835d57f83f78c518ed9287499c20", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nconst f1 = (a, b, c) => a**2 + b === c;\nconst f2 = (a, b, c) => a + b**2 === c;\n\nrl.on('line', (d) => {\n const [n, m] = d.split(' ').map(Number);\n let ans = 0;\n\n for (let i = 0; i <= n; i++) {\n for (let j = 0; j <= m; j++) {\n if (f1(i, j, n) && f2(i, j, m)) {\n ans++;\n }\n }\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "a265ab7cbb63a78abb9ab1d5796f0250", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n \nreadLine.on('close', () => {\n let [a, b] = input[0].split(' ').map(x => +x);\n let k = 0;\n while (a <= b) {\n a *= 3;\n b *= 2;\n k++;\n }\n console.log(k);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "d62717fb70c0c83e1f769e609b4a7c8d", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n↑入力 ↓出力');\n Main();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var one = nextIntArray();\n var s = one[0];\n var v1 = one[1];\n var v2 = one[2];\n var t1 = one[3];\n var t2 = one[4];\n var L = t1 * 2 + v1 * s;\n var R = t2 * 2 + v2 * s;\n if(L < R){\n myout(\"First\");\n }else if(L > R){\n myout(\"Second\");\n }else{\n myout(\"Friendship\");\n }\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "43d8a6075c9beb199b16a98d7640dcbb", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nlet a, b, c;\nrl.on('line', (line) => {\n [a, b, c] = line.split(' ').map(i => parseInt(i));\n}).on('close', () => {\n process.stdout.write(\"\" + Math.ceil(a / c) * Math.ceil(b / c));\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "6079f6342faec36f124e0a9bf243e2e9", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = ''\nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os')\n const lines = i.split(EOL) /*your input text, split by lines*/\n \n function process(str) {\n str = str.toLowerCase();\n var arr = str.split(\"\");\nvar value = \"i\";\n var value2 = \"a\";\n var value3 = \"u\";\n var value4 = \"o\";\n var value5 = \"y\";\n var value6 = \"e\";\n arr = arr.filter(function(item) {\n return (item !== value && item!== value2 && item!== value3 && item!== value4 && item!== value5 && item!== value6);\n \n});\n \n \n arr.forEach(function(element,index,array) {\n array[index] = \".\" + element;\n })\n \n var newString = arr.join(\"\");\n console.log(newString);\n \n \n \n \n \n }\n \nprocess(lines[0]);\n \n \n})", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "eddacbc29ac54a0b3ce2108825404739", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on(\"line\", (answer) => {\n\trl.close();\n\tconsole.log(/[HQ9]/g.test(answer) ? \"YES\" : \"NO\");\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "b47c7e5e3b021842c8631e16e4491e9d", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nlet input = [];\nlet readline=require('readline');\nlet RL=readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nlet TC=RL.on('line', (line)=>{\n input.push(line.trim());\n});\nRL.on('close', ()=>{\n let [n, m, a] = input[0].split(\" \");\n let row=Math.ceil(parseInt(n)/parseInt(a));\n let col=Math.ceil(parseInt(m)/parseInt(a));\n\n console.log(row*col);\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "fcc44f5a8b6e78b67782371033629909", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// readline = require('readline')\nlet stdinInput = '';\n\n// //file\n// var fs = require('fs');\n// const inputfile = '_in.txt';\n// const outputfile = '_out.txt';\n// fs.writeFileSync(outputfile, '');\n// var myInterface = readline.createInterface({\n// input: fs.createReadStream(inputfile),\n// });\n// myInterface.on('line', function (line) {\n// stdinInput += line+'\\n';\n// }).on('close', () => {\n// main(); \n// process.exit(0);\n// })\n /*\n * Api Scanner\n */\n class Scanner {\n constructor() {\n this.index = -1;\n this.lines = stdinInput.trim().split('\\n'); // eslint-disable-line\n }\n \n nextLine() {\n this.index += 1;\n return this.lines[this.index].trim();\n }\n nextArray(fn) {\n const array = this.nextLine().split(' ');\n return fn === String ? array : array.map(fn);\n }\n \n hasNext() {\n return this.index < this.lines.length;\n }\n }\n \n process.stdin.resume();\n process.stdin.setEncoding('utf-8');\n process.stdin.on('data', (input) => { stdinInput += input; });\n process.stdin.on('end', () => { main(); });\n\nvar n;\nfunction main() {\n const is = new Scanner();\n \n // const s = is.nextArray(Number);\n // const t = is.nextArray(Number);\n // // const k = is.nextArray();\n\n n = parseInt(is.nextLine());\n // console.log(n);\n\n\n if(kt()==1)\n console.log(\"YES\");\n\t\telse\n console.log(\"NO\");\n }\n \n function kt(){\n for(var i=2; i input.push(line));\n\nreadLine.on('close', () => {\n let row = 0;\n let col = 0;\n input.forEach((item, index) => {\n const findOne = item.split(' ')\n const findCol = findOne.indexOf('1')\n if (findCol !== -1) {\n col = findCol + 1\n row = index + 1\n }\n })\n let _result = 0\n let _difRow = 0\n if (row !== 3) {\n if (row > 3)\n _difRow = row - 3\n else if (row < 3)\n _difRow = 3 - row\n }\n let _difCol = 0\n if (col !== 3) {\n if (col > 3)\n _difCol = col - 3\n else if (col < 3)\n _difCol = 3 - col\n }\n _result = _difRow + _difCol\n console.log(_result)\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "65c5a2a007d85a0c6a4ca562ad862e53", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout,\n\tterminal: false\n});\n\nrl.on('line', line => {\n\tconst [n, m] = line.split(' ').map(i => parseInt(i));\n\tconsole.log(Math.floor(n * m / 2));\n\trl.close();\n});\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "cd93e50e47d486b5736cce0e38816f7d", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\nreadline.question(\"\", (a) => {\n readline.question(\"\", (b) => {\n readline.question(\"\", (c) => {\n a=parseInt(a)\n b=parseInt(b)\n c=parseInt(c)\n console.log(Math.max(a + b + c, a + b * c, (a + b) * c, a * b + c, a * (b + c), a * b * c))\n readline.close();\n })\n })\n})", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "743edb2007dd3b9fcd9da83b43ccd624", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet count = 0;\nlet friends = [];\nlet grapes = [];\n\nrl.on('line', (d) => {\n if (count === 0) {\n friends = d.split(' ').map(Number);\n }\n else {\n grapes = d.split(' ').map(Number);\n }\n\n count++;\n});\n\nrl.on('close', () => {\n let ans = 'YES';\n\n let [x, y, z] = friends;\n let [a, b, c] = grapes;\n\n a -= x;\n\n if (a < 0) {\n ans = 'NO';\n }\n\n let temp = (a + b) - y;\n\n if (temp < 0) {\n ans = 'NO';\n }\n\n temp += c;\n\n if (temp - z < 0) {\n ans = 'NO';\n }\n\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "greedy", "implementation"], "code_uid": "b626a4f129eb579a54f45496d1eb2ae7", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n');\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr('time : ' + end + 'ms');\n myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var one = nextIntArray();\n var min = Math.min(one[0], one[1]);\n var output = 1;\n for(var i = 1; i <= min; i++){\n output *= i;\n }\n myout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation", "number theory"], "code_uid": "c9452e098008faa7c65f5c76bbdf5127", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const str = readLine();\n let [count0, count1] = [0, 0];\n let [max0, max1] = [0, 0];\n\n for (let i = 0; i < str.length; i++) {\n const num = +str[i];\n\n if (num === 0) {\n count0++;\n max1 = Math.max(count1, max1);\n max0 = Math.max(count0, max0);\n count1 = 0;\n } else {\n count1++;\n max1 = Math.max(count1, max1);\n max0 = Math.max(count0, max0);\n count0 = 0;\n }\n }\n if (max0 >= 7 || max1 >= 7) console.log(\"YES\");\n else console.log(\"NO\");\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "d95275a880386af64afcc575999942d8", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n// utils\nconst MOD = 1e9 + 7;\nconst mod = (n) => ((n % MOD) + MOD) % MOD;\nconst add = (a, b) => mod(mod(a) + mod(b));\nfunction mul() {\n for (var a = arguments, r = a[0], i = a.length; --i; )\n r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;\n return r;\n}\nfunction inv(b) {\n for (var a = MOD, u = 0, v = 1, t; b; v = t)\n (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);\n u %= MOD;\n return u < 0 ? u + MOD : u;\n}\n\nfunction main() {\n const n = +readLine();\n\n function countAlmostPrimes(n) {\n const primes = getAllPrimesUpto(n);\n let almostPrimeCount = 0;\n\n for (let i = 1; i <= n; i++) {\n let count = 0;\n let j = 0;\n while (primes[j] < i && j < n) {\n if (i % primes[j] === 0) count++;\n j++;\n }\n if (count === 2) almostPrimeCount++;\n }\n return almostPrimeCount;\n }\n\n console.log(countAlmostPrimes(n));\n}\n\nfunction getAllPrimesUpto(n) {\n const primes = [];\n for (let i = 2; i <= n; i++) {\n let isPrime = true;\n for (let j = 2; j <= Math.floor(Math.sqrt(i)); j++) {\n if (i % j === 0) {\n isPrime = false;\n break;\n }\n }\n if (isPrime) primes.push(i);\n }\n\n return primes;\n}\n", "lang_cluster": "Javascript", "tags": ["number theory"], "code_uid": "1e2014c2df395f3c3d6efc3c5b72dcac", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.setEncoding('utf8');\nprocess.stdin.on('readable',()=>{\n let input = process.stdin.read();\n if(input){\n input = input.toString().trim();\n let startValue = +input.split(\" \")[0];\n let iterations = +input.split(\" \")[1];\n\n for(let i = 0; i < iterations; i++){\n if(startValue % 10 === 0){\n startValue /= 10;\n }else{\n startValue-=1;\n }\n }\n process.stdout.write(startValue.toString());\n}\n})\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "61955a7a12872d6ba8fdc29164046be1", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nlet y = 1;\n\nrl.on('line', (m) => {\n let x = m.split(' ').map(Number).indexOf(1);\n\n if (x !== -1) {\n console.log(Math.abs(x + 1 - 3) + Math.abs(y - 3));\n }\n\n y++;\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "7049c6d7101245d9cfb96456bf3203e6", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// 479A - Expression\n// http://codeforces.com/problemset/problem/479/A\n\nfunction main() {\n let a = [];\n for (let i = 0; i < 3; i++) {\n a.push(parseInt(read()));\n }\n writeline(Math.max(\n a[0] + a[1] + a[2],\n a[0] * (a[1] + a[2]),\n (a[0] + a[1]) * a[2],\n a[0] * a[1] * a[2]));\n return 0;\n}\n\nvar input = \"\";\nvar read;\nvar writeline = (x) => process.stdout.write(x + \"\\n\");\nvar write = (x) => process.stdout.write(x);\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf8\");\nprocess.stdin.on(\"data\", (chunk) => input += chunk);\nprocess.stdin.on(\"end\", () => {\n input = input.trim().split(/\\s+/);\n read = () => input.shift();\n process.exit(main() || 0);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "92242b7799da09ad6cd183db5123df58", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\n\nvar myArr = [];\n\nrl.on('line', function (input) {\n myArr = input.split(' ').map(item => {return parseInt(item);});\n\n /*for (var i = 0; i < myArr.length; i++)\n console.log(myArr[i]);*/\n /* myArr.forEach(element => {\n console.log(\"element = \" + element + \" type of = \" + typeof(element));\n });\n*/\nvar n = myArr[0];\nvar m = myArr[1];\nvar a = myArr[2];\nvar x = !(m%a) ? m/a : parseInt((m/a).toFixed(2))+1;\nvar y = !(n%a) ? n/a : parseInt((n/a).toFixed(2))+1;\n\n\nconsole.log(x*y);\n\n\n rl.close();\n})\n\n\n\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "c29d5e49276f5ac5f5365c1f7b18e1ed", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "var line = readline().split(\" \"),\n digits = [],\n a = line[0],\n count = a.length,\n maxDigit = count-1, // крайнее число с которого надо начать\n countD = 0,\n newLine = a.split(\"\"); \n\n\nfunction sumDigits(number) {\n var s = 0;\n for (var c in number) {\n s += +number[c];\n }\n return s;\n};\n\ndigits.push(a);\nwhile (countD < count) {\n for (var i = 0; i < count; i++) { \n newLine[maxDigit] = 9; // заменили на 9 текущую 48 -> 49\n countD++; // счётчик девяток\n newLine[(maxDigit-1)] = (new Number(newLine[maxDigit - 1]) > 0 ? --newLine[maxDigit - 1] : 0); // 49 -> 39\n --maxDigit; // перешли от крайнего числа к следующему с края\n var n = newLine.join(\"\");\n (n <= line ? digits.push(n.replace(/^0+/img, \"\")) : \"\");\n }\n}\n\nvar max = sumDigits(digits[0]), maxValue = digits[0];\nfor (var i = 1, l = digits.length; i < l; ++i) {\n var item = sumDigits(digits[i]);\n if (max < item) {\n max = item;\n \n maxValue = digits[i];\n }\n}\n\nprint(maxValue);", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "9c34d68476560cfb2fca4c89b9282adb", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString='';\nlet currentLine=0;\nprocess.stdin.on('data',inputStdin=>{\n inputString+=inputStdin;\n});\nprocess.stdin.on('end',_=>{\n inputString=inputString.trim().split(\"\\n\").map(string=>{\n return string.trim();\n });\n main();\n});\nfunction readLine()\n{\n return inputString[currentLine++]; \n}\n\nfunction main()\n{\n const [n,k]=readLine().trim().split(' ').map(a=>{return +(a.trim());});\n let arr=readLine().trim().split(' ').map(a=>{return +(a.trim());});\n let ans=0;\n for(let i=0;ik)\n {\n break;\n }\n ans++;\n if(i==n-1)\n {\n console.log(ans);\n return;\n }\n }\n for(let i=n-1;i>=0;--i)\n {\n if(arr[i]>k)\n {\n break;\n }\n ans++;\n }\n console.log(ans);\n}", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "d3b6b461d5d6934684e6518434e4bcb0", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Ultra-Fast Mathematician\n\nconst {EOL} = require('os');\n\nlet inp = '';\n\nprocess.stdin.on('data', c => inp += c);\n\nprocess.stdin.on('end', () => {\n let lines = inp.split(EOL);\n \n for(let i = 0; i < lines[0].length; i++) {\n \tprocess.stdout.write((lines[0][i] == lines[1][i]) ? '0' : '1');\n }\n\n return;\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f4d992be32ff560d4691e8df0938bdc0", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n \nconst input = [];\nreadLine.on('line', line => input.push(line));\n \nreadLine.on('close', () => {\n let [_num, _del] = input[0].split(' ')\n for (let i = 0; i < _del; i++) {\n if (_num % 10 === 0) {\n _num = _num / 10\n } else {\n _num -= 1;\n }\n }\n console.log(_num)\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "7488b8c43699764e11c75315f8c5fe38", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', (input) => {\n rl.close();\n console.log(solve(input));\n});\n\n\nconst solve = (equation) => {\n let res = '';\n let onesCounter = 0;\n let twosCounter = 0;\n let threesCounter = 0;\n\n for (let i = 0; i < equation.length; i++) {\n if (equation[i] === '1') onesCounter++;\n else if (equation[i] === '2') twosCounter++;\n else if (equation[i] === '3') threesCounter++;\n }\n\n while (onesCounter != 0) {\n res += '1+'\n onesCounter--;\n }\n\n while (twosCounter != 0) {\n res += '2+'\n twosCounter--;\n }\n\n while (threesCounter != 0) {\n res += '3+'\n threesCounter--;\n }\n\n if (res[res.length - 1] === '+') return res.slice(0, res.length - 1);\n else return res;\n}", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "95257a000cecb484a100fe31badd2ae3", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n let nums = input[0].split(' ').map(x => parseInt(x));\n nums.sort((a, b) => a - b);\n console.log( Math.abs(nums[1]-nums[0]) + Math.abs(nums[2]-nums[1]) );\n}); \n", "lang_cluster": "Javascript", "tags": ["math", "sortings", "implementation"], "code_uid": "2aaab4fb155d8a3d6ebfb8c0f90015d8", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nconst horseShoe = () => {\n let ar = input[0].split(' ');\n let ar2 = new Set(ar);\n\n console.log(4 - ar2.size);\n};\n\n\nreadLine.on('close', horseShoe);", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "af6cb78cc3235ecbc2539427743d36a4", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\nrl.on('line', (line) => {\n const x = Number(line);\n const r = x % 5;\n const q = (x - r) / 5;\n const z = r ? 1 : 0;\n console.log(q + z);\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "b9ed836dfba3dc1c547b0617450dae74", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nconst gcd = (a, b) => {\n if(b === 0) {\n return a;\n }\n\n return gcd(b, a % b);\n}\n\nrl.on('line', (d) => {\n const n = +d;\n let a, b;\n\n if (n % 2 === 1) {\n a = Math.floor(n / 2);\n b = Math.ceil(n / 2);\n }\n else {\n const mid = n / 2;\n a = mid - 1;\n b = mid + 1;\n }\n\n while (gcd(a, b) !== 1) {\n a--;\n b++;\n }\n\n console.log(a, b);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "f14cd28dee55b151e02003ef9b3b9fa5", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nconst isPalindrome = (s) => {\n return s === [...s].reverse().join('');\n}\n\nconst getLexicalLarger = (a, b) => {\n const arr = [a, b];\n const [r] = arr.sort().reverse();\n\n return r;\n}\n\nrl.on('line', (str) => {\n let best = '';\n const len = 2 ** str.length;\n\n for (let i = 0; i < len; i++) {\n const seq = i.toString(2).padStart(str.length, 0);\n let curr = '';\n\n for (let j = 0; j < seq.length; j++) {\n if (seq[j] === '1') {\n curr += str[j];\n }\n }\n\n if (isPalindrome(curr)) {\n best = getLexicalLarger(best, curr);\n }\n }\n\n console.log(best);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "binary search", "bitmasks", "greedy", "strings", "implementation"], "code_uid": "01a1c360fc4713cdf27fc1b56479b910", "src_uid": "9a40e9b122962a1f83b74ddee6246a40", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n');\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr('time : ' + end + 'ms');\n myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var N = nextInt();\n var s = next();\n var output = \"\";\n var count = 1;\n var index = 0;\n while(index < N){\n \toutput += s[index];\n \tindex += count;\n \tcount++;\n }\n myout(output);\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e3276b7f45b90ec8a42b4193c922d4e2", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.setEncoding('ASCII');\n\nlet string = '';\nprocess.stdin.on('data', (data) => string += data);\n\nprocess.stdin.on('end', () => {\n const array = string.trim().split('\\n');\n const line = array[0].split(' ').map(Number);\n\n let n = line[0], d = line[1];\n let cost = array[1].split(' ').map(Number);\n let visitors = Number(array[2]);\n\n cost.sort((a, b) => a - b);\n \n let profit = 0;\n for (let i = 0; i < cost.length; ++i) {\n if (visitors == 0) break;\n profit += cost[i];\n visitors--;\n }\n\n profit -= (visitors * d);\n console.log(profit);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e4a4963bbd6326bc85f91c5c9f053399", "src_uid": "5c21e2dd658825580522af525142397d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var dataitr;\r\nvar stdin_input = \"\";\r\nprocess.stdin.resume();\r\nprocess.stdin.setEncoding(\"ascii\");\r\nprocess.stdin.on(\"data\", function (input) { stdin_input += input; });\r\nprocess.stdin.on(\"end\", function () { dataitr = stdin_input.split('\\n').values(); main(); });\r\n\r\nconst rl = () => dataitr.next().value.trim();\r\nconst rn = () => Number(rl());\r\nconst ra = () => rl().split(' ');\r\nconst rna = () => ra().map(x => Number(x));\r\n\r\nfunction main () {\r\n\tlet T = rn();\r\n\twhile (T--) {\r\n\t\tconst n = rn();\r\n\r\n\t\tconst s = new Set();\r\n\t\tfor (let i = 1; i*i <= n; i++)\r\n\t\t\ts.add(i*i);\r\n\r\n\t\tfor (let i = 1; i*i*i <= n; i++)\r\n\t\t\ts.add(i*i*i);\r\n\r\n\t\tconsole.log(s.size);\r\n\t}\r\n}\r\n\r\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "7cd3580ec5aea8948e22594a431e1197", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nlet input = [];\n\nrl.on(\"line\", (line) => {\n input.push(line);\n});\n\nrl.on(\"close\", () => {\n console.log(solution(input[0].split(\" \"), input[1]));\n});\n\nconst solution = ([n, k], numbers) => {\n let res = 0;\n numbers = numbers.split(\" \").map((num) => parseInt(num));\n n = parseInt(n);\n k = parseInt(k);\n for (let i = 0; i < n; i++) {\n if (numbers[i] >= numbers[k-1] && numbers[i] > 0) {\n res += 1;\n } else {\n break;\n }\n }\n return res;\n};\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "35a7ba409135c5a65ea9f1bf00699ec3", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () =>\n{\n // const nums = input[1].split(' ').map(x => parseInt(x));\n\n let myString = input[0];\n\n const dis = function (s)\n {\n let arr = new Set()\n\n for (let i = 0; i < s.length; i++)\n {\n\n for (let j = 0; j < s.length; j++)\n {\n if (s[i] == s[j] && i != j)\n {\n\n arr.add(s[j])\n break\n }\n\n\n\n\n }\n }\n return arr\n }\n\n\n let count=0\n\n let mySet = dis(myString)\n\n for (let i = 0; i < myString.length; i++) {\n if (!mySet.has(myString[i])) {\n count++\n }\n \n }\n count= count + mySet.size\n if (count%2==0) {\n console.log('CHAT WITH HER!');\n \n }else {\n console.log('IGNORE HIM!')\n }\n\n});", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "562541e0195d4a028db94f4583faa855", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet inputString = \"\";\nlet currentLine = 0;\n\nprocess.stdin.on(\"data\", (inputStdin) => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((string) => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n const x = readline();\n\n fn(x);\n}\n\nfunction fn(str) {\n let upperCaseCount = 0;\n let lowerCaseCount = 0;\n\n for (let char of str) {\n if (/[A-Z]/.test(char)) {\n upperCaseCount++;\n } else {\n lowerCaseCount++;\n }\n }\n\n console.log(\n upperCaseCount > lowerCaseCount ? str.toUpperCase() : str.toLowerCase()\n );\n\n return upperCaseCount > lowerCaseCount\n ? str.toUpperCase()\n : str.toLowerCase();\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "4594971c826ac65ffdd7b8b88951c843", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var line_number = 0;\nconst cs = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nvar lines = {};\ncs.on(\"line\", (input) => {\n if (input == \"\") {\n cs.close();\n }\n lines[line_number] = input.split(\" \");\n line_number += 1;\n}).on(\"close\", () => {\n main();\n process.exit();\n});\n\nfunction isOp(str) {\n return str.length === 1 && str.match(/[<=>]/);\n}\nfunction isChr(str) {\n return str.length === 1 && str.match(/[a-z]/i);\n}\nfunction isInt(str) {\n return str.length === 1 && !isNaN(str);\n}\n\nfunction print(str) {\n console.log(str);\n}\n\nfunction exit(status=0) {\n process.exit(status);\n}\n\nfunction predict(test) {\n let op = \"\";\n let ops = [];\n let opVariables = [];\n let limits = [];\n for (let t of test) {\n // console.log(t);\n for (let i = 0; i < t.length; i++) {\n if (isOp(t[i])) {\n op = t[i];\n if (isOp(t[i + 1])) {\n op += t[i + 1];\n i += 1;\n }\n ops.push(op);\n op = \"\";\n } else if (isChr(t[i])) {\n // console.log(t[i])\n op = t[i];\n for (var j = i + 1; j < t.length; j++) {\n if (isChr(t[j]) || isInt(t[j])) {\n op += t[j];\n i = j;\n } else break;\n }\n opVariables.push(op);\n op = \"\";\n } else {\n if (i == 0 || (i > 0 && isOp(t[i - 1]))) {\n op = t[i];\n let j = i + 1;\n for (; j < t.length; j++) {\n if (isInt(t[j])) {\n op += t[j];\n i = j;\n } else break;\n }\n limits.push(op);\n op = \"\";\n }\n }\n }\n }\n\n let min = limits[0];\n let max = limits[1];\n\n let pvs = ops.map((o, i) => [o, opVariables[i]]);\n\n for (let pv of pvs) {\n if (pv[1] == undefined) {\n pv[1] = max;\n }\n // print(`${min} ${pv[0]} ${pv[1]} ?`)\n if (eval(`${min}${pv[0]}${pv[1]}`)) {\n // print(` ${min} ${pv[0]} ${pv[1]} true`)\n min = pv[1];\n } else {\n print(\"input error\");\n process.exit();\n }\n }\n}\n\nvar n;\nfunction main() {\n for(let r = 0; r < 15; r++) {\n for(let c = 0; c < 15; c++) {\n if (lines[r][c] === '1') {\n print(Math.abs(3-1-r)+Math.abs(3-1-c))\n exit()\n }\n }\n }\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "7913c964afbd2cedcddfe7cf15481613", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n var [n, k] = readLine().split(\" \").map(Number);\n for (let i = 0; i < k; i++) {\n if (n % 10 === 0) {\n n = n / 10;\n } else {\n n = n - 1;\n }\n }\n console.log(n);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "1758ce2157532d1088fa60d56ca5c598", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "function ProblemSolver() {\n this.HAS_TEST_CASES = false ;\n this.INPUT_FILE_NAME = \"sample.in\" ;\n this.OUTPUT_FILE_NAME = \"sample.out\" ;\n this.DO_OUTPUT_TO_FILE = false ;\n this.CLEAR_ARRAY_PER_CASE = false ;\n\n this.solveCase = function() {\n var res , i , j , fl , cn , a , b , c ;\n res = 26 ;\n cn = this.s.length ;\n for( i = 0 ; i < cn ; i++ ) {\n res += 25 ;\n }\n print( res ) ;\n } ;\n\n this.init = function() {\n this.lim1 = 100010 ;\n this.lim2 = 110 ;\n this.cc = 1 ;\n this.ind = 1 ;\n this.n = 0 ;\n this.cn = 0 ;\n this.declareAndFillArrays() ;\n } ;\n\n this.getInput = function( irObj ) {\n var hasMoreInput , i ;\n hasMoreInput = true ;\n try {\n this.s = irObj.nextString() ;\n }\n catch( ex ) {\n hasMoreInput = false ;\n }\n return hasMoreInput ;\n } ;\n\n this.clearArraysPerCase = function() {\n var i ;\n this.arr = new Array() ;\n this.adjList = new Array() ;\n for( i = 0 ; i < this.lim1 ; i++ ) {\n this.arr.push( 0 ) ;\n this.adjList.push( new Array() ) ;\n }\n } ;\n\n this.clearPerCase = function() {\n this.cn = 0 ;\n this.cc++ ;\n if( this.CLEAR_ARRAY_PER_CASE == true ) {\n this.clearArraysPerCase() ;\n }\n } ;\n\n this.declareAndFillArrays = function() {\n var i , j ;\n this.srr = new Array() ;\n this.vis = new Array() ;\n this.arr = new Array() ;\n this.brr = new Array() ;\n this.memo = new Array() ;\n this.done = new Array() ;\n this.adjList = new Array() ;\n for( i = 0 ; i < this.lim1 ; i++ ) {\n this.srr.push( '' ) ;\n this.vis.push( 0 ) ;\n this.arr.push( 0 ) ;\n this.brr.push( 0 ) ;\n this.adjList.push( new Array() ) ;\n }\n for( i = 0 ; i < this.lim2 ; i++ ) {\n this.memo.push( new Array() ) ;\n this.done.push( new Array() ) ;\n for( j = 0 ; j < this.lim2 ; j++ ) {\n this.memo[ i ].push( -1 ) ;\n this.done[ i ].push( 0 ) ;\n }\n }\n } ;\n\n this.init() ;\n}\n\nfunction InputReader() {\n var self = this ;\n this.allLines = new Array() ;\n this.currrentLineNumber = 0 ;\n this.currrentCharacterIndex = 0 ;\n this.callBackFunction = null ;\n this.parentContext = null ;\n\n this.readAllLines = function() {\n var singleLine ;\n while( true ) {\n try {\n singleLine = readline() ;\n if( singleLine == null ) {\n break ;\n }\n }\n catch( ex ) {\n break ;\n }\n this.allLines.push( singleLine ) ;\n }\n } ;\n\n this.readAllLinesFromRhino = function() {\n var brObj , line ;\n importPackage( java.io ) ;\n importPackage( java.lang ) ;\n brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;\n this.allLines = [] ;\n while( true ) {\n line = brObj.readLine() ;\n if( line == null ) {\n break;\n }\n this.allLines.push( line ) ;\n }\n } ;\n\n this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {\n self.chunkData += chunk ;\n } ;\n\n this.readEndFromNodeJsJudgeServer = function() {\n self.parseRawData( self.chunkData ) ;\n self.parentContext.runCases() ;\n } ;\n\n this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {\n this.parentContext = parentContext ;\n process.stdin.resume() ;\n process.stdin.setEncoding( 'utf8' ) ;\n this.chunkData = '' ;\n process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;\n process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;\n } ;\n\n this.parseRawData = function( data ) {\n var len , i , currentString ;\n len = data.length ;\n currentString = '' ;\n this.allLines = [] ;\n for( i = 0 ; i < len ; i++ ) {\n if( data[ i ] == '\\r' ) {\n }\n else if( data[ i ] == '\\n' ) {\n this.allLines.push( currentString ) ;\n currentString = '' ;\n }\n else {\n currentString += data[ i ] ;\n }\n }\n if( currentString != '' ) {\n this.allLines.push( currentString ) ;\n }\n } ;\n\n this.readAllLinesFromFile = function( inputFileName ) {\n var currentDirectory , fsObj , inputFilePath , rawData ;\n fsObj = require( 'fs' ) ;\n currentDirectory = __dirname ;\n if( currentDirectory.indexOf( 'D:' ) != -1 ) {\n //on windows\n inputFilePath = currentDirectory + '\\\\' + inputFileName ;\n }\n else {\n //on linux\n inputFilePath = currentDirectory + '/' + inputFileName ;\n }\n rawData = fsObj.readFileSync( inputFilePath , \"utf8\" ) ;\n this.parseRawData( rawData ) ;\n } ;\n\n this.next = function( flag ) {\n var len , i , startIdx , res , endIdx ;\n if( flag == 0 ) {\n if( this.currrentCharacterIndex != 0 ) {\n this.currrentLineNumber++ ;\n this.currrentCharacterIndex = 0 ;\n }\n res = '' ;\n len = this.allLines[ this.currrentLineNumber ].length ;\n if( typeof( len ) == 'function' ) {\n len = this.allLines[ this.currrentLineNumber ].length() ;\n }\n for( i = this.currrentCharacterIndex ; i < len ; i++ ) {\n res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;\n }\n this.currrentLineNumber++ ;\n this.currrentCharacterIndex = 0 ;\n return res ;\n }\n while( true ) {\n if( this.currrentLineNumber >= this.allLines.length ) {\n throw new Error( 'No more tokens available!' ) ;\n }\n startIdx = -1 ;\n len = this.allLines[ this.currrentLineNumber ].length ;\n if( typeof( len ) == 'function' ) {\n len = this.allLines[ this.currrentLineNumber ].length() ;\n }\n for( i = this.currrentCharacterIndex ; i < len ; i++ ) {\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {\n startIdx = i ;\n break ;\n }\n }\n if( startIdx == -1 ) {\n this.currrentLineNumber++ ;\n this.currrentCharacterIndex = 0 ;\n continue ;\n }\n res = '' ;\n endIdx = len - 1 ;\n for( i = startIdx ; i < len ; i++ ) {\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {\n endIdx = i ;\n break ;\n }\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {\n res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;\n }\n else {\n res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;\n }\n }\n this.currrentCharacterIndex = endIdx ;\n if( endIdx == len - 1 ) {\n this.currrentLineNumber++ ;\n this.currrentCharacterIndex = 0 ;\n }\n return res ;\n }\n } ;\n\n this.nextInt = function() {\n return parseInt( this.next( 1 ) ) ;\n } ;\n\n this.nextDouble = function() {\n return parseFloat( this.next( 1 ) ) ;\n } ;\n\n this.nextString = function() {\n return this.next( 1 ) ;\n } ;\n\n this.nextLine = function() {\n return this.next( 0 ) ;\n } ;\n}\n\nfunction FileOutputHandler() {\n this.resultantStringArray = new Array() ;\n\n this.addNewLine = function( newString ) {\n this.resultantStringArray.push( newString ) ;\n } ;\n\n this.clearPercase = function() {\n this.resultantStringArray = new Array() ;\n } ;\n\n this.flushOutOutputToFile = function( outputFileName ) {\n var i , sz , res , currentDirectory , fsObj , outputFilePath ;\n res = '' ;\n sz = this.resultantStringArray.length ;\n for( i = 0 ; i < sz ; i++ ) {\n if( i != 0 ) {\n res += '\\n' ;\n }\n res += this.resultantStringArray[ i ] ;\n }\n fsObj = require( 'fs' ) ;\n currentDirectory = __dirname ;\n if( currentDirectory.indexOf( 'D:' ) != -1 ) {\n //on windows\n outputFilePath = currentDirectory + '\\\\' + outputFileName ;\n }\n else {\n //on linux\n outputFilePath = currentDirectory + '/' + outputFileName ;\n }\n fsObj.writeFileSync( outputFilePath , res ) ;\n this.clearPercase() ;\n } ;\n}\n\nfunction CodeExecutioner() {\n this.irObj = new InputReader() ;\n this.psObj = new ProblemSolver() ;\n this.fohObj = new FileOutputHandler() ;\n\n this.runCases = function() {\n var testCases , hasMoreTestCases , i ;\n if( this.psObj.HAS_TEST_CASES == true ) {\n testCases = this.irObj.nextInt() ;\n for( i = 0 ; i < testCases ; i++ ) {\n this.psObj.clearPerCase() ;\n this.psObj.getInput( this.irObj ) ;\n this.psObj.solveCase() ;\n }\n }\n else {\n while( true ) {\n this.psObj.clearPerCase() ;\n hasMoreTestCases = this.psObj.getInput( this.irObj ) ;\n if( hasMoreTestCases == false ) {\n break;\n }\n this.psObj.solveCase() ;\n }\n }\n if( this.psObj.DO_OUTPUT_TO_FILE == true ) {\n this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME ) ;\n }\n } ;\n\n this.detectEnvironmentType = function() {\n var environmentType = null ;\n try {\n if( importPackage != null ) {\n environmentType = 'rhino' ;\n }\n }\n catch( ex1 ) {\n try {\n //for nodejs local server check\n if( __dirname != null && ( __dirname.indexOf( 'D:') != -1 || __dirname.indexOf( '/media/') != -1 ) ) {\n environmentType = 'local-node-js' ;\n }\n else {\n environmentType = 'server-node-js' ;\n }\n }\n catch( ex2 ) {\n try {\n if( readline == null || typeof( readline ) != 'function' ) {\n environmentType = 'server-node-js' ;\n }\n else {\n try {\n if( Map != null ) {\n environmentType = 'spider-monkey' ;\n }\n else {\n environmentType = 'javascript-v8' ;\n }\n }\n catch( ex3 ) {\n environmentType = 'javascript-v8' ;\n }\n }\n }\n catch( ex3 ) {\n environmentType = 'server-node-js' ;\n }\n }\n }\n return environmentType ;\n } ;\n\n this.configureStreamsAndReadInput = function() {\n var localContext , isNodeJsJudgeServer , environmentType ;\n isNodeJsJudgeServer = false ;\n environmentType = this.detectEnvironmentType() ;\n if( environmentType == 'local-node-js' ) {\n try {\n if( print == null || typeof( print ) != 'function' ) {\n print = console.log ;\n }\n }\n catch( ex ) {\n print = console.log ;\n }\n if( this.psObj.DO_OUTPUT_TO_FILE == true ) {\n localContext = this.fohObj ;\n print = function() {\n localContext.addNewLine.apply( localContext , arguments ) ;\n }\n }\n this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME ) ;\n this.runCases() ;\n }\n else if( environmentType == 'server-node-js' ) {\n try {\n if( print == null || typeof( print ) != 'function' ) {\n print = console.log ;\n }\n }\n catch( ex ) {\n print = console.log ;\n }\n this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;\n }\n else if( environmentType == 'javascript-v8' ) {\n this.irObj.readAllLines() ;\n this.runCases() ;\n }\n else if( environmentType == 'rhino' ) {\n this.irObj.readAllLinesFromRhino() ;\n this.runCases() ;\n }\n else if( environmentType == 'spider-monkey' ) {\n this.irObj.readAllLines() ;\n this.runCases() ;\n }\n } ;\n\n this.configureStreamsAndReadInput() ;\n}\n\nnew CodeExecutioner() ;\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "strings"], "code_uid": "fc775d2994622658e71cc7280412b908", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nconst points = {\n q: 9,\n r: 5,\n b: 3,\n n: 3,\n p: 1\n};\nlet white = 0;\nlet black = 0;\n\nrl.on('line', (str) => {\n for (let i = 0; i < str.length; i++) {\n if (['Q', 'R', 'B', 'N', 'P'].includes(str[i])) {\n white += points[str[i].toLowerCase()];\n }\n\n if (['q', 'r', 'b', 'n', 'p'].includes(str[i])) {\n black += points[str[i]];\n }\n }\n c++;\n});\n\nrl.on('close', () => {\n if (white > black) {\n console.log('White');\n }\n else if (white < black) {\n console.log('Black');\n }\n else {\n console.log('Draw');\n }\n})\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "bf5686e04f0d52d768caa6c1f69eebad", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nfunction main() {\n const is = new Scanner();\n const [n, k] = is.nextArray(Number);\n let answer = Math.trunc((k - 1) / 2);\n if (k > n)\n answer = Math.max(0, answer - (k - n - 1));\n console.log(answer);\n}\n\n\n/*\n * Api Scanner\n */\nclass Scanner {\n constructor() {\n this.index = -1;\n this.lines = stdinInput.trim().split('\\n'); // eslint-disable-line\n }\n\n nextLine() {\n this.index += 1;\n return this.lines[this.index].trim();\n }\n\n nextInt() {\n return parseInt(this.nextLine(), 10);\n }\n\n nextDouble() {\n return parseFloat(this.nextLine());\n }\n\n nextArray(fn) {\n const array = this.nextLine().split(' ');\n return fn === String ? array : array.map(fn);\n }\n\n hasNext() {\n return this.index < this.lines.length;\n }\n}\n\nlet stdinInput = '';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nprocess.stdin.on('data', (input) => { stdinInput += input; });\nprocess.stdin.on('end', () => { main(); });\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "ec27825fd3ada15b2285d1b3dfd35e9c", "src_uid": "98624ab2fcd2a50a75788a29e04999ad", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(str) {\n\n let inputs = str.trim().split('\\n');\n let wearCount = 0;\n for (let i = 1; i <= +inputs[0]; i++) {\n let homeTeam = inputs[i].trim().split(' ');\n\n for (let j = 1; j <= +inputs[0]; j++) {\n\n if (j != i) {\n\n let guestTeam = inputs[j].trim().split(' ');\n if (homeTeam[1] === guestTeam[0]) {\n wearCount++;\n }\n }\n }\n }\n return wearCount.toString();\n}\n\n\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "726c98a7aec69a54cc943db95e1269a3", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\n/**\n * \n * @param {*} str \n * @param {*} seperator \n */\nfunction splitter(str, seperator = '') {\n return str.trim().split(seperator);\n}\n\n/**\n * \n * @param {*} arr \n */\nfunction strToNumArr(arr = []) {\n return arr.map(num => Number(num));\n}\n\n/**\n * \n * @param {*} num1 \n * @param {*} num2 \n */\nfunction matrixArray(num1, num2) {\n return Array(num1).fill(Array(num2));\n}\n\nlet log = function () {\n return Function.prototype.bind.call(console.log, console, '');\n}();\n\nfunction removeEmptyItem(arr, index) {\n return arr.slice(0, index).concat(arr.slice(index + 1, arr.length));\n}\n\nfunction range(min, max) {\n\n let arr = [];\n for (let index = min; index < max; index++) {\n arr.push(index);\n\n }\n return arr;\n}\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(str) {\n\n let n = +str.trim();\n let count = 0;\n let inc = 0;\n while (count <= n) {\n inc++;\n count += (inc * (inc + 1)) / 2;\n }\n return (inc - 1).toString();\n}\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f973de3869b775985abdbef25f189766", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n\tvar N = nextInt();\n\tif(N % 2 == 0){\n\t\tmyout(N / 2 + 1);\n\t}else{\n\t\tmyout(Math.ceil(N / 2));\n\t}\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "9f669288d133ace2f49f78a9f344a882", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nconst solve = (input) => {\n\n splitWatermelon = (weight) => {\n for (let w1 = 1; w1 < weight; w1++) {\n let w2 = weight - w1;\n\n if (w1 % 2 === 0 && w2 % 2 === 0 ) {\n return true;\n }\n\n }\n \n return false;\n }\n\n console.log(splitWatermelon(input) ? 'YES' : 'NO');\n};\n\nrl.question('', (input) => {\n solve(input);\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "838bb48f89d845da4190f33c166e51d8", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n var str1 = readLine().toLowerCase();\n var str2 = readLine().toLowerCase();\n var result = str1.localeCompare(str2);\n console.log(result);\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "1bf00c49d407fe6bacefda1909f9cb5b", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false,\n});\n\nlet c = 0;\nlet x1, y1, x2, y2;\n\nrl.on(\"line\", (d) => {\n if (c === 0) {\n [x1, y1] = d.split(\" \").map(Number);\n c++;\n return;\n }\n\n [x2, y2] = d.split(\" \").map(Number);\n const ans = Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2));\n console.log(ans);\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "f05d78639c301ee462daed3426805247", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(str) {\n\n let inputs = +str.trim();\n let bills = [1, 5, 10, 20, 100];\n let billLength = bills.length;\n let moves = 0;\n while (inputs) {\n let diff = inputs - bills[billLength - 1];\n if (diff >= 0) {\n moves++;\n inputs = diff;\n }\n\n for (let index = billLength - 1; index >= 0; index--) {\n let diff = inputs - bills[index];\n if (diff >= 0) {\n inputs = diff;\n moves++;\n break;\n }\n\n }\n }\n\n return moves.toString();\n}\n\n\n\n\n", "lang_cluster": "Javascript", "tags": ["greedy", "dp"], "code_uid": "2c91264562e33a31b2267e1a21cd9b74", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction isPrime(x) {\n\tlet s = Math.sqrt(x);\n\tlet i = 2;\n\twhile (i <= s) {\n\t\tif (x % i === 0) {\n\t\t\treturn false;\n\t\t}\n\t\ti++;\n\t}\n\treturn true;\n}\n\nfunction main() {\n\tlet k = readLine() >> 0,\n\t\tl = readLine() >> 0,\n\t\tm = readLine() >> 0,\n\t\tn = readLine() >> 0,\n\t\td = readLine() >> 0;\n\n\tlet hit = 0;\n\tfor (let i = 1; i <= d; ++i)\n\t\tif (i % k === 0 || i % l === 0 || i % m === 0 || i % n === 0) hit++;\n\n\tconsole.log(hit);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "7421fdf979b66475d4086e34c0cc1ba2", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction solve() {\n let l1 = readLine();\n let l2 = readLine();\n let s1 = l1.toLowerCase().split();\n let s2 = l2.toLowerCase().split();\n let l = l1.length;\n for (var i = 0; i < l; i++) {\n if (s1[i] > s2[i])\n return 1;\n else if (s1[i] < s2[i])\n return -1\n }\n return 0;\n}\n\nfunction main() {\n console.log(solve());\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "63aed73816b93b29f83508f59c67b9a7", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var input = null;\n//input = ['2'];\nfunction main(input) {\n var w = parseInt(input[0]);\n if (w == 2)\n solution('NO');\n for (var i = 2; i < 50; i += 2) {\n if (w % 2 == 0)\n solution('YES');\n }\n solution('NO');\n}\n///////////////////////////////////////////////////////////////////////////////////////\nif (!input) {\n var input_1 = '';\n process.stdin.on('data', function (char) { return input_1 += char; });\n process.stdin.on('end', function () {\n var EOL = require('os').EOL;\n var inputs = input_1.split(EOL).slice(0, -1);\n main(inputs);\n });\n}\nelse\n main(input);\nfunction solution(data) {\n console.log(data);\n process.exit(0);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "cffd81057cce8d7fa7e60c1775f9896a", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// https://codeforces.com/problemset/problem/977/B\n// Big O:\n// Time complexity: O(n)\n// Space complexity:\n\nconst readline = require(\"readline\");\n\n// Read input\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet stringLength;\nrl.on('line', (input) => {\n if (stringLength) {\n console.log(findMostCommonGram(input, stringLength));\n rl.close();\n } else {\n stringLength = input;\n }\n});\n\n// Problem\nfunction findMostCommonGram(string, stringLength) {\n let mostCommonGram = \"\";\n let mostCommonGramOccurrences = 0;\n const gramOccurrences = {};\n\n for (let i = 0; i < stringLength - 1; i++) {\n const twogram = string[i] + string[i + 1];\n const occurrences = gramOccurrences[twogram] ? gramOccurrences[twogram] : 0;\n const currentOcurrences = occurrences + 1;\n if (currentOcurrences > mostCommonGramOccurrences) {\n mostCommonGram = twogram;\n mostCommonGramOccurrences = currentOcurrences;\n }\n\n gramOccurrences[twogram] = currentOcurrences;\n }\n\n return mostCommonGram;\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "03de5128cd6f32061ea12a79c718c1e2", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\nlet n = 0\nrl.on('line', (l) => {\n n = parseInt(l)\n let d = [100, 20, 10, 5, 1]\n let count = 0\n\n d.some((x) => {\n //if (n / x === 0) return true;\n count += Math.floor(n / x);\n n = n % x;\n })\n\n console.log(count)\n rl.close();\n})", "lang_cluster": "Javascript", "tags": ["greedy", "dp"], "code_uid": "8c5b99641f8cfd59e5ace64bc72fc18b", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction main() {\n\tconst str1 = readLine().toLowerCase();\n\tconst str2 = readLine().toLowerCase();\n\n\tlet diff = 0;\n\n\tfor (let i = 0, l = str1.length; i < l; ++i) {\n\t\tif (str1.charCodeAt(i) === str2.charCodeAt(i)) {\n\t\t\tcontinue;\n\t\t} else {\n\t\t\tdiff = str1.charCodeAt(i) - str2.charCodeAt(i);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tconst res = diff < 0 ? -1 : diff > 0 ? 1 : 0;\n\tconsole.log(res);\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "5c8dd47cfa867c78edb1c76da2955320", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n \n// single line input\nreadline.on('line', line => {\nreadline.close(), line = line.split(\" \").map(item => parseInt(item))\nconsole.log(theaterSquare(line[0], line[1], line[2]))\n});\n\nfunction theaterSquare(n, m, a) {\n let x = Math.ceil(n/a), y = Math.ceil(m/a)\n return x * y\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "7f98318a1b626f381752db0db0607871", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\nreadline.question(\"\", (weight) => {\n weight!=2?weight%2==0?console.log(\"YES\"):console.log(\"NO\"):console.log(\"NO\");\n readline.close()\n})", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "f021329efa51427060cfcabbfe6fd9be", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = (()=>{\n process.stdin.resume();\n process.stdin.setEncoding('utf-8');\n \n let inputString = '';\n let currentLine = 0;\n \n process.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n });\n \n process.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n });\t\n \n function readline() {\n return inputString[currentLine++];\n }\n return readline;\n})()\n \n \nfunction main() {\n\tconsole.log(readline().match(/(.)\\1*/g).filter(str=>str.length%2===0).length);\n \n}", "lang_cluster": "Javascript", "tags": ["two pointers", "implementation"], "code_uid": "82bedb41cbf3dcce764346b8016dc952", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nlet inputs = [];\n\n// Create readline Interface\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\n// Read Inputs\nrl.on('line', inputLine => {\n let nums = inputLine.split(' ').map(num => parseInt(num));\n let n = nums[0];\n let m = nums[1];\n let a = nums[2];\n let b = nums[3];\n\n if (n === 1) {\n if (a < b)\n return console.log(a)\n else\n return console.log(b)\n } else if (n % m === 0) {\n if (a < b) {\n return console.log(n * a)\n } else {\n return console.log(Math.ceil((n / m)) * b)\n }\n } else {\n if (m > n)\n return console.log(b)\n else if ( a < b) {\n return console.log((Math.floor((n / m)) * b) + (n % m) * a)\n } else {\n return console.log((Math.floor((n / m)) * b) + b)\n }\n\n }\n\n\n return console.log(n)\n\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "bb67dfaa12dee97b0fa0715d196b2e78", "src_uid": "faa343ad6028c5a069857a38fa19bb24", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n \nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n \nlet inputString = '';\nlet currentLine = 0;\n \nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n \nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n \nfunction readline() {\n return inputString[currentLine++];\n}\n// Make a Snippet for the code above this and then write your logic in main();\n \n \nfunction main() {\n const x = readline();\n var line2 = readline(); \n \n \n // console log function here\n console.log(removeAdjacent(x, line2));\n}\n \n// function here\n\nfunction removeAdjacent(l, s) {\n\n\tlet sArr = Array.from(s);\n\n\t// create a dictionary where every letter in associated the its positions in the string, \n\t// and a linkde list where every element has a reference in the dictionary near the position here stored\n\n\tlet sll = {value:s[0], prev: null, next: null};\n\tlet lettersDict = {[s[0]]: [{position: 0, elem: sll}]};\n\tlet start = sll;\n\tlet currElemLinkedList = sll;\n\n\tfor (let i = 1; i < l; i++) {\n\t\tlet curr = s[i];\n\n\t\tcurrElemLinkedList.next = {value:curr, prev: currElemLinkedList, next: null};\n\t\tif (curr in lettersDict) {\n\t\t\tlettersDict[curr].push({position: i, elem: currElemLinkedList.next});\n\t\t}\n\t\telse {\n\t\t\tlettersDict[curr] = [{position: i, elem: currElemLinkedList.next}];\n\t\t}\n\n\t\tcurrElemLinkedList = currElemLinkedList.next;\n\t}\n\n\tlet end = currElemLinkedList;\n\n\t// order the keys of the dictionary by ascii value\n\tconst keys = Object.keys(lettersDict);\n\tkeys.sort((a, b) => {\n\t\treturn b.charCodeAt(0) - a.charCodeAt(0)\n\t});\n\n\t// for every entry in keys check the string for adjacents\n\treturn keys.reduce((acc, curr) => {\n\t\tlet nEliminated = 0;\n\n\n\t\tfor (let i = 0; i < lettersDict[curr].length; i++) {\n\t\t\tlet elem = lettersDict[curr][i].elem;\n\t\t\tif (elem) {\n\t\t\t\tlet position = lettersDict[curr][i].position;\n\n\t\t\t\tlet leftComparable = elem.prev && elem.prev.value;\n\t\t\t\tlet rightComparable = elem.next && elem.next.value;\n\n\t\t\t\tif ((leftComparable && (leftComparable.charCodeAt(0) - elem.value.charCodeAt(0) == -1)) ||\n\t\t\t\t\t(rightComparable && (rightComparable.charCodeAt(0) - elem.value.charCodeAt(0) == -1))) {\n\t\t\t\t\tnEliminated++;\n\n\t\t\t\t\tlettersDict[curr][i].elem = null;\n\t\t\t\t\tif (leftComparable === elem.value) {\n\t\t\t\t\t\ti -= 2\n\t\t\t\t\t}\n\t\t\t\t\tlet prev = elem.prev;\n\t\t\t\t\tlet next = elem.next;\n\t\t\t\t\tif (prev) {\n\t\t\t\t\t\tprev.next = next;\n\t\t\t\t\t}\n\t\t\t\t\tif (next) {\n\t\t\t\t\t\tnext.prev = prev;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t}\n\n\t\treturn acc + nEliminated;\n\t}, 0)\n}", "lang_cluster": "Javascript", "tags": ["brute force", "greedy", "strings", "constructive algorithms"], "code_uid": "792c211efd8016a788187d752918bc0b", "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n let n = parseInt(input[0]);\n let code = input[1];\n \n if(code.length == 1){\n console.log(code.charAt(0)); process.exit();\n }\n \n let answer = ''\n let j = 0;\n for(let i = 0; i < n; i++, j+=i){\n answer += code.charAt(j);\n }\n console.log(answer);\n});\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "b051ca27d2b96c354f626d9a3823c257", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet data = [];\nrl.on('line', (input) => {\n data.push(input);\n});\n\nrl.on('close', () => {\n solve(data);\n});\n\nfunction solve(data) {\n\n s1 = data[0];\n s2 = data[1];\n\n console.log(compare(s1, s2));\n\n}\n\nfunction compare(s1, s2) {\n for (let i = 0; i < s1.length; i++) {\n s1c = s1[i].toLowerCase().charCodeAt(0);\n s2c = s2[i].toLowerCase().charCodeAt(0);\n if (s1c > s2c) {\n return 1;\n } else if (s1c < s2c) {\n return -1;\n }\n }\n return 0;\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "06350a39a023ca9235338423350dfe4a", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n});\n\nconst lines = [];\n\nreadline.on('line', (line) => {\n lines.push(Number(line));\n});\n\nconst processAngles = (n, angles) => {\n for (let i = 0; i < 2 ** (n - 1); i += 1) {\n const bitbask = i.toString(2).padStart(angles.length, '0');\n const rotation = angles.reduce((acc, angle, idx) => {\n if (bitbask[idx] === '0') {\n return acc + angle;\n }\n\n return acc - angle;\n }, 0);\n\n if (rotation % 360 === 0) {\n return 'YES';\n }\n }\n\n return 'NO';\n};\n\nreadline.on('close', () => {\n const [n, ...angles] = lines;\n\n console.log(processAngles(n, angles));\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "dp", "bitmasks"], "code_uid": "3ca19734d911bc8fe6411cbc75310791", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nrl.on('line', (inputString) => {\n let numberOfSquares = parseInt(inputString);\n console.log(findTheNumberOfLinesForLady(numberOfSquares));\n process.exit();\n});\n\nfunction findTheNumberOfLinesForLady(forTheNumberOfSquaress) {\n let a = Math.sqrt(forTheNumberOfSquaress);\n let b = Math.trunc(a);\n if (a == b) return (a + a);\n if (b * (b + 1) >= forTheNumberOfSquaress) return b + b + 1;\n return b + b + 2;\n}", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms", "binary search"], "code_uid": "01c288949ad793614e1da88d8126fd19", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction main() {\n\tconst [m, n] = readLine()\n\t\t.split(' ')\n\t\t.map(x => x >> 0);\n\n\tconsole.log(Math.floor((m * n) / 2));\n}\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "be5918f384e08a7813b0f95573f87617", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction divideEvenWatermelon(weight) {\n if ((weight < 1 && weight > 100 ) || (weight % 2 !== 0)) return 'NO';\n if (weight === 2) return 'NO';\n let evenWeights = [];\n for (let i = 0; i < weight; i++) {\n if (i % 2 === 0 && i > 0) {\n evenWeights.push(i);\n }\n }\n for (let i = 0; i < evenWeights.length; i++) {\n for (let j = 0; j < evenWeights.length; j++) {\n if (evenWeights[i] + evenWeights[j] === weight) return 'YES';\n }\n }\n}\n\nfunction main() {\n const x = +(readline());\n console.log(divideEvenWatermelon(x));\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "4be1f4150c95990777b9cbadcdb60442", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n// utils\nconst MOD = 1e9 + 7;\nconst mod = (n) => ((n % MOD) + MOD) % MOD;\nconst add = (a, b) => mod(mod(a) + mod(b));\nconst sub = (a, b) => mod(mod(a) - mod(b));\nfunction mul() {\n for (var a = arguments, r = a[0], i = a.length; --i; )\n r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;\n return r;\n}\nfunction inv(b) {\n for (var a = MOD, u = 0, v = 1, t; b; v = t)\n (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);\n u %= MOD;\n return u < 0 ? u + MOD : u;\n}\nfunction pow(base, n) {\n if (n === 0) return 1;\n let p = pow(base, Math.floor(n / 2));\n let res = mul(mod(p), mod(p));\n if (n % 2 === 1) res = mul(mod(res), base);\n return res;\n}\nfunction highestOneBit(i) {\n i |= i >> 1;\n i |= i >> 2;\n i |= i >> 4;\n i |= i >> 8;\n i |= i >> 16;\n return i - (i >>> 1);\n}\n\nfunction main() {\n const arr = [];\n const permutations = [];\n function permutation(arr, len, store = \"\") {\n if (store.length === len) {\n permutations.push(store);\n return;\n }\n for (let i = 0; i < arr.length; i++) {\n const newArr = [...arr];\n const newChar = newArr.splice(i, 1);\n permutation(newArr, len, store.concat(newChar));\n }\n }\n\n permutation([1, 2, 3, 4, 5], 5);\n\n for (let i = 0; i < 5; i++) {\n const line = readLine()\n .split(\" \")\n .map((n) => parseInt(n));\n arr.push(line);\n }\n\n let max = -Infinity;\n for (let value of permutations) {\n max = Math.max(max, calculate(value));\n }\n\n console.log(max);\n\n function calculate(str) {\n const [one, two, three, four, five] = [+str[0] - 1, +str[1] - 1, +str[2] - 1, +str[3] - 1, +str[4] - 1];\n return (\n arr[one][two] +\n arr[two][three] +\n arr[three][four] +\n arr[three][four] +\n arr[four][five] +\n arr[four][five] +\n arr[two][one] +\n arr[three][two] +\n arr[four][three] +\n arr[four][three] +\n arr[five][four] +\n arr[five][four]\n );\n }\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "33e430fd9a95b12753b6e7990610e042", "src_uid": "be6d4df20e9a48d183dd8f34531df246", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\n\nrl.on('line', (line) => {\n const [length, index] = line.split(' ').map(Number);\n const half = length % 2 === 0 ? length / 2 : parseInt(length / 2) + 1;\n if (index > half) {\n // console.log(`(${index} - ${half}) * 2 `);\n console.log((index - half) * 2)\n } else {\n console.log((index * 2) - 1)\n }\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "6e3a1e6940fdb0eaa82e00e1dec9243a", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf8\");\n\nprocess.stdin.on(\"data\", function(chunk) {\n main(chunk.toString().split(\"\\n\"));\n});\n\nfunction main(stdIn = []) {\n let [num, k] = stdIn[0].split(\" \");\n while (k > 0) {\n const dec = num % 10 > k ? k : num % 10;\n k = num % 10 == 0 ? k - 1 : k - dec;\n num = num % 10 == 0 ? num / 10 : num - dec;\n }\n console.log(num);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "8ddc32b18b40b75f1608e5851de89ced", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction main() {\n\tlet arr = [];\n\tfor (i = 0; i < 5; i++) {\n\t\tarr[i] = readLine()\n\t\t\t.split(' ')\n\t\t\t.map(x => x >> 0);\n\t}\n\n\tlet cord = [];\n\tlet brk = false;\n\n\tfor (let i = 0; i < 5; i++) {\n\t\tfor (let j = 0; j < 5; j++) {\n\t\t\tif (arr[i][j] === 1) {\n\t\t\t\tcord.push(i, j);\n\t\t\t\tbrk = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (brk) break;\n\t}\n\n\tconst moves = Math.abs(2 - cord[0]) + Math.abs(2 - cord[1]);\n\tconsole.log(moves);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "d4986614a388bf0d05fb9ba21b0b4ab5", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var s = next().toLowerCase();\n var s = myconv(s, 0);\n var output = \"\";\n var b = \"aiueoy\";\n for(var i = 0; i < s.length; i++){\n if(b.indexOf(s[i]) == -1){\n output += \".\" + s[i];\n }\n }\n myout(myconv(output, 0));\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "81c1c9a5a05f9fe2aa71974d5ccee71d", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nlet input = [];\nrl.on('line', (inputString) => {\n input = input.concat(inputString.split(' '));\n if (input.length == 6) {\n let [w, h, u1, d1, u2, d2] = input.map(v => parseInt(v));\n for (; h >= 0; h--) {\n w += h;\n if (h == d1) w -= u1;\n if (h == d2) w -= u2;\n w = Math.max(w, 0);\n }\n console.log(w);\n process.exit();\n }\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3c536998eaa1434bf9360129641cc458", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction multiply(a, b) {\n\ta = a.toString(10).split('').reverse();\n\tb = b.toString(10).split('').reverse();\n\n\tif (a.length < b.length) {\n\t\t[a, b] = [b, a];\n\t}\n\n\tlet res = Array(a.length + b.length).fill(0);\n\tfor (let i = 0, lb = b.length; i < lb; ++i) {\n\t\tlet carry = 0;\n\t\tlet scarry = 0;\n\t\tfor (let j = 0, la = a.length; j < la; ++j) {\n\t\t\tlet m = b[i] * a[j];\n\t\t\tm += carry;\n\n\t\t\tif (m > 9) {\n\t\t\t\tlet [c, d] = m.toString(10).split('');\n\t\t\t\tres[i + j] += (scarry >> 0) + (d >> 0);\n\t\t\t\tcarry = c >> 0;\n\t\t\t} else {\n\t\t\t\tres[i + j] += (scarry >> 0) + m;\n\t\t\t\tcarry = 0;\n\t\t\t}\n\n\t\t\tif (res[i + j] > 9) {\n\t\t\t\tlet [c, d] = res[i + j].toString(10).split('');\n\t\t\t\tres[i + j] = d >> 0;\n\t\t\t\tscarry = c;\n\t\t\t} else {\n\t\t\t\tscarry = 0;\n\t\t\t}\n\t\t}\n\t\tif (carry > 0) res[a.length + i] = carry;\n\t\tif (scarry > 0) res[a.length + i] = scarry;\n\t}\n\n\tres.reverse();\n\tlet mulVal = '';\n\tlet flag = false;\n\tres.forEach(d => {\n\t\tif (!flag && d !== 0) flag = true;\n\t\tif (flag) mulVal += d;\n\t});\n\treturn mulVal;\n}\n\nfunction main() {\n\tlet n = readLine() >> 0;\n\tlet f = readLine()\n\t\t.split(' ')\n\t\t.map(x => x >> 0);\n\n\tlet s = f.reduce((a, c) => a + c);\n\tlet c = 0;\n\tlet i = 1;\n\twhile (i <= 5) {\n\t\tif ((s + i) % (n + 1) !== 1) c++;\n\t\ti++;\n\t}\n\tconsole.log(c);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "6e3cb9b1a516ebc8de49782f84a922d1", "src_uid": "ff6b3fd358c758324c19a26283ab96a4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.setEncoding('utf8');\n\nprocess.stdin.on('readable', () => {\n let input = process.stdin.read();\n input = input.trim();\n\n if (input !== null) {\n let xss = 0;\n\n for (let i = 0; i < input.length; i++) {\n if (input[i] == 'x') {\n if (input.substring(i).startsWith('x'.repeat(3))) {\n xss++;\n }\n }\n }\n\n process.stdout.write(`${xss}\\n`);\n process.exit(0);\n }\n});", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "b201b8de3716e074b6bf0d5f4a8a19a9", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n \nlet inputString = '';\nlet currentLine = 0;\n \nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n \nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n \nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n const t = Number(readLine())\n for (let _i = 0; _i < t; _i++) {\n const [n, k, l] = readLine().split(/\\s/).map(Number)\n const ds = readLine().split(/\\s/).map(Number)\n let result = true\n for (let i = 0; i < n; i++) {\n const d = ds[i]\n let tide = l - d\n if (tide < 0) {\n result = false\n break\n }\n if (tide >= k) {\n continue\n }\n let increasing = tide === 0\n let iDiff = 1\n while(i + iDiff < n) {\n tide = increasing ? tide + 1 : tide - 1\n if (tide === 0) {\n increasing = true\n }\n const _d = ds[i + iDiff]\n if (_d <= l - k) {\n break\n }\n if (_d + tide > l) {\n tide = l - _d\n if (increasing || tide < 0) {\n result = false\n break\n }\n if (tide === 0) {\n increasing = true\n }\n }\n iDiff++\n }\n if (!result) {\n break\n }\n i = i + iDiff\n }\n console.log(result ? 'Yes' : 'No')\n }\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "greedy", "dp"], "code_uid": "26ea776ac09094af1cac5f1c6ca32bbc", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n// read each line\nrl.on(\"line\", (lineInput) => {\n if (lineInput % 2 == 0 && lineInput != 2) {\n console.log(\"Yes\");\n } else console.log(\"NO\");\n});\n\n// when all file readed\nrl.on(\"close\", () => {});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "00e9d7e3e7fd349092b7f45727d5138c", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\nlet nums = readline().split(' ');\nlet n = parseInt(nums[0]);\nlet m = parseInt(nums[1]);\n\nminClicks(n, m);\n}\n\n\nfunction minClicks(n, m) {\n let queue = [n];\n let distance = new Map();\n distance.set(n, 0);\n // BFS \n while (queue[0] != m) {\n let cur = queue.shift();\n\n let curDist = distance.get(cur) + 1;\n if (!distance.get(cur - 1) && cur > 0 ) {\n distance.set(cur - 1, curDist);\n queue.push(cur - 1);\n }\n if (!distance.get(cur * 2) && cur < 10000) {\n distance.set(cur * 2, curDist);\n queue.push(cur * 2);\n }\n }\n console.log(distance.get(m));\n}", "lang_cluster": "Javascript", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "c4c1b4531048f0845302a86cba8c9aee", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const rl = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', (line) => {\n const [n, m, a] = line.split(' ').map(i => parseInt(i));\n\n let x;\n if (a >= n) {\n x = 1;\n } else {\n x = Math.floor(n / a) + (n % a ? 1 : 0);\n }\n\n let y;\n if (a >= m) {\n y = 1;\n } else {\n y = Math.floor(m / a) + (m % a ? 1 : 0);\n }\n\n console.log(x * y);\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "029bd8492763152e1ba761c29a8cee62", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string =>{\n return string.trim();\n });\n main();\n})\n\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n var x = readLine();\n x = parseInt(x);\n var arr = [4,7,47,74,44,444,447,474,477,777,774,744];\n var flag = false;\n for(var i = 0; i < arr.length; i++) {\n if(x % arr[i] === 0) {\n flag = true;\n }\n }\n if(flag === true) {\n console.log(\"YES\\n\");\n } else {\n console.log(\"NO\\n\");\n }\n}", "lang_cluster": "Javascript", "tags": ["brute force", "number theory"], "code_uid": "46431fc11f48e50e5178748cd490998a", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n \nconst input = [];\nreadLine.on('line', line => input.push(line));\n \nreadLine.on('close', () => {\n let [bear1, bear2] = input[0].split(' ')\n bear1 = parseInt(bear1)\n bear2 = parseInt(bear2)\n let [DelimiterBear1, DelimiterBear2] = '3 2'.split(' ')\n DelimiterBear1 = parseInt(DelimiterBear1)\n DelimiterBear2 = parseInt(DelimiterBear2)\n let count = 0\n while (bear1 <= bear2) {\n bear1 = bear1 * DelimiterBear1\n bear2 = bear2 * DelimiterBear2\n count++\n }\n console.log(count)\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "462b0829f14e365e368f8cf1fc5593c5", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var s = next();\n var used = new Set();\n for(var i = 0; i < s.length; i++){\n used.add(s[i]);\n }\n myout((used.size % 2 == 0) ? \"CHAT WITH HER!\" : \"IGNORE HIM!\");\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "19cd8de444b46daa6c2a2146d3e7942a", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//↓見なくていいよ!ここから--------------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\nvar obj;\nvar inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n myerr(\"-----start-----\");\n var start = new Date();\n Main();\n var end = new Date() - start;\n myerr(\"----- end -----\");\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n var returnObj = {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(!this.hasNext()){throw \"ArrayIndexOutOfBoundsException これ以上ないよ\";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}\n };\n return returnObj;\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//[no]要素の扱い。数値型\n//不明値、異常時:引数そのまま返す 1:数値へ変換\n//2:半角SPで分割 4:半角SPで分割し、数値配列へ\n//6:1文字で分割 7:1文字で分割し、数値配列へ\n//8:半角SPで結合 9:改行で結合 0:文字なしで結合\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//↑見なくていいよ!ここまで--------------------------------------------------\nfunction Main(){\n var w = nextInt();\n \n for(var i = 1; i < w; i++){\n if(i % 2 == 0 && (w - i) % 2 == 0){\n myout(\"YES\");\n return;\n }\n }\n myout(\"NO\");\n \n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "2c302786b813c58daf2910840729c48b", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Generated by CoffeeScript 2.5.1\nvar lines, mainAux, print, readline, rl, rli, write;\n\nrl = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nprint = console.log;\n\nwrite = function(...args) {\n return process.stdout.write(args.join(' '));\n};\n\nlines = [];\n\nrl.on('line', function(line) {\n return lines.push(line);\n});\n\nrl.on('close', main);\n\nrli = 0;\n\nreadline = function() {\n return lines[rli++];\n};\n\nmainAux = function() {\n var args, weight;\n args = readline();\n weight = args;\n if (weight < 4) {\n return print('NO');\n }\n if ((weight - 2) % 2 === 0) {\n return print('YES');\n } else {\n return print('NO');\n }\n};\n\nfunction main() {\n return mainAux();\n};\n\n//# sourceMappingURL=watermelon.js.map\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "882aab34adb12c4b5f19005b05facfdc", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume()\nprocess.stdin.setEncoding('utf-8')\n\nvar arr = ''\nprocess.stdin.on('data', (i) => {\n arr += i\n})\n\n\nprocess.stdin.on('end', () => {\n arr = arr.split('\\n')\n const n = parseInt(arr.shift())\n if(n == 1){\n console.log('Ehab')\n }\n\n else if(n % 2 == 0){\n console.log('Mahmoud')\n }\n else {\n console.log('Ehab')\n }\n})", "lang_cluster": "Javascript", "tags": ["math", "games"], "code_uid": "d45f2fca2c9cda28c958f87ac8eec53f", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// https://codeforces.com/problemset/problem/4/A\n\nfunction main(weight) {\n process.stdout.write(weight > 2 && weight % 2 === 0 ? 'YES' : 'NO')\n}\n\n// Handle standard input\nprocess.stdin.resume()\nprocess.stdin.setEncoding('utf-8')\n\nlet inputString = ''\n\nprocess.stdin.on('data', (inputStdin) => inputString += inputStdin)\nprocess.stdin.on('end', () => main(+inputString.trim()))\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "19a3a4584a605c2e75fdbdcd39038ef9", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n let [x, y] = readLine().split(' ').map(Number);\n let n = parseInt(readLine());\n\n let third = y - x;\n let fourth = third - y;\n let fifth = fourth - third;\n let sixth = fifth - fourth;\n if (n % 6 === 1) {\n if (Math.sign(x) !== -1) {\n console.log(x % 1000000007);\n } else {\n console.log(((x % 1000000007) + 1000000007) % 1000000007);\n }\n } else if (n % 6 === 2) {\n if (Math.sign(y) !== -1) {\n console.log(y % 1000000007);\n } else {\n console.log(((y % 1000000007) + 1000000007) % 1000000007);\n }\n } else if (n % 6 === 3) {\n if (Math.sign(third) !== -1) {\n console.log(third % 1000000007);\n } else {\n console.log(((third % 1000000007) + 1000000007) % 1000000007);\n }\n } else if (n % 6 === 4) {\n if (Math.sign(fourth) !== -1) {\n console.log(fourth % 1000000007);\n } else {\n console.log(((fourth % 1000000007) + 1000000007) % 1000000007);\n }\n } else if (n % 6 === 5) {\n if (Math.sign(fifth) !== -1) {\n console.log(fifth % 1000000007);\n } else {\n console.log(((fifth % 1000000007) + 1000000007) % 1000000007);\n }\n } else if (n % 6 === 0) {\n if (Math.sign(sixth) !== -1) {\n console.log(sixth % 1000000007);\n } else if (Math.sign(sixth) === -1) {\n console.log(((sixth % 1000000007) + 1000000007) % 1000000007);\n }\n }\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "2b647d4ede1277c4002c247e839c711e", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n let len = +readLine();\n const arr = readLine()\n .split(\" \")\n .map((n) => parseInt(n));\n let [completed, i, sum] = [false, 0, 0];\n\n while (!completed) {\n i = i % arr.length;\n sum += arr[i];\n if (sum >= len) {\n console.log(i + 1);\n completed = true;\n }\n i++;\n }\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "5120318b238ab159104d884b5a75bf01", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var one = nextIntArray();\n var max = Math.max(one[0], one[1]);\n var min = Math.min(one[0], one[1]);\n var ok = min;\n max -= min;\n var ng = Math.floor(max / 2);\n myout(ok + \" \" + ng);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "919593c05c0c987ba3997812dba19acf", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet input = '';\nprocess.stdin.on('data', (line) => {\n input += line;\n});\nprocess.stdin.on('end', () => {\n const lines = input.split('\\n');\n const k = BigInt(lines.shift());\n const occur = Array(10).fill(1n);\n let count = 1n;\n let index = 0;\n while (count < k) {\n occur[index]++;\n count = occur.reduce((acc, value) => acc * value, 1n);\n index++;\n if (index === 10) {\n index = 0;\n }\n }\n const word = \"codeforces\";\n const ans = occur\n .map((value, index) => word[index].repeat(Number(value)))\n .join('');\n console.log(ans);\n});\n// input helper\nfunction lineToNumArray(line) {\n return line.split(' ').map(element => parseInt(element, 10));\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "constructive algorithms", "math", "greedy", "strings"], "code_uid": "4edc0303aaedb84c5e099a1c04ad1da3", "src_uid": "8001a7570766cadcc538217e941b3031", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n\nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n \nRL.on('line', line => input.push(line));\n\nRL.on('close', () => {\n const str = input[0];\n let nowPos = 0, answer = 0;\n\n for (let i = 0; i < str.length; i += 1) {\n let pos = parseInt(str.charCodeAt(i), 10) - 97;\n if (pos !== nowPos) {\n let left = Math.abs(pos - nowPos);\n let right = 26 - nowPos + pos;\n if (pos > nowPos) {\n right = 26 - pos + nowPos;\n }\n\n answer += Math.min(left, right)\n }\n\n nowPos = pos;\n }\n\n console.log(answer);\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "605ae372b701852836537a0b6f897df7", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict'\n\nconst B = '127'\nconst S = '32767'\nconst I = '2147483647'\nconst L = '9223372036854775807'\n\nlet ipt = ''\nprocess.stdin.on('data', s => ipt += s)\nprocess.stdin.on('end', () => {\n ipt = ipt.trim()\n console.log(\n fit(ipt, B) && 'byte'\n || fit (ipt, S) && 'short'\n || fit (ipt, I) && 'int'\n || fit (ipt, L) && 'long'\n || 'BigInteger'\n )\n\n function fit (a, b) {\n if (a.length < b.length) return true\n if (a.length > b.length) return false\n for (let i = 0; i < a.length; i += 5) {\n const ap = +a.slice(i, i + 5)\n const bp = +b.slice(i, i + 5)\n if (ap < bp) return true\n if (ap > bp) return false\n }\n return true\n }\n})", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "3bb4b708241b7d59c79570e8c6fd71f5", "src_uid": "33041f1832fa7f641e37c4c638ab08a1", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nfunction is_unique(str) {\n var obj = {};\n for(var z=0; z < str.length; z++) {\n var ch = str[z];\n if(obj[ch]) return false; else obj[ch] = true;\n }\n return true;\n}\n\nrl.question('', (inputLine) => {\n let obj = {};\n let distinct = 1;\n let loopIndex = parseInt(inputLine) + 1;\n \n for(let i = loopIndex; i <= 10000; i++) {\n let year = i + '';\n // console.log(year);\n if(is_unique(year)){\n console.log(year);\n break;\n }\n }\n \n rl.close();\n});\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "30ba257aefdcaeb13132596a512c53a9", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n});\n\nvar inp = [];\nvar ninp = 0;\n\nfunction main() {\n\trl.question('', (answer) => {\n\t\tif (answer.length) {\n\t\t\tinp.push(answer);\n\t\t\t\n\t\t\tninp++;\n\t\t\tif(ninp == 2){ rl.close(); solve(); }\n\t\t\telse main();\n\t\t}\n\t});\n}\nfunction solve() {\n\tvar n = inp[0]*1;\n\tvar s = inp[1];\n\tvar cont1=0, cont2=0;\n\tvar a = ['R','B'];\n\tfor(var i=0; i cont2) cont1 = cont2;\n\tconsole.log(cont1);\n}\nmain();", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "1ec991aafda00caeb471285d59b61591", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet n, k;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n [n, k] = d.split(' ').map(Number);\n return;\n }\n\n const arr = d.split(' ').map(Number);\n\n let sum = 0;\n let days = 0;\n while (k > 0 && days < n) {\n sum += arr[days];\n let maxCandies = Math.min(8, sum);\n\n k -= maxCandies;\n sum -= maxCandies;\n days++;\n }\n\n if (k > 0) {\n console.log(-1);\n }\n else {\n console.log(days);\n }\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "82b3065bb76acb9c903326ef2da67c60", "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet n, m, k;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n [n, m, k] = d.split(' ').map(Number);\n return;\n }\n\n const arr = [0, ...d.split(' ').map(Number)];\n let ans = 0;\n let L = m - 1;\n let R = m + 1;\n while (L > 0 || R < arr.length) {\n if (arr[L] !== 0 && arr[L] <= k) {\n ans = 10 * Math.abs(m - L);\n break;\n }\n\n if (arr[R] !== 0 && arr[R] <= k) {\n ans = 10 * Math.abs(m - R);\n break;\n }\n\n L--;\n R++;\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "341d0db2db17634e77ef3eab0927e098", "src_uid": "57860e9a5342a29257ce506063d37624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n\nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n \nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n const [n, m] = input[0].split(\" \").map(x => parseInt(x));\n if (n < m) { console.log('-1'); return }\n\n //console.log(`n = ${n}; m = ${m}; n/m = ${n/m}`);\n console.log(Math.ceil(n/2/m) * m);\n});", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "3265f32e958abd755a037c125559d656", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (str) => {\n if (c === 0) {\n c++;\n return;\n }\n\n let ans = 0;\n let counter = 0;\n\n for (let i = 0; i < str.length; i++) {\n if (str[i] === 'x') {\n counter++;\n }\n else {\n counter = 0;\n }\n if (counter >= 3) {\n ans++;\n }\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "dbd94db683c01ce0d86c80901e236f30", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// https://codeforces.com/problemset/problem/977/A\n// Big O:\n// n: iterations, m: length of the string\n// Time complexity: O(n*m) => O(n)\n// Space complexity: O(n*m) => O(n)\n\nconst readline = require(\"readline\");\n\nfunction substract(number, iterations) {\n\n let result = number;\n while (iterations > 0) {\n const lastDigit = getLastDigit(result);\n if (lastDigit == 0) {\n result = removeLastDigit(result);\n } else {\n result -= 1;\n }\n\n iterations--;\n }\n\n return result;\n}\n\nfunction getLastDigit(number) {\n const { numberAsString, numberLength } = getNumberStringValues(number);\n const lastDigit = numberAsString.charAt(numberLength - 1);\n return parseInt(lastDigit);\n}\n\nfunction removeLastDigit(number) {\n const { numberAsString, numberLength } = getNumberStringValues(number);\n const numberWithoutLastDigit = numberAsString.slice(0, numberLength - 1);\n return parseInt(numberWithoutLastDigit);\n}\n\nfunction getNumberStringValues(number) {\n const numberAsString = number.toString();\n const numberLength = numberAsString.length;\n return { numberAsString, numberLength }\n}\n\n// Read input\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.question(\"\", function (line) {\n const input = line.split(\" \");\n const number = parseInt(input[0]);\n const iterations = parseInt(input[1]);\n console.log(substract(number, iterations));\n\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e96b6226948154fcf040b3c900492fef", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n let [l, r, a] = d.split(' ').map(Number);\n let ans = 0;\n\n while (l < r && a !== 0) {\n l++;\n a--;\n }\n\n while (r < l && a !== 0) {\n r++;\n a--;\n }\n\n ans += Math.min(l, r) * 2;\n ans += Math.floor(a / 2) * 2;\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "ce37f715986e4ac1f475c61a06a15cc5", "src_uid": "e8148140e61baffd0878376ac5f3857c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "var t = readline();\r\n \r\nfor (var i = 0; i < t; i++) {\r\n var n = readline();\r\n var a = new Set();\r\n \r\n for(var j = 1; j * j <= n; j++) {\r\n a.add(j * j);\r\n }\r\n \r\n for(var j = 1; j * j * j <= n; j++) {\r\n a.add(j * j * j);\r\n }\r\n print(a.size);\r\n}", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "9bd9c6f84fdb4e231d21d0fcce7a06f2", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n\tvar one = nextIntArray();\n\tvar N = one[0];\n\tvar K = one[1];\n\tvar reqR = 2 * N;\n\tvar reqG = 5 * N;\n\tvar reqB = 8 * N;\n\tvar output = 0;\n\toutput += Math.ceil(reqR / K);\n\toutput += Math.ceil(reqG / K);\n\toutput += Math.ceil(reqB / K);\n\tmyout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "ed3264f8f0625ba307075b8aca128062", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let readline = require('readline');\nlet intInput = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n});\nlet input;\nintInput.on('line', (line) => {\n\tinput = line.split(\" \")\n});\nintInput.on('close', () => {\n\tlet num = Number(input[0]);\n\tlet k = Number(input[1]);\n\tfor (let i = 0; i < k; i++) {\n\t\tlet numToStr = num.toString();\n\t\tif (numToStr[numToStr.length - 1] == 0) {\n\t\t\tnumToStr = numToStr.slice(0, numToStr.length - 1);\n\t\t\tnum = Number(numToStr);\n\t\t} else {\n\t\t\tnum = num - 1\n\t\t}\n\t}\n\tconsole.log(num)\n})\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "b510dd3926e251549a6361b0632143e2", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume()\nprocess.stdin.setEncoding('utf-8')\n\nvar arr = ''\nprocess.stdin.on('data', (i) => {\n arr += i\n})\n\nprocess.stdin.on('end', () => {\n const n = parseInt(arr)\n const sq = Math.sqrt(n)\n let k = 0\n for(let i = 1; i <= sq; i++) {\n if(n % i == 0) {\n if(n / i == i) k ++\n else k +=2\n }\n }\n console.log(k)\n\n})", "lang_cluster": "Javascript", "tags": ["math", "number theory"], "code_uid": "202ac6b631969da13c64b2be745d4b0e", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require(\"readline\");\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nrl.on(\"line\", function(line){\n var k = line.split(' ')[0];\n var n = line.split(' ')[1];\n var w = line.split(' ')[2];\n var price = 0;\n for(var i= 1; i<= w; i++){\n price += k * i;\n \n }\n if ((price - n) > 0 ){\n console.log(price-n);\n } else {\n console.log(0);\n }\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "6ce28aaead01c126f8d0dc3d963d4464", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Lights Out\n\nconst {EOL} = require('os');\n\nlet inp = '';\n\nprocess.stdin.on('data', c => inp += c);\n\nprocess.stdin.on('end', () => {\n const m = inp.split(EOL).map(c => c.split(' ').map(r => +r));\n \n let res = [[1, 1, 1], [1, 1, 1], [1, 1, 1]];\n for(let i = 0; i < 3; i++) {\n \tfor(let j = 0; j < 3; j++) {\n \t\tif(i != 0) {\n\t\t\t\tres[i][j] += m[i - 1][j];\n \t\t}\n \t\tif(j != 0) {\n \t\t\tres[i][j] += m[i][j - 1];\n \t\t}\n \t\tif(i != 2) {\n \t\t\tres[i][j] += m[i + 1][j];\n \t\t}\n \t\tif(j != 2) {\n \t\t\tres[i][j] += m[i][j + 1];\n \t\t}\n \t\tres[i][j] = (res[i][j] + m[i][j]) % 2;\n \t}\n }\n\n for(let i = 0; i < 3; i++) {\n \tfor(let j = 0; j < 3; j++) {\n \t\tprocess.stdout.write(res[i][j] + '');\n \t}\n \tprocess.stdout.write(EOL);\n }\n return;\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "a8890d486a9a648c58497933859095b2", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(str) {\n let year = +str.trim() + 1;\n while (true) {\n let yearStr = String(year);\n let uniqueLength = [...new Set(yearStr)].length;\n if (uniqueLength === yearStr.length) {\n break;\n }\n year++;\n }\n\n return year.toString();\n}\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "e4c4661c1e4aa15fb4023b1e51618d2e", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (str) => {\n if (str.length >= 5 && /[a-z]/.test(str) && /[A-Z]/.test(str) && /[0-9]/.test(str)) {\n console.log('Correct');\n }\n else {\n console.log('Too weak');\n }\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "56861e479f0d539537a51ade771525f8", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var line_number = 0;\nconst cs = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nvar lines = {};\ncs.on(\"line\", (input) => {\n if (input == \"\") {\n cs.close();\n }\n lines[line_number] = input.split(\" \");\n line_number += 1;\n}).on(\"close\", () => {\n main();\n process.exit();\n});\n\nfunction isOp(str) {\n return str.length === 1 && str.match(/[<=>]/);\n}\nfunction isChr(str) {\n return str.length === 1 && str.match(/[a-z]/i);\n}\n// function isInt(str) {\n// return str.length === 1 && !isNaN(str);\n// }\nfunction isInt(str) {\n return str.length === 1 && str.match(/[0-9*]/);\n}\n\nfunction print(str) {\n console.log(str);\n}\n\nfunction exit(status = 0) {\n process.exit(status);\n}\n\nfunction predict(test) {\n let op = \"\";\n let ops = [];\n let opVariables = [];\n let limits = [];\n for (let t of test) {\n // console.log(t);\n for (let i = 0; i < t.length; i++) {\n if (isOp(t[i])) {\n op = t[i];\n if (isOp(t[i + 1])) {\n op += t[i + 1];\n i += 1;\n }\n ops.push(op);\n op = \"\";\n } else if (isChr(t[i])) {\n // console.log(t[i])\n op = t[i];\n for (var j = i + 1; j < t.length; j++) {\n if (isChr(t[j]) || isInt(t[j])) {\n op += t[j];\n i = j;\n } else break;\n }\n opVariables.push(op);\n op = \"\";\n } else {\n if (i == 0 || (i > 0 && isOp(t[i - 1]))) {\n op = t[i];\n let j = i + 1;\n for (; j < t.length; j++) {\n if (isInt(t[j])) {\n op += t[j];\n i = j;\n } else break;\n }\n limits.push(op);\n op = \"\";\n }\n }\n }\n }\n\n let min = limits[0];\n let max = limits[1];\n\n let pvs = ops.map((o, i) => [o, opVariables[i]]);\n\n for (let pv of pvs) {\n if (pv[1] == undefined) {\n pv[1] = max;\n }\n // print(`${min} ${pv[0]} ${pv[1]} ?`)\n if (eval(`${min}${pv[0]}${pv[1]}`)) {\n // print(` ${min} ${pv[0]} ${pv[1]} true`)\n min = pv[1];\n } else {\n print(\"input error\");\n exit();\n }\n }\n}\n\nvar k,n,w\nfunction main() {\n [k,n,w] = lines[0].map(x => parseInt(x,10))\n// print(w)\n predict([\"1<=k<=1000\"])\n predict([\"1<=w<=1000\"])\n predict([\"0<=n<=10**9\"])\n\n let s = 0\n for(let i=1; i<=w; i++) {\n s += k*i\n }\n\n print(s-n>0?s-n:0)\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "52b4bad679250f711e98a86653ead2ad", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let n = parseInt(readLine());\n let fingersArray = readLine().split(' ').map(Number);\n let sum = 0;\n for (let i = 0; i < fingersArray.length; i++) {\n sum = sum + fingersArray[i];\n }\n let ways = 0;\n for (let i = 1; i <= 5; i++) {\n if ((sum + i) % (n + 1) !== 1) {\n ways++;\n }\n }\n console.log(ways);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "d9151110ba7611191c03177f7a1a1464", "src_uid": "ff6b3fd358c758324c19a26283ab96a4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet currentLine = 0;\nlet inputString = \"\";\n\nprocess.stdin.on(\"data\", (raw_data) => {\n inputString += raw_data;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((line) => {\n return line.trim();\n });\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n/******** Main function*************/\n\nfunction main() {\n var n = +readLine();\n\n function isDistinctDigits(year) {\n var arr = (\"\" + year).split(\"\");\n if (\n arr[0] !== arr[1] &&\n arr[0] !== arr[2] &&\n arr[0] !== arr[3] &&\n arr[1] !== arr[2] &&\n arr[1] !== arr[3] &&\n arr[2] !== arr[3]\n ) {\n return true;\n } else {\n return false;\n }\n }\n\n for (var i = n + 1; i <= Infinity; i++) {\n if (isDistinctDigits(i)) {\n console.log(i);\n break;\n }\n }\n}\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "7c54b62933f8fe34fb219680e3840289", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet currentLine = 0;\nlet inputString = \"\";\n\nprocess.stdin.on(\"data\", (raw_data) => {\n inputString += raw_data;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((line) => {\n return line.trim();\n });\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n/******** Main function*************/\n\nfunction main() {\n var [n, m] = readLine().split(\" \").map(Number);\n\n var res = 1;\n for (var i = 1; i <= Math.min(n, m); i++) {\n res *= i;\n }\n console.log(res);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation", "number theory"], "code_uid": "ebf02214a826df9f32835934cf41e7ca", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', (input) => {\n console.log(da(input))\n rl.close()\n});\n\nfunction da (n) {\n if (n == 2) return \"NO\"\n return n % 2 ? \"NO\" : \"YES\"\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "526d4cc11135d5f88d160f293d5e2b99", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let readline = require('readline');\nlet rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n});\n\nrl.on('line', function(line) {\n\tcapsLock(line);\n\trl.close();\n});\n\nlet capsLock = (input) => {\n\tif (checkStr(input.substring(1))) {\n\t\tlet firstChar = input.charAt(0);\n\t\tcheckStr(firstChar) ? (firstChar = firstChar.toLowerCase()) : (firstChar = firstChar.toUpperCase());\n\t\tconsole.log(firstChar + '' + input.substring(1).toLowerCase());\n\t} else {\n\t\tconsole.log(input);\n\t}\n};\n\nlet checkStr = (str) => {\n\treturn str === str.toUpperCase();\n};\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "f5d7eca17500f11f50fa9cf69bb89395", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "console.log('25')", "lang_cluster": "Javascript", "tags": ["number theory"], "code_uid": "d33d7b147c1acca3bfe649f961811d37", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nfunction test(t, k,min = 0, max = 100) {\n// console.log(`t=${t}, k=${k}`)\n if ((t < min || t > max) || (k < min || k > max) || t {\n if (argc == 0) {\n // test(input);\n [n,k] = input.split(' ').map(i => parseInt(i, 10));\n test(n,k,min=1,max=50)\n // console.log(k)\n } else {\n // this my code belong place\n a = input.split(' ').map(i => parseInt(i,10))\n ak = a.reduce(function(x,y){ return (y >= a[k-1] && y !== 0 && 1)+x },0)\n// console.log(n)\n }\n\n if (argc == 1) \n {\n // console.log(ak)\n console.log(ak)\n readline.close();\n }\n else argc += 1;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "ff65301c7404b839eccd3a3e0ed743e1", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nconst gcd = (a, b) => {\n while (b !== 0n) {\n let temp = b;\n b = a % b;\n a = temp;\n }\n\n return a;\n};\n\nrl.on('line', (d) => {\n let [a, b] = d.split(' ').map(BigInt);\n\n if (a === b) {\n console.log(a.toString());\n }\n else {\n console.log(1);\n }\n});\n", "lang_cluster": "Javascript", "tags": ["math", "number theory"], "code_uid": "aa4f11d109382c0fe6a025cfb2f1d94d", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n \nlet stdinInput = '';\n \nprocess.stdin.on('data', input => {\n stdinInput += input;\n})\n \nprocess.stdin.on('end', () => {\n main(stdinInput);\n})\n \nfunction main(data) {\n data = data.split(/\\r?\\n/);\n const testCases = data[0] * 1;\n \n solve(data[1], testCases)\n}\n\nfunction solve(line, length) {\n let map = {}\n let i;\n for(i = 0; i < length - 1; i++) {\n let twogram = line.substring(i, i + 2)\n map[twogram] = twogram in map ? map[twogram] + 1 : 1\n }\n\n let maxtg = \"\"\n let curMax = 0\n let keys = Object.keys(map)\n keys.forEach( key =>\n {\n if (map[key] > curMax) {\n curMax = map[key]\n maxtg = key\n }\n }\n )\n console.log(maxtg)\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "13d9fdca973d2e33e5588bc31af87fd2", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst INPUT = 'test.in';\nconst LOCAL = process.env.ENABLE_LOCAL_ENV === 'true';\nconst log = (...args) => {\n LOCAL && console.log(...args)\n};\nlet rl;\nlet lineNr = 0;\n\n/**\n * MAIN\n */\n(async () => {\n const promises = await setup(INPUT);\n await Promise.all(promises);\n})();\n\n\nfunction setup() {\n const promises = []\n rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false,\n });\n\n rl.on('line', (line) => {\n promises.push(work(line, lineNr));\n lineNr++;\n });\n\n rl.on('error', (err) => {\n log('Error:', err);\n });\n\n return new Promise(res => {\n rl.on('close', () => {\n res(promises)\n log('Done!');\n });\n });\n}\n\nasync function work(line, lineNr) {\n const solutionForLine = await solve(line.trim());\n const responseLine = `${solutionForLine}\\n`;\n process.stdout.write(responseLine);\n}\n\n/**\n * \n * Solution goes below\n * \n */\nfunction solve(line) {\n const w = parseInt(line);\n let i = 1;\n while(Math.pow(2, i) <= Math.ceil(w / 2)) {\n const rem = w - Math.pow(2, i);\n if (rem % 2 === 0) return 'YES';\n i++;\n }\n return 'NO';\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "1989ab807286ab3d173810e3c307faf2", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//nodejs v4.2.6\nprocess.stdin.resume(); \n\tprocess.stdin.setEncoding('utf8');\n\t//Taking a usr input\n\tprocess.stdin.on('data', function (text) {\n\t\t\t//Printing out user input\n\t\t\t\tif(text==2){\n\t\t\t\t\tconsole.log('NO')\n\t\t\t\t}else\n\t\t\t\tif(text%2 == 0){\n\t\t\t\t\tconsole.log('YES');\n\t\t\t\t}else{\n\t\t\t\t\tconsole.log('NO')\n\t\t\t\t}\n\t});\n ", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "23db0fcdf15caa7201c498797b5ea23f", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n \nconst input = [];\nreadLine.on('line', line => input.push(line));\n \nreadLine.on('close', () => {\n let [first, second] = input\n let [people, seconds] = first.split(' ')\n let arrOrder = second.split('')\n for (let a = 0; a < seconds; a++) {\n for (let b = 0; b < people; b++) {\n const el = arrOrder[b]\n if (el === 'G') {\n arrOrder[b] = el\n } else if (el === 'B') {\n const checkNext = arrOrder[b + 1]\n if (checkNext === 'G') {\n arrOrder[b] = 'G'\n arrOrder[b + 1] = 'BG'\n } else {\n arrOrder[b] = el\n }\n } else {\n arrOrder[b] = 'B'\n }\n }\n }\n console.log(arrOrder.toString().replace(/(\\,)/g,''))\n});", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "2b8fb87ede0fe063b3858180c1fa450d", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n \nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n const [m, n] = input.pop().split(' ').map(x => parseInt(x));\n let [min, max] = [Math.min(m, n), Math.max(m, n)];\n\n if (min % 2 === 0) {\n console.log( max * (min/2) );\n } else {\n if (min === 1) {\n console.log(parseInt(max/2));\n } else {\n console.log( (max * ((min-1)/2)) + parseInt(max/2) );\n }\n }\n});", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "961f9e9f6522f5595da19fcbc00fdd67", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet inputString = \"\";\nlet currentLine = 0;\n\nprocess.stdin.on(\"data\", (inputStdin) => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((string) => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n const x = readline().split(\" \");\n \n \n horseshoeOnTheOtherHoof(x);\n}\n\nfunction horseshoeOnTheOtherHoof(colors) {\n console.log(4 - new Set(colors).size);\n\n}\n\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "8bb0a42415b634748de57676a370fac3", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// problem name: Routine Problem\n// problem link: https://codeforces.com/problemset/problem/337/B\n// contest link: https://codeforces.com/contest/337\n// author: reyad\n// time: (?)\n\n'use strict';\n\nfunction gcd(a, b) {\n\twhile(b != 0) {\n\t\tlet t = b;\n\t\tb = a % b;\n\t\ta = t;\n\t}\n\treturn a;\n}\n\nfunction main() {\n\tlet a = nextInt();\n\tlet b = nextInt();\n\tlet c = nextInt();\n\tlet d = nextInt();\n\n\tif(c * b > a * d) {\n\t\tlet x = b * c - d * a;\n\t\tlet y = b * c;\n\t\tlet g = gcd(x, y);\n\t\tconsole.log((x / g) + '/' + (y / g));\n\t}\n\telse {\n\t\tlet x = d * a - b * c;\n\t\tlet y = d * a;\n\t\tlet g = gcd(x, y);\n\t\tconsole.log((x / g) + '/' + (y / g));\n\t}\n}\n\n\n\n// reader and main caller\n\nlet readline = require('readline');\n\nlet rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout,\n\tterminal: false\n});\n\nlet inputBuf = [];\nlet inputBufCnt = 0;\nlet tk = []\nlet tkCnt = 0;\n\nfunction nextLine() {\n\treturn inputBuf[inputBufCnt++];\n}\nfunction next() {\n\tif(tkCnt == tk.length) {\n\t\ttk = inputBuf[inputBufCnt++].split(' ');\n\t\ttkCnt = 0;\n\t}\n\treturn tk[tkCnt++];\n}\nfunction nextInt() {\n\treturn parseInt(next());\n}\nfunction nextDouble() {\n\treturn parseFloat(next());\n}\n\nrl.on('line', (line) => {\n\tinputBuf.push(line);\n}).on('close', () => {\n\tmain();\n});\n", "lang_cluster": "Javascript", "tags": ["math", "greedy", "number theory"], "code_uid": "b956a6da37cc8349f69e09aa14a10e1f", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n})\nreadline.question(\"\",ans=>{\n if(ans.match(/[HQ9]/g))\n console.log(\"YES\")\n else\n console.log(\"NO\")\n readline.close()\n})\n\n\n\n\n/* ahsgdiojidqh iuwhu\nHqweuyquir\nljhfasQkajshd\nosaufHlaksjd\nQaslkdhjasd */", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "02d7551bbd599e44144abf059f0c4320", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let standard_input = process.stdin;\n\nstandard_input.setEncoding('utf-8');\n\nlet x = 0;\nlet k = 0;\n\n\nstandard_input.on('data', data =>{\n\nlet data_found = data.split(\" \")\nlet x = parseInt(data_found[0]);\nlet k = parseInt(data_found[1]);\n\nfor(var i = 0;i < k;i++)\n{\n if(x % 10 == 0)\n {\n x = x / 10;\n }\n else\n {\n x = x-1;\n }\n\n}\n\nconsole.log(x)\n\n\n\n\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "b15b099427c9c9f6395f33bc4bf2a9d3", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Beautiful Year\n\nconst {EOL} = require('os');\n\nlet inp = '';\n\nprocess.stdin.on('data', c => inp += c);\n\nprocess.stdin.on('end', () => {\n const n = +inp.split(EOL)[0];\n\n let dist = (i) => {\n \treturn (i + '').length == (new Set((i + '').split(''))).size;\n };\n\n for(var i = n + 1; !dist(i); i++) {}\n\n \tprocess.stdout.write(i + '');\n\n return;\n});", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "3a3a5aabd448458671ac0b495c3bae50", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n var answer;\n if(/^S(.*)F$/g.test(stdin[1])){\n answer='YES';\n }else{\n answer='NO';\n }\n console.log(answer);\n}\n\nconst readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar stdin = [];\nrl.on('line', function (line) {\n stdin.push(line);\n});\nrl.on('close', main);\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "840c326f0b183b8637c7496681399721", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\n\nreadLine.on('close', () => {\n const [k] = input[0].split(' ').map(x => parseInt(x));\n const nums = input[1].split(' ').map(x => parseInt(x));\n\n nums.sort((a, b) => a - b);\n if (k === 0) { console.log(0); return; }\n \n let sum = 0; let c = 0;\n for (let i = nums.length-1; i >= 0; i -= 1) {\n sum += nums[i];\n if (sum >= k) {\n console.log(c+1); return;\n }\n\n c += 1;\n }\n\n console.log(-1);\n}); ", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "054c0e1fdbd2f0041f4c1a6663ee6bda", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const len = +readLine() + 1;\n let count = 0;\n const sum = readLine()\n .split(\" \")\n .reduce((sum, n) => sum + +n, 0);\n\n for (let i = 1; i <= 5; i++) {\n if ((sum + i) % len !== 1) count++;\n }\n console.log(count);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "25f75fe51c35ba78eaf9f6fc738b1451", "src_uid": "ff6b3fd358c758324c19a26283ab96a4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString='';\nlet currentLine=0;\nprocess.stdin.on('data',inputStdin=>{\n inputString+=inputStdin;\n});\nprocess.stdin.on('end',_=>{\n inputString=inputString.trim().split(\"\\n\").map(string=>{\n return string.trim();\n });\n main();\n});\nfunction readLine()\n{\n return inputString[currentLine++]; \n}\nfunction main()\n{\n const N=parseInt(readLine());\n let marks=readLine().trim().split(' ').map(x=>{return +(x);});\n marks.sort((a,b)=>a-b);\n let sum=marks.reduce((a,b)=>a+b);\n //console.log(marks);\n for(let i=0;i=4.5)\n {\n console.log(i);\n return;\n }\n sum=sum-marks[i]+5;\n }\n if(sum/N>=4.5)\n {\n console.log(N);\n }\n}\n\n\n", "lang_cluster": "Javascript", "tags": ["sortings", "greedy"], "code_uid": "b9adfcadba880096bab905182c1d4f95", "src_uid": "715608282b27a0a25b66f08574a6d5bd", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\nconst bananas = () => {\n const [k, n, w] = input[0].split(' ').map(x => +x);\n let q = 0;\n for (let i = 1; i <= w; i++) {\n q += i*k;\n }\n console.log(q <= n ? 0 : q - n );\n};\n\nreadLine.on('close', bananas);\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "5773638d61f41b7e0cc583d8d31c88d1", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function printAnswer([l1, l2]) {\n const [x, y, z] = l1.split(' ').map(Number);\n const [a, b, c] = l2.split(' ').map(Number);\n const ans = solve(x, y, z, a, b, c);\n console.log(['YES', 'NO'][ans]);\n}\n\nfunction solve(x, y, z, a, b, c) {\n if (x > a || x + y > a + b || x + y + z > a + b + c) {\n return 1;\n } else {\n return 0;\n }\n}\n\nconst readline = require('readline');\nconst rl = readline.createInterface({ input: process.stdin });\nconst input = [];\nrl.on('line', (line) => input.push(line));\nrl.on('close', () => printAnswer(input));\n", "lang_cluster": "Javascript", "tags": ["brute force", "greedy", "implementation"], "code_uid": "80047449340a067cf5c9abb8654ff88d", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nreadline.on('line',main);\n\nfunction main(line) {\n const letters = [\"A\", \"O\", \"Y\", \"E\", \"U\", \"I\"];\n let mas = line\n .split('')\n .filter(letter => letters.indexOf(letter.toUpperCase()) === -1);\n let newMas = [];\n for (let i = 0; i < mas.length; i++){\n newMas.push('.');\n newMas.push(mas[i].toString().toLowerCase());\n }\n console.log(newMas.join(''));\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "a26c258895165d03dbe778c9d2c0a217", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('ascii');\n\nvar input_stdin = \"\";\nvar input_stdin_array = \"\";\nvar input_currentline = 0;\n\nprocess.stdin.on('data', function (data) {\n input_stdin += data;\n});\n\nprocess.stdin.on('end', function () {\n input_stdin_array = input_stdin.split(\"\\n\");\n main(); \n});\n\nfunction readLine() {\n return input_stdin_array[input_currentline++];\n}\n\nfunction solveMeFirst(a, b, c) {\n // Hint: Type return a+b below \n var ret = 0;\n ret = Math.ceil(a/c)*Math.ceil(b/c);\n return ret;\n}\n\n\nfunction main() {\n var a, b; \n var c, d, e;\n e = readLine();\n d = e.toString().split(' ');\n a = parseInt(d[0]); b = parseInt(d[1]); c = parseInt(d[2]);\n\n var res = solveMeFirst(a, b, c);\n console.log(res);\n}\n\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "bbd661ebceb319ecccb092173be0297f", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"ascii\");\n_input = \"\";\nprocess.stdin.on(\"data\", function (input) {\n _input += input;\n});\n\nprocess.stdin.on(\"end\", function () {\n processData(_input);\n});\n\nfunction processData(input) {\n const values = input.split('\\n')\n if (values && values.length > 0 && values[0]%2 === 0) {\n const temp = Math.floor(values[0]/2)\n if (temp%2 === 0) {\n console.log(\"YES\")\n\n } else {\n let eneteredValue = parseInt(values[0])\n for(let i=2;i {\n input.push(line);\n});\n\nRL.on('close', () => {\n let {0:n, 1:m, 2:k} = {...input[0].split(' ')};\n n = parseInt(n); m = parseInt(m); k = parseInt(k);\n\n if(m >= n && k >= n)\n console.log('Yes');\n else\n console.log('No');\n});\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "660de8723440c801fd9ee3c846aba0ff", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar check = function (str) {\n let len = str.length;\n if (len == 0 || len > 16)\n return false;\n\n for (let i = 0; i < len; i++) {\n if (!((str[i] >= '0' && str[i] <= '9') ||\n (str[i] >= 'a' && str[i] <= 'z') ||\n (str[i] >= 'A' && str[i] <= 'Z') ||\n str[i] == '_'))\n return false;\n }\n return true;\n}\n/*\n\n input = \"something@ipsu.edu.tetu.com/pageone\"\n\n hostName = \"ipsu.edu.tetu.com\";\n\n arr[] = {\"ipsu\", \"edu\", \"tetu\", \"com\"}\n\n*/\nvar checkHost = function(hostName){\n let len = hostName.length;\n if(len==0 || len>32)\n return false;\n \n let arr = hostName.split('.');\n for(let i=0; i {\n\n let AtIndex = input.indexOf('@');\n let isUser = false, isHost = false, isResource = false;\n if (AtIndex != -1) {\n let userName = input.substring(0, AtIndex);\n isUser=check(userName);\n \n let slashIndex = input.indexOf('/');\n let hostName = slashIndex != -1 ? input.substring(AtIndex+1, slashIndex) : input.substring(AtIndex+1);\n isHost=checkHost(hostName);\n\n if(slashIndex == -1) \n isResource=true;\n else{\n let resource = input.substring(slashIndex+1);\n isResource=check(resource);\n }\n }\n /*\n if(isUser && isHost && isResource)\n console.log(\"YES\");\n else\n console.log(\"NO\");\n */\n console.log((isUser && isHost && isResource) ? \"YES\" : \"NO\");\n rl.close();\n});\n\n\n\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "cf8a04b7c694870600436ab88aeb7db3", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input.push(line);\n});\n\n\nRL.on('close', () => {\n let {0:n, 1:m} = {...input[0].split(' ')};\n n = parseInt(n); m = parseInt(m);\n let nums = []; input[1].split(' ').forEach(i => nums.push(parseInt(i)));\n let y = new Set(); input[2].split(' ').forEach(i => y.add(parseInt(i)));\n \n let answer = '';\n for(let i of nums) {\n if(y.has(i)) {\n answer += `${i} `;\n }\n }\n console.log(answer);\n\n});\n\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "cc1134fcf4b6fc9fb9b2a42b5f33caa0", "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n const arr = d.split(' ').map(Number);\n arr.sort((a, b) => a - b);\n let ans = Math.max(0, arr[arr.length - 1] - 25);\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["greedy", "implementation"], "code_uid": "66e71f6ee5f1735141f6fb014ade9ef1", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let word = readLine().toLowerCase();\n let wordArray = word.split('');\n for (let i = 0; i < wordArray.length; i++) {\n if (\n wordArray[i] === 'a' ||\n wordArray[i] === 'e' ||\n wordArray[i] === 'i' ||\n wordArray[i] === 'o' ||\n wordArray[i] === 'u' ||\n wordArray[i] === 'y'\n ) {\n // wordArray.splice(i, 1);\n delete wordArray[i];\n }\n }\n let next = wordArray.join('');\n let nextArray = next.split('');\n for (let i = 0; i < nextArray.length; i++) {\n nextArray[i] = '.' + nextArray[i];\n // console.log(next);\n }\n // console.log(nextArray);\n let final = nextArray.join('');\n console.log(final);\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "6a700895ee025704411ec6ce9700dbba", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction main() {\n\tlet [n, m] = readLine()\n\t\t.split(' ')\n\t\t.map(x => x >> 0);\n\n\tlet arr = readLine()\n\t\t.split(' ')\n\t\t.map(x => x >> 0);\n\n\tarr.sort((a, b) => a - b);\n\tlet d = [];\n\tfor (let i = 0; i <= m - n; i++) {\n\t\td.push(arr[i + n - 1] - arr[i]);\n\t}\n\tconsole.log(Math.min(...d));\n}\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "8bc8baad550cb35505c37b88fb51a75d", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n [n, k] = d.split(' ').map(Number);\n return;\n }\n\n const str = d;\n let idxG = str.indexOf('G');\n let idxT = str.indexOf('T');\n let ans = 'NO';\n\n for (let i = idxG; i <= idxT; i += k) {\n if (str[i] === '#') {\n break;\n }\n\n if (str[i] === 'T') {\n ans = 'YES';\n }\n }\n\n for (let i = idxG; i >= idxT; i -= k) {\n if (str[i] === '#') {\n break;\n }\n\n if (str[i] === 'T') {\n ans = 'YES';\n }\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "7a7c3674751f9c6eb3224ecd35647964", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict'\r\nObject.defineProperty(exports, '__esModule', { value: !0 })\r\nvar os = require('os')\r\nfunction fastModuloPower(e, n, t) {\r\n let r = 1n\r\n for (let s = n, i = e; s > 0; s >>= 1, i = (i * i) % t)\r\n 1 & s && (r = (r * i) % t)\r\n return r\r\n}\r\nconst stdin = process.stdin,\r\n stdout = process.stdout,\r\n integerRegex = /-?\\d+/g,\r\n decimalRegex = /-?\\d+(?:\\.\\d+)?/g\r\nclass InputAndOutput {\r\n lineIndex = 0\r\n lines = []\r\n dried() {\r\n return this.lineIndex >= this.lines.length\r\n }\r\n readLine() {\r\n const e = this.lines[this.lineIndex]\r\n return (this.lineIndex += 1), e\r\n }\r\n readIntegersOfLine() {\r\n const e = this.readLine().match(integerRegex)\r\n return null == e ? [] : e.map(e => Number(e))\r\n }\r\n readNumsOfLine() {\r\n const e = this.readLine().match(decimalRegex)\r\n return null == e ? [] : e.map(e => Number(e))\r\n }\r\n print(e) {\r\n stdout.write(e)\r\n }\r\n async init() {\r\n const e = await this.readLines()\r\n this.lines = e\r\n }\r\n readLines() {\r\n const e = []\r\n return new Promise(n => {\r\n stdin.on('data', n => e.push(n)),\r\n stdin.on('end', function () {\r\n const t = e.join('').split(os.EOL)\r\n n(t)\r\n })\r\n })\r\n }\r\n}\r\nasync function __main__(e) {\r\n const n = new InputAndOutput()\r\n await n.init(), e(n)\r\n}\r\nconst MOD = BigInt(1000000007),\r\n MAX_N = 200010,\r\n f = new Array(MAX_N),\r\n h = new Array(MAX_N)\r\nfunction solve(e, n) {\r\n if (0 === n) return 1n\r\n const t = 1 & e ? f[e - 1] + 1n : f[e - 1] - 1n,\r\n r = fastModuloPower(t, n, MOD)\r\n if (1 & e) return r\r\n for (let t = 0, r = 1n; t <= n; ++t, r = (r * f[e]) % MOD) h[t] = r\r\n let s = 0n\r\n for (let e = 1, r = 1n; e <= n; ++e)\r\n (s += (r * h[n - e]) % MOD), (r = (r * t) % MOD)\r\n return (((fastModuloPower(f[e], n, MOD) - s * f[e - 1]) % MOD) + MOD) % MOD\r\n}\r\n__main__(function (e) {\r\n f[0] = 1n\r\n for (let e = 1; e < MAX_N; ++e) f[e] = (2n * f[e - 1]) % MOD\r\n const n = Number(e.readLine())\r\n for (let t = 1; t <= n; ++t) {\r\n const [n, t] = e.readIntegersOfLine(),\r\n r = solve(n, t)\r\n e.print(r + '\\n')\r\n }\r\n})\r\n", "lang_cluster": "Javascript", "tags": ["math", "dp", "combinatorics", "bitmasks", "matrices"], "code_uid": "b3b73fec04d64fb0b781505662b36dab", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n var arr=stdin[0].split(' ').map(a => Number(a));\n var num=Math.ceil(arr[0]/arr[2])*Math.ceil(arr[1]/arr[2]);\n console.log(num);\n}\n\nconst readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar stdin = [];\nrl.on('line', function (line) {stdin.push(line);});\nrl.on('close', main);", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "ea8c1ae785c1bd8c224a2582708cf2ce", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet data = [];\nrl.on('line', (input) => {\n data.push(input);\n});\n\nrl.on('close', () => {\n solve(data);\n});\n\nfunction solve(data) {\n\n let row, col;\n for (let i = 0; i < data.length; i++) {\n line = data[i].split(\" \");\n for (let j = 0; j < line.length; j++) {\n if (line[j] === \"1\") {\n row = i + 1;\n col = j + 1;\n }\n }\n }\n\n console.log(Math.abs((3-row)) + Math.abs((3-col)));\n\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0d55a9be7621952d3fb443f172b8dc15", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const {EOL} = require('os')\n\nlet ipt = ''\nprocess.stdin.on('data', s => ipt += s)\nprocess.stdin.on('end', () => {\n const [x, y] = ipt.split(EOL).slice(0, -1)[0].split(' ').map(v => parseInt(v))\n\n const P = [2]\n o: for (let i = 3; i <= y; i++) {\n for (let j = 0; j < P.length; j++) {\n if (!(i % P[j])) continue o\n }\n P.push(i)\n }\n\n const i = P.indexOf(x)\n console.log(P[i + 1] == y ? 'YES' : 'NO')\n})", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "0ec1a58bfe58e2dbb82dd99c55e8a869", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\nlet input = []\nrl.on('line', line => {\n input = line.split(' ').map(x => parseInt(x))\n const output = solution(input[0], input[1])\n console.log(output)\n})\nrl.on('close', () => {\n \n})\n\n\n\nconst solution = function(n, k){\n let res = n;\n const getLastDigit = function(d){\n let last = d%10;\n return +last;\n };\n\n for (let i = 0; i < k; i++){\n let lastDigit = getLastDigit(res);\n \n if (lastDigit !== 0) {\n res--;\n } else {\n res = res/10;\n }\n }\n return res;\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "bbe8d7117a8c9f2db039f20644a244c3", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n let [k, r] = d.split(' ').map(Number);\n // let ans = 0;\n // let coin = 10;\n // let c = 1;\n // let v = k;\n\n // while (true) {\n // if (v % coin === 0 || v % coin === r) {\n // break;\n // }\n // else {\n // ans++;\n // v = k * c;\n // c++;\n // }\n // }\n\n let ans = 1;\n while(true) {\n if (ans*k % 10 === 0 || ans*k % 10 === r) {\n console.log(ans);\n break;\n }\n\n ans++;\n }\n\n // console.log(Math.max(1, ans));\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "c360498cf4bd332049174e7b64f5eb8f", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//96A\nconst readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nrl.question('', (answer) => {\n rl.close()\n let team1 = 0\n let team2 = 0\n let array = answer.split(\"\")\n let i = 1\n array.forEach(function(player) {\n \n if (player == 0) {\n team2 = 0\n team1++\n if (team1 == 7) {\n if (!i == 0) {\n console.log(\"YES\")\n i = 0\n\n }\n }\n } else {\n team2 ++\n team1 = 0\n if (team2 == 7) {\n if (!i == 0) {\n console.log(\"YES\")\n i = 0\n }\n \n \n }\n }\n })\n if (!i == 0) {\n console.log(\"NO\")\n }\n \n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "474009101f4161ce1626dc61f1e33ec5", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// 131A - cAPS lOCK\n// http://codeforces.com/problemset/problem/131/A\n\nfunction main() {\n let s = read();\n let ans = s;\n if (s.length === 1 || s.substring(1, s.length) === s.substring(1, s.length).toUpperCase()) {\n ans = \"\";\n for (let i = 0; i < s.length; i++) {\n if (s[i] === s[i].toUpperCase()) {\n ans += s[i].toLowerCase();\n } else {\n ans += s[i].toUpperCase();\n }\n }\n }\n writeline(ans);\n return 0;\n}\n\nvar input = \"\";\nvar read;\nvar writeline = (x) => process.stdout.write(x + \"\\n\");\nvar write = (x) => process.stdout.write(x);\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf8\");\nprocess.stdin.on(\"data\", (chunk) => input += chunk);\nprocess.stdin.on(\"end\", () => {\n input = input.trim().split(/\\s+/);\n read = () => input.shift();\n process.exit(main() || 0);\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "dfe0e7e5516661814f2296c6434f86a9", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nfunction eatMoreTimka(tim, oleg){\n let year = 0;\n while (tim <= oleg){\n tim *= 3;\n oleg *= 2;\n year++;\n }\n //console.log(`Tim will be bigger than Oleg after ${year} years!\\n${tim} versus ${oleg}`)\n return(year);\n}\n\nrl.on('line', (line) => {\n [tim, oleg] = line.split(' ', 2).map(Number);\n console.log(eatMoreTimka(tim, oleg));\n process.exit(0);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "c18d51b7bedb99c37b107138988915b8", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', (firstLine) => {\n rl.on('line', (secondLine) => {\n let output;\n if(firstLine.toLowerCase() < secondLine.toLowerCase()) {\n output = -1\n } else if(firstLine.toLowerCase() == secondLine.toLowerCase()){\n output = 0\n } else if(firstLine.toLowerCase() > secondLine.toLowerCase()){\n output = 1\n }\n console.log(output); \n rl.close();\n });\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "dcc3c08f89752622f0e1dd8983135fc1", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\nrl.on('line', function(line){\n console.log(solve(line))\n })\n\nfunction solve(line){\n var cnt = 0;\n for(var i = 0; i < line.length; i++)\n if(line[i] == '7' || line[i] == '4')\n cnt++\n if(cnt == 7 || cnt == 4)\n return 'YES'\n else\n return 'NO'\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "a2536d49bc5133dd001639ba7fc06c88", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const stdin = process.openStdin();\n\nprocess.stdin.on('data', function (chunk) {\n lines = chunk.toString().split('\\n');\n lines.map((line, i) => processLine(line, i));\n});\n\nlet meta;\nlet scores;\nlet output = 0;\nfunction processLine(text, i) {\n if (i === 0) {\n meta = text.toString().trim().split(' ');\n } else if (i === 1) {\n scores = text.toString().trim().split(' ').map(each => parseInt(each, 10));\n const border = scores[meta[1] - 1];\n scores.forEach(score => {\n if (score && score >= border) {\n output += 1;\n }\n })\n console.log(output);\n }\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "4c63aa5eddb24e56d68226038c9b7fef", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = ''\nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os')\n const lines = i.split(EOL);\n\n function foo (length, minCount, maxCount) {\n\n function generateGrowArray(n) {\n return [...Array(n)].reduce(acc => {\n acc.push((acc[acc.length - 1]) * 2 || 1);\n return acc;\n }, []);\n }\n\n function getMinArray(length, minCount) {\n let growArray = generateGrowArray(minCount);\n\n let lineArray = new Array(length - minCount).fill(1);\n return lineArray.concat(growArray);\n }\n\n function getMaxArray(length, maxCount) {\n let growArray = generateGrowArray(maxCount);\n\n let lineArray = new Array(length - maxCount).fill(growArray[growArray.length - 1]);\n return growArray.concat(lineArray);\n }\n\n function getSum(array) {\n return array.reduce((a, b) => a + b);\n }\n\n let minArray = getMinArray(length, minCount);\n //console.log(minArray);\n let maxArray = getMaxArray(length, maxCount);\n //console.log(maxArray);\n return [getSum(minArray), getSum(maxArray)].join(\" \");\n }\n\n\n let data = lines[0].split(\" \").map(Number);\n let result = foo(...data);\n\n console.log(result);\n})", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "f8247e8beb05f72f04caa9a83ca0ae82", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n \nlet stdinInput = '';\n \nprocess.stdin.on('data', input => {\n stdinInput += input;\n})\n \nprocess.stdin.on('end', () => {\n main(stdinInput);\n})\n \nfunction main(data) {\n data = data.split(' ');\n const count = Math.floor(data[0] * data[1] / 2);\n process.stdout.write(count + '');\n}", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "f6798efd06fe850ad436af4e9a1ddf3d", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input.push(line);\n});\n\n\nRL.on('close', () => {\n const n = input[0]; let count = 0; let nowPos = 0; \n for(let i = 0; i < n.length; i += 1){\n const pos = parseInt(n.charCodeAt(i), 10)-97;\n let tmpCount = 0;\n if(nowPos !== pos) {\n if(nowPos > pos) {\n const right = nowPos - pos;\n const left = 26-nowPos + pos;\n\n if(right > left)\n count += left;\n else \n count += right;\n } else {\n const right = pos - nowPos;\n const left = nowPos + 26 - pos;\n\n if(right > left)\n count += left;\n else \n count += right;\n }\n }\n nowPos = pos;\n }\n console.log(count);\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "be07cd7f41497d3a73d5a363187a2a1c", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const mainFunction = (lines) => {\n let k, a, b;\n [k, a, b] = lines[0].split(\" \").map(Number)\n let c = Math.floor(a / k),\n d = Math.floor(b / k),\n cc = a % k,\n dd = b % k\n console.log((cc && !d) || (dd && !c) ? -1 : c + d)\n}\n\nconst { EOL } = require('os'),\n fs = require(\"fs\");\nif (__filename.substr(9, 4) != \"azer\") {\n let yourInput = ''\n process.stdin.on('data', i => yourInput += i)\n process.stdin.on('end', () => mainFunction(yourInput.split(EOL)))\n} else {\n mainFunction(fs.readFileSync('input.txt', 'utf8').split(EOL))\n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "58f68dc772154d74930a1927aaa531a5", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//nodejs v4.2.6\nprocess.stdin.resume(); \n\tprocess.stdin.setEncoding('utf8');\n\t//Taking a usr input\n\tprocess.stdin.on('data', function (text) {\n\t\t\t//Printing out user input\n\t\t\tvar input = parseInt(text)\n\t\t\t\tif(input===2){\n\t\t\t\t\tconsole.log('NO')\n\t\t\t\t}else\n\t\t\t\tif(input%2 === 0){\n\t\t\t\t\tconsole.log('YES');\n\t\t\t\t}else{\n\t\t\t\t\tconsole.log('NO')\n\t\t\t\t}\n\t});\n ", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "e41631a9dd4e7e6939fea214d9780f2a", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet stdin = '';\n\nprocess.stdin.on('data', (input) => {\n stdin += input;\n});\n\nprocess.stdin.on('end', () => {\n const data = stdin.split('\\n')[1];\n\n let counter = 0;\n\n for (let i = 0; i < data.length - 1; i++)\n if (data[i] === data[i + 1]) counter++;\n\n process.stdout.write(String(counter));\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3f7ed6a42723d94d7a190cd733db7b43", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n↑入力 ↓出力');\n Main();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var one = nextIntArray();\n var a = one[0];\n var b = one[1];\n var c = one[2];\n var output = c * 2 + Math.min(b, a) * 2;\n if(b != a){\n output++;\n }\n myout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "ffa1f2dfff9f77d8759b776809599a0a", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\nreadline.question(\"\", (weights) => {\n weights=weights.split(\" \");\n w1=weights[0];\n w2=weights[1];\n let year=0;\n while(true)\n {\n year++;\n w1*=3;\n w2*=2;\n // console.log(`${year}=> w1:${w1},w2:${w2}`)\n if(w1>w2){\n break;\n }\n\n }\n console.log(year)\n readline.close()\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "095d08b497033aec22d3028a0062cf34", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\n\nconst runMain = () => {\n inputString = inputString.trim().split('\\n').map(string => string.trim());\n main();\n process.exit();\n}\nconst readLine = () => inputString[currentLine++];\n\nprocess.stdin.on('data', inputStdin => inputString += inputStdin);\nprocess.stdin.on('end', runMain);\nprocess.on('SIGINT', runMain);\n\nfunction main() {\n const [a, b] = readLine().split(' ').map(num => Number(num));\n console.log(Math.floor(Math.log(b / a) / Math.log(3 / 2)) + 1);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f059cbc5ddd249da15976746cb32c1cd", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let z = '';\nprocess.stdin.on('data', c => z += c);\nprocess.stdin.on('end', () => {\n const {\n EOL\n } = require('os');\n let input = z.split(EOL)[0]\n\n let aCount = input.match(/[a]/g).length;\n let othersCount = input.length-aCount;\n if (aCount > othersCount) {\n console.log(input.length);\n return 0;\n }\n console.log(input.length-(othersCount-aCount+1));\n \n\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "290a79684fd00789b94162dd3a897598", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (str) => {\n let ans = 0;\n\n for (let i = 0; i < str.length - 2; i++) {\n for (let j = i + 1; j < str.length - 1; j++) {\n for (let k = j + 1; k < str.length; k++) {\n const val = str[i] + str[j] + str[k];\n\n if (val === 'QAQ') {\n ans++;\n }\n }\n }\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "dp"], "code_uid": "a10b14d8c2f4e3fb24b9e56b581ca38c", "src_uid": "8aef4947322438664bd8610632fe0947", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var dataitr;\r\nvar stdin_input = \"\";\r\nprocess.stdin.resume();\r\nprocess.stdin.setEncoding(\"ascii\");\r\nprocess.stdin.on(\"data\", function (input) { stdin_input += input; });\r\nprocess.stdin.on(\"end\", function () { dataitr = stdin_input.split('\\n').values(); main(); });\r\n\r\nconst rl = () => dataitr.next().value.trim();\r\nconst rn = () => Number(rl());\r\nconst ra = () => rl().split(' ');\r\nconst rna = () => ra().map(x => Number(x));\r\n\r\nconst MOD = 998244353;\r\n\r\nfunction main () {\r\n\tconst n = rn();\r\n\r\n\tconst dp = Array(n + 1).fill(0);\r\n\tfor (let i = 1; i <= n; i++) {\r\n\t\tfor (let j = i; j <= n; j += i) {\r\n\t\t\tdp[j]++;\r\n\t\t}\r\n\t}\r\n\r\n\tfor (let i = 1, psm = 0; i <= n ; i++) {\r\n\t\tdp[i] += psm;\r\n\t\tpsm = (psm + dp[i]) % MOD;\r\n\t}\r\n\r\n\tconsole.log(dp[n]);\r\n}\r\n\r\n", "lang_cluster": "Javascript", "tags": ["math", "dp", "combinatorics"], "code_uid": "0ae25a5e2a5b5cedbe3412436611616d", "src_uid": "09be46206a151c237dc9912df7e0f057", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet currentLine = 0;\nlet inputString = \"\";\n\nprocess.stdin.on(\"data\", (raw_data) => {\n inputString += raw_data;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((line) => {\n return line.trim();\n });\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n/******** Main function*************/\n\nfunction main() {\n var [m, n, a] = readLine().split(\" \").map(Number);\n\n var numberOfn, numberOfm;\n\n // if (n % a) {\n // numberOfn = Math.floor(n / a + 1);\n // } else {\n // numberOfn = Math.floor(n / a);\n // }\n\n // if (m % a) {\n // numberOfm = Math.floor(m / a + 1);\n // } else {\n // numberOfm = Math.floor(m / a);\n // }\n var sum = Math.ceil(n / a) * Math.ceil(m / a);\n\n console.log(sum);\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "6a89a18f9c1b0a43cb614e7dfdcb7232", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data', (n) => \n process.stdout.write(n < 4 || n % 2 ? 'NO' : 'YES')\n);", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "8c2c72a05508af2573a06009bca1c496", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(str) {\n let values = str.trim().split(' ');\n let subtractTo = +values[0];\n\n for (let i = 0; i < +values[1]; i++) {\n let remainder = subtractTo % 10;\n if (remainder === 0) {\n subtractTo /= 10;\n }\n else {\n subtractTo -= 1;\n }\n }\n\n return subtractTo.toString();\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "114fd48acc17daf6ad13fb13d568c626", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\nasync function read(stream) {\n const chunks = [];\n for await (const chunk of stream) chunks.push(chunk); \n return Buffer.concat(chunks).toString('utf8');\n}\nfunction comp(s,t){\n for(let i = 0; i < s.length; ++i){\n if(s[i] != t[i]){\n if(s[i] < t[i])\n return -1;\n else\n return 1;\n }\n }\n return 0;\n}\nconst input = read(process.stdin);\ninput.then(\n lines => {\n lines = lines.split('\\n')\n let s = lines[0].toLowerCase()\n let t = lines[1].toLowerCase()\n console.log(comp(s,t))\n }\n)\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "66cb6e8be87385b49dfa29f8027744f3", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "if (process.argv[2] === \"test\") {\n solve([\"3 7\"]);\n} else {\n let i = \"\";\n process.stdin.on(\"data\", (c) => (i += c));\n process.stdin.on(\"end\", () => {\n const { EOL } = require(\"os\");\n const lines = i.split(EOL);\n\n solve(lines);\n });\n}\n\nfunction solve(lines) {\n const [m, n] = lines[0].split(\" \");\n console.log(Math.floor((m * n) / 2));\n}\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "7e26f7d395e146844d66c585cfbe703f", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction main() {\n\tconst position = readLine().split('');\n\tlet counter = 1,\n\t\t{ length } = position,\n\t\tdangerous = false,\n\t\tcurrentPlayer = position[0];\n\n\tfor (let i = 1; i < length; ++i) {\n\t\tif (position[i] === currentPlayer) {\n\t\t\tcounter++;\n\t\t} else {\n\t\t\tcounter = 1;\n\t\t\tcurrentPlayer = position[i];\n\t\t}\n\n\t\tif (counter >= 7) {\n\t\t\tdangerous = true;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tdangerous ? console.log('YES') : console.log('NO');\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "1a2600b4b99f1f6c8656ba43f90971d7", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main(input) {\n \n let [limak, bob] = input.split(' ');\n [limak, bob] = [parseInt(limak), parseInt(bob)];\n let counter = 0;\n while(true){\n if(limak > bob) {\n console.log(counter);\n return;\n }\n else {\n limak = 3 * limak;\n bob = 2 * bob;\n counter++;\n }\n } \n \n \n}\n\nfunction getBaseLog(a, b) {\n return Math.log(b) / Math.log(a)\n}\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input;\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "6cab12dd34032787ad282176e86257dd", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet a, b;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n [yH, bH] = d.split(' ').map(Number);\n return;\n }\n\n const [y, g, b] = d.split(' ').map(Number);\n\n const yellow = y * 2 + g;\n const blue = b * 3 + g;\n const ans = Math.max(0, yellow - yH) + Math.max(0, blue - bH);\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "b29fbcc5085d3c128e3cc3cac7a27368", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction main() {\n\tconst a = readLine() >> 0;\n\tconst b = readLine() >> 0;\n\tconst c = readLine() >> 0;\n\n\tlet values = [];\n\tvalues.push(a + b + c);\n\tvalues.push(a * (b + c));\n\tvalues.push(a * b + c);\n\tvalues.push((a + b) * c);\n\tvalues.push(a + b * c);\n\tvalues.push(a * b * c);\n\n\tconsole.log(Math.max(...values));\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "39e20d1e01b044eed4e6200e7d1abaeb", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\r\nvar read = require('readline').createInterface({\r\n\tinput: process.stdin, output: process.stdout\r\n});\r\nvar obj; var inLine = []; var outputList = [];var retcode = new Set();\r\nread.on('line', function(input){\r\n\tvar tmp = input.split(' ');\r\n\tfor(var i = 0; i < tmp.length; i++){\r\n\t\tinLine.push(tmp[i]);\r\n\t\tif(i == tmp.length - 1){\r\n\t\t\tretcode.add(inLine.length);\r\n\t\t}\r\n\t}\r\n});\r\nread.on('close', function(){\r\n\tobj = init(inLine);\r\n\tconsole.error('\\n↑入力 ↓出力');\r\n\tMain();\r\n\tconsole.log(myconv(outputList, 9));\r\n});\r\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\r\nfunction nextArray(size, code){\r\n\tvar ret = new Array(size);\r\n\tfor(var i = 0; i < size; i++){\r\n\t\tif(code == 'int'){\r\n\t\t\tret[i] = nextInt();\r\n\t\t}else if(code == 'long'){\r\n\t\t\tret[i] = nextLong();\r\n\t\t}else if(code == 'double'){\r\n\t\t\tret[i] = nextDouble();\r\n\t\t}else{\r\n\t\t\tret[i] = next();\r\n\t\t}\r\n\t}\r\n\treturn ret;\r\n}\r\nfunction nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');} function nextDoubleArray(size){return nextArray(size, 'double');}\r\nfunction nextCharArray(){return myconv(next(),6);}\r\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());} function nextDouble(){return parseFloat(next());}\r\nfunction getCountMap(list){\r\n\tvar map = {};\r\n\tfor(var i = 0; i < list.length; i++){\r\n\t\tif(map[list[i]] == null){\r\n\t\t\tmap[list[i]] = 0;\r\n\t\t}\r\n\t\tmap[list[i]]++;\r\n\t}\r\n\treturn map;\r\n}\r\nfunction init(input){ \r\n\treturn {\r\n\t\tlist : input, index : 0, max : input.length,\r\n\t\thasNext : function(){return (this.index < this.max);},\r\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},\r\n\t\tisReturn : function(){return retcode.has(this.index);}\r\n\t};\r\n}\r\nfunction myout(s){outputList.push(s);}\r\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\r\nfunction isReturn(){return obj.isReturn();}\r\n//param \"no\" is\r\n//unknown or outlier : return i. 1: parseInt.\r\n//2: split space. 4: split space and parseInt.\r\n//6: split 1 character. 7: split 1 character and parseInt.\r\n//8: join space. 9: join nextline. 0: join no character.\r\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\r\n\r\n//Don't have to see. end------------------------------------------\r\nfunction Main(){\r\n\tvar t = nextInt();\r\n\twhile(hasNext()){\r\n\t\tvar N = nextInt();\r\n\t\tvar set = new Set();\r\n\t\tfor(var i = 1; i * i <= N; i++){\r\n\t\t\tif(i * i * i <= N){\r\n\t\t\t\tset.add(i * i * i);\r\n\t\t\t}\r\n\t\t\tset.add(i * i);\r\n\t\t}\r\n\t\tmyout(set.size);\r\n\t}\r\n}\r\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "e4079a308cf01b12642bd6cb4324a265", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet l = 0;\nrl.on('line', (input) => {\n rl.close();\n let inp = input.split(\" \").map(x => parseInt(x))\n let ct = 0\n let s = inp[1]\n for (let i = inp[0]; i >= 0 && s > 0; i--) {\n ct += Math.floor(s / i)\n s = s - i * Math.floor(s / i)\n }\n console.log(ct)\n return 0;\n});\n", "lang_cluster": "Javascript", "tags": ["math", "greedy", "implementation"], "code_uid": "d4fe24a597e7cddd315f38ddcfdb6533", "src_uid": "04c067326ec897091c3dbcf4d134df96", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout,\n\tterminal: false\n});\n\nrl.on(\"line\", (line) => {\n var n = parseInt(line);\n if (n % 2 == 1) console.log(0);\n else {\n console.log(Math.pow(2, n/2));\n }\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["math", "dp"], "code_uid": "3d12f7e30b15fde2dcf158c053dffd14", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '',\n currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nconst readline = () => {\n return inputString[currentLine++];\n};\n\n//////////\n\nconst main = () => {\n const [n, m, a] = readline().split(' ').map(x => parseInt(x));\n\n console.log(Math.ceil(n / a) * Math.ceil(m / a));\n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "528d734e695b877241c35775b3174639", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet l = 0;\nrl.on('line', (input) => {\n if (l === 0) { l++ }\n else {\n rl.close();\n let arr = input.split(\" \").map(x => parseInt(x))\n let cnt = 0\n let max = 0\n for (let i = 1; i < arr.length; i++) {\n if (arr[i]===arr[i-1]+1) {\n cnt++\n if(i===1 && arr[i-1]===1){\n cnt++\n }\n if(i+1max){\n max=cnt\n }\n } else {\n cnt=0\n }\n }\n console.log(max)\n return 0;\n }\n})\n", "lang_cluster": "Javascript", "tags": ["greedy", "implementation"], "code_uid": "0fbf830dfae3f4fd634dfa55045c5e9d", "src_uid": "858b5e75e21c4cba6d08f3f66be0c198", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\nvar answer = 0;\nvar counter = 0;\nvar check = true;\n\nrl.on(\"line\", input => {\n \n let temp = input.match(/B/g);\n \n counter =(temp!=null)? temp.length : 0;\n\n if (counter == 8) {\n answer++;\n } \n else if (check && counter > 0) {\n answer += counter;\n check = false;\n }\n \n\n \n}).on(\"close\", () => {\n console.log(answer);\n });\n", "lang_cluster": "Javascript", "tags": ["brute force", "constructive algorithms"], "code_uid": "2b61f73a6f3ed5a1a49db7fcd043168f", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let buffer = '';\r\nprocess.stdin.on('data', c => buffer += c);\r\nprocess.stdin.on('end', () => {\r\n const { EOL } = require('os');\r\n const lines = buffer.split(EOL);\r\n lines.pop();\r\n\r\n main(lines);\r\n});\r\n\r\nfunction main(lines) {\r\n let index = 0;\r\n let T = Number(lines[index++]);\r\n let N;\r\n\r\n while (T--) {\r\n N = Number(lines[index++]);\r\n solve(N);\r\n }\r\n}\r\n\r\nfunction solve(N) {\r\n const seen = new Set();\r\n let result = 1;\r\n let sqrtN = Math.floor(Math.sqrt(N));\r\n let a, b;\r\n\r\n for (let n = 2; n <= sqrtN; ++n) {\r\n a = n ** 2;\r\n b = n ** 3;\r\n \r\n if (a <= N && !seen.has(a)) {\r\n result++;\r\n seen.add(a);\r\n }\r\n\r\n if (b <= N && !seen.has(b)) {\r\n result++;\r\n seen.add(b);\r\n }\r\n }\r\n\r\n console.log(result);\r\n}", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "b33c3ab250cdd19148a10cbaca74296c", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n\tvar N = nextInt();\n\tif(N <= 2){\n\t\tmyout(N);\n\t}else{\n\t\tmyout(1);\n\t}\n}\n", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms"], "code_uid": "a498808b77a4032b0f1a26d2b9c929aa", "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let x = parseInt(readLine());\n if (x % 5 == 0) {\n console.log(x / 5);\n } else {\n console.log(Math.floor(x / 5) + 1);\n }\n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "c0ea4a117e3cefd88a0cc5f78858967b", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let readline = require('readline');\nlet rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n});\n\nrl.on('line', function(line) {\n\tchatRoom(line);\n\trl.close();\n});\n\n//M N\nlet chatRoom = (input) => {\n\t//hello\n\tlet word = [ 'h', 'e', 'l', 'l', 'o' ];\n\tlet count = 0;\n\tfor (let i = 0; i < input.length; i++) {\n\t\tif (input.charAt(i) === word[count]) {\n\t\t\tcount++;\n\t\t}\n\t}\n\tcount === 5 ? console.log('YES') : console.log('NO');\n};\n", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "da866595c5a0fc3e272a76fa61ec5bda", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let brain = readLine();\n while (brain.includes('>')) {\n brain = brain.replace('>', '1000');\n }\n while (brain.includes('<')) {\n brain = brain.replace('<', '1001');\n }\n while (brain.includes('+')) {\n brain = brain.replace('+', '1010');\n }\n while (brain.includes('-')) {\n brain = brain.replace('-', '1011');\n }\n while (brain.includes('.')) {\n brain = brain.replace('.', '1100');\n }\n while (brain.includes(',')) {\n brain = brain.replace(',', '1101');\n }\n while (brain.includes('[')) {\n brain = brain.replace('[', '1110');\n }\n while (brain.includes(']')) {\n brain = brain.replace(']', '1111');\n }\n let ans = convertBase(brain, 2, 10);\n\n let final = 0;\n let length = ans.length;\n for (let i = 0; i < length; i++) {\n final = (final * 10 + (ans[i] - 0)) % 1000003;\n }\n console.log(final);\n}\n\nfunction parseBigInt(bigint, base) {\n //convert bigint string to array of digit values\n for (var values = [], i = 0; i < bigint.length; i++) {\n values[i] = parseInt(bigint.charAt(i), base);\n }\n return values;\n}\n\nfunction formatBigInt(values, base) {\n //convert array of digit values to bigint string\n for (var bigint = '', i = 0; i < values.length; i++) {\n bigint += values[i].toString(base);\n }\n return bigint;\n}\n\nfunction convertBase(bigint, inputBase, outputBase) {\n //takes a bigint string and converts to different base\n var inputValues = parseBigInt(bigint, inputBase),\n outputValues = [], //output array, little-endian/lsd order\n remainder,\n len = inputValues.length,\n pos = 0,\n i;\n while (pos < len) {\n //while digits left in input array\n remainder = 0; //set remainder to 0\n for (i = pos; i < len; i++) {\n //long integer division of input values divided by output base\n //remainder is added to output array\n remainder = inputValues[i] + remainder * inputBase;\n inputValues[i] = Math.floor(remainder / outputBase);\n remainder -= inputValues[i] * outputBase;\n if (inputValues[i] == 0 && i == pos) {\n pos++;\n }\n }\n outputValues.push(remainder);\n }\n outputValues.reverse(); //transform to big-endian/msd order\n return formatBigInt(outputValues, outputBase);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "299edb6bbe5187a1a2ffae14bca968ce", "src_uid": "04fc8dfb856056f35d296402ad1b2da1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var one = nextIntArray();\n var k = one[0];\n var r = one[1];\n var count = 1;\n while(true){\n if(k * count % 10 == r || k * count % 10 == 0){\n break;\n }\n count++;\n }\n myout(count);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "718671d65bdf2bc1abd922a1424d8dde", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\n\nconst runMain = () => {\n inputString = inputString.trim().split('\\n').map(string => string.trim());\n main();\n process.exit();\n}\nconst readLine = () => inputString[currentLine++];\n\nprocess.stdin.on('data', inputStdin => inputString += inputStdin);\nprocess.stdin.on('end', runMain);\nprocess.on('SIGINT', runMain);\n\nfunction main() {\n const n = readLine();\n const str1 = readLine();\n let pred = '';\n let str2 = ''; \n for (let i = 0; i < n; i++) {\n if (str1[i] !== pred) {\n str2 += str1[i];\n pred = str1[i];\n }\n }\n console.log(str1.length - str2.length);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "361caeb936edc0950e24bd27c7ec418e", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction print(s) {\n process.stdout.write(`${s}`);\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n // input\n const n = readline();\n const colors = readline();\n let pre;\n let result = 0;\n for (let i = 0; i < n; i++) {\n const c = colors.charAt(i);\n if (pre === c) {\n result++;\n } else {\n pre = c;\n }\n }\n // output\n print(result);\n}\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3ec8c11531bb3dc5c1094c90e80adcd3", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline')\n\nconst rl = readLine.createInterface({\n input: process.stdin,\n output: process.stdout,\n})\n\nconst input = []\n\nrl.on('line', line => input.push(line.toString().split(' ').map(Number)))\n\nrl.on('close', () => {\n const [[w]] = input\n console.log(['NO', 'YES'][Number((w - 2) % 2 === 0 && w > 3)])\n})\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "bddd834c4b289e01e1a2ae72508b1554", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\r\nvar read = require('readline').createInterface({\r\n\tinput: process.stdin, output: process.stdout\r\n});\r\nvar obj; var inLine = []; var outputList = [];var retcode = new Set();\r\nread.on('line', function(input){\r\n\tvar tmp = input.split(' ');\r\n\tfor(var i = 0; i < tmp.length; i++){\r\n\t\tinLine.push(tmp[i]);\r\n\t\tif(i == tmp.length - 1){\r\n\t\t\tretcode.add(inLine.length);\r\n\t\t}\r\n\t}\r\n});\r\nread.on('close', function(){\r\n\tobj = init(inLine);\r\n\tconsole.error('\\n↑入力 ↓出力');\r\n\tMain();\r\n\tconsole.log(myconv(outputList, 9));\r\n});\r\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\r\nfunction nextArray(size, code){\r\n\tvar ret = new Array(size);\r\n\tfor(var i = 0; i < size; i++){\r\n\t\tif(code == 'int'){\r\n\t\t\tret[i] = nextInt();\r\n\t\t}else if(code == 'long'){\r\n\t\t\tret[i] = nextLong();\r\n\t\t}else if(code == 'double'){\r\n\t\t\tret[i] = nextDouble();\r\n\t\t}else{\r\n\t\t\tret[i] = next();\r\n\t\t}\r\n\t}\r\n\treturn ret;\r\n}\r\nfunction nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');} function nextDoubleArray(size){return nextArray(size, 'double');}\r\nfunction nextCharArray(){return myconv(next(),6);}\r\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());} function nextDouble(){return parseFloat(next());}\r\nfunction getCountMap(list){\r\n\tvar map = {};\r\n\tfor(var i = 0; i < list.length; i++){\r\n\t\tif(map[list[i]] == null){\r\n\t\t\tmap[list[i]] = 0;\r\n\t\t}\r\n\t\tmap[list[i]]++;\r\n\t}\r\n\treturn map;\r\n}\r\nfunction init(input){ \r\n\treturn {\r\n\t\tlist : input, index : 0, max : input.length,\r\n\t\thasNext : function(){return (this.index < this.max);},\r\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},\r\n\t\tisReturn : function(){return retcode.has(this.index);}\r\n\t};\r\n}\r\nfunction myout(s){outputList.push(s);}\r\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\r\nfunction isReturn(){return obj.isReturn();}\r\n//param \"no\" is\r\n//unknown or outlier : return i. 1: parseInt.\r\n//2: split space. 4: split space and parseInt.\r\n//6: split 1 character. 7: split 1 character and parseInt.\r\n//8: join space. 9: join nextline. 0: join no character.\r\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\r\n\r\n//Don't have to see. end------------------------------------------\r\nfunction Main(){\r\n\tvar t = nextInt();\r\n\twhile(hasNext()){\r\n\t\tvar N = nextInt();\r\n\t\tmyout((1 << N) - 1);\r\n\t}\r\n}\r\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "680d01e7f81f2871ad6ceb8cfdbb685d", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n var num = stdin[0].split(' ');\n var n = parseInt(num[0]);\n var m = parseInt(num[1]);\n var a = parseInt(num[2]);\n var na = (n - n % a) / a;\n var ma = (m - m % a) / a;\n if (na * a < n) na = na + 1;\n if (ma * a < m) ma = ma + 1;\n console.log(na * ma);\n}\n\nconst readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar stdin = [];\nrl.on('line', function (line) {stdin.push(line);});\nrl.on('close', main)", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "773af5fcb3a6331a798a1c24ec4d47e0", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n let n = +d;\n const letters = ['D', 'A', 'C', 'B'];\n let best = n % 4;\n let idx = 0;\n\n for (let i = 0; i <= 2; i++) {\n const current = (n + i) % 4;\n const prevBest = best;\n\n if (current === 1) {\n idx = i;\n best = current;\n break;\n }\n\n best = Math.max(best, current);\n\n if (prevBest !== best) {\n idx = i;\n }\n }\n\n console.log(idx, letters[best]);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "8b8d3cd35cdd42994ebd2a78a17e3528", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n let n = parseInt(input[0]);\n let num = []; input[1].split(' ').forEach(i => num.push(parseInt(i)));\n\n let max = 0, count = 0;\n for(let i = 0; i < n; i++){\n for(let j = i; j < n; j++)\n if(num[i] === num[j])\n count++;\n if(max < count)\n max = count;\n count = 0;\n }\n console.log(max);\n});\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "05df9c05ae636f8aa1803c2b8db30ecb", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nconst fs = require('fs');\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++].split(' ');\n}\n\nfunction readInt(s) {\n return parseInt(s, 10);\n}\n\nfunction readIntArray(a) {\n\n return a.map(e => parseInt(e, 10));\n}\n\nfunction solve(n) {\n let a = [0, 1, 2, 0, 2, 1, 0];\n let max = 0;\n for (let i = 0; i < 7; i++) {\n let korm = n.slice(0);\n let days = 0;\n let ok = true;\n for (let j = i; j < 7; j++) {\n if (korm[a[j]] > 0) {\n korm[a[j]]--;\n days++;\n } else {\n ok = false;\n break;\n }\n }\n if (!ok) {\n if (days > max) max = days;\n continue;\n }\n let weeks = Math.min(Math.floor(korm[0] / 3), Math.floor(korm[1] / 2), Math.floor(korm[2] / 2));\n days += weeks * 7;\n korm[0] -= 3 * weeks;\n korm[1] -= 2 * weeks;\n korm[2] -= 2 * weeks;\n for (let j = 0; j < 7; j++) {\n if (korm[a[j]] > 0) {\n korm[a[j]]--;\n days++;\n } else {\n break;\n }\n }\n if (days > max) max = days;\n }\n return max;\n}\n\nfunction main() {\n\n const a = readIntArray(readLine());\n let result = solve(a);\n console.log(result);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "6f766ced6441dc19379ab9c91389ee4e", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = ''\nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os')\n const lines = i.split(EOL) /*your input text, split by lines*/\n if(lines[0] % 2 === 0 && lines[0] > 2) {\n console.log(\"YES\")\n } else {\n console.log(\"NO\");\n }\n})", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "866eea7acf3f0dbb48f102eb40c51c73", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let stdin = process.stdin;\nstdin.setEncoding('utf8');\nstdin.on('data', function (data) {\n let input = data.split('\\n');\n console.log(solution(input[0]));\n});\n\n// End of interface\n\nconst solution = (n) => {\n\tlet res = 0;\n\tfor (let i=1; i>\")\n \n console.log(str.join(' '));\n}\n\nconst readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar stdin = [];\nrl.on('line', function (line) {stdin.push(line);});\nrl.on('close', main);\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "fd4275b9863bc8385d4e4921cb3d8fed", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n');\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr('time : ' + end + 'ms');\n myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var one = nextIntArray();\n var n = one[0];\n var m = one[1];\n var output = 0;\n for(var i = 0; i <= n; i++){\n for(var j = 0; j <= m; j++){\n if(i * i + j == n && i + j * j == m){\n output++;\n }\n }\n }\n myout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "825baad22c447ffc0c1fe337e0508996", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nvar n,m,a;\nrl.on('line', (line) => {\n [n,m,a]=line.split(' ');\n}).on('close',()=>{\n var ans=Math.ceil(n/a)*Math.ceil(m/a);\n console.log(ans);\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "bae014ffb12123175c9f2b4cfe1aeac5", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const arr = readLine().split(\"WUB\");\n console.log(arr.join(\" \").trim());\n}\n", "lang_cluster": "Javascript", "tags": ["strings"], "code_uid": "828f75e697fca4f8da27ce8c7a7fb3a3", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\nlet numberOfStones;\nlet arrOfStones;\nlet previousElement;\nlet counter = 0;\nrl.on(\"line\", (input) => {\n if (!numberOfStones) {\n numberOfStones = parseInt(input.split(\" \"))\n } else {\n arrOfStones = input.split(\" \").toString();\n for (let i = 0; i < arrOfStones.length; i++) {\n const currentElement = arrOfStones[i];\n if (!previousElement) {\n previousElement = currentElement;\n continue;\n } else {\n previousElement = arrOfStones[i-1];\n if (previousElement == currentElement) {\n counter++\n }\n else continue ;\n }\n } \n console.log(counter)\n rl.close();\n }\n\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "91ec773750cacfc3907ba60e85f5dbfc", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data', function(chunk){\n var inp = Number(chunk);\n console.log(inp > 2 && inp % 2 === 0 ? 'YES' : 'NO');\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "8bda13c20c4c6c220317f38931f2c272", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet k = 0;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n k = +d;\n return;\n }\n\n const arr = d.split(' ').map(Number);\n arr.sort((a, b) => b - a);\n\n let sum = 0;\n let ans = 0;\n\n for (let i = 0; i < arr.length; i++) {\n if (sum < k) {\n sum += arr[i];\n ans++;\n }\n }\n\n if (sum < k) {\n console.log(-1);\n }\n else {\n console.log(ans);\n }\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "90188a54b1d7fc6f2f99bfddaa2b2086", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n \nlet inputString = '';\nlet currentLine = 0;\n \nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n \nprocess.stdin.on('end', _ => {\n inputString = inputString.split(/\\n/);\n main(); \n});\n \nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n const n = BigInt(readLine())\n let plus = 1n\n let minus = 1n\n const div = 1000000007n\n for (let i = 0n; i < n - 1n; i++) {\n plus *= (n - i)\n plus %= div\n minus *= 2n\n minus %= div\n }\n console.log((plus >= minus ? plus - minus : plus - minus + div).toString())\n}\n", "lang_cluster": "Javascript", "tags": ["math", "dp", "combinatorics", "graphs"], "code_uid": "6dda449d44e6db835a260598b5050dcf", "src_uid": "3dc1ee09016a25421ae371fa8005fce1", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict'\n\nconst {EOL} = require('os')\n\nlet ipt = ''\nprocess.stdin.on('data', s => ipt += s)\nprocess.stdin.on('end', () => {\n const [a, b] = ipt.split(EOL)[0].split(' ').map(v => parseInt(v))\n\n const da = []\n const db = []\n\n let [c, d] = [a, b]\n let i = 2\n while (c > 1) {\n while (!(c % i)) {\n c /= i\n da.push(i)\n }\n i++\n }\n i = 2\n while (d > 1) {\n while (!(d % i)) {\n d /= i\n db.push(i)\n }\n i++\n }\n\n let p = 1\n\n const od = []\n for (let j = 0; j < da.length; j++) {\n let x = db.indexOf(da[j])\n if (~x) {\n od.push(da[j])\n da.splice(j, 1)\n db.splice(x, 1)\n }\n }\n for (let j = 0; j < db.length; j++) {\n let x = da.indexOf(db[j])\n if (~x) {\n od.push(db[j])\n db.splice(j, 1)\n da.splice(x, 1)\n }\n }\n p = od.reduce((p, v) => p * v, 1)\n\n if (a > b) {\n console.log(a - p > b ? 'Masha' : a - p < b ? 'Dasha' : 'Equal')\n } else if (a < b) {\n console.log(b - p > a ? 'Dasha' : b - p < a ? 'Masha' : 'Equal')\n }\n})", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "2a32643143556b8f401277c78f5dd812", "src_uid": "06eb66df61ff5d61d678bbb3bb6553cc", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = '';\nconst {EOL} = require('os');\nprocess.stdin.on('data', i => input += i);\n\nprocess.stdin.on('end', async () => {\n const isSumOfDigitsDivisibleByFour = num => num.toString().split('').reduce((acc, num) => acc + parseInt(num), 0) % 4 === 0;\n\n let number = parseInt(input.split(EOL)[0]);\n while (!isSumOfDigitsDivisibleByFour(number++)) {}\n console.log(--number);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "dd84fc845c7cb9b26616b80af9fe35d6", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (data) => {\n let [a, b, c, d] = data.split(' ').map(Number);\n let x = Math.min(a, c, d);\n\n a -= x;\n c -= x;\n d -= x;\n\n let y = Math.min(a, b);\n\n console.log(x*256 + y*32);\n});\n", "lang_cluster": "Javascript", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "547f2db6088b6823ac7488a858a535e1", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction abs(x) {\n return x < 0 ? -x : x;\n}\n\nfunction solve() {\n let n = 5;\n let data = []\n for (let i = 0; i < n; i++) {\n let l = readLine();\n let d = l.split(' ');\n let len = d.length;\n let row = []\n for (let j = 0; j < len; j++)\n row.push(d[j] == \"1\" ? 1 : 0);\n data.push(row);\n }\n\n let x = 0, y = 0;\n for (let i = 0; i < n; i++) {\n for (let j = 0; j < n; j++) {\n if (data[i][j] == 1) {\n x = j;\n y = i;\n }\n }\n }\n\n return abs(x - 2) + abs(y - 2);\n}\n\nfunction main() {\n console.log(solve());\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "771f7b526be828d98e30905654cfeb40", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction multiply(a, b) {\n\ta = a.toString(10).split('').reverse();\n\tb = b.toString(10).split('').reverse();\n\n\tif (a.length < b.length) {\n\t\t[a, b] = [b, a];\n\t}\n\n\tlet res = Array(a.length + b.length).fill(0);\n\tfor (let i = 0, lb = b.length; i < lb; ++i) {\n\t\tlet carry = 0;\n\t\tlet scarry = 0;\n\t\tfor (let j = 0, la = a.length; j < la; ++j) {\n\t\t\tlet m = b[i] * a[j];\n\t\t\tm += carry;\n\n\t\t\tif (m > 9) {\n\t\t\t\tlet [c, d] = m.toString(10).split('');\n\t\t\t\tres[i + j] += (scarry >> 0) + (d >> 0);\n\t\t\t\tcarry = c >> 0;\n\t\t\t} else {\n\t\t\t\tres[i + j] += (scarry >> 0) + m;\n\t\t\t\tcarry = 0;\n\t\t\t}\n\n\t\t\tif (res[i + j] > 9) {\n\t\t\t\tlet [c, d] = res[i + j].toString(10).split('');\n\t\t\t\tres[i + j] = d >> 0;\n\t\t\t\tscarry = c;\n\t\t\t} else {\n\t\t\t\tscarry = 0;\n\t\t\t}\n\t\t}\n\t\tif (carry > 0) res[a.length + i] = carry;\n\t\tif (scarry > 0) res[a.length + i] = scarry;\n\t}\n\n\tres.reverse();\n\tlet mulVal = '';\n\tlet flag = false;\n\tres.forEach(d => {\n\t\tif (!flag && d !== 0) flag = true;\n\t\tif (flag) mulVal += d;\n\t});\n\treturn mulVal;\n}\n\nfunction main() {\n\tlet [n, k] = readLine()\n\t\t.split(' ')\n\t\t.map(x => parseInt(x));\n\n\tlet m = Math.ceil(n / 2);\n\tlet x = 0;\n\tif (k > m) {\n\t\tif ((n & 1) === 1) {\n\t\t\tx = 2 * k - n - 1;\n\t\t} else {\n\t\t\tx = 2 * k - n;\n\t\t}\n\t} else {\n\t\tx = 2 * k - 1;\n\t}\n\tconsole.log(x);\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "edb1b31b359fbfd698a4ab7497b520df", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const { EOL } = require('os');\n\nlet i = '';\nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n let lines = i.split(EOL);\n \n tester(lines[0]); \n});\n\nfunction tester(y) {\n let newY = Number(y) + 1;\n let stringY = String(newY);\n let countNumbers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n let isAllDifferent = true;\n\n for(let i = 0; i < stringY.length; i++) {\n let n = +stringY.charAt(i);\n \n countNumbers[n]++;\n }\n\n countNumbers.map(c => {\n if (c > 1) isAllDifferent = false;\n });\n\n isAllDifferent\n ? console.log(newY)\n : tester(newY)\n}", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "39c911819cdc8386ecf43d7410c3f718", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nfunction main() {\n const is = new Scanner();\n const [n, m] = is.nextArray().map(Number);\n const word = is.nextLine().split('');\n word.forEach((item, index, array) => {\n array[index] = item.charCodeAt() - 'a'.charCodeAt() + 1;\n });\n word.sort((a, b) => a - b);\n\n function theFor(i, j, accum, number) {\n if (m === number) {\n return accum;\n }\n if (j === n) {\n return -1;\n }\n\n if (word[j] - word[i] > 1) {\n return theFor(j, j + 1, accum + word[j], number + 1);\n }\n return theFor(i, j + 1, accum, number);\n }\n\n console.log(theFor(0, 1, word[0], 1));\n}\n\n/*\n * Api Scanner\n */\n\nclass Scanner {\n constructor() {\n this.index = 0;\n this.lines = stdinInput.trim().split('\\n'); // eslint-disable-line\n }\n\n nextLine() {\n return this.lines[this.index++]; // eslint-disable-line\n }\n\n nextInt() {\n return parseInt(this.nextLine(), 10);\n }\n\n nextDouble() {\n return parseFloat(this.nextLine());\n }\n\n nextArray() {\n return this.nextLine().split(' ');\n }\n\n hasNext() {\n return this.index < this.lines.length;\n }\n}\n\nlet stdinInput = '';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nprocess.stdin.on('data', (input) => { stdinInput += input; });\nprocess.stdin.on('end', () => { main(); });\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "c16e3ae646390c45d9dcba7990c17564", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let ans = readLine()\n .split('+')\n .map(value => parseInt(value));\n ans.sort((a, b) => a - b);\n console.log(ans.reduce((sum, value) => {\n return sum + \"+\" + value;\n }))\n}", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "87681e64765b823d09d0671041e594cf", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.question('', (answer) => {\n // TODO: Log the answer in a database\n\n check(answer);\n\n rl.close();\n});\n\nfunction check(x) {\n var arr = x.split(\" \");\n let F = parseInt(arr[0]);\n let S = parseInt(arr[1]);\n let counter = 0;\n\n\n \n \n \n \n while (F <= S) {\n \n\n for (let k in arr) {\n if (k == 0) {\n F = F * 3;\n }\n\n if (k == 1) {\n S = S * 2;\n }\n\n }\n \n counter++;\n }\n\nconsole.log(counter);\n\n\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e593d364cc62a7f2ae6aa2c416b8e223", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.setEncoding('utf8');\n\nprocess.stdin.on('readable', () => {\n let input = process.stdin.read();\n input = input.trim();\n\n input = input.split('+');\n input = input.sort((a, b) => a - b);\n\n console.log(input.join('+'));\n process.exit(0);\n});", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "cf70cac4f326fdb9c37a80fa983e3aa5", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const stdin = process.stdin;\nstdin.setEncoding(\"utf8\");\nlet n;\nlet data;\nstdin.on(\"data\", function(rawInput) {\n const inputLines = rawInput.split(\"\\n\");\n const [n, k] = splitAndConvert(inputLines[0], 2);\n const result = solve(n, k);\n console.log(result);\n});\nfunction splitAndConvert(stringOfNumbers, numOfValid) {\n return stringOfNumbers\n .split(\" \")\n .slice(0, numOfValid)\n .map(function(num) {\n return parseInt(num);\n });\n}\nfunction solve(n, k) {\n const red = Math.ceil((n * 2) / k);\n const green = Math.ceil((n * 5) / k);\n const blue = Math.ceil((n * 8) / k);\n return red + green + blue;\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "86d885f4531e77ea646adca4f2a9d4dd", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = ''\nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os')\n const lines = i.split(EOL) /*your input text, split by lines*/\n\n const BubbleSort = (vector) => {\n for (let i = vector.length - 1; i >= 1; i--) {\n for (let j = 1; j <= i; j++) {\n if (vector[j] < vector[j-1]) {\n let temp = vector[j-1];\n vector[j-1] = vector[j];\n vector[j] = temp;\n }\n }\n }\n\n return vector;\n\n }\n\n let vector = lines[0].split(' ').map( n => parseInt(n));\n vector = BubbleSort(vector);\n let res = 0;\n res = vector[2] - vector[0];\n\n console.log(res);\n});\n\n\n\n", "lang_cluster": "Javascript", "tags": ["math", "sortings", "implementation"], "code_uid": "5a5682ad73e19dbffae3c2189b02fdff", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\n\nrl.on('line', (d) => {\n let [k, n, w] = d.split(' ').map(Number);\n\n for (let i = 1; i <= w; i++) {\n n -= k*i;\n }\n\n console.log(Math.abs(Math.min(0, n)));\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "2d5820431d1a8b5dc5f5d30e5b906b93", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\nfunction isPrime(num) {\n if (num == 2) return true;\n if (num % 2 == 0 || num < 2) return false;\n let s = Math.sqrt(num);\n for (let i = 3; i <= s; i+=2) {\n if (num % i == 0) return false;\n }\n return true;\n};\n\nfunction hasExactlyTwoPrimeDivis(num) {\n var counter = 0;\n for (var i = 2; i < num; i++) {\n if (num % i == 0 && isPrime(i))\n counter++;\n if (counter > 2)\n return false;\n \n }\n return counter==2;\n}\n\n\nrl.on('line', (input) => {\n var N = parseInt(input);\n var ans = 0;\n for (let i = 6; i <= N; i++) \n ans+=hasExactlyTwoPrimeDivis(i);\n \n \n console.log(ans);\n rl.close();\n});\n\n\n", "lang_cluster": "Javascript", "tags": ["number theory"], "code_uid": "3a6df57ffae45dd577a444cef85a6168", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\n\nlet inputs = [];\nconst vowels = ['a', 'o', 'y', 'e', 'u', 'i'];\n\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\n\nrl.on('line', lineInput => {\n inputs.push(lineInput);\n rl.close();\n})\n\n\nrl.on('close', () => {\n\n let word = inputs[0];\n \n word = word.split('').filter(char => {\n if (!vowels.includes( char.toLowerCase() ))\n return char\n }).map(char => {\n return `.${char}`\n }).join('').toLowerCase()\n\n console.log(word)\n})", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "6387d97653d8236447eef5c548475e8e", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Petya and Strings\n\nconst {EOL} = require('os');\n\nlet inp = '';\n\nprocess.stdin.on('data', c => inp += c);\n\nprocess.stdin.on('end', () => {\n let lines = inp.split(EOL);\n lines[0] = lines[0].toLowerCase();\n lines[1] = lines[1].toLowerCase();\n\n process.stdout.write((lines[0] > lines[1]) ? '1' : ((lines[0] < lines[1]) ? '-1' : '0'));\n return;\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "944ac369c26a0cbce912aef193295472", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar input = [];\nrl.on('line', function (line) {input.push(line);});\nrl.on('close', function() {\n for (let i = 0; i < input.length; i++) {\n const newArray = input[i].split(' ');\n input[i] = newArray;\n }\n\n// console.log(input);\n\n for (let i = 0; i < input.length; i++) {\n for (let j = 0; j < input[i].length; j++) {\n if (input[i][j] === '1') {\n // 2\n let x = Math.abs(j - 2);\n let y = Math.abs(i - 2);\n // console.log(i+1,j+1);\n console.log(x + y)\n }\n }\n }\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "edb2e645e49ffaa2078e0c1b882187af", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n var game = {\n 'rock': 'scissors',\n 'scissors': 'paper',\n 'paper': 'rock'\n };\n var F = stdin[0],\n M = stdin[1],\n S = stdin[2];\n if (game[F] === M && game[F] === S) {\n console.log('F');\n } else if (game[M] === F && game[M] === S) {\n console.log('M');\n } else if (game[S] === F && game[S] === M) {\n console.log('S');\n } else {\n console.log('?');\n }\n}\n\nconst readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar stdin = [];\nrl.on('line', function (line) {\n stdin.push(line);\n});\nrl.on('close', main);", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "33bc9be83c507806877e0205e5f99731", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n let answer = 0;\n let [n, k] = input[0].split(' ').map(x => parseInt(x));\n \n if (n % 2 === 0) {\n if (k >= n/2) {\n if (k === n/2)\n console.log(k*2 - 1);\n else\n console.log( (k - (n/2)) * 2 ); \n } else {\n console.log(k*2 - 1);\n }\n } else {\n if (k >= (n+1)/2) {\n if (k === (n+1)/2)\n console.log(k*2 - 1);\n else console.log( (k - ((n+1)/2)) * 2 ); \n } else {\n console.log(k*2 - 1);\n }\n }\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "6aec4d7ba8bb635eff5967fe484c2d22", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const stdin = process.stdin;\nstdin.setEncoding(\"utf8\");\nlet data = \"\";\nstdin.on(\"data\", function(chunk) {\n data += chunk;\n});\nstdin.on(\"end\", function() {\n const inputs = data.split(/[\\n\\r]+/);\n const [n, k] = splitAndConvert(inputs[0], 2);\n const result = solve(n, k);\n console.log(result);\n});\n\nfunction splitAndConvert(stringOfNumbers, numOfValid) {\n return stringOfNumbers\n .split(\" \")\n .slice(0, numOfValid)\n .map(function(num) {\n return parseInt(num);\n });\n}\n\nfunction solve(n, k) {\n for (let i = 0; i < k; i++) {\n if (n % 10) {\n n = n - 1;\n } else {\n n = n / 10;\n }\n }\n return n;\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "d445f4c0adeb550c73be90637dc01924", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n \nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n \nlet inputString = '';\nlet currentLine = 0;\n \nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n \nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n \nfunction readline() {\n return inputString[currentLine++];\n}\n// Make a Snippet for the code above this and then write your logic in main();\n \n \nfunction main() {\n const x = readline();\n console.log(x%2==0&&x>2?'YES':'NO');\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "3bdc88116afea90467c377dee0a2854f", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var input = ''\nprocess.stdin.on('data', c => input += c)\nprocess.stdin.on('end', () => {\n console.log('.' + input.toLowerCase().replace(/[aeiouy]|\\W/g, '').replace(/\\B/g, '.'))\n})", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "44cb0185aa941ac6de4efdeabda47cae", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nconst readline = require('readline')\n\nclass ReadStream {\n lines = []\n\n currPromise = undefined\n\n readlineHandler = input => {\n this.lines.push(input)\n }\n\n constructor() {\n this.rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n });\n\n this.rl.on('line', this.readlineHandler)\n }\n\n async next() {\n this.currPromise = new Promise((resolve, reject) => {\n const tempPromise = this.currPromise ? this.currPromise : Promise.resolve()\n \n tempPromise.then(_ => {\n if (this.lines .length) {\n resolve(this.lines.shift())\n }\n else {\n this.rl.off('line', this.readlineHandler)\n this.rl.once('line', (input) => {\n resolve(input)\n this.rl.on('line', this.readlineHandler)\n })\n }\n })\n \n })\n return this.currPromise\n }\n\n close() {\n this.rl.off('list', this.readlineHandler)\n this.rl.close()\n }\n}\n\n\nconst cin = new ReadStream()\n\nasync function main() {\n const weight = parseInt(await cin.next())\n\n if (weight % 2 === 0 && weight > 2) {\n console.log('YES')\n } else {\n console.log('NO')\n }\n\n // cin.close()\n}\n\nmain()", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "9f47973d9d993a692614e61e15cb3399", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nlet _inputLines;\nlet _lineNumber = 0;\nlet inputReader = _inputReader ();\n\nfunction _main() {\n\t\n\t_inputLines = _inputData.trim().split('\\n').map((string) => {\n\t\treturn string.trim();\n\t});;\n\t\n\tlet s = inputReader.readLine();\n\tlet t = inputReader.readLine();\n\t\n\tvar flag = true;\n\t\n\tfor (var i = 0; i < s.length; i++) {\n\t if (s[i] != t[t.length - 1 - i]) flag = false;\n\t}\n\t\n\tif (flag) console.log(\"YES\");\n\telse console.log(\"NO\");\n\n}\n\nvar _inputData = '';\nfunction cacheInput(data) {\n\t_inputData += data;\n}\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf8');\nprocess.stdin.on('data', cacheInput).on('end', _main);\n\nfunction _inputReader () {\n\tfunction readLine(){\n\t\treturn _inputLines[_lineNumber++];\n\t}\n\t\t\n\t\n\treturn {\n\t\treadLine,\n\t}\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "3ce912d4e3c7d61e9c5dd47ad257ba08", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (str) => {\n if (c === 0) {\n c++;\n return;\n }\n\n let ans = 0;\n\n for (let i = 0; i < str.length; i++) {\n if (str[i] === 'R' && str[i + 1] === 'U' || str[i] === 'U' && str[i + 1] === 'R') {\n ans++;\n i++;\n }\n else {\n ans++;\n }\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "eaa06d01c11e7e962c08b07078784dc3", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet n, s;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n [n, s] = d.split(' ').map(Number);\n return;\n }\n\n const arr = d.split(' ').map(Number);\n arr.sort((a, b) => a - b);\n let amount = 0;\n\n for (let i = 0; i < n - 1; i++) {\n amount += arr[i];\n }\n\n if (amount > s) {\n console.log('NO');\n }\n else {\n console.log('YES');\n }\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "fda1eb514db41a397692f24b807e3a9f", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.setEncoding('utf8');\n\nprocess.stdin.on('readable', () => {\n let input = process.stdin.read();\n if (input !== null) {\n let odd = Array.from(new Set(input.trim().split(''))).length;\n\n if (odd % 2 === 0) process.stdout.write(`CHAT WITH HER!\\n`);\n else process.stdout.write(`IGNORE HIM!\\n`);\n }\n});", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "9cb2955ce824e3b65312c591d5c72eb2", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nlet secondLine = false;\n\n\n// Create readline Interface\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet inputs = [];\n\n\n\nrl.on('line', lineInput => {\n inputs.push(lineInput);\n})\n\n// Read Inputs\nrl.on('close', () => {\n const line1 = inputs[0].split(' ');\n const songs = inputs[1].split(' ');\n const D = parseInt(line1[1].split(' ')[0]);\n let spareTime = 0;\n let neededDurationForSongs = 0;\n for (let i = 0; i < songs.length; i++) {\n neededDurationForSongs += parseInt(songs[i]);\n }\n\n spareTime = (songs.length - 1) * 10;\n\n if (neededDurationForSongs + spareTime > D)\n return console.log(-1)\n\n let durationsForJokes = D - neededDurationForSongs;\n\n return console.log(Math.floor(durationsForJokes / 5))\n});", "lang_cluster": "Javascript", "tags": ["greedy", "implementation"], "code_uid": "5386f595aa0e0e781482305eecc9507b", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction main() {\n\tconst num = readLine() >> 0;\n\tconst happy = [];\n\tconst regex = /^[47]+$/g;\n\n\tfor (let i = 1; i <= 1000; ++i) {\n\t\tif (regex.test(i.toString(10))) {\n\t\t\thappy.push(i);\n\t\t}\n\t}\n\n\tif (regex.test(num.toString(10))) {\n\t\tconsole.log('YES');\n\t\treturn;\n\t}\n\n\tlet almost = false;\n\n\tfor (let i = 0, l = happy.length; i < l; ++i) {\n\t\tif (num % happy[i] === 0) {\n\t\t\talmost = true;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\talmost ? console.log('YES') : console.log('NO');\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "number theory"], "code_uid": "435a6648e855508d809c0ddd10efed4a", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (str) => {\n if (c === 0) {\n c++;\n return;\n }\n\n const ans = str.match(/[B]+/g) || [];\n console.log(ans.length);\n console.log(ans.map(x => x.length).join(' '));\n\n // let ans = 0;\n // const arr = [];\n // let inc = 0;\n\n // for (let i = 0; i < str.length - 1; i++) {\n // if (str[i] === 'B') {\n // inc++;\n\n // if (str[i + 1] === 'W') {\n // ans++;\n // arr.push(inc);\n // }\n // }\n // else {\n // inc = 0;\n // }\n // }\n\n // if (str[str.length - 1] === 'B') {\n // ans++;\n // inc++;\n // arr.push(inc);\n // }\n\n // console.log(ans);\n // console.log(arr.join(' '));\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0ae721a48047802e8ba14c9f82bd1b9a", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n//\nlet numberOfStones;\nlet arrOfStones;\nlet previousElement;\nlet counter = 0;\nrl.on(\"line\", (input) => {\n if (!numberOfStones) {\n numberOfStones = parseInt(input.split(\" \"))\n // console.log(numberOfStones, typeof (numberOfStones))\n } else {\n arrOfStones = input.split(\" \").toString();\n // console.log(arrOfStones, typeof (arrOfStones))\n for (let i = 0; i < arrOfStones.length; i++) {\n const currentElement = arrOfStones[i];\n if (!previousElement) {\n previousElement = currentElement;\n continue;\n } else {\n previousElement = arrOfStones[i-1];\n if (previousElement == currentElement) {\n counter++\n }\n else continue ;\n\n }\n\n\n } \n console.log(counter)\n rl.close();\n }\n\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "54ffc97c92362b7115742e261138d953", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar countChar = function(s){\n let counter = 0;\n for(let i=0; i {\n if(input==\"BBBBBBBB\")\n ans++;\n else if(!met){\n ans += countChar(input);\n met=true;\n } \n \n }).on('close',()=>{\n console.log(ans);\n });", "lang_cluster": "Javascript", "tags": ["brute force", "constructive algorithms"], "code_uid": "e430afde7e6e2bbd130d4f8163c97af5", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function findGreeting(str) {\n const word = 'hello';\n let i = 0;\n for(const l of str) {\n if(l === word[i]) {\n i++;\n }\n }\n return i === word.length ? 'YES' : 'NO';\n}\n\nconst { EOL } = require('os');\n\nlet i = '';\n\nprocess.stdin.on('data', c => i += c)\n process.stdin.on('end', () => {\n const lines = i.split(EOL)\n const res = findGreeting(lines[0])\n console.log(res);\n })\n\n", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "cc1947aa97264f16041ec1ef0e29ee90", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nprocess.stdin.on('data', (input) => {\n const isDanger = () => {\n let team, count;\n\n for (let i = 0; i < input.length; i++) {\n team = input[i];\n count = 1;\n\n for (; input[i + 1] === team && i < input.length - 1; i++) count++;\n\n if (count > 6) return 'YES';\n }\n\n return 'NO';\n };\n\n process.stdout.write(isDanger());\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "e7fa392814a92e423fd44b3f1e451aad", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let fs = require('fs');\n\nlet txt = fs.readFileSync(0, \"utf-8\").split(\"\\r\\n\").filter(data => {\n return data.length > 0;\n});\n\nfor (let i = 0; i < txt.length; i++) {\n let info = txt[i].split(\" \").filter(data => {\n return data.length > 0;\n });\n doit(info[0] * 1, info[1] * 1 - 1);\n}\n\nfunction doit(n, index) {\n if (index < Math.ceil(n / 2)) {\n console.log(index * 2 + 1);\n } else {\n let r = index - Math.ceil(n / 2);\n console.log(r * 2 + 2);\n }\n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "1fb182ee5fda8c7472111c538e3103cf", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Plate Game - https://codeforces.com/problemset/problem/197/A\n\nconst readline = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nreadline.question(\"\", (_input) => {\n const input = _input.split(\" \").map(Number);\n digiGame(input[0], input[1], input[2]);\n});\n\nconst digiGame = (a, b, r) => {\n if (2 * r <= a && 2 * r <= b) {\n console.log(\"First\");\n } else {\n console.log(\"Second\");\n }\n};\n", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms", "games"], "code_uid": "3717f6ab1f1422311f99437c357d025b", "src_uid": "90b9ef939a13cf29715bc5bce26c9896", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input.push(line);\n});\n\n\nRL.on('close', () => {\n let {0:w, 1:h, 2:k} = {...input[0].split(' ')};\n w = parseInt(w); h = parseInt(h); k = parseInt(k);\n\n let answer = 0;\n for(let i = 0; i < k; i++){\n answer += (w*2 + h*2 - 4);\n w -= 4; h-=4;\n }\n console.log(answer);\n});\n\n\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "f4bcfbf2188d6e21b5bb5904cf1fdf72", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (str) => {\n if (/[HQ9]/.test(str)) {\n console.log('YES');\n }\n else {\n console.log('NO');\n }\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e73ab6801e0d6b5197e67c8330292241", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// https://codeforces.com/problemset/problem/596/A\n// Big O:\n// Time complexity:\n// Space complexity:\n\n// Read input\nvar readline = require(\"readline\");\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet numberOfVertices;\nlet vertices = [];\nrl.on('line', (input) => {\n if (!numberOfVertices) {\n numberOfVertices = parseInt(input);\n return;\n }\n\n const verticesArray = input.split(\" \").map(Number)\n const x = verticesArray[0];\n const y = verticesArray[1];\n vertices.push({ x, y });\n\n if (vertices.length === numberOfVertices) {\n console.log(findRectangleArea(numberOfVertices, vertices));\n rl.close();\n }\n\n});\n\n// Problem\nfunction findRectangleArea(numberOfVertices, vertices) {\n\n const xPositions = new Set();\n const yPositions = new Set();\n\n for (let vertex of vertices) {\n xPositions.add(vertex.x);\n yPositions.add(vertex.y);\n }\n\n if (xPositions.size < 2 || yPositions.size < 2) {\n return -1;\n }\n\n const xPositionsArray = Array.from(xPositions)\n const yPositionsArray = Array.from(yPositions)\n\n return Math.abs((xPositionsArray[0] - xPositionsArray[1]) * (yPositionsArray[0] - yPositionsArray[1]));\n}", "lang_cluster": "Javascript", "tags": ["geometry", "implementation"], "code_uid": "1ba001078df55e56641cc403f2a666ac", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n\tvar N = nextInt();\n\tvar list = nextCharArray();\n\tvar output = \"\";\n\tvar isOne = false;\n\tfor(var i = 0; i < N; i++){\n\t\tif(list[i] == \"0\"){\n\t\t\toutput += \"0\";\n\t\t}else{\n\t\t\tisOne = true;\n\t\t}\n\t}\n\tif(isOne){\n\t\tmyout(\"1\" + output);\n\t}else{\n\t\tmyout(\"0\");\n\t}\n\t\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "75644be457b43e659f10dc936d157307", "src_uid": "ac244791f8b648d672ed3de32ce0074d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet currentLine = 0;\nlet inputString = \"\";\n\nprocess.stdin.on(\"data\", (raw_data) => {\n inputString += raw_data;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((line) => {\n return line.trim();\n });\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n/******** Main function*************/\n\nfunction main() {\n var s = readLine();\n var t = readLine().split(\"\");\n\n var str = \"\";\n for (var i = 0; i < t.length; i++) {\n str = str + t[t.length - 1 - i];\n }\n if (str === s) {\n console.log(\"YES\");\n } else {\n console.log(\"NO\");\n }\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "25e2f6b9badf3dce739ad80c7f9096f8", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const { EOL } = require('os');\n\nlet i = '';\nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n let lines = i.split(EOL);\n \n tester(lines[0], lines[1]); \n});\n\nfunction tester(w1, w2) {\n let newW = '';\n\n for(let i = w1.length - 1; i >= 0; i--) {\n newW += String(w1.charAt(i));\n }\n\n console.log(newW === w2 ? 'YES' : 'NO');\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "48c9331686ddc024ad981a282dd78062", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.question('', (weight) => {\n \n if (weight % 2 == 0 && weight > 2) {\n console.log(\"YES\");\n } else {\n console.log(\"NO\");\n }\n\n rl.close();\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "bf20117f958a0ee59424a18e6abaf896", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n \nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n let [n, m, a, b] = input[0].split(' ').map(x => parseInt(x));\n \n if (b/m <= a) {\n if (n % m === 0) {\n console.log( (n/m) * b );\n } else {\n console.log(Math.min(\n (parseInt(n/m) * b) + (n - parseInt(n/m) * m) * a,\n parseInt(Math.ceil(n/m) * b)\n ));\n }\n } else {\n console.log(n*a);\n }\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "edd4e0ece434a962c1423648512254f6", "src_uid": "faa343ad6028c5a069857a38fa19bb24", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\n\nconst runMain = () => {\n inputString = inputString.trim().split('\\n').map(string => string.trim());\n main();\n process.exit();\n}\nconst readLine = () => inputString[currentLine++];\n\nprocess.stdin.on('data', inputStdin => inputString += inputStdin);\nprocess.stdin.on('end', runMain);\nprocess.on('SIGINT', runMain);\n\nfunction main() {\n const str1 = readLine().toLowerCase();\n const str2 = readLine().toLowerCase();\n console.log(str1 > str2 ? 1 : (str1 < str2 ? -1 : 0));\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "f6107aeeede98498dd561658612be432", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n \nconst isVowel = (char) => {\n return [\"a\", \"o\", \"u\", \"i\", \"e\"].includes(char);\n}\n \nrl.on('line', (str) => {\n let ans = 'YES';\n \n for (let i = 1; i < str.length; i++) {\n if (!isVowel(str[i]) && !isVowel(str[i - 1]) && str[i - 1] !== 'n') {\n ans = 'NO';\n break;\n }\n }\n \n if (!isVowel(str[str.length - 1]) && str[str.length - 1] !== 'n') {\n ans = 'NO';\n }\n \n console.log(ans);\n c++;\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "d2650d3f00cecd4f9682ae6b4f165992", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction printResult(x) {\n process.stdout.write(x);\n}\n\nfunction main() {\n const arrPoints = new Array(8);\n for (let i = 0; i < 8; i++) {\n let rl = readLine().split(' ').map(Number);\n arrPoints[i] = new Point(rl[0], rl[1]);\n }\n\n eightPointSet(arrPoints);\n}\n\nfunction Point(x, y)\n{\n this.x = x;\n this.y = y;\n}\n\nconst comparePoints = (a, b) => {\n if (a.x < b.x || (a.x === b.x && a.y < b.y)) {\n return -1;\n }\n if (a.x > b.x || (a.x === b.x && a.y > b.y)) {\n return 1;\n }\n return 0;\n}\n\n/**\n * eightPointSet\n *\n * 2 4 7\n * 1 6\n * 0 3 5\n *\n * => Equal\n * x0 = x0 = x2\n * x3 = x4\n * x5 = x6 = x7\n * y0 = y3 = y5\n * y1 = y6\n * y2 = y4 = y7\n *\n * => Not equal\n * x0 != x3\n * x3 != x5\n * y0 != y1\n * y1 != y2\n */\nconst eightPointSet = (a) => {\n a.sort(comparePoints);\n if (a[0].x === a[1].x && a[1].x === a[2].x\n && a[3].x === a[4].x\n && a[5].x === a[6].x && a[6].x === a[7].x\n && a[0].y === a[3].y && a[3].y === a[5].y\n && a[1].y === a[6].y\n && a[2].y === a[4].y && a[4].y === a[7].y\n\n && a[0].x !== a[3].x\n && a[3].x !== a[5].x\n && a[0].y !== a[1].y\n && a[1].y !== a[2].y) {\n printResult('respectable');\n } else {\n printResult('ugly');\n }\n};", "lang_cluster": "Javascript", "tags": ["sortings"], "code_uid": "ffd5bfad2bf0fd2c8b1351d71aeebd78", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input.push(line);\n});\n\nfunction fact(num)\n{\n if(num === 0)\n return 1;\n return num * fact(num-1);\n}\n\nRL.on('close', () => {\n const check = new Set(); check.add('a'); check.add('e');\n check.add('i'); check.add('o'); check.add('u');\n const str = input[0];\n let answer = 0;\n for(let i = 0; i < str.length; i += 1) {\n \n if(check.has(str.charAt(i))) {\n answer += 1;\n } else if( !isNaN(parseInt(str.charAt(i), 10)) && parseInt(str.charAt(i), 10) % 2 === 1) {\n answer += 1;\n }\n }\n console.log(answer);\n});\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "d9fba72394bed0c23548d2cb9092f59c", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\r\nprocess.stdin.setEncoding('utf-8');\r\nlet inputString = '';\r\nlet currentLine = 0;\r\nprocess.stdin.on('data', inputStdin => {\r\n inputString += inputStdin;\r\n});\r\nfunction readLine() {\r\n return inputString[currentLine++];\r\n};\r\nprocess.stdin.on('end', _ => {\r\n inputString = inputString.trim().split('\\n').map(string => {\r\n return string.trim();\r\n });\r\n solve();\r\n // cmd: node cp.js < input.txt > output.txt\r\n});\r\nfunction solve() {\r\n let t = parseInt(readLine());\r\n while (t--) {\r\n let set=new Set();\r\n set.add(1);\r\n let num=parseInt(readLine());\r\n for(let i=2;i<=Math.sqrt(num);i++){\r\n let pow=Math.pow(i,2);\r\n let cube=Math.pow(i,3);\r\n if(pow<=num){\r\n set.add(pow)\r\n }\r\n if(cube<=num){\r\n set.add(cube)\r\n }\r\n }\r\n console.log(set.size);\r\n }\r\n}\r\n\r\n\r\n\r\n//------------------------------------------------------------------------------------\r\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "ecc7128c755ad081d8cbabeef56571bb", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction checkLuckyNumber(n) {\n let check = 1;\n for (var i = 0; i <= 9; i++) {\n if (String(n).indexOf(i) != -1 && i != 4 && i != 7) {\n check = 0;\n break;\n }\n }\n if (check == 1) return true;\n else return false;\n}\n\nfunction count4(n) {\n return String(n).split('').filter(value => value == '4').length;\n}\n\nfunction count7(n) {\n return String(n).split('').filter(value => value == '7').length;\n}\n\n\nfunction main() {\n let n = parseInt(readLine());\n let l = 0;\n let r = 0;\n let A = [];\n A[0] = 0;\n while (1) {\n // console.log(A)\n A[++r] = A[l] * 10 + 4;\n if (A[r] >= n && count4(A[r]) == count7(A[r])) {\n console.log(A[r]);\n break;\n }\n A[++r] = A[l] * 10 + 7;\n if (A[r] >= n && count4(A[r]) == count7(A[r])) {\n console.log(A[r]);\n break;\n }\n l++;\n }\n}", "lang_cluster": "Javascript", "tags": ["brute force", "binary search", "bitmasks"], "code_uid": "14fa8303f4ace6585d1ae333e351c650", "src_uid": "77b5f83cdadf4b0743618a46b646a849", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n let n = +d;\n\n let curr = 1;\n let x = 1;\n\n while (n >= curr) {\n n -= curr;\n x++;\n curr += x;\n }\n\n console.log(x - 1);\n\n // let sum = 0;\n // let ans = 0;\n // let c = 1;\n\n // while (sum < n) {\n // let s = 0;\n // for (let j = 1; j <= c; j++) {\n // s += j;\n // }\n\n // sum += s;\n // c++;\n\n // if (sum > n) {\n // break;\n // }\n // else {\n // ans++;\n // }\n // }\n\n // console.log(ans);\n\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "52c0f70161a6ffcdd3e7ccd399d43804", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n \nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n const [n, k] = input[0].split(' ').map(x => parseInt(x));\n let time = 240; let answer = 0, problems = 1;\n\n while (time - (problems*5) >= k && answer < n) {\n answer += 1;\n time -= (problems*5);\n problems += 1; \n }\n\n console.log(answer);\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation", "binary search"], "code_uid": "b8d6b937729ed655415c6c1e274a52bb", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nconst readline = require('readline')\n\nclass ReadStream {\n lines = []\n\n currPromise = undefined\n\n readlineHandler = input => {\n this.lines.push(input)\n }\n\n constructor() {\n this.rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n });\n\n this.rl.on('line', this.readlineHandler)\n }\n\n async next() {\n this.currPromise = new Promise((resolve, reject) => {\n const tempPromise = this.currPromise ? this.currPromise : Promise.resolve()\n \n tempPromise.then(_ => {\n if (this.lines .length) {\n resolve(this.lines.shift())\n }\n else {\n this.rl.off('line', this.readlineHandler)\n this.rl.once('line', (input) => {\n resolve(input)\n this.rl.on('line', this.readlineHandler)\n })\n }\n })\n \n })\n return this.currPromise\n }\n\n close() {\n this.rl.off('list', this.readlineHandler)\n this.rl.close()\n }\n}\n\n\nconst cin = new ReadStream()\n\nasync function main() {\n const weight = parseInt(await cin.next())\n\n if (weight % 2 === 0 && weight > 2) {\n console.log('YES')\n } else {\n console.log('NO')\n }\n\n cin.close()\n}\n\nmain()", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "46e75ad42b38e267490abef257ef1d41", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n/*\n 012345678910\nstr = \"abcdZZZefgh\"\n\nstrart = 4\nlen = 3\n\n 012345\ninput=\"///one\"\n 01234\ninput=\"//one\"\n*/\nvar eraseAt = function(str, start, len){\n return str.substring(0, start) + str.substring(start + len);\n}\n\nrl.on('line', (input) => {\n \n for(let i=0; i 1 && input[input.length-1] == '/')\n input = eraseAt(input ,input.length-1, 1);\n \n console.log(input);\n rl.close();\n });", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "d06462495f426482850a3ccfa9e83207", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\r\nprocess.stdin.setEncoding('utf-8');\r\n\r\nlet inputString = '';\r\nlet currentLine = 0;\r\n\r\nprocess.stdin.on('data', inputStdin => {\r\n inputString += inputStdin;\r\n});\r\n\r\nprocess.stdin.on('end', _ => {\r\n inputString = inputString.trim().split('\\n').map(string => {\r\n return string.trim();\r\n });\r\n\r\n main();\r\n});\r\n\r\nfunction readLine() {\r\n return inputString[currentLine++];\r\n}\r\n\r\nlet stepeni = [1, 2]\r\nlet stepen = function (n) {\r\n if (stepeni[n]) return stepeni[n];\r\n let l = stepeni.length - 1;\r\n while (l < n) {\r\n stepeni.push(2 * stepeni[l++]);\r\n }\r\n return stepeni[n];\r\n}\r\n\r\nfunction main() {\r\n let t = readLine();\r\n let red = [];\r\n while (t--) {\r\n red.push(readLine());\r\n }\r\n red.map(e => console.log((stepen(parseInt(e)) - 1)))\r\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "557dee034e003d4c509f11e857929890", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet i = 0;\nlet point;\nrl.on('line', (line) => {\n\n let row = line.split(' ').map(Number);\n if (!point) {\n for (let j = 0; j < row.length; j++) {\n if (row[j] === 1) {\n point = {i, j};\n }\n }\n }\n i++\n if (i === 5) {\n let moves = 0;\n if (point.i > 2) {\n moves += point.i - 2;\n } else if (point.i < 2) {\n moves += 2 - point.i;\n }\n if (point.j > 2) {\n moves += point.j - 2;\n } else if (point.j < 2) {\n moves += 2 - point.j;\n }\n console.log(moves);\n }\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "a40b862d02b642b31f344ae5742a5808", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n// 9- 8- 8- 7- 7- 7- 7- 7- 7- 6- 5- 3- 2- 2- 2 2- 2- 2 1- 1- 1 0- 0-\n\n// 7 4 2 - - - - - \n// value = 3\n// arr[minIndx] = 4\n// min = 1\n// 4 - - -\n\n// 9 8 8 7 6 5 4 2 1 0\n// 7 7 7 2 1 0\n// 7 7 2 2 1 \n// 1 1\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet arr = []\nlet input = []\nlet n;\nvar readline = require('readline')\n\nprocess.stdin.on('data', inputStdin => {\n input += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n input = input.trim().split('\\n').map(string => {\n return string.trim();\n });\n n = input[0]\n arr = input[1].split(\" \")\n arr = arr.map(s=>parseInt(s))\n main(); \n});\nfunction main() {\n // console.log(\"len\",arr.length)\n let visted = {};\n arr.sort(function(a, b){return b-a});\n// arr.reverse();\n // arr.map(s=>console.log(typeof s))\n\n function findMinDifference(value) {\n let min = 100000000;\n let minIndex;\n for (let i = 0; i < arr.length; i++) {\n if (visted[i]) continue;\n if (Math.abs(arr[i] - value) < min ) {\n min = Math.abs(arr[i] - value);\n minIndex = i;\n }\n }\n visted[minIndex] = true;\n return arr[minIndex];\n }\n let pils = 1;\n let boxesCanHold = arr[0]; // 9\n visted[0] = true;\n\n for (let i = 0; i < arr.length; i++) {\n if (visted[i]) continue;\n if(boxesCanHold ==0){\n boxesCanHold = arr[i];\n visted[i] = true;\n ++pils;\n }\n if(boxesCanHold!=0){\n let nextStrength = findMinDifference(boxesCanHold-1);\n boxesCanHold = nextStrength >= boxesCanHold ? --boxesCanHold : nextStrength; \n // console.log(nextStrength,\" \",boxesCanHold)\n }\n boxesCanHold = boxesCanHold < 0 ? 0 : boxesCanHold;\n if (boxesCanHold == 0 && Object.keys(visted).length != arr.length) {\n // console.log(\"here\")\n i = 0;\n }\n else if(i < arr.length-1 && Object.keys(visted).length != arr.length){\n i = 0;\n }\n\n }\n console.log(pils );\n\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "greedy"], "code_uid": "6e6b2af4c00bb8de243aefdfdb79dc24", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n\nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n \nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n const code = input[0];\n const m = code[0]; const r = code[1];\n\n let flag = false;\n input[1].split(' ').forEach(card => {\n if (m === card[0] || r === card[1]) {\n flag = true;\n }\n });\n\n console.log( flag ? \"YES\" : \"NO\" );\n});", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "7b1d0b08d7060185ae6aa22326e6b291", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nconst readLine=()=> inputString[currentLine++];\n/* ================================================ \n Main Solution Starts Here \n===================================================*/\n\nconst isVowel=(x)=>{\n let result;\n result = x === \"A\" || x===\"Y\" || x === \"E\" || x === \"I\" || x === \"O\" || x === \"U\" || x===\"a\" || x === \"e\" || x === \"i\" || x === \"o\" || x === \"u\" || x===\"y\"\n return result;\n}\n\nconst main=()=>{\n\tlet first = readLine().toLowerCase()\n\tlet newString=''\n\tfor(let char of first){\n\t\tif(!isVowel(char))\n\t\t\tnewString+='.'+char\n\t}\n\n\tconsole.log(newString)\n\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "f9147826bc53915de88ce2cd98f7be5d", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n let n = +d;\n let ans = 'NO';\n\n while (n > 0) {\n if (n % 7 === 0) {\n ans = 'YES';\n break;\n }\n\n if (n % 3 === 0) {\n ans = 'YES';\n break;\n }\n\n n -= 7;\n }\n\n n = +d;\n while (n > 0) {\n if (n % 7 === 0) {\n ans = 'YES';\n break;\n }\n\n if (n % 3 === 0) {\n ans = 'YES';\n break;\n }\n\n n -= 3;\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["greedy", "implementation"], "code_uid": "9fcdb9f10d596a4283b44cbb7e91a6e1", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = '';\nprocess.stdin.on('data', (c) => {\n i += c;\n});\nprocess.stdin.on('end', () => {\n const { EOL } = require('os');\n const line = i.split(EOL);\n const [n, m, a] = line[0].split(' ');\n console.log(minFlagStones(n, m, a));\n});\n\nfunction minFlagStones(n, m, a) {\n return Math.ceil(n / a) * Math.ceil(m / a);\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "97d593d59a724429fe1a8c7bd894b25b", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const [x, y, a] = readLine()\n .split(\" \")\n .map((n) => parseInt(n));\n\n console.log(Math.ceil(x / a) * Math.ceil(y / a));\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "cf6acd7f5fb36a613d906c5f3b3df725", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n const n = +d;\n const weeks = Math.floor(n / 7);\n const remainder = n % 7;\n const min = weeks * 2 + (remainder === 6 ? 1 : 0);\n const max = (weeks * 2) + Math.min(2, remainder);\n\n console.log(min, max);\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math", "greedy", "constructive algorithms", "brute force"], "code_uid": "657274042a5e8b9d3f6f502c4a3cb2c6", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data', function(input) {\n\t[n,m,a] = input.toString().split(' ');\n\tx = Math.ceil;\n\tconsole.log(x(n/a) * x(m/a));\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "aeed2576d2bc74bc760b99dae10b26ee", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputBuffer = \"\", curLine = 0;\n\nfunction readline() {\n\treturn inputBuffer[curLine++];\n}\n\nlet curTokens = [], curToken = 0;\n\nfunction next() {\n\twhile (curToken >= curTokens.length) {\n\t\tcurTokens = readline().split(/[\\s]+/);\n\t\tcurToken = 0;\n\t}\n\treturn curTokens[curToken++];\n}\n\nfunction nextInt () {\n\treturn parseInt(next(), 10);\n}\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf8\");\n\nprocess.stdin.on('data', (chunk) => {\n\tinputBuffer += chunk;\n});\n\nprocess.stdin.on('end', () => {\n\tinputBuffer = inputBuffer.trim().split('\\n').map(line => line.trim());\n\tmain();\n});\n\n\n\nfunction print(data) {\n\tprocess.stdout.write(data + \"\\n\");\n}\n\nfunction main () {\n\tconst a = nextInt();\n\tconst b = nextInt();\n\n\t// console.log(a + ' ' + b);\n\n\tif (a === b) {print(1); return; }\n\n\tconst lg = (Math.log(b/a) / Math.log(1.5));\n\n\tconst ceilLog = Math.ceil(lg);\n\n\tif (parseInt(lg, 10) === ceilLog) print(ceilLog+1);\n\telse print(ceilLog);\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "50d4f841ddea313bec4bfca53bc6fd17", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst strs = [];\n\nreadline.on('line', line => {\n strs.push(line.toLowerCase());\n if (strs.length === 2) {\n if (strs[0] === strs[1]) {\n console.log(0);\n } else if (strs[0] < strs[1]) {\n console.log(-1);\n } else if (strs[0] > strs[1]) {\n console.log(1);\n }\n }\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "21d8da3a8c962db9693d1fea8e9b741e", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data', data => {\n var input = data.toString().trim().split(\" \");\n \n process.stdout.write((Math.ceil(parseInt(input[0]) / parseInt(input[2])) *Math.ceil(parseInt(input[1]) / parseInt(input[2]))).toString());\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "790e0eeb37cf3a766b8aefea34bc2ec8", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = '';\nprocess.stdin.on('data', (c) => {\n i += c;\n});\nprocess.stdin.on('end', () => {\n const { EOL } = require('os');\n const lines = i.split(EOL);\n let nums = lines[1].split(' ');\n nums = nums.map(num => parseInt(num, 10));\n console.log(getMinNums(nums));\n});\n\n\nfunction getMinNums(nums) {\n nums = nums.sort((a, b) => a - b);\n let count = 0;\n for (let i = 0; i < nums.length; i++) {\n if (nums[i] > 0) {\n count++;\n for (let j = i + 1; j < nums.length; j++) {\n if (nums[j] % nums[i] === 0) {\n nums[j] = 'a';\n }\n }\n }\n }\n return count;\n}\n", "lang_cluster": "Javascript", "tags": ["math", "greedy", "implementation"], "code_uid": "ae3f42bf5831f161fba9e189cc524625", "src_uid": "63d9b7416aa96129c57d20ec6145e0cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = ''\nprocess.stdin.on('data', c => i += c )\nprocess.stdin.on('end', () => {\n const {EOL} = require('os')\n const lines = i.split(EOL)\n actOn(lines)\n})\n\nfunction actOn(lines) {\n for(let line of lines) {\n if(line !== '') {\n let answer = '';\n splitted = line.split(\"\")\n for(let c of splitted) {\n if('aeiouy'.split(\"\").includes(c.toLowerCase())) {\n continue;\n } else {\n answer += '.' + c.toLowerCase()\n }\n }\n console.log(answer)\n }\n }\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "c60802516e4d31b29dc572458edb2abb", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nconst readline = require('readline');\n\nlet lines = [];\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\nrl.on('line', (line) => {\n lines.push(line);\n});\n\n\n\nrl.on('close', (cmd) => {\n let n = parseInt(lines[0]);\n let sf = 0;\n let fs = 0;\n const s = lines[1];\n for (let i = 0; i < n - 1; ++i) {\n if (s[i] == 'S' && s[i + 1] == 'F') { ++sf; }\n if (s[i] == 'F' && s[i + 1] == 'S') { ++fs; }\n }\n const ret = sf > fs ? \"YES\" : \"NO\";\n console.log(ret);\n process.exit(0);\n\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "5b7832acbbc012930c794f87cc765883", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n \nconst input = [];\nreadLine.on('line', line => input.push(line));\n \nreadLine.on('close', () => {\n const [n] = input[0].split(' ').map(x => parseInt(x));\n\n console.log(25);\n}); ", "lang_cluster": "Javascript", "tags": ["number theory"], "code_uid": "52a1f38302020e8c5835ecb1918457f5", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let n = parseInt(readLine());\n let stones = readLine();\n let final = 0;\n for (let i = 0; i < n; i++) {\n if (stones[i] === stones[i + 1]) {\n final++;\n }\n }\n console.log(final);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0a1c540417086eb1d003a6322ee1541c", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const main = (data) => {\n const n = +data[1];\n let x = data[0];\n\n for (let i = 0; i < n; i++) {\n if (x[x.length - 1] === '0') {\n x = x.slice(0, x.length - 1);\n } else {\n x = x.slice(0, x.length - 1) + ('' + (+x[x.length - 1] - 1));\n }\n }\n\n console.log(x);\n};\n\nlet data = '';\n\nprocess.stdin.on('data', input => data += input);\nprocess.stdin.on('end', () => {\n data = data.split(' ');\n\n main(data);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "aa380cac7e61ad23d0e7dae9abfdf2f3", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n \nconst rl = readline.createInterface({\n input: process.stdin\n});\n \nlet lines = [];\nrl.on('line', (line) => {\n lines.push(line);\n}).on('close', () => {\n let c = +lines[0].split(' ')[1];\n const us = lines[1].split(' ').map(v => +v);\n\n if (us[0] <= 0) {\n process.stdout.write('0');\n } else if (us[c - 1] > 0) {\n while(us[c - 1] === us[c] && c - 1 !== us.length) {\n c++;\n }\n process.stdout.write(c.toString());\n } else {\n while(us[c - 1] <= 0 && c !== 0 ) {\n c--;\n }\n process.stdout.write(c.toString());\n }\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "7444440c72827c89cdc4a8b8a63510e3", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let stdin = process.stdin;\nstdin.setEncoding('utf8');\nstdin.on('data', function (data) {\n let input = data.split('\\n');\n let n = input[0].split(' ').map(function (a) { return parseInt(a); });\n let k = input[1].split(' ').map(function (a) { return parseInt(a); });\n let result = solution(n, k);\n console.log(result);\n});\n\n// End of interface\n\nconst solution = (n, studentsArray) => {\n\tlet res = 0;\n\tstudentsArray.sort(function(a, b){return a-b});\n\tfor (let i = 0; i input.push(line));\nconst gender = () => {\n let count = 0;\n let s = input.toString();\n const a = {};\n for (let i = 0; i < s.length; i++) {\n a[s[i]] = true;\n }\n console.log( Object.keys(a).length % 2 === 0 ? \"CHAT WITH HER!\" :\"IGNORE HIM!\");\n\n};\n\nreadLine.on('close', gender);\n", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "5750d2ed4cf649540716fb4a097175a2", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nlet input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n const cord = parseInt(input[0], 10)\n const _result = Math.ceil(cord / 5)\n console.log(_result)\n})", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "4725544473ff5da39d6ed913bda4e228", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n \nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n \nlet inputString = '';\nlet currentLine = 0;\n \nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n \nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n \nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main(){\n const w = readLine();\n if (w%2===0 && w!=2){\n console.log(\"YES\");\n }\n else{\n console.log(\"NO\");\n }\n \n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "c7fdf0da9c857e4736c0cd3451cb068e", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n\tvar t = nextInt();\n\tvar output = new Array(t);\n\tfor(var i = 0; i < t; i++){\n\t\tvar x = nextInt();\n\t\tvar count = 1;\n\t\tvar now = 1;\n\t\twhile(true){\n\t\t\tif(now == x){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tvar tmp = now % 10;\n\t\t\tnow *= 10;\n\t\t\tnow += tmp;\n\t\t\tif(now > 9999){\n\t\t\t\tnow %= 10;\n\t\t\t\tnow++;\n\t\t\t}\n\t\t\tcount += now.toString().length;\n\t\t}\n\t\toutput[i] = count;\n\t}\n\tmyout(myconv(output, 9));\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "7e3603afe107657e54fed33560b00aa1", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nconst isVowel = (char) => {\n return [\"a\", \"o\", \"u\", \"i\", \"e\"].includes(char);\n}\n\nrl.on('line', (str) => {\n let ans = 'YES';\n\n for (let i = 1; i < str.length; i++) {\n if (!isVowel(str[i]) && !isVowel(str[i - 1]) && str[i - 1] !== 'n') {\n ans = 'NO';\n break;\n }\n }\n\n if (!isVowel(str[str.length - 1]) && str[str.length - 1] !== 'n') {\n ans = 'NO';\n }\n\n console.log(ans);\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "126196ee065dc03caab48f933938b112", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nlet _inputLines;\nlet _lineNumber = 0;\nlet inputReader = _inputReader ();\n\nfunction _main() {\n\t\n\t_inputLines = _inputData.trim().split('\\n').map((string) => {\n\t\treturn string.trim();\n\t});;\n\tlet [s, v1, v2, t1, t2] = inputReader.readNumberArray();\n\t\n\tlet res1 = 2 * t1 + v1 * s;\n\tlet res2 = 2 * t2 + v2 * s;\n\tif (res1 < res2) {\n\t\tconsole.log(\"First\");\n\t} else if (res1 > res2) {\n\t\tconsole.log(\"Second\");\n\t} else {\n\t\tconsole.log(\"Friendship\");\n\t}\n\n}\n\nvar _inputData = '';\nfunction cacheInput(data) {\n\t_inputData += data;\n}\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf8');\nprocess.stdin.on('data', cacheInput).on('end', _main);\n\nfunction _inputReader () {\n\tfunction readNumberArray(){\n\t\treturn _inputLines[_lineNumber++].split(' ').map(val => Number(val));\n\t}\n\t\t\n\t\n\treturn {\n\t\treadNumberArray,\n\t}\n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "77e3642cc3a54207771a05c2734ea36f", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', function(line){\n m = parseInt(line.split(' ')[0]);\n n = parseInt(line.split(' ')[1]);\n console.log(Math.floor((m*n)/2));\n process.exit(0);\n});", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "6984a4af39f9e5fc838af2fa62a634a1", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nconst divisors = (n) => {\n const divs = [];\n\n for (let i = 1; i <= n / 2; i++) {\n if (n % i === 0) {\n divs.push(i);\n }\n }\n\n divs.push(n);\n\n return divs;\n}\n\nrl.on('line', (d) => {\n const arr = divisors(+d);\n let min = Infinity;\n let a = 1;\n let b = 1;\n\n for(let i = 0; i < arr.length; i++) {\n for (let j = i; j < arr.length; j++) {\n const v = arr[j] - arr[i];\n\n if (v < min && arr[j] * arr[i] === +d) {\n min = v;\n a = arr[i];\n b = arr[j];\n }\n }\n }\n\n console.log(a, b);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "c82dc8e7cab20a06a2044d4c72965c0d", "src_uid": "f52af273954798a4ae38a1378bfbf77a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf8');\n\nvar input= '', cin, cout;\n\nprocess.stdin.on('data', function(chunk) {\n input+=chunk;\n});\n\nprocess.stdin.on('end', function() {\n input = input.split('\\n');\n cout = function(data) {process.stdout.write(data+'\\n')};\n var inputLineIndex = 0;\n cin = function(){return inputLineIndex>=input.length?undefined:input[inputLineIndex++]};\n process.exit(main() || 0);\n});\n\nfunction main() {\n [n, m, k] = cin().split(' ');\n let res = 0;\n for (let i = 0; i < k; i++) {\n res += 2*(+n + +m - 8*(+i)) - 4;\n }\n cout(res);\n return 0;\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "b002cce73f6e68b0c91ade534d43fed5", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\nvar IsPrime = function (num) {\n if (num == 2)\n return true;\n if (num < 2 || num % 2 == 0)\n return false;\n var limit = parseInt(Math.sqrt(num));\n for (i = 3; i <= limit; i += 2) {\n if (num % i == 0)\n return false;\n }\n return true;\n}\n\nvar prev = 2,\n n, k, counter = 0,\n helper;\n\nrl.on('line', (input) => {\n var temp = input.split(' ').map(item => parseInt(item));\n n = temp[0];\n k = temp[1];\n\n for (let i = 3; i <= n; i++) {\n if (IsPrime(i)) {\n helper = prev + i + 1;\n if (IsPrime(helper) && helper <= n)\n counter++;\n prev = i;\n }\n }\n console.log((counter >= k) ? \"YES\" : \"NO\");\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math", "number theory"], "code_uid": "9fcf42a5f5cdc8168a63a01ffe569b73", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n //let [x1, x2, x3, x4] = input[0].split(' ').map(x => parseInt(x));\n let [n] = input[0].split(' ').map(x => parseInt(x));\n\n let answ = 0;\n while (n > 0) {\n if (n % 2 === 0) n /= 2;\n else if (n % 2 === 1) {\n n -= 1; answ += 1;\n n /= 2;\n }\n }\n\n console.log(answ);\n}); \n ", "lang_cluster": "Javascript", "tags": ["bitmasks"], "code_uid": "795f3ebbc261db9173b64811bf0ea30d", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data', input => {\n input = String(input).split(' ');\n\n n = input[0];\n m = input[1];\n a = input[2];\n\n n_neded = 0;\n m_neded = 0;\n\n if (n % a != 0) {\n n_neded = Math.floor(n / a) + 1;\n } else {\n n_neded = Math.floor(n / a);\n }\n\n if (m % a != 0) {\n m_neded = Math.floor(m / a) + 1;\n } else {\n m_neded = Math.floor(m / a);\n }\n\n console.log(n_neded * m_neded);\n\n }\n)", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "43e7cb0792703d0fb424f17d5f1dacb6", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n })\n \n // multi line input\n readline.on('line', line => {\n let number = parseInt(line)\n console.log(watermelon(number))\n})\n\n//it's a main function \nfunction watermelon(number) {\n return number > 2 && number%2 === 0 ? 'YES' : 'NO'\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "cf1078ab71249d2031a32b71b538208d", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline')\nconst rl = readLine.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\n\nrl.question('', (line) => {\n n = parseInt(line) \n main()\n})\n\nlet wynik = 0\n\nfunction main() {\n if (n % 2 === 0){\n wynik = n/2\n } else\n wynik = (n-1)/2 - n\n console.log(wynik)\n rl.close()\n}", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "081af609f6e1ce5c368090635c576726", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let s1 = readline();\n let lowercase = 0;\n let uppercase = 0;\n\n for (let i = 0 , c = s1.length ; i < c ; i++){\n if (s1[i].charCodeAt(0) >=97) lowercase++;\n else uppercase ++;\n }\n console.log((lowercase >= uppercase)? s1.toLowerCase() : s1.toUpperCase());\n}\n\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "b223bf2547a8b03643f8ac6c15ef101c", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n\tvar one = nextIntArray();\n\tvar N = one[0];\n\tvar K = one[1];\n\tvar list = nextIntArray();\n\tvar count = 0;\n\twhile(list.length > 0){\n\t\tvar L = list[0];\n\t\tif(L <= K){\n\t\t\tcount++;\n\t\t\tlist.shift();\n\t\t\tcontinue;\n\t\t}\n\t\tvar R = list[list.length - 1];\n\t\tif(R <= K){\n\t\t\tcount++;\n\t\t\tlist.pop();\n\t\t\tcontinue;\n\t\t}\n\t\tbreak;\n\t}\n\t\n\tmyout(count);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "a2370fd0cf3452ec2121ae85812d7b1d", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var read = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\nvar obj;\nvar inLine = [];\nread.on('line', function (input) { inLine.push(input); });\nread.on('close', function () {\n obj = init(inLine);\n myerr(\"-----start-----\");\n var start = new Date();\n Main();\n var end = new Date() - start;\n myerr(\"----- end -----\");\n myerr(\"Time: \" + (end) + \"ms\");\n myerr(\"Memory: \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction nextInt() { return myconv(next(), 1); }\nfunction nextStrArray() { return myconv(next(), 2); }\nfunction nextIntArray() { return myconv(next(), 4); }\nfunction nextCharArray() { return myconv(next(), 6); }\nfunction next() { return obj.next(); }\nfunction hasNext() { return obj.hasNext(); }\nfunction init(input) {\n var returnObj = {\n list: input, index: 0, max: input.length,\n hasNext: function () { return (this.index < this.max); },\n next: function () { if (!this.hasNext()) { throw \"ArrayIndexOutOfBoundsException\"; } else { var returnInput = this.list[this.index]; this.index++; return returnInput; } }\n };\n return returnObj;\n}\nfunction myout(s) { console.log(s); }\nfunction myerr(s) { console.error(\"debug:\" + require(\"util\").inspect(s, false, null)); }\nfunction myconv(i, no) { try { switch (no) { case 1: return parseInt(i); case 2: return i.split(\" \"); case 4: return i.split(\" \").map(Number); case 6: return i.split(\"\"); case 7: return i.split(\"\").map(Number); case 8: return i.join(\" \"); case 9: return i.join(\"\\n\"); case 0: return i.join(\"\"); default: return i; } } catch (e) { return i; } }\n\n\nfunction Main() {\n var mat = [];\n \n var j = 0;\n for (var i = 0; i < 5; i++) {\n mat[i] = nextIntArray();\n for (var j = 0; mat[i][j] < 5; j++) {\n if (mat[i][j] === 1) {\n myout(Math.abs(i - 2) + Math.abs(j - 2));\n }\n }\n }\n \n} // Use Terminal to debug, not Debug Console!", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "699987d2051547ead6850c024132f4d5", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(str) {\n let inputs = str.trim().replace(/\\r/g, '').split('\\n');\n let dragons = inputs.slice(0, inputs.length - 1);\n let totalDragons = +inputs[inputs.length - 1];\n let damagedDragons = 0;\n if (dragons.indexOf('1') !== -1) {\n damagedDragons = totalDragons;\n }\n else {\n\n for (let i = 1; i <= totalDragons; i++) {\n if (i % dragons[0] == 0 || i % dragons[1] == 0 || i % dragons[2] == 0 || i % dragons[3] == 0) {\n damagedDragons++;\n }\n }\n }\n\n return damagedDragons.toString();\n}\n", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "60b7a2efa55b41c9198781996f9aa649", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let fs = require('fs');\n\nlet txt = fs.readFileSync(0, \"utf-8\").split(/[\\n\\r]/).filter(data => data.length > 0);\n\nfor (let i = 0; i < txt.length; i += 2) {\n doit([...new Set(txt[i + 1].split(\"\").filter(data => data.length > 0).map(data => data.toLowerCase().charCodeAt(0)).sort((a, b) => a - b))]);\n}\n\nfunction doit(tab) {\n for (let i = 0; i < 26; i++) {\n if (tab[i] != i + 97) {\n console.log('NO');\n return;\n }\n }\n console.log(\"YES\");\n\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "ab7305dd63b9f58debe7d4b454947e1b", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar GCD = function (a, b) {\n if (b == 0) return a;\n return GCD(b, a % b);\n};\n\n\nrl.on('line', (input) => {\n var cont = input.split(' ').map(item => parseInt(item));\n var w = cont[0];\n var y = cont[1];\n var max = (w > y) ? w : y;\n var dot = 6 - max + 1;\n var temp = GCD(6, dot);\n //console.log(\"cont = %d type = %s\", dot / temp, typeof (6 / temp));\n console.log(\"%d/%d\",dot/temp,6/temp);\n rl.close();\n}).on('close', () => {\n});", "lang_cluster": "Javascript", "tags": ["math", "probabilities"], "code_uid": "de495a96f3fbbca1665c57fd9056b711", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "/**\nPolycarp has just invented a new binary protocol for data transmission. He is encoding positive integer decimal number to binary string using following algorithm:\n\nEach digit is represented with number of '1' characters equal to the value of that digit (for 0 it is zero ones).\nDigits are written one by one in order corresponding to number and separated by single '0' character.\nThough Polycarp learnt how to encode the numbers, he has no idea how to decode them back. Help him calculate the decoded number.\n\nInput\nThe first line contains one integer number n (1 ≤ n ≤ 89) — length of the string s.\n\nThe second line contains string s — sequence of '0' and '1' characters, number in its encoded format. It is guaranteed that the number corresponding to the string is positive and doesn't exceed 109. The string always starts with '1'.\n\nOutput\nPrint the decoded number.\n\nExamples\ninput\n3\n111\noutput\n3\ninput\n9\n110011101\noutput\n2031\n\n */\n\nlet inputString = '';\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n let lengthOfString = Number(inputString[0]);\n let string = inputString[1];\n\n solution(lengthOfString, string);\n\n});\n\nfunction solution(lengthOfString, string) {\n\n let onesCount = 0;\n let zeorCount = '';\n let digit = [];\n\n for (let index = 0; index < lengthOfString; index++) {\n\n if (string[index] == '1') {\n\n onesCount++;\n\n if (zeorCount.length > 1)\n digit.push(zeorCount.substring(0, zeorCount.length - 1));\n\n zeorCount = '';\n }\n\n if (string[index] == '0') {\n\n zeorCount += '0';\n\n if (onesCount)\n digit.push(onesCount.toString());\n\n onesCount = 0;\n }\n }\n\n if (onesCount)\n digit.push(onesCount.toString());\n\n if (zeorCount.length )\n digit.push(zeorCount);\n\n console.log(digit.join(\"\"));\n\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "326ba4f8b0a865bc918c92ea6aea0ee8", "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n\nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n \nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n const param = input[0];\n const pattern = \"qwertyuiopasdfghjkl;zxcvbnm,./\";\n \n const answer = [];\n for (let i = 0; i < input[1].length; i += 1) {\n let k = pattern.indexOf(input[1][i]);\n \n if (param === 'R') {\n answer.push(pattern.charAt(k-1));\n } else {\n answer.push(pattern.charAt(k+1));\n }\n }\n console.log(answer.join(''))\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e916f2e910271da77d8a6495036781a9", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n const str1 = input[0], str2 = input[1];\n\n if (str1.length !== str2.length) {\n console.log('NO'); return;\n }\n\n let j = str1.length-1;\n for (let i = 0; i < str1.length; i += 1, j -= 1 ) {\n if (str1[i] !== str2[j]) {\n console.log('NO'); return;\n }\n }\n\n console.log('YES');\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "68886b533da2abd4c74f65990b6f29d7", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction readAsInt(){\n return parseInt(readline());\n}\n\nfunction readAsIntList(){\n return readline().split(' ').filter(i => i).map(i => parseInt(i));\n}\n\n\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n let name = readline();\n console.log([...new Set(name.split(''))].length % 2 === 0 ? 'CHAT WITH HER!' : 'IGNORE HIM!' );\n}\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "8871f8836a5002b72ceca9732643bd88", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction isPrime(x) {\n\tlet s = Math.sqrt(x);\n\tlet i = 2;\n\twhile (i <= s) {\n\t\tif (x % i === 0) {\n\t\t\treturn false;\n\t\t}\n\t\ti++;\n\t}\n\treturn true;\n}\n\nfunction main() {\n\tlet s1 = readLine().split(''),\n\t\ts2 = readLine().split(''),\n\t\tres = s1.map((d, i) => (d !== s2[i] ? '1' : '0'));\n\tconsole.log(res.join(''));\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "37ef380143bf4cbc394d75a5facfe30c", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (str) => {\n if (c === 0) {\n c++;\n return;\n }\n\n let ones = 0;\n let zeros = 0;\n\n for (let i = 0; i < str.length; i++) {\n if (str[i] === '1') {\n ones++;\n }\n else {\n zeros++;\n }\n }\n\n if (ones === 0) {\n console.log(0);\n }\n else {\n console.log(`1${'0'.repeat(zeros)}`);\n }\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f80c536907eea64f4f9094ed3e259b9e", "src_uid": "ac244791f8b648d672ed3de32ce0074d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nlet _inputLines;\nlet _lineNumber = 0;\nlet inputReader = _inputReader ();\n\nfunction _main() {\n\t\n\t_inputLines = _inputData.trim().split('\\n').map((string) => {\n\t\treturn string.trim();\n\t});;\n\t \n\t// To read Number from console\n\tlet noOfTestCases = inputReader.readNumber();\n\t\n\tif(noOfTestCases%2==0 && noOfTestCases!==2){\n\t console.log('YES');\n\t}\n\telse \n\t console.log(\"NO\");\n\t// console.log(noOfTestCases,typeof noOfTestCases);\n\t// while(noOfTestCases--){\n\t// // To read generic array separated by space\n\t// let tmp = inputReader.readArray();\n\t// console.log(tmp, typeof tmp);\n\t \n\t// // To read boolean value i.e. 'true' or 'false' (It's case insensitive)\n\t// tmp = inputReader.readBoolean();\n\t// console.log(tmp, typeof tmp);\n\t \n\t// // To read a single character\n\t// tmp = inputReader.readChar();\n\t// console.log(tmp, typeof tmp);\n\t \n\t// // to read a line\n\t// tmp = inputReader.readLine();\n\t// console.log(tmp, typeof tmp);\n\t \n\t// // To read a numeric array\n\t// tmp = inputReader.readNumberArray();\n\t// console.log(tmp, typeof tmp);\n\t// }\n\n}\n\nvar _inputData = '';\nfunction cacheInput(data) {\n\t_inputData += data;\n}\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf8');\nprocess.stdin.on('data', cacheInput).on('end', _main);\n\nfunction _inputReader () {\n\tfunction readArray() {\n\t\treturn _inputLines[_lineNumber++].split(' ');\n\t}\n\t\t\n\tfunction readBoolean(){\n\t\tlet word = _inputLines[_lineNumber++];\n\t\tif(word.toLowerCase() == \"true\" || word.toLowerCase() == \"1\"){\n\t\t\treturn true;\n\t\t}else {\n\t\t\treturn true;\n\t\t}\n\t}\n\t\t\n\tfunction readChar(){\n\t\treturn _inputLines[_lineNumber++].trim();\n\t}\n\t\t\n\tfunction readNumber(){\n\t\treturn Number(_inputLines[_lineNumber++]);\n\t}\n\t\t\n\tfunction readLine(){\n\t\treturn _inputLines[_lineNumber++];\n\t}\n\t\t\n\tfunction readNumberArray(){\n\t\treturn _inputLines[_lineNumber++].split(' ').map(val => Number(val));\n\t}\n\t\t\n\t\n\treturn {\n\t\treadArray,\n\t\treadBoolean,\n\t\treadChar,\n\t\treadNumber,\n\t\treadLine,\n\t\treadNumberArray,\n\t}\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "b8af217f90593d2b7ee29924bccb7e07", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', (input) => {\n //console.log(input);\n ar = input.split(' ');\n\n n = ar[0];\n m = ar[1];\n a = ar[2];\n\n if (m * n <= a * a) {\n console.log(1);\n return;\n }\n\n res = Math.ceil(n / a) * Math.ceil(m / a);\n console.log(res);\n\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "6bd7e584008b94014d9ebaca3a524a8d", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nconst store = {};\n\nfunction main() {\n\tlet n = readLine() >> 0;\n\n\tlet i = 1,\n\t\ttries = 0;\n\n\twhile (i <= n) {\n\t\ttries += (n - i) * i + 1;\n\t\ti++;\n\t}\n\n\tconsole.log(tries);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "a55cc5231d6c10340516f580ace86d8f", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nrl.on('line', (d) => {\n let str = '';\n for (let i = 0; i <= +d; i++) {\n str += i;\n }\n\n console.log(str[+d]);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3ec6dbdcc3e8cb4a1726e2be501042c6", "src_uid": "2d46e34839261eda822f0c23c6e19121", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Beautiful Matrix\n\nconst {EOL} = require('os');\n\nlet inp = '';\n\nprocess.stdin.on('data', c => inp += c);\n\nprocess.stdin.on('end', () => {\n let lines = inp.split(EOL);\n \n let loc = [];\n for(let i in lines) {\n \tif(lines[i].indexOf('1') != -1) {\n \t\tloc = [+i, ~~(lines[i].indexOf('1') / 2)];\n \t}\n }\n\n process.stdout.write(Math.abs(2 - loc[0]) + Math.abs(2 - loc[1]) + '');\n\n return;\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "7430514996d044fc9a79c29dad67befe", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadline.on('line', line => input.push(line));\n\nreadline.on('close', () => {\n const [year] = input;\n \n for (i = parseInt(year) + 1; i < 10000; i++) {\n let y = i.toString();\n let l = y.length;\n\n let ll = y.split('').filter((val, index, arr) => {\n return arr.indexOf(val) === index;\n }).length;\n\n if(l === ll) {\n console.log(i);\n break;\n }\n }\n});", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "1123eaf8c25f2270e0aa9f9a10f11459", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n\tvar N = nextInt();\n\tvar list = nextIntArray();\n\tvar max = Math.max.apply(null, list);\n\tfor(var i = max; i <= 300; i++){\n\t\tvar L = 0;\n\t\tvar R = 0;\n\t\tfor(var j = 0; j < N; j++){\n\t\t\tL += list[j];\n\t\t\tR += i - list[j];\n\t\t}\n\t\tif(L < R){\n\t\t\tmyout(i);\n\t\t\treturn;\n\t\t}\n\t}\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "a8b0f993e10b537558721de177c1524d", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n})\nvar matrix = [];\nreadline.on(\"line\", ans => {\n matrix.push(ans.split(\" \"))\n if (matrix.length == 5) {\n var pos = [];\n for (let i = 0; i < matrix.length; i++) {\n for (let j = 0; j < matrix[i].length; j++) {\n matrix[i][j] == 1 ? pos.push(i, j) : void 0;\n }\n }\n var res = 0;\n for (let k = 0; k < pos.length; k++) {\n res += Math.abs(pos[k] - 2);\n }\n console.log(res);\n readline.close();\n }\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "b750ae39cb000b1c29556b3424aae069", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n})\n \n // multi line input\nreadline.on('line', line => {\n let strings = line\n console.log(stringTask(strings))\n})\n\n//it's a main function stringTask\nfunction stringTask(strings) {\n let lowerLetter = strings.toLowerCase()\n let findeLetterWithOutVowels = lowerLetter.replace(/[aeiouy]/g, '')\n \n return findeLetterWithOutVowels.replace(/(\\w)/g, ('.$1'))\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "57011b87a945755f8950cadc6a58f5fc", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = '';\nprocess.stdin.on('data', c => input += c);\nprocess.stdin.on('end', sol);\n\nfunction sol() {\n const A = input\n .split(' ')\n .map(Number);\n const sum = A.reduce((a, b) => a + b, 0);\n const result =\n (A[0] === sum - A[0]) ||\n (A[1] === sum - A[1]) ||\n (A[2] === sum - A[2]) ||\n (A[3] === sum - A[3]) ||\n (A[0] + A[1] === A[2] + A[3]) ||\n (A[0] + A[2] === A[1] + A[3]) ||\n (A[0] + A[3] === A[1] + A[2])\n\n process.stdout.write(\n result ? 'YES' : 'NO',\n 'utf8',\n () => process.stdout.end()\n );\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "631b8c7d400f7c2003ae34706a14b5e4", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\nconst year = () => {\n let boolean = false;\n let c = +input[0];\n while (boolean === false) {\n c++; //1988\n let newString = `${c}`;\n let ar = [];\n for (const x of newString) {\n ar.push(x); // 1 9 8 8\n }\n let j = new Set(ar); // 1 9 8\n if (ar.length === j.size) {\n console.log(c);\n boolean = true;\n }\n }\n\n};\nreadLine.on('close', year);", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "0f39e9e5e4d9341950e794240d092c54", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst rl = readline.createInterface({\n\t input: process.stdin,\n\t output: process.stdout,\n\tterminal : false\n});\n\n\nrl.on(\"line\", main)\nlet i = 0;\nlet n = 0;\nlet m = []\nfunction main(input){\n\t\n\tm.push(input.split(' '))\n\ti++\n\tif(i < 5){\n\t\treturn\n\t}\n\n\tlet x = 0\n\tlet y = 0\n\tfor(var j = 0; j < 5; j++){\n\t\tfor(var k = 0 ; k < 5; k++){\n\t\t\tif(m[j][k] === \"1\"){\n\t\t\t\ty = j\n\t\t\t\tx = k\n\t\t\t}\n\t\t}\n\t}\n\t\n\tconsole.log(Math.abs((x+1)-3) + Math.abs((y+1)-3))\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "bcab939cab3d36719d8d68bb6fa40e4c", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n// utils\nconst MOD = 1e9 + 7;\nconst mod = (n) => ((n % MOD) + MOD) % MOD;\nconst add = (a, b) => mod(mod(a) + mod(b));\nfunction mul() {\n for (var a = arguments, r = a[0], i = a.length; --i; )\n r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;\n return r;\n}\nfunction inv(b) {\n for (var a = MOD, u = 0, v = 1, t; b; v = t)\n (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);\n u %= MOD;\n return u < 0 ? u + MOD : u;\n}\n\nfunction main() {\n let [count0, found1] = [0, false];\n const str = readLine();\n\n for (let i = 0; i < str.length; i++) {\n if (!found1 && str[i] === \"1\") found1 = true;\n if (found1 && str[i] === \"0\") count0++;\n }\n\n if (count0 >= 6 && found1) console.log(\"yes\");\n else console.log(\"no\");\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "b03bf0d70fd3fb66cc3784b80eb1801b", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const lines = [];\n\nconst helpers = {\n arrStringtoInt: (arr, splitter) => {\n return arr.split(splitter).map(num => parseInt(num));\n },\n insterAt: (arr, idx, item) => {\n const newArray = [...arr];\n newArray.splice(idx, 0, item);\n return newArray;\n },\n sortAscending: (arr) => {\n return arr.sort((a, b) => a - b);\n },\n sortDescending(arr) {\n return arr.sort((a, b) => b - a);\n }\n}\n\nconst readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n// multi line input\nreadline.on('line', line => {\n lines.push(line);\n});\n\nreadline.on('close', line => {\n const matchs = [];\n let total = 0;\n\n for (let x = 1; x < lines.length; x++) {\n const m = helpers.arrStringtoInt(lines[x], ' ');\n matchs.push(m);\n }\n\n\n // [ [1,2], [2,4], [3,4] ]\n\n let n = matchs.length;\n\n\n for (let y = 0; y < n; y++) {\n\n for (let x = 0; x < n; x++) {\n if (y != x) {\n if(matchs[y][0] == matchs[x][1]) {\n total++;\n }\n }\n }\n }\n\n\n console.log(total)\n\n\n\n});\n\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "b2d1266284da26675aea7bcddf78996c", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n let ans = 0;\n let [n, k] = d.split(' ').map(Number);\n let time = 240;\n time -= k;\n\n let c = 1;\n let inc = 5;\n while (time > 0 && n > 0) {\n time -= inc * c;\n\n if (time >= 0) {\n ans++;\n n--;\n c++;\n }\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation", "binary search"], "code_uid": "1d12264c01feb3a1ee039e066318bec4", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\n\n const readline = require('readline');\n\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n });\n\n rl.question('', (value) => {\n let s = value;\n let isPalindrome = true;\n let oneLetter = true;\n for(let idx = 0; idx < Math.floor(s.length/2) && isPalindrome; idx += 1){\n if(s.charAt(idx) != s.charAt(s.length-idx-1)){\n isPalindrome = false;\n }\n if(s[idx] !== s[idx+1] && oneLetter){\n oneLetter = false;\n }\n }\n if(!isPalindrome){\n console.log(s.length);\n }else if(oneLetter) {\n console.log(0);\n }else {\n console.log(s.length-1);\n }\n rl.close();\n\n });\n", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "394a8f87c29c3a7afc95cd8162f3c8bd", "src_uid": "6c85175d334f811617e7030e0403f706", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n const arr = d.split(' ').map(Number);\n arr.sort((a, b) => a - b);\n console.log(arr[Math.floor(arr.length / 2)]);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation"], "code_uid": "e2d70f8761cbab482db58a8c5a9deb72", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nconst readLine=()=> inputString[currentLine++];\n/* ================================================ \n Main Solution Starts Here \n===================================================*/\n\nconst main=()=>{\n\tlet counts={}\n\tlet userName=readLine()\n\t\n\tlet set = new Set()\n\tfor(let char of userName)\n\t\tset.add(char)\n\n\n\tif(set.size%2==0)\n\t\tconsole.log('CHAT WITH HER!')\n\telse console.log('IGNORE HIM!')\n}", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "8d7ee78e49cdc975ef01782aac9345f6", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nlet cin='';\nprocess.stdin.on(\"data\",d=>{\n\tcin+=d;\n}).on('end',()=>{\n\tcin = cin.split(\" \");\n\tcin[0] *= 1;\n\tcin[1]*=1;\n\tfor(let i=0;i<(cin[1]);i++){\n\t\tif(cin[0]%10==0)cin[0]/=10;\n\t\telse cin[0]-=1;\n\t\t\n\t\tif(i==(cin[1])-1)\n\t\t\tprocess.stdout.write(cin[0]+'\\n');\n\n\t}\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f8dbf1efe54361389a7383c953d6fc04", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction main() {\n\tconst [n, x] = readLine()\n\t\t.split(' ')\n\t\t.map(x => x >> 0);\n\tlet count = 0;\n\n\tfor (let i = 1; i <= n; i++) {\n\t\tif (x % i === 0 && x / i <= n) {\n\t\t\tcount++;\n\t\t}\n\t}\n\n\tconsole.log(count);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation", "number theory"], "code_uid": "c6d5245ae9d0b651921c7c4c061ee066", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main(input) {\n\n // console.log(input,\"ii\");\n input =input.split(/\\n/g);\n let p = input[0].split(' ');\n // l = a.length;\n let n = parseInt(p[0]);\n let a = parseInt(p[1]);\n let x= parseInt(p[2]);\n let b = parseInt(p[3]);\n let y = parseInt(p[4]);\n var print = \"NO\";\n let gg =x;\n let ll =y;\n // if(b>y) {\n // ll = parseInt(b)-parseInt(y);\n // } else {\n // // ll = parseInt(y)+ parseInt(n) - parseInt(b) ;\n // ll = b + n - y -1;\n // }\n\n // if(a {\n /**\n * n, n-1, ..., n-l, 2^1, ..., 2^(l-1)\n * 2^1, ..., 2^(r-1), 2^(r-1), ..., 2^(r-1)\n * \n * 5, 2, 3\n * => 1, 1, 1, 2\n * => 1, 2, 4, 4, 4 \n */\n const low_bound = 1 * (n - l + 1) + [...Array(l).keys()].slice(1).reduce((a, c) => a + Math.pow(2, c), 0);\n const high_bound = [...Array(r).keys()].reduce((a, c) => a + Math.pow(2, c), 0) + (n - r) * Math.pow(2, r - 1);\n return `${low_bound} ${high_bound}`;\n}\n\n/**\n * \n * Submission standard input read-in\n * \n */\n\nif (MODE === \"SUBMIT\") {\n var readline = require('readline');\n\n var rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n });\n\n rl.question(\"\", function(answer) {\n const parsed = answer.split(' ').map(i => parseInt(i));\n console.log(CF_1204_B(...parsed));\n rl.close();\n });\n}\n\n/**\n * \n * Test cases and benchmarking code below this point\n * \n * Unrelated to the solution code\n * \n */\n\nif (MODE === \"TEST\") {\n const { performance } = require('perf_hooks');\n let timer = performance.now();\n\n // Assumptions:\n // 1 <= n <= 1000\n // 1 <= l <= r <= min(n, 20)\n // [n, l, r]\n const test_cases = [\n [4, 2, 2],\n [5, 1, 5]\n ]\n test_cases.forEach(( v ) => {\n console.log( CF_1204_B( ...v ) );\n });\n\n timer = performance.now() - timer;\n console.log(`Time elapsed for test case: ${timer.toFixed(2)}ms`)\n}", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "4275ddb60d79cc28d2983f71f6713ccd", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet s ;\nlet upperCounter = 0 ;\nlet lowerCounter = 0 ; \nlet temp ; \nrl.on(\"line\",(input)=>{\n s = input.split(\" \").toString()\n //console.log(typeof(s))\n temp = s; \n // console.log(temp[0].toLowerCase,s[0])\n \n for(let i = 0 ; i < s.length ; i++){\n if((temp[i].toLowerCase()) == s[i]) lowerCounter++\n else upperCounter++;\n }\n if(lowerCounter>= upperCounter) console.log(s.toLowerCase())\n else console.log(s.toUpperCase());\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "1f310bbdf349283214140dee6df1f957", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict'\n\nconst {EOL} = require('os')\n\nlet ipt = ''\nprocess.stdin.on('data', s => ipt += s)\nprocess.stdin.on('end', () => {\n let [p1, p2, p3, p4, a, b] = ipt.split(EOL)[0].split(' ').map(v => parseInt(v))\n let c = 0\n for (let i = a; i <= b; i++) {\n [\n i % p4 % p3 % p2 % p1 == i,\n i % p3 % p4 % p2 % p1 == i,\n i % p3 % p2 % p4 % p1 == i,\n i % p3 % p2 % p1 % p4 == i,\n i % p4 % p2 % p3 % p1 == i,\n i % p2 % p4 % p3 % p1 == i,\n i % p2 % p3 % p4 % p1 == i,\n i % p2 % p3 % p1 % p4 == i,\n i % p4 % p2 % p1 % p3 == i,\n i % p2 % p4 % p1 % p3 == i,\n i % p2 % p1 % p4 % p3 == i,\n i % p2 % p1 % p3 % p4 == i,\n i % p4 % p3 % p1 % p2 == i,\n i % p3 % p4 % p1 % p2 == i,\n i % p3 % p1 % p4 % p2 == i,\n i % p3 % p1 % p2 % p4 == i,\n i % p4 % p1 % p3 % p2 == i,\n i % p1 % p4 % p3 % p2 == i,\n i % p1 % p3 % p4 % p2 == i,\n i % p1 % p3 % p2 % p4 == i,\n i % p4 % p1 % p2 % p3 == i,\n i % p1 % p4 % p2 % p3 == i,\n i % p1 % p2 % p4 % p3 == i,\n i % p1 % p2 % p3 % p4 == i,\n ].filter(Boolean).length >= 7 && c++\n }\n\n console.log(c)\n})", "lang_cluster": "Javascript", "tags": ["implementation", "number theory"], "code_uid": "09ecf961b52d231c1762c79777cbeda2", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const data = [];\nprocess.stdin.on('data', (chunk) => data.push(chunk));\n\nprocess.stdin.on('end', () => {\n const n = +(data.join('').trim());\n console.log(n % 2 || n === 2 ? 'NO' : 'YES')\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "8bb1e7686dfff4a1f9098cea211fd44d", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\n\nconst readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n})\nreadline.question(\"\",(ans)=>{\n console.log(ans.match(/(.)\\1{6,}/)?\"YES\":\"NO\")\n readline.close();\n})", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "0c893fcf65050c3897f919ee628c6142", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var s = next();\n var t = next();\n var output = \"\";\n for(var i = 0; i < s.length; i++){\n if(s[i] != t[i]){\n output += \"1\";\n }else{\n output += \"0\";\n }\n }\n myout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "1b62891feda814e04c1385ae520b18a3", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const state = { stdin: Buffer.alloc(0) };\nconst consume = (chunk) =>\n (state.stdin = Buffer.concat(\n [state.stdin, chunk],\n state.stdin.length + chunk.length\n ));\nconst commit = (answer) => process.stdout.write(answer);\n//\nconst main = (args) => {\n let data = parseInt(state.stdin.toString(\"utf8\"));\n let solution = \"NO\";\n if (data < 1 || data > 100) return commit(solution);\n\n // divide the watermelon into two parts,\n // each of them weighing even (%2==0) number of kilos;\n\n for (let i = 1; i < data; i++) {\n let partOne = data - i;\n let partTwo = data - partOne;\n if (partOne % 2 === 0 && partTwo % 2 === 0) {\n solution = \"YES\";\n // console.log(data, partOne, partTwo)\n commit(solution);\n return;\n }\n }\n commit(solution);\n};\n\nprocess.stdin.on(\"data\", consume).on(\"end\", main);\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "75b357ef203b25648e4ee29a69d63063", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', (inputStdin) => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', (_) => {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((string) => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\n// Make a Snippet for the code above this and then write your logic in main()\nfunction main() {\n const numOfInterestingMinutes = readline();\n const interestingMinutes = readline();\n\n countNumberOfMinutes(\n parseInt(numOfInterestingMinutes),\n interestingMinutes.split(' ')\n );\n}\n\nfunction countNumberOfMinutes(numOfInterestingMinutes, interestingMinutes) {\n const firstInterestingMinute = parseInt(interestingMinutes[0])\n if (firstInterestingMinute >= 16) {\n console.log(15);\n return;\n }\n\n if (numOfInterestingMinutes === 1) {\n console.log(firstInterestingMinute + 15);\n return;\n }\n\n let watchMinutes = firstInterestingMinute;\n let diff = 0\n\n for (let i = 1; i < numOfInterestingMinutes; i++) {\n diff =\n parseInt(interestingMinutes[i]) - parseInt(interestingMinutes[i - 1]);\n if (diff >= 16) {\n watchMinutes += 15;\n break;\n } else {\n watchMinutes += diff;\n }\n }\n\n if (diff < 16)\n watchMinutes += 15\n\n console.log(watchMinutes >= 90 ? 90 : watchMinutes);\n}\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "57dab4db554d0ca79edcf9a57af0620b", "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\n\nconst nextRound = () => {\n let count = 0;\n const [n, k] = input[0].split(' ').map(x => +x);\n const ar = input[1].split(' ').map(x => +x);\n for (const x of ar) {\n if ((x >= ar[k-1]) && (x >0)) {\n count++;\n }\n }\n console.log(count);\n};\n\n\nreadLine.on('close', nextRound);", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "71c42dce766f54e5afe7e4e4d1769efe", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nconst input = [];\n\nrl.on('line', line => {\n input.push(line);\n});\n\nrl.on('close', () => {\n solution(input[0], input[1]);\n});\n\nfunction solution(first, second) {\n for (let i = 0; i < first.length; i++) {\n if (first[i].toLowerCase() > second[i].toLowerCase()) {\n console.log('1');\n return;\n } else if (first[i].toLowerCase() < second[i].toLowerCase()) {\n console.log('-1');\n return;\n }\n }\n\n console.log('0');\n return;\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "c9b59867443213aea2cea45779d03374", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict'\nprocess.stdin.on('data', data => {\n data = data.toString()\n const [n, m, a] = data.split(' ').map(a => parseInt(a))\n console.log(Math.ceil(n / a) * Math.ceil(m / a))\n})\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "60630914fa22cc36f6efb812fa8a446a", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\n\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nvar a,b;\nvar expect = 'first_string';\nrl.on('line', function(line){\n if(expect == 'first_string'){\n a = line.toLowerCase();\n expect = 'second_string';\n }else { \n b = line.toLowerCase();\n console.log(a.localeCompare(b));\n process.exit(0);\n }\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "8c6f8b310ec8fd6989d071824d175a22", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n var n=Number(stdin[0]),m=0;\n for(var i=1;i {\n word = 'hello'\n i = 0\n for(l of str) if(l == word[i]) i++\n console.log(i == word.length ? 'YES' : 'NO')\n rl.close();\n});\n", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "234363d9274612080f10d1a19f567d4f", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nfunction createReadLine() {\n process.stdin.resume();\n process.stdin.setEncoding('utf-8');\n\n let inputString = '';\n let currentLine = 0;\n\n process.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n });\n\n process.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n });\n\n function readline() {\n return inputString[currentLine++];\n }\n\n return readline;\n}\n\nconst readline = createReadLine();\n\nfunction readInts(){\n return readline().split(' ').map((value => Number.parseInt(value)));\n}\n\nfunction readFloats(){\n return readline().split(' ').map((value => Number.parseFloat(value)));\n}\n\nfunction readStr() {\n return readline();\n}\n\nfunction readInt(){\n return Number.parseInt(readline());\n}\n\nfunction readFloat(){\n return Number.parseFloat(readline());\n}\n\n\n\nfunction main() {\n const str = readStr();\n const result = solve(str);\n console.log(result);\n}\n\nfunction solve(str){\n const strArr = str.toString().split('')\n let number = Number.parseInt(str);\n let counter = 0;\n while (number > 0){\n number = number - Math.max(...number.toString().split(''))\n counter ++;\n }\n return counter;\n}\n\nmodule.exports.solve = solve;\n", "lang_cluster": "Javascript", "tags": ["dp"], "code_uid": "dad97ab53457f3fe5f9b8096c3650f8a", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "(()=>{\"use strict\";var e={312:(e,t)=>{Object.defineProperty(t,\"__esModule\",{value:!0});let n=\"\",r=[],s=0;function o(){return r[s++]}t.default={runMain:e=>{process.stdin.resume(),process.stdin.setEncoding(\"utf-8\"),process.stdin.on(\"data\",(e=>{n+=e})),process.stdin.on(\"end\",(t=>{r=n.trim().split(\"\\n\").map((e=>e.trim())),e()}))},readline:o,nextNumbers:function(){return o().split(\" \").map((e=>parseFloat(e)))}}},965:function(e,t,n){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const s=r(n(312));s.default.runMain((function(){const e=s.default.nextNumbers();console.log(Math.ceil(e[0]/e[2])*Math.ceil(e[1]/e[2]))}))}},t={};!function n(r){if(t[r])return t[r].exports;var s=t[r]={exports:{}};return e[r].call(s.exports,s,s.exports,n),s.exports}(965)})();", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "939b5547b5a82f680d2a651b85baaba6", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n const arr = d.split(' ').map(Number);\n const sum = arr.reduce((a, b) => a + b, 0);\n const obj = {0: 0};\n let best = sum;\n\n for (let i = 0; i < arr.length; i++) {\n if (obj[arr[i]]) {\n obj[arr[i]] = Math.min(3, obj[arr[i]] + 1);\n }\n else {\n obj[arr[i]] = 1;\n }\n }\n\n for (let key in obj) {\n if (obj[key] > 1) {\n const val = key * obj[key];\n best = Math.min(best, sum - val);\n }\n }\n\n console.log(best);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation"], "code_uid": "5fd55afaf561753516687fdbf41a85d1", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = '';\nprocess.stdin.on('data', (c) => {\n i += c;\n});\nprocess.stdin.on('end', () => {\n const { EOL } = require('os');\n const lines = i.split(EOL);\n const tuple = enhance(parseInt(lines[0], 10));\n console.log(`${tuple[1]} ${tuple[0]}`);\n});\n\nfunction enhance(hp) {\n const tuple = ['D', 0];\n for (let i = 0; i <= 2; i++) {\n const remainder = (hp + i) % 4;\n if (remainder === 1) {\n if ('A' < tuple[0]) {\n tuple[0] = 'A';\n tuple[1] = i;\n }\n }\n if (remainder === 3) {\n if ('B' < tuple[0]) {\n tuple[0] = 'B';\n tuple[1] = i;\n }\n }\n if (remainder === 2) {\n if ('C' < tuple[0]) {\n tuple[0] = 'C';\n tuple[1] = i;\n }\n }\n }\n return tuple;\n}\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "b0bf41e9c0e4da7ae60a6f94f72a2d65", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function findGreeting( input ) {\n const greeting = 'hello';\n\n if ( input.length < greeting.length ) {\n return 'NO';\n }\n\n const inputArr = Array.from( input );\n let index = 0;\n\n for ( let i = 0; i < inputArr.length; i++ ) {\n const char = inputArr[ i ];\n\n if ( char === greeting[ index ] ) {\n index++;\n }\n }\n\n if ( greeting.length <= index ) {\n return 'YES';\n }\n\n return 'NO';\n}\n\n\n\nconst { EOL } = require('os');\n\nlet i = '';\n\nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n const lines = i.split(EOL)\n const res = findGreeting(lines[0])\n console.log(res);\n})", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "f00a87b9e1a200df3be8aebfa6e1bc87", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// http://codeforces.com/problemset/problem/977/A\nmodule.exports = solve;\nfunction solve(line) {\n let [a, b] = line.split(' ').map(n => Number.parseInt(n, 10));\n let i = 0;\n while(a <= b) {\n a *= 3;\n b *= 2;\n i++;\n }\n return i;\n // console.log(line, a, b);\n // return Math.ceil(Math.log2(b / a) / Math.log2(3 / 2));\n}\n\n\nconst rl = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nlet i = 1;\nrl.on('line', (line) => {\n if (i++) {\n console.log(solve(line))\n rl.close();\n }\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "ac9b4024c6c3ed28eaea5cdb5f6ad9d5", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\n// Create readline Interface\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet grid = [];\n// Read Inputs\n\nrl.on('line', lineInput => {\n grid.push(lineInput);\n})\nrl.on('close', () => { \n let r = grid[0].split(\" \")[0];\n let c = grid[0].split(\" \")[1];\n\n \n // rows\n let clearRows = 0, rows = [];\n for (let i = 1; i <= r; i++) {\n const row = grid[i];\n rows.push(row)\n if (!row.split('').includes('S'))\n clearRows++;\n }\n\n // cols\n let clearCols = 0;\n for (let i = 0; i < c; i++) {\n let f = 0;\n for (let j = 0; j < r; j++) {\n const box = rows[j].split('')[i];\n if (box === 'S') { f = 1; break; }\n }\n if (!f)\n clearCols++;\n }\n let overlaps = clearCols * clearRows;\n let ans = ((clearCols * r) + (clearRows * c)) - overlaps\n\n console.log(ans)\n\n});", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "7734844fa8e0baa0a384ed95d06482c3", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n\nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n \nRL.on('line', line => input.push(line));\n\nRL.on('close', () => {\n let [n, k] = input[0].split(' ').map(x => parseInt(x));\n\n for (let i = 0; i < k; i += 1) {\n if (n % 10 === 0) n /= 10;\n else n -= 1;\n }\n\n console.log(n);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "4eac642b26669b1d29c7d076aec4097d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict'; /*jslint node:true, browser:true, es6:true*/\nconst rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })\nconst print = console.log\nconst lines = []\nrl.on('line', line => {\n lines.push(line);\n});\nrl.on('close', main)\nlet rli = 0;\nfunction readline() {\n return lines[rli++];\n}\n\nlet mem = new Map();\nfunction query(n){\n let RES = 0;\n for (let i=1; i<=9; i++)\n {\n let k = i;\n let res = 0;\n while (k<10000)\n {\n res++;\n RES += res;\n if (k==n)\n return RES;\n k = (k*10)+i;\n }\n }\n return RES\n}\n\nfunction main() {\n var q = +readline();\n while (q--)\n {\n var n = +readline();\n print(query(n));\n }\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "7e480033fc079796d045b9f42234d214", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict'\n\nconst {EOL} = require('os')\n\nlet ipt = ''\nprocess.stdin.on('data', s => ipt += s)\nprocess.stdin.on('end', () => {\n const N = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'B', 'H']\n let [a, b, c] = ipt.split(EOL)[0].split(' ').map(n => N.indexOf(n)).sort((a, b) => a - b)\n if (\n 12 - c + a == 3 && b - a == 4\n || b - a == 3 && c - b == 4\n || c - b == 3 && 12 - c + a == 4\n ) console.log('minor')\n else if (\n 12 - c + a == 4 && b - a == 3\n || b - a == 4 && c - b == 3\n || c - b == 4 && 12 - c + a == 3\n ) console.log('major')\n else console.log('strange')\n})", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "31a54d656d1be6e09d3b4b7aed86418b", "src_uid": "6aa83c2f6e095848bc63aba7d013aa58", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume()\nprocess.stdin.setEncoding('utf8')\n\nlet currentLine = 0\nlet inputString = ''\n\nprocess.stdin.on('data', chunk => {\n inputString += chunk\n})\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(line => {\n return line.trim()\n })\n main()\n})\n\nfunction readLine() {\n return inputString[currentLine++]\n}\n\nfunction main() {\n const [n, m] = readLine().trim().split(' ').map(Number)\n let middle = 0\n // even\n if(n % 2 === 0) {\n middle = parseInt(n/2);\n if(m <=middle) {\n console.log(m + (m-1))\n } else {\n console.log((m-middle) * 2)\n }\n \n } else if(n % 2 !== 0) {\n middle = parseInt((n/2) + 1);\n if(m <= middle) {\n console.log(m + (m-1))\n } else {\n console.log((m-middle) * 2)\n }\n }\n\n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "58cb60d84670095fb53fee1f0c04b4e8", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nlet inputs = [];\n\n// Create readline Interface\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\n\n// Read Inputs\nrl.on('line', lineInput => {\n inputs.push(lineInput)\n})\n\nrl.on('close', () => {\n\n const nums = inputs.map(num => parseInt(num));\n\n let maxValue = nums[0] * (nums[1] + nums[2]);\n\n maxValue = Math.max(maxValue, (nums[0] * nums[1]) * nums[2])\n maxValue = Math.max(maxValue, (nums[0] + nums[1]) + nums[2])\n maxValue = Math.max(maxValue, (nums[0] + nums[1]) * nums[2])\n \n console.log(maxValue)\n})", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "5c5f5f6a6376c0875a273c9eb80651a6", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\r\n\r\nvar readline = require('readline');\r\n\r\nfunction _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }\r\n\r\nvar readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);\r\n\r\nasync function solve(read) {\r\n const rn = async () => Number(await read());\r\n const n = await rn();\r\n const check = m => {\r\n let ans = Math.floor((m - 1) / 2);\r\n if (m > 4) ans += Math.floor(m / 4) - 1;\r\n return ans >= n;\r\n };\r\n let l = 3,\r\n r = 10 ** 12;\r\n while (l < r) {\r\n const m = Math.floor((l + r) / 2);\r\n if (check(m)) {\r\n r = m;\r\n } else {\r\n l = m + 1;\r\n }\r\n }\r\n return l;\r\n}\r\n\r\nasync function main(r) {\r\n try {\r\n let t = 1;\r\n let res = new Array(t);\r\n for (let i = 0; i < t; i++) {\r\n res[i] = await solve(r);\r\n }\r\n return res.join('\\n');\r\n } catch (error) {\r\n console.log('zdebug' + error);\r\n }\r\n}\r\n\r\nconst rl = readline__default[\"default\"].createInterface({\r\n input: process.stdin,\r\n output: process.stdout\r\n});\r\nconst it = rl[Symbol.asyncIterator]();\r\nasync function read() {\r\n return (await it.next()).value;\r\n}\r\nvoid async function () {\r\n const output = await main(read);\r\n process.stdout.write(output);\r\n}();\r\n", "lang_cluster": "Javascript", "tags": ["math", "geometry", "binary search"], "code_uid": "5b84d6a8a1b5442ddd7280ec225fcce4", "src_uid": "d0a8604b78ba19ab769fd1ec90a72e4e", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(str) {\n let input = str.trim().split('\\n');\n let numeric = input[0].split(' ');\n let seconds = +numeric[1];\n let bg = input[1].split('');\n let newbg = [...bg];\n for (let i = 0; i < seconds; i++) {\n\n for (let i = 1; i < bg.length; i++) {\n if (bg[i - 1] < bg[i]) {\n let temp = bg[i - 1];\n newbg[i - 1] = bg[i];\n newbg[i] = temp;\n }\n }\n bg = newbg;\n newbg = [...bg];\n }\n return bg.join('').toString();\n}\n", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "131be3ee9855a769365e9e37c433ed5a", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data', input => {\n const tests = input.toString().split('\\n');\n console.log(check(tests));\n});\n\nfunction check(tests) {\n const str1 = tests[0].trim();\n const str2 = tests[1].trim();\n\n // Both strings length are same.\n let flag = 0;\n for (let index = 0; index < str1.length; index++) {\n const s1 = str1[index].toLowerCase();\n const s2 = str2[index].toLowerCase();\n if (s1 === s2) {\n flag = 0;\n } else if (s1 > s2) {\n flag = 1;\n break;\n } else {\n flag = -1;\n break;\n }\n }\n\n return flag;\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "5ebf7cb7632e501ce1fc60e94fe5d9cc", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n});\nrl.question(\"\", (N) => {\n N = parseInt(N);\n if (N % 2 == 0 && N >= 4) {\n console.log(\"YES\");\n } else {\n console.log(\"NO\");\n }\n rl.close();\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "ee0ab0b406d1b2d20b6c364d9804781f", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet n, k;\n\nrl.on('line', (d) => {\n if (c === 0) {\n [n, k] = d.split(' ').map(Number);\n c++;\n return;\n }\n\n const arr = d.split(' ').map(Number);\n arr.sort((a, b) => a - b);\n\n let ans = 0;\n\n for (let i = 0; i < arr.length; i++) {\n if (k % arr[i] === 0) {\n ans = k / arr[i];\n }\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "8043f3c040799820b44490c33d4e9796", "src_uid": "80520be9916045aca3a7de7bc925af1f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nlet input = [];\nrl.on('line', (inputString) => {\n let [x, y] = inputString.split(' ').map(v => parseInt(v));\n input = input.concat([x, y]);\n if (input.length == 6) {\n let [w, h, u1, d1, u2, d2] = input;\n for (; h >= 0; h--) {\n w += h;\n if (h == d1) w -= u1;\n if (h == d2) w -= u2;\n if (w < 0) w = 0;\n }\n console.log(w);\n process.exit();\n }\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "51fbc984acff984bbc5431fafb5967b8", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const funkyNumbers = n => {\n let funkyNumber = 'NO';\n\n const maxTriangle = maxTrianglePossible(n);\n\n for(let i = maxTriangle; i > 0; i--) {\n const firstTriangle = triangleNumbers(i);\n const rem = n - firstTriangle;\n\n if(rem === 0) continue;\n\n const secFactor = maxTrianglePossible(rem);\n const secTriangle = triangleNumbers(secFactor);\n\n const triangles = firstTriangle + secTriangle;\n\n if(triangles == n) {\n funkyNumber = 'YES';\n break;\n } \n }\n \n return funkyNumber; \n};\n\n//k(k+1) / 2 = n where n is an integer\n//k(k+1) = n*2\n//k^2 + k - n*2 = 0 -> factors\nconst maxTrianglePossible = n => Math.floor( Math.sqrt(n*2) );\n\nconst triangleNumbers = x => ( x * (x + 1) ) / 2;\n\n//stdin → stdout\nconst readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n \nreadline.on('line', n => {\n readline.close();\n \n const res = funkyNumbers(n);\n console.log(res);\n});", "lang_cluster": "Javascript", "tags": ["brute force", "implementation", "binary search"], "code_uid": "2cdb11124cc62ba0607d65bd8cae1af0", "src_uid": "245ec0831cd817714a4e5c531bffd099", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on(\"line\", (line) => {\n let n = \"\";\n let m = \"\";\n [n, m] = line.split(\" \");\n for (let index = 1; index <= n; index++) if (index % m === 0) n++;\n console.log(n);\n});\n\nrl.on(\"close\", () => {});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "f3e05a6326ddaf58e6dbd455cbb60535", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\n\nconst rl = readline.createInterface(process.stdin);\n\nrl.on(\"line\", line => {\n const letters = new Set(line.split(\"\"));\n\n if (letters.size % 2) {\n console.log(\"IGNORE HIM!\");\n } else {\n console.log(\"CHAT WITH HER!\");\n }\n\n process.exit(0);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "d32217f83bafcd3cf40a6b76aa141c23", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n');\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr('time : ' + end + 'ms');\n myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var N = nextInt();\n var list = nextIntArray();\n var map = {0:[list[0]]};\n for(var i = 1; i < N; i++){\n \tvar key = Object.keys(map);\n \tvar isOK = false;\n \tfor(var j = 0; j < key.length; j++){\n \t\tif(map[key[j]].indexOf(list[i]) == -1){\n \t\t\tisOK = true;\n \t\t\tmap[key[j]].push(list[i]);\n \t\t\tbreak;\n \t\t}\n \t}\n \tif(!isOK){\n \t\tmap[key.length] = [list[i]];\n \t}\n }\n myerr(map);\n myout(Object.keys(map).length);\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0b4852214979f5c2e843dcfec4669652", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (str) => {\n let a = 0;\n let x = 0;\n\n for (let i = 0; i < str.length; i++) {\n if (str[i] === 'a') {\n a++;\n }\n else {\n x++;\n }\n }\n\n if (a <= x) {\n console.log(str.length - (x - a + 1));\n }\n else {\n console.log(str.length);\n }\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "297a042a7228f3fff42580433ff9afad", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let num = readLine()\n .split('')\n .map(value => parseInt(value));\n let only7and4 = num.filter((value) => {\n return value == 7 || value == 4;\n })\n if (only7and4.length == 4 || only7and4.length == 7) {\n console.log('YES');\n } else console.log('NO');\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3eda5e2c28b55d8cefa31f7dcafb5e5d", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet l = 0;\nrl.on('line', (input) => {\n rl.close();\n let inp = input.split(\" \").map(x => parseInt(x))\n let res = Math.ceil((inp[0]*8)/inp[1]) + Math.ceil((inp[0]*5)/inp[1]) + Math.ceil((inp[0]*2)/inp[1])\n console.log(res)\n return 0;\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "c27b657eaf46c18a832a28f5c1c4141e", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nvar STATE = 1;\nvar a, b, c;\nrl.on('line', function (input) {\n var params = input.split(' ');\n a = parseInt(params[0], 10);\n b = parseInt(params[1], 10);\n c = parseInt(params[2], 10);\n // console.log(STATE + ':', a,b,c);\n \n if (b !== a) {\n console.log(Math.min(a,b) * 2 + 2 * c + 1);\n } else {\n console.log(Math.min(a,b) * 2 + 2 * c);\n }\n}).on('close', function() {\n process.exit(0);\n});", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "7ae05e8d97d35ecc2e9ca99b2a2d0ff9", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "/**\n * ilya and bank account\n */\nfunction ilyaAndBankAccount(line) {\n if (line > 0) console.log(parseInt(line) + \"\");\n else {\n line = line.split(\"\");\n if (line.length == 2) console.log(0);\n else {\n if (line[line.length - 1] > line[line.length - 2]) {\n line.pop();\n line = line.join(\"\");\n console.log(parseInt(line) + \"\");\n } else {\n let save = line.pop();\n line.pop();\n line.push(save);\n line = line.join(\"\");\n console.log(parseInt(line) + \"\");\n }\n }\n }\n}\n\n// ------------------------------------------------------------------------------------------\nconst readline = require(\"readline\");\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on(\"line\", (line) => {\n ilyaAndBankAccount(line);\n});\nrl.on(\"close\", () => {});\n", "lang_cluster": "Javascript", "tags": ["implementation", "number theory"], "code_uid": "7d490e3f8e188df1e77a96e520905272", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(str) {\n\n let inputs = str.trim().split('\\n');\n let alphabets = inputs[1];\n let alphabetFound = [];\n for (let i = 65; i <= 90; i++) {\n let caps = String.fromCharCode(i);\n let small = caps.toLowerCase();\n let capIndex = alphabets.indexOf(caps);\n let smallIndex = alphabets.indexOf(small);\n if (capIndex !== -1 || smallIndex !== -1) {\n let index = capIndex !== -1 ? capIndex : smallIndex;\n alphabetFound.push(alphabets[index]);\n }\n }\n\n let msg = alphabetFound.length === 26 ? 'YES' : 'NO';\n\n return msg.toString();\n}\n\n\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "44fb7462c4fd3cabf4eae9037a4aec9f", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "(()=>{\"use strict\";var t={965:(t,s)=>{process.stdin.resume(),process.stdin.setEncoding(\"utf-8\");let e=\"\",n=[],r=0;process.stdin.on(\"data\",(t=>{e+=t})),process.stdin.on(\"end\",(t=>{n=e.trim().split(\"\\n\").map((t=>t.trim())),function(){const t=n[r++].split(\" \").map((t=>parseInt(t)));console.log(Math.ceil(t[0]/t[2])*Math.ceil(t[1]/t[2]))}()}))}},s={};!function e(n){if(s[n])return s[n].exports;var r=s[n]={exports:{}};return t[n](r,r.exports,e),r.exports}(965)})();", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "b51dbbc617b485f00a98d5885a817979", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var dataitr;\r\nvar stdin_input = \"\";\r\nprocess.stdin.resume();\r\nprocess.stdin.setEncoding(\"ascii\");\r\nprocess.stdin.on(\"data\", function (input) { stdin_input += input; });\r\nprocess.stdin.on(\"end\", function () { dataitr = stdin_input.split('\\n').values(); main(); });\r\n\r\nconst rl = () => dataitr.next().value.trim();\r\nconst rn = () => Number(rl());\r\nconst ra = () => rl().split(' ');\r\nconst rna = () => ra().map(x => Number(x));\r\n\r\nconst MOD = 1000000007n;\r\n\r\nfunction fast_pow(a, p)\r\n{\r\n\tlet res = 1n;\r\n\twhile (p) {\r\n\t\tif (p % 2n == 0) {\r\n\t\t\ta = a * a % MOD;\r\n\t\t\tp /= 2n;\r\n\t\t} else {\r\n\t\t\tres = res * a % MOD;\r\n\t\t\tp--;\r\n\t\t}\r\n\t}\r\n\treturn res;\r\n}\r\n\r\nfunction main () {\r\n\tconst k = rn();\r\n\r\n\tconst ans = fast_pow(4n, 2n**BigInt(k)-2n) * 6n % MOD;\r\n\r\n\tconsole.log(ans.toString());\r\n}\r\n\r\n", "lang_cluster": "Javascript", "tags": ["math", "combinatorics"], "code_uid": "d0512f156af6d546c7f54d3004ddbb9c", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nlet stdin = [];\nrl.on('line', function (line) {stdin.push(line);});\nrl.on('close', solution);\n\n\nfunction solution() {\n let line = stdin[0].split(' ');\n var n = parseInt(line[0]);\n var k = parseInt(line[1]);\n\n var main = function(n, k){\n res = n;\n var getLastDigit = function(d){\n last = d%10;\n return +last;\n };\n\n for (i = 0; i < k; i++){\n var lastDigit = getLastDigit(res);\n //if the last digit of the number is non-zero, she decreases the number by one;\n // the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit).\n if (lastDigit !== 0) {\n res--;\n } else {\n res = res/10;\n }\n }\n return res;\n }\n\n var result = main(n, k);\n console.log(result);\n return result;\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "cf8dedcc17684bfdcb608a692ade039a", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const rl = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet firstLine = true;\nlet winIndex;\n\nrl.on('line', (line) => {\n if (firstLine) {\n winIndex = parseInt(line.split(' ')[1]) - 1; // to zero-based :)\n firstLine = false;\n } else {\n const points = line.split(' ').map(i => parseInt(i));\n\n while(points[winIndex] === 0 && winIndex > 0) {\n winIndex--;\n }\n if (points[winIndex] === 0) {\n console.log(0);\n return;\n }\n\n let i = winIndex + 1;\n while (points[i] && points[i] === points[winIndex]) {\n i++;\n }\n\n console.log(i);\n }\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "23bd9606c67bbc5f519ccb3a9c362e6c", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// NYAN NYAN\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n// ░░░░░░░░░░▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄░░░░░░░░░\n// ░░░░░░░░▄▀░░░░░░░░░░░░▄░░░░░░░▀▄░░░░░░░\n// ░░░░░░░░█░░▄░░░░▄░░░░░░░░░░░░░░█░░░░░░░\n// ░░░░░░░░█░░░░░░░░░░░░▄█▄▄░░▄░░░█░▄▄▄░░░\n// ░▄▄▄▄▄░░█░░░░░░▀░░░░▀█░░▀▄░░░░░█▀▀░██░░\n// ░██▄▀██▄█░░░▄░░░░░░░██░░░░▀▀▀▀▀░░░░██░░\n// ░░▀██▄▀██░░░░░░░░▀░██▀░░░░░░░░░░░░░▀██░\n// ░░░░▀████░▀░░░░▄░░░██░░░▄█░░░░▄░▄█░░██░\n// ░░░░░░░▀█░░░░▄░░░░░██░░░░▄░░░▄░░▄░░░██░\n// ░░░░░░░▄█▄░░░░░░░░░░░▀▄░░▀▀▀▀▀▀▀▀░░▄▀░░\n// ░░░░░░█▀▀█████████▀▀▀▀████████████▀░░░░\n// ░░░░░░████▀░░███▀░░░░░░▀███░░▀██▀░░░░░░\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n\n// 백준의 노드 버전이 너무 낮아 babel 사용. \n// 풀이는 solve() 함수에 있음.\n\nconst CODEFORCES_NODE = \"cf\";\nconst CODEFORCES_V8 = \"cf-v8\";\nconst BEAKJOON = \"bj\";\nconst TEST = \"test\";\n// var SITE = BEAKJOON;\nvar SITE = CODEFORCES_NODE;\nvar DEBUG = false; \n\nif(SITE == BEAKJOON){\n if (!String.prototype.startsWith) {\n String.prototype.startsWith = function(search, pos) {\n return this.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;\n };\n }\n if (!String.prototype.endsWith) {\n String.prototype.endsWith = function(search, this_len) {\n if (this_len === undefined || this_len > this.length) {\n this_len = this.length;\n }\n return this.substring(this_len - search.length, this_len) === search;\n };\n }\n if (!String.prototype.repeat) {\n String.prototype.repeat = function(count) {\n 'use strict';\n if (this == null) {\n throw new TypeError('can\\'t convert ' + this + ' to object');\n }\n var str = '' + this;\n count = +count;\n if (count != count) {\n count = 0;\n }\n if (count < 0) {\n throw new RangeError('repeat count must be non-negative');\n }\n if (count == Infinity) {\n throw new RangeError('repeat count must be less than infinity');\n }\n count = Math.floor(count);\n if (str.length == 0 || count == 0) {\n return '';\n }\n // Ensuring count is a 31-bit integer allows us to heavily optimize the\n // main part. But anyway, most current (August 2014) browsers can't handle\n // strings 1 << 28 chars or longer, so:\n if (str.length * count >= 1 << 28) {\n throw new RangeError('repeat count must not overflow maximum string size');\n }\n var maxCount = str.length * count;\n count = Math.floor(Math.log(count) / Math.log(2));\n while (count) {\n str += str;\n count--;\n }\n str += str.substring(0, maxCount - str.length);\n return str;\n }\n }\n}\n\nString.prototype.replaceAt=function(index, replacement) {\n return this.substr(0, index) + replacement+ this.substr(index + replacement.length);\n}\n\nFunction.prototype.repeat = function(times){\n for(let i = 0; i < times; i++){\n this();\n }\n}\n\nArray.prototype.getMaxConsecutiveSum = function(defaultValue = -Infinity){\n const N = this.length;\n let maxsum = defaultValue;\n let cursum = defaultValue;\n let cur;\n for(var ii = 0; ii < N; ii++){\n cur = this[ii];\n if(cursum + cur > 0){\n if(cur > cursum + cur){\n cursum = cur;\n } else cursum += cur;\n } else {\n cursum = cur;\n if(maxsum < cursum){\n maxsum = cursum;\n }\n }\n if(maxsum < cursum){\n maxsum = cursum;\n }\n }\n this.maxConsecutiveSum = maxsum;\n return maxsum;\n}\n\ntry {\n require('manakin').global;\n // require (\"babel-polyfill\");\n} catch (error) {\n\n}\ntry {\n process.argv.forEach(function (val, index, array) {\n if (val.startsWith(\"site\")) {\n switch (val.split(\"=\")[1]) {\n case \"test\":\n // console.log('change site to test')\n SITE = TEST;\n break;\n case \"cf-node\":\n // console.log('change site to cf')\n SITE = CODEFORCES_NODE;\n break;\n case \"cf\":\n // console.log('change site to cf')\n SITE = CODEFORCES_NODE;\n break;\n case \"cf-v8\":\n // console.log('change site to cf')\n SITE = CODEFORCES_V8;\n break;\n case \"bj\":\n // console.log('change site to bj')\n SITE = BEAKJOON;\n break;\n }\n }\n if (val.startsWith(\"debug\")) {\n switch (val.split(\"=\")[1]) {\n case \"true\":\n DEBUG = true;\n break;\n case \"false\":\n DEBUG = false;\n break;\n }\n }\n });\n} catch (error) {\n}\n\nlet inputFilePath = '';\nswitch(SITE){\n case TEST:\n const config = require('config');\n var fs = require(\"fs\");\n var path = require('path');\n inputFilePath = config.get('INPUTFILEPATH') || path.resolve(__dirname, \"input.txt\");\n break;\n default:\n inputFilePath = './input.txt';\n break;\n}\nconst INPUTFILEPATH = inputFilePath;\n\n// if (!String.prototype.endsWith) {\n// \tString.prototype.endsWith = function(search, this_len) {\n// \t\tif (this_len === undefined || this_len > this.length) {\n// \t\t\tthis_len = this.length;\n// \t\t}\n// \t\treturn this.substring(this_len - search.length, this_len) === search;\n// \t};\n// }\n// if (!Array.prototype.includes) {\n// Array.prototype.includes = function (target) {\n// return this.indexOf(target) !== -1\n// }\n// }\n\nconst newLine = '\\n';\nvar ans;\nvar inputText = \"\";\nvar lineCount = 0;\nvar lines;\nvar input;\nvar readline;\nvar getlines;\nvar lineOpen = false;\nvar readingLine = '';\n\nvar clockStart;\nvar clock;\n\nvar print;\nprint = console.log;\nvar it;\nvar step;\nfunction EnableLogging(){\n it = console.info;\n step = console.success;\n}\nfunction DisableLogging(){\n it = function it(params) {\n return 0;\n }\n step = it;\n}\nif (DEBUG) {\n EnableLogging();\n clock = function(start) {\n if ( !start ) return process.hrtime();\n var end = process.hrtime(start);\n return Math.round((end[0]*1000) + (end[1]/1000000));\n }\n} else {\n DisableLogging();\n}\n\n// prepares test data. to replace line input, assign arrays to lines variable.\nfunction prepareTestData() {\n // it(lines);\n\n // lines = ['custom line 1', 'custom line 2'];\n}\n\n// executes exactly once for both test and run. execution time will be included to elapsed time. \nconst prepareSolve = () => {\n \n}\n\nfunction power(x, y) { //분할 정복을 이용하여 x^y 구하기\n let ret = 1;\n while (y > 0) {\n if (y % 2) {\n ret *= x;\n ret %= P;\n }\n x *= x;\n x %= P;\n y /= 2;\n }\n return ret;\n}\n\nfunction createArray(lengths) {\n var arr = new Array(lengths || 0),\n i = lengths;\n if (arguments.length > 1) {\n var args = Array.prototype.slice.call(arguments, 1);\n while (i--) arr[lengths - 1 - i] = createArray.apply(this, args);\n }\n return arr;\n}\n\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ MAIN SOLVE FUNCTION ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n\nfunction solve(){\n let [n, s] = readInts();\n\n var asdasd = 0;\n\n while(s > 0){\n // it(s, n, s%n, Math.floor(s/n), asdasd);\n asdasd = asdasd + Math.floor(s/n);\n s = s%n;\n n = n-1;\n }\n print(asdasd);\n}\n\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n\nfunction resetRead(){\n lineCount = 0;\n}\n\nfunction checkMemoryUsage() {\n it(process.memoryUsage());\n}\n\nfunction readOne(separator=' ') {\n if(lineOpen && readingLine != null){\n // if(lineOpen){\n // it(readingLine);\n let splitPos = readingLine.search(separator)\n \n let ret = readingLine.slice(0, splitPos);\n if(splitPos == -1){\n // it('close');\n ret = readingLine;\n readingLine = '';\n lineOpen = false;\n }\n readingLine = readingLine.substr(splitPos + 1)\n // it(ret, readingLine, splitPos);\n return ret;\n } else {\n readingLine = readline();\n lineOpen = true;\n if(readingLine == null) return '';\n return readOne(separator);\n }\n}\n\nfunction readInts() {\n try {\n lineOpen = false;\n return readline()\n .split(\" \")\n .map(x => parseInt(x));\n } catch (error) {\n console.error(error);\n return null;\n }\n}\n\nswitch (SITE) {\n case TEST:\n var fs = require(\"fs\");\n var path = require('path');\n // input = fs.createReadStream(path.resolve(__dirname, \"input.txt\"), {\n // encoding: \"utf8\"\n // });\n input = fs.createReadStream(INPUTFILEPATH, {\n encoding: \"utf8\"\n });\n\n function inputListener(line) {\n console.log(line);\n if(line.startsWith('end')){\n console.log('end');\n closing();\n }\n if (!line) {\n closing();\n }\n lineCount++;\n inputText += line + \"\\r\\n\";\n }\n\n\n function readlines() {\n const readline = require(\"readline\");\n const rl = readline.createInterface({\n input,\n output: process.stdout,\n terminal: false\n });\n rl.on(\"line\", inputListener);\n rl.on('close', closing);\n }\n\n getlines = function* (inputText) {\n var lines = inputText.split(/\\r?\\n/);\n for (let line of lines) {\n yield line + newLine;\n }\n }\n\n readline = function () {\n return lines.next().value.trim();\n }\n\n readlines();\n\n break;\n\n case CODEFORCES_NODE:\n input = process.stdin;\n\n function inputListener(line) {\n if (!line) {\n closing();\n }\n lineCount++;\n inputText += line + \"\\r\\n\";\n }\n\n function readlines() {\n const readline = require(\"readline\");\n const rl = readline.createInterface({\n input,\n output: process.stdout,\n terminal: false\n });\n rl.on(\"line\", inputListener);\n rl.on('close', closing);\n }\n\n getlines = function* (inputText) {\n var lines = inputText.split(/\\r?\\n/);\n for (let line of lines) {\n yield line + newLine;\n }\n }\n\n readline = function () {\n return lines.next().value.trim();\n }\n\n readlines();\n\n break;\n case BEAKJOON:\n var fs = require('fs');\n if (DEBUG) {\n // input = fs.readFileSync('./input.txt').toString();\n inputText = fs.readFileSync(INPUTFILEPATH).toString();\n \n } else {\n inputText = fs.readFileSync('/dev/stdin').toString();\n }\n\n readline = function () {\n lineCount++;\n let line = lines[lineCount - 1];\n if (line)\n return lines[lineCount - 1].trim();\n else return null;\n }\n\n getlines = function (inputText) {\n lineCount = 0;\n return inputText.split(/\\r?\\n/);\n }\n\n // lines = getlines(input);\n closing();\n break;\n default:\n break;\n}\n\nfunction closing() {\n if(DEBUG){\n DisableLogging();\n const prepareClock = clock();\n lines = getlines(inputText);\n prepareSolve();\n const prepareClockElapsedTime = clock(prepareClock);\n EnableLogging();\n prepareTestData();\n solve();\n resetRead();\n console.warn('performance check');\n DisableLogging();\n clockStart = clock();\n // lines = getlines(inputText);\n solve();\n console.warn(`${clock(clockStart) + prepareClockElapsedTime} ms`);\n EnableLogging();\n process.exit();\n } else {\n lines = getlines(inputText);\n prepareSolve();\n solve();\n process.exit();\n }\n}", "lang_cluster": "Javascript", "tags": ["math", "greedy", "implementation"], "code_uid": "d3c0e46a75891d4347a0ce726ca51de1", "src_uid": "04c067326ec897091c3dbcf4d134df96", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline'),\n rl = readline.createInterface(process.stdin, process.stdout);\n\n \nrl.on('line', function (line) {\n \n var n=line.split(' ')\n n%2==0 && n!=2 ? console.log(\"YES\") : console.log(\"NO\");\n rl.close();\n\n}).on('close', function () {\n\n process.exit(0);\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "85d3c147b4a7acf05b857c68c43d3a56", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n// single line input\n// readline.on('line', line => {\n// readline.close(), console.log(line)}\n// });\n\n// multi line input\nreadline.on('line', line => {\n let val = parseFloat(line);\n console.log( val%2 ==0 && val >2? 'YES': 'NO');;\n readline.close();\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "a0f9fde7ba09b8298574003fdd94ffa9", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet l = 0;\nlet cups = []\nlet medals = []\n\nrl.on('line', (input) => {\n if (l === 0) {\n cups = input.split(' ').map(function (item) {\n return parseInt(item, 10);\n });\n } else if (l === 1) {\n medals = input.split(' ').map(function (item) {\n return parseInt(item, 10);\n });\n } else {\n function add(a, b) {\n return a + b;\n }\n rl.close();\n let shelfs = parseInt(input)\n var cupsSum = cups.reduce(add, 0);\n var medalsSum = medals.reduce(add, 0);\n shelfs-=Math.ceil(cupsSum/5)\n shelfs-=Math.ceil(medalsSum/10)\n if(shelfs>=0){\n console.log(\"YES\")\n return 0\n }\n console.log(\"NO\")\n\n return 0;\n }\n l++\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "06f0200a4e2495da5c1e761ebcd6212e", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n var n=Number(stdin[0]);\n var arr=stdin[1].split('');\n var count=0;\n for(var i=0;i Number(n));\n const cantidadVertical = Math.ceil(largo / baldoza)\n const cantidadHorizontal = Math.ceil(ancho / baldoza)\n\n console.log(cantidadVertical * cantidadHorizontal);\n})\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "67cfb68fce85a51d06b64fe92698382e", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (str) => {\n if (c === 0) {\n c++;\n return;\n }\n\n let ans = 0;\n const arr = [];\n let inc = 0;\n\n for (let i = 0; i < str.length - 1; i++) {\n if (str[i] === 'B') {\n inc++;\n\n if (str[i + 1] === 'W') {\n ans++;\n arr.push(inc);\n }\n }\n else {\n inc = 0;\n }\n }\n\n if (str[str.length - 1] === 'B') {\n ans++;\n inc++;\n arr.push(inc);\n }\n\n console.log(ans);\n console.log(arr.join(' '));\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "9220c5a4f9fff2c3ba63063eff42525e", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n//const lineReader = require('fs');\n//const scanner = lineReader.createReadStream('main.in');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nconst N = 102;\nlet n, m, lp = 0; \n\nrl.on('line', (input) => {\n if (lp === 0){\n lp = 1;\n let t = input.split(' ').map((x) => { return parseInt(x); });\n n = t[0];\n m = t[1];\n } else if (lp === 1) {\n let a = input.split(' ').map((x) => { return parseInt(x); });\n let fd = new Array(N);\n let an = new Array(N);\n fd.fill(0);\n for (let i = 0; i < m; i++){\n for (let j = a[i]; j <= n; j++){\n if (fd[j] === 0){\n an[j] = a[i]; \n fd[j] = 1;\n }\n }\n }\n for (let i = 1; i <= n; i++)console.log(an[i]);\n rl.close();\n }\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "db71a7b7572e12adf2360cec348b0201", "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n})\nreadline.question('', (x) => {\n a = [];\n a1 = x.split(' ');\n for (var i = 0; i < a1.length; i++) {\n a.push(Number(a1[i]));\n }\n a.sort((a,b) => {\n return a-b;\n });\n\n if ((a[0] + a[3] == a[1] + a[2]) || (a[0] + a[1] + a[2] == a[3])) {\n console.log('YES');\n }\n else \n console.log('NO');\n\n readline.close();\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "5bcac60511a04b7edbec70189163e2a0", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let data = '';\nprocess.stdin.on('data', c => data += c);\n\nconst solution = () => {\n\tlet line = data.split('\\n');\n\tlet n = parseInt(line[0],10);\n\tlet a = line[1].split(' ').map(v => parseInt(v,10));\n\tlet c = 0;\n\twhile(a.length > 0){\n\t\tc++;\n\t\tlet t = [];\n\t\tlet min = Math.min(...a);\n\t\tfor(let i of a){\n\t\t\tif (i%min !== 0){\n\t\t\t\tt.push(i);\n\t\t\t}\n\t\t}\n\t\ta = t;\n\t\t\n\t}\n\tconsole.log(c);\n};\n\nprocess.stdin.on('end',solution);", "lang_cluster": "Javascript", "tags": ["math", "greedy", "implementation"], "code_uid": "128d84b551bf3f7548e20b9a3ecf64f8", "src_uid": "63d9b7416aa96129c57d20ec6145e0cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n let n = parseInt(input[0]);\n let num = []; input[1].split(' ').forEach(i => num.push(parseInt(i)));\n num.sort((a, b) => a-b);\n let answer = 0;\n for(let i = 1; i < n; i+=2){\n answer += num[i]-num[i-1];\n }\n console.log(answer);\n});\n\n", "lang_cluster": "Javascript", "tags": ["sortings"], "code_uid": "a4a5f0f6553f17803c6e27927ddaf124", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Alternative\n// https://www.npmjs.com/package/competitive-programming-js\n\"use strict\"\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', inputStdin => { inputString += inputStdin; });\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n main();\n});\nfunction input() { return inputString[currentLine++]; }\nconst println = (x = \"\") => process.stdout.write(String(x) + \"\\n\");\nconst print = x => { process.stdout.write(String(x)); }\n// >>>>>>>>>>>>> Main starts here <<<<<<<<<<<<<<\n\nfunction main() {\n let n = input();\n if (n[0] === '-') {\n if (n.length >= 3) {\n if (parseInt(n[n.length-1]) > parseInt(n[n.length-2])) {\n n = n.substr(0, n.length-1);\n } else {\n n = n.substr(0, n.length-2) + n[n.length-1];\n }\n } else {\n\n }\n };\n n = parseInt(n);\n println(n);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation", "number theory"], "code_uid": "883361e289090c50e0e413d416d2d07a", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function run(input, count = 0) {\n var i = input.indexOf('xxx');\n if (i == -1) return count;\n else return run(input.substr(i + 1), count + 1)\n}\n \nprocess.stdin.setEncoding('utf8');\n \nprocess.stdin.on('readable', () => {\n let input = process.stdin.read();\n input = input.trim();\n \n if (input !== null && typeof input != 'number') {\n process.stdout.write(run(input) + '\\n');\n }\n \n process.exit(0);\n \n});", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "049e7a9b56bff8954d8d99d8b8dcc451", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n// const fs = require('fs');\n \nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n \nlet inputString = '';\nlet currentLine = 0;\n \nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n \nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n \n main();\n});\n \nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction bCoins(n) {\n var arr = [n];\n var i,k,max = n;\n for (i = n-1; i >= 1; i--){\n if(max % i === 0){\n arr.push(i);\n max = i;\n }\n }\n // arr.push(1)\n console.log(arr.join(' '))\n}\nfunction main() {\n // const ws = fs.createWriteStream(process.env.OUTPUT_PATH);\n \n const n = parseInt(readLine(), 10);\n \n var res = bCoins(n);\n \n // ws.write(res.join(' ') + '\\n');\n \n // ws.end();\n}", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "80164ed43aa4691a2c4ce4fad0dd3732", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString\n .trim()\n .split('\\n')\n .map(string => {\n return string.trim();\n });\n\n process.stdout.write(main(inputString));\n process.exit();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nconst main = ([inputString]) => {\n const int = parseInt(inputString);\n return int % 2 === 0 && int > 2 ? 'YES' : 'NO';\n};\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "f10ce87ca8fc510ced5d02ae303a17ab", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nconst store = {};\n\nfunction main() {\n\tlet n = readLine() >> 0;\n\n\tif (n === 0) {\n\t\tconsole.log(1);\n\t\treturn;\n\t}\n\n\tlet map = { 1: 8, 2: 4, 3: 2, 4: 6 };\n\tn = n % 4;\n\tif (n === 0) n = 4;\n\tconsole.log(map[n]);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation", "number theory"], "code_uid": "748ef1c35b6b088c02cc3e6eee2c0706", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n// var numbers = readline().split(\" \").map(function(x) { return parseInt(x); });\n \nreadline.on('line', line => {\n readline.close();\n\n const number = line.split(\" \")[0];\n \n if (number > 2 && number % 2 === 0) {\n console.log('YES');\n } else {\n console.log('NO');\n }\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "b6966feeee02d3a51926db2c5fb68a16", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "/*\r\n===== READ INPUT DATA START =====\r\n=================================\r\n*/\r\n\r\nprocess.stdin.resume();\r\nprocess.stdin.setEncoding(\"utf-8\");\r\n\r\nlet inputString = '';\r\n\r\nprocess.stdin.on(\"data\", (inputStdin) => {\r\n inputString += inputStdin;\r\n});\r\n\r\nprocess.stdin.on(\"end\", (_) => {\r\n const lines = inputString.trim().split(\"\\n\").map(string => string.trim()).filter(Boolean);\r\n\r\n main(lines);\r\n});\r\n\r\n/*\r\n===== READ INPUT DATA END =====\r\n===============================\r\n*/\r\n\r\nfunction main(lines) {\r\n let index = 0;\r\n let T = Number(lines[index++]);\r\n let N;\r\n \r\n while (T--) {\r\n N = Number(lines[index++]);\r\n solve(N);\r\n }\r\n}\r\n \r\nfunction solve(N) {\r\n const seen = new Set();\r\n let result = 1;\r\n let sqrtN = Math.floor(Math.sqrt(N));\r\n let a, b;\r\n \r\n for (let n = 2; n <= sqrtN; ++n) {\r\n a = n ** 2;\r\n b = n ** 3;\r\n \r\n if (a <= N && !seen.has(a)) {\r\n result++;\r\n seen.add(a);\r\n }\r\n \r\n if (b <= N && !seen.has(b)) {\r\n result++;\r\n seen.add(b);\r\n }\r\n }\r\n \r\n console.log(result);\r\n}", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "16370a5511c4d9594cc3b98453f009fa", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function solution(num){ \n var ret = 0;\n for (var i = 1; i <= num / 2; i++){\n if (num % i == 0) ret++;\n }\n return ret;\n}\nprocess.stdin.addListener(\"data\", (data)=>{\n var num = parseInt(data.toString())\n \n console.log(solution(num))\n})", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "8cc857719b8810b7fb0412b1cdec41f9", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "readline = require('readline')\nlet stdinInput = '';\n\nfunction file1(){\n //file\n var fs = require('fs');\n const inputfile = '_in.txt';\n const outputfile = '_out.txt';\n fs.writeFileSync(outputfile, '');\n var myInterface = readline.createInterface({\n input: fs.createReadStream(inputfile),\n });\n myInterface.on('line', function (line) {\n stdinInput += line+'\\n';\n }).on('close', () => {\n main(); \n process.exit(0);\n })\n}\n\nfunction std1(){\n process.stdin.resume();\n process.stdin.setEncoding('utf-8');\n process.stdin.on('data', (input) => { stdinInput += input; });\n process.stdin.on('end', () => { main(); });\n}\n /*\n * Api Scanner\n */\n class Scanner {\n constructor() {\n this.index = -1;\n this.lines = stdinInput.trim().split('\\n'); // eslint-disable-line\n }\n \n nextLine() {\n if(this.index >= this.lines.length-1)\n return false;\n this.index += 1;\n return this.lines[this.index].trim();\n }\n nextArray(fn) {\n let checkarr = this.nextLine();\n if(checkarr===false)\n return false;\n const array = checkarr.split(' ');\n return fn === String ? array : array.map(fn);\n }\n \n hasNext() {\n return this.index < this.lines.length;\n }\n }\n \n// file1();\nstd1();\n\nlet ntest, s1, s2;\nfunction main() {\n const is = new Scanner();\n \n while(true){\n s1 = is.nextLine();\n if(s1===false)\n return;\n s2 = is.nextLine();\n\n \n for(let i=0; i {\n let s = x + '';\n let n = s.length;\n let rest = 0;\n for (let i = 1; i <= n; i++) {\n rest += i;\n }\n return 10 * (s[0] - 1) + rest;\n};\n\nconst main = () => {\n const readline = require('readline');\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n });\n let input = [];\n rl.on('line', (line) => {\n input.push(line.split(\" \").map(x => Number(x)));\n });\n rl.on('close', () => {\n let t = Number(input[0][0]);\n let i = 1;\n while (t > 0) {\n let data = input.slice(i, i + 1);\n console.log(solve(data[0][0]));\n t--;\n i++;\n }\n });\n};\n\nmain()", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "5f0aadd726d4e8f039bd1ba19bba01d5", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const [n, m] = d.split(' ').map(Number);\n const min = Math.min(n, m);\n\n if (min % 2 === 0) {\n console.log('Malvika');\n }\n else {\n console.log('Akshat');\n }\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "d760868fdd4fc5806460cd665dd7f179", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "/**\n * Created by ishanarora on 25/11/18.\n */\n\nconst stdin = process.openStdin();\nlet content = ``;\nstdin.addListener('data', d => {\n content += d.toString();\n});\n\nstdin.addListener('end', () => {\n content = content.split(\" \");\n console.log(factors(parseInt(content[0]), parseInt(content[1])));\n});\n\n\n\nfunction factors(elem1, elem2) {\n let count = 0;\n for (var i = 1; i <= elem1; i++) {\n if (elem2 % i == 0 && elem2 / i <= elem1) {\n count += 1;\n }\n }\n return count;\n}\n\n", "lang_cluster": "Javascript", "tags": ["implementation", "number theory"], "code_uid": "418b1463d7a54a419765431e24f22bde", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var input='';\n\nprocess.stdin.on('data',givenInput=>{\n input+=givenInput;\n})\n\nprocess.stdin.on('end',()=>{\n main(input);\n})\n\nconst main=(input)=>{\n let num=Number(input.split(' ')[0]);\n const k=Number(input.split(' ')[1]);\n \n for(let i=0;i {\n inputString += inputStd;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const matrix = [];\n let [_r, _c] = [0, 0];\n const target = 2;\n for (let i = 0; i < 5; i++) {\n let row = readLine()\n .split(\" \")\n .map((n) => parseInt(n));\n matrix.push(row);\n }\n for (let row = 0; row < 5; row++) {\n for (let col = 0; col < 5; col++) {\n if (matrix[row][col] === 1) {\n [_r, _c] = [row, col];\n break;\n }\n }\n }\n const dist = Math.abs(target - _r) + Math.abs(target - _c);\n console.log(dist);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "1253ef08554247cdae360507d9695ca4", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false,\n});\n\nlet c = 0;\n\nrl.on(\"line\", (str) => {\n if (str[0] !== \"1\") {\n console.log(\"NO\");\n return;\n }\n\n let ans = \"YES\";\n let prev = str[0];\n\n for (let i = 1; i < str.length - 1; i++) {\n if (prev === \"4\" && str[i] === \"4\" && str[i + 1] === \"4\") {\n ans = \"NO\";\n break;\n } else if (str[i] !== \"4\" && str[i] !== \"1\") {\n ans = \"NO\";\n break;\n } else {\n prev = str[i];\n }\n }\n\n if (str[str.length - 1] !== \"4\" && str[str.length - 1] !== \"1\") {\n ans = \"NO\";\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "greedy"], "code_uid": "d32faefac483f2e96c2dfb853405eeee", "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nreadline.on('line', input => {\n const seq = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard'];\n let segment = 0;\n let segmentFloor = 1;\n let segmentCeiling = 5;\n\n while (!(input >= segmentFloor && input <= segmentCeiling)) {\n segment++;\n segmentFloor = segmentCeiling + 1;\n segmentCeiling = segmentCeiling + Math.pow(2, segment) * 5;\n }\n\n const nthAfterFloor = input - segmentFloor + 1;\n\n const pointer = Math.ceil(nthAfterFloor / Math.pow(2, segment)) - 1;\n\n console.log(seq[pointer]);\n});", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "eb9b722b14bdd90b1b5188fa430b84a0", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const [len, limit] = readLine()\n .split(\" \")\n .map((n) => parseInt(n));\n const arr = readLine()\n .split(\" \")\n .map((n) => parseInt(n));\n let maxIndex = -1;\n let maxMove = -1;\n for (let i = 0; i < len; i++) {\n const candy = arr[i];\n let move = Math.floor(candy / limit);\n if (candy % limit > 0) move++;\n const diff = candy - limit;\n\n if (move >= maxMove) {\n if (diff > 0) {\n maxIndex = i;\n }\n maxMove = move;\n }\n }\n maxIndex = maxIndex === -1 ? len - 1 : maxIndex;\n console.log(maxIndex + 1);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "1063b24ea8667a310fc44579be17deba", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet n, k;\n\nrl.question('', str => {\n [n, k] = str.split(\" \");\n solution(n, k);\n rl.close();\n});\n\nfunction solution(n, k) {\n for(let i = 0; i < k; i++) {\n if (n % 10 === 0) n /= 10;\n else n -= 1;\n }\n console.log(n);\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f68a639f06a63f611059100335bd6d4b", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var N = nextInt();\n var s = next().toUpperCase();\n var set = new Set();\n for(var i = 0; i < N; i++){\n set.add(s[i]);\n }\n myout((set.size == 26) ? \"YES\" : \"NO\");\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "d4d285331c33ab128e1f073245e92bfc", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet l = 0;\nrl.on('line', (input) => {\n if (l == 0) { l++ }\n else {\n rl.close();\n let strArray = input.split(\" \")\n let s = strArray.map(function (item) {\n return parseInt(item, 10);\n });\n s = s.sort(function sortNumber(a, b) {\n return a - b;\n })\n let res = 0;\n for (let i = 0; i < input.length; i += 2) {\n let d = s[i + 1] - s[i]\n if (d > 0) {\n res += d\n }\n }\n console.log(res)\n return 0;\n }\n});\n", "lang_cluster": "Javascript", "tags": ["sortings"], "code_uid": "280b8116935cf616b8f9a5af1adfefaa", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n');\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr('time : ' + end + 'ms');\n myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var alist = nextIntArray();\n var asum = 0;\n var blist = nextIntArray();\n var bsum = 0;\n var N = nextInt();\n for(var i = 0; i < 3; i++){\n \tasum += alist[i];\n \tbsum += blist[i];\n }\n while(asum > 0){\n \tasum -= 5;\n \tN--;\n }\n while(bsum > 0){\n \tbsum -= 10;\n \tN--;\n }\n \n myout((N < 0) ? \"NO\" : \"YES\");\n \n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "7ebdcf8d62bc5fdd7bf6b179b15a68d8", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let n = parseInt(readLine());\n let ans = 0;\n while (n != 0) {\n if (n >= 100) {\n ans += Math.floor(n / 100);\n n -= Math.floor(n / 100) * 100;\n }\n if (n >= 20 && n < 100) {\n ans += Math.floor(n / 20);\n n -= Math.floor(n / 20) * 20;\n }\n if (n >= 10 && n < 20) {\n ans += Math.floor(n / 10);\n n -= Math.floor(n / 10) * 10;\n }\n if (n >= 5 && n < 10) {\n ans += Math.floor(n / 5);\n n -= Math.floor(n / 5) * 5;\n }\n if (n >= 1 && n < 5) {\n ans += Math.floor(n);\n n -= n;\n }\n }\n console.log(ans);\n}", "lang_cluster": "Javascript", "tags": ["greedy", "dp"], "code_uid": "ebfbaad5fddc7bb5e47219cbeb540e3c", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n\tvar one = nextIntArray();\n\tvar x = one[0];\n\tvar y = one[1];\n\tvar z = one[2];\n\tvar t1 = one[3];\n\tvar t2 = one[4];\n\tvar t3 = one[5];\n\tvar work = Math.abs(x - y) * t1;\n\tvar eleve = (Math.abs(x - z) * t2) + (t3 * 3) + (Math.abs(x - y) * t2);\n\tmyerr({work, eleve});\n\tif(eleve <= work){\n\t\tmyout(\"YES\");\n\t}else{\n\t\tmyout(\"NO\");\n\t}\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "d3401543d4e775a18623a4b2b48281a1", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const mainFunction = (lines) => {\n let n, a, b, c, ans = -1;\n [n, a, b, c] = lines[0].split(\" \").map(Number)\n for (let i = 0; i <= 4000; i++) {\n for (let j = 0; j <= 4000; j++) {\n let asd = i * a,\n zxc = j * b,\n z = (n - asd - zxc)\n if (z > 0 && z % c === 0) {\n z /= c\n if (i + j + z > ans)\n ans = i + j + z\n }\n if (asd + zxc === n)\n if (i + j > ans)\n ans = i + j\n }\n }\n console.log(ans)\n}\n\nconst { EOL } = require('os')\nif (__filename.substr(9, 4) != \"azer\") {\n let yourInputData = ''\n process.stdin.on('data', i => yourInputData += i)\n process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))\n} else {\n const fileSystem = require(\"fs\");\n mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))\n}", "lang_cluster": "Javascript", "tags": ["brute force", "dp"], "code_uid": "e9ff5eca593cbc1fc19a808feb77a60c", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\nreadline.question(\"\",(w1)=>{\n readline.question(\"\",(w2)=>{\n console.log(w1.toUpperCase().localeCompare(w2.toUpperCase()));\n readline.close();\n })\n})", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "962ecc2c238be4e8e6c4932c1dc314a6", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nlet inputs = [];\n\n// Create readline Interface\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\n\n// Read Inputs\nrl.on('line', lineInput => {\n inputs.push(lineInput)\n})\n\nrl.on('close', () => {\n\n const arr = inputs.map(elem => elem.split(' ').map(num => parseInt(num)))\n let n = 0;\n\n for (let i = 1; i < arr.length; i++) {\n\n for (let j = 1; j < arr.length; j++) {\n if (arr[i][0] == arr[j][1])\n n++\n }\n\n }\n\n console.log(n);\n\n})", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "6ea96008ef1afb1022cbf68ffff5ecdb", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let n = parseInt(readLine());\n let arr = [];\n let ans = 0;\n for (var i = 0; i < n; i++) {\n arr.push(readLine().split(' ').map(value => parseInt(value)));\n }\n for (var i = 0; i < n; i++) {\n for (var k = 0; k < n; k++) {\n if (arr[i][0] == arr[k][1]) {\n ans++;\n }\n }\n }\n console.log(ans);\n}", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "524e4d8dfae1d824b351a48de4c697c4", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let stdin = process.openStdin();\n\nstdin.addListener(\"data\", function(input) {\n let string = input.toString().trim().split(' ');\n let subtractedNumber = string[0];\n let count = string[1];\n\n for (count; count > 0; count--) {\n if (subtractedNumber % 10 === 0) {\n subtractedNumber = subtractedNumber / 10;\n } else {\n subtractedNumber--;\n }\n }\n\n console.log(subtractedNumber);\n process.exit();\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "8a673c4cf8346a8fbe55f4af42e3879f", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nfunction gdc(x, y) {\n let cx = x, cy = y;\n while (cx != 0 && cy != 0) {\n if (cx > cy) cx = cx % cy;\n else cy = cy % cx;\n }\n return cx + cy;\n}\n\nreadLine.on('close', () => {\n let [a, b, n] = input[0].split(' ').map(x => parseInt(x));\n\n let semen = true;\n while (true) {\n let d = gdc(n, semen ? a : b);\n n -= d;\n\n if (n === 0) { console.log(semen ? 0 : 1); return };\n semen = !semen;\n }\n}); ", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "4209fe7d0bacd9f8282641fe2455ee5e", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (str) => {\n let count = 1;\n\n for (let i = 1; i < str.length; i++) {\n if (str[i] === str[i - 1]) {\n count++;\n }\n else {\n if (count >= 7) {\n break;\n }\n\n count = 1;\n }\n }\n\n console.log(count >= 7 ? 'YES' : 'NO');\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "a60aaebf30050de462d8e5ea0315f41a", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputBuffer = \"\", curLine = 0;\n\nfunction readline() {\n\treturn inputBuffer[curLine++];\n}\n\nlet curTokens = [], curToken = 0;\n\nfunction next() {\n\twhile (curToken >= curTokens.length) {\n\t\tcurTokens = readline().split(/[\\s]+/);\n\t\tcurToken = 0;\n\t}\n\treturn curTokens[curToken++];\n}\n\nfunction nextInt () {\n\treturn parseInt(next(), 10);\n}\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf8\");\n\nprocess.stdin.on('data', (chunk) => {\n\tinputBuffer += chunk;\n});\n\nprocess.stdin.on('end', () => {\n\tinputBuffer = inputBuffer.trim().split('\\n').map(line => line.trim());\n\tmain();\n});\n\n\n\nfunction print(data) {\n\tprocess.stdout.write(data + \"\\n\");\n}\n\nfunction main () {\n\tconst n = nextInt();\n\n\tlet f = [];\n\tf[0] = 0, f[1] = 1, f[2] = 1, f[3] = 1, f[4] = 1, f[5] = 1;\n\t// console.log(f);\n\tfor(let i = 6; i <= n; i++) \n\t\tf[i] = Math.min(f[i-1], f[i-2], f[i-3], f[i-4], f[i-5])+1;\n\tprint(f[n]);\n\t// console.log(f);\n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "819354673334ec51be3f8816a1e7cef6", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input.push(line);\n});\n\n\nRL.on('close', () => {\n let {0:a, 1:b} = {...input[0].split(' ')};\n a = parseInt(a); b = parseInt(b);\n let f = 0;\n if(a < b) {\n f = fact(a);\n } else {\n f = fact(b);\n }\n console.log(f);\n});\n\nfunction fact(num) {\n if(num === 0)\n return 1;\n return num * fact(num-1);\n}", "lang_cluster": "Javascript", "tags": ["math", "implementation", "number theory"], "code_uid": "a0de98c6e646e2a7fbbed07949d4336a", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar input = [];\nrl.on('line', function (line) {input.push(line);});\nrl.on('close', function() {\n const word = input[0];\n let lowerCount = 0;\n let upperCount = 0;\n \n for(let i = 0; i < word.length; i++) {\n if(isUpperCased(word[i])) upperCount++;\n if(!isUpperCased(word[i])) lowerCount++;\n }\n \n if (upperCount > lowerCount) {\n console.log(word.toUpperCase())\n } else if( lowerCount === upperCount || lowerCount > upperCount) {\n console.log(word.toLowerCase())\n }\n \n});\n\nfunction isUpperCased(l) {\n return l.toUpperCase() === l;\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "95be2fc644b60698672a296f7316f34a", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "function main(){\n\nvar line1 = readline();\nvar n = parseInt(line1);\n\nvar line2 = readline().split(' ').map(Number);\n\nvar pos1 = 0;\nvar posn = 0;\n\nfor(i=0;iposn){\n var diff = pos1-posn;\n if(posn>n-1-pos1){\n\tdiff+=posn;\n }\n else{\n\tdiff+=(n-1-pos1);\n }\n print(diff);\n return;\n}else{\n var diff = posn-pos1;\n if(pos1>n-1-posn){\n\tdiff+=pos1;\n }else{\n\tdiff+=(n-1-posn);\n }\n print(diff);\n return;\n}\n\n}\n\nmain();", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation"], "code_uid": "f0f88a9eff831b7ac71e879c3b41f1f5", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n \nrl.on('line', line => {\n const input = line.split(' ');\n console.log(solution(input));\n})\n\nl = console.log;\ne = process.exit;\n\nfunction solution(input) {\n const cost = Number(input[0]);\n const money = Number(input[1]);\n const numberOfBananas = Number(input[2]);\n let total = 0;\n // The banana cost keeps going up\n // k for the first, 2k for the second\n // so let's run an accumulator for this\n for (let i = 1; i <= numberOfBananas; i++) {\n total += i * cost;\n }\n\n if (total > money) {\n return total - money;\n } else {\n return 0;\n }\n}\n\n\n// Input = 3 17 4\n// Output = 13", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "49ac46dba9acb6e2136cd750793ea961", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main(data) {\n\tfor(let i = parseInt(data[0]) + 1; i < Number.MAX_VALUE; i++) {\n\t\ti = i.toString();\n\t\tconst inputArray = i.split('');\n\t\tlet ouputArray = Array.from(new Set(inputArray));\n\t\tif(inputArray.length == ouputArray.length) {\n\t\t\tconsole.log(ouputArray.join(''));\n\t\t\tprocess.exit(0);\n\t\t}\n\t}\n}\n\nprocess.stdin.on('data', data => {\n\tmain(data.toString().trim().split(/\\n/));\n});\n\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "4357177efaab2a1a56cdf73c36aa1e0c", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n\n let number = readline();\n var res= number.replaceAll(\"144\",\" \").replaceAll(\"14\",\" \").replaceAll(\"1\",\" \").trim();\n if(res.length > 0)\n {\n console.log(\"NO\");\n }\n else{\n console.log(\"YES\");\n }\n}\n\nString.prototype.replaceAll = function(search, replacement) {\n var target = this;\n return target.split(search).join(replacement);\n};", "lang_cluster": "Javascript", "tags": ["brute force", "greedy"], "code_uid": "c2537d96ba04ffbd435a5d6931cbf772", "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\n\nfunction splitAndParseInt(line) {\n return line.split(\" \").map((x) => parseInt(x));\n}\n\nreadLine.on(\"line\", (line) => input.push(line));\nreadLine.on(\"close\", () => {\n let string1 = input[0].toLowerCase();\n let string2 = input[1].toLowerCase();\n console.log(string1.localeCompare(string2))\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "c7f9d9817e64ce7e319df74a2f2de029", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n let [n, position] = readLine().split(' ').map(Number);\n // let odds = [];\n // let evens = [];\n // let result = [];\n // for (let i = 1; i <= n; i++) {\n // // if (i % 2 === 0) {\n // // evens.push(i);\n // // } else {\n // // odds.push(i);\n // // }\n // if (i % 2 !== 0) {\n // result.push(i);\n // } else {\n // continue;\n // }\n // }\n // for (let i = 1; i <= n; i++) {\n // if (i % 2 === 0) {\n // result.push(i);\n // } else {\n // continue;\n // }\n // }\n // // let final = [...odds, ...evens]; // [1,3,5,7,9,11,13,2,4,6,8,10,12]\n // console.log(result[position - 1]); [1,3,5,7,2,4,6,8]\n let partition;\n if (n % 2 === 0) {\n partition = n / 2;\n } else {\n partition = parseInt(n / 2) + 1;\n }\n let final;\n if (position <= partition) {\n final = position * 2 - 1;\n } else {\n final = (position - partition) * 2;\n //[1, 3, 5, 7, 2, 4, 6];\n }\n console.log(final);\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "0c91a3c77be8881026ead82d4dfc6c16", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst rl = readline.createInterface({\n\t input: process.stdin,\n\t output: process.stdout,\n\tterminal : false\n});\n\n\nrl.on(\"line\", main)\nlet arr = []\nfunction main(input){\n\tarr = input.split('+')\n\tarr.sort(function(a, b){\n\t\treturn parseInt(a) - parseInt(b)\n\t})\n\n\t\n\tlet r = \"\"\n\n\tfor(j = 0; j < arr.length; j++){\n\t\tif(arr.length === 1){\n\t\t\tconsole.log(arr[j])\n\t\t\tcontinue\n\t\t}\n\t\tif(arr.length === j+1){\n\t\t\tr = r + arr[j]\n\t\t\tcontinue\n\t\t}\n\n\t\tr = r + arr[j] + \"+\"\n\t}\n\tconsole.log(r)\n\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "0274ba2b38cea83815fa4c253290bc04", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadline.on('line', line => { input.push(line); });\n\nreadline.on('close', () => {\n const n = input[0].split(' ');\n const ns = new Set(n);\n console.log(n.length - ns.size);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "93755669ff3fe34c0ab9fb996f0fefc5", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let store = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}];\n\nfunction checkDigit(n, dig) {\n if (dig == 0) {\n return { count: int(n == 0 ? 0 : 1), decrement: 0 };\n }\n if (dig > n) {\n return {\n count: int(1),\n decrement: dig - n\n };\n }\n return {\n count: int(2),\n decrement: dig\n };\n}\n\nfunction getNumString(arr) {\n const joined = arr.join(\"\");\n const trimmed = joined.replace(/0/g, \" \").trimLeft();\n return trimmed.replace(/\\s/g, \"0\") || \"0\";\n}\n\nfunction solveCore(n, dig = 0) {\n if (store[dig][n]) {\n return store[dig][n];\n }\n if (n.length === 1) {\n return (store[dig][n] = checkDigit(n, dig));\n }\n\n let first = n[0];\n let tailArr = n.substring(1).split(\"\");\n let total = int();\n\n while (first >= 0) {\n const r = solveCore(getNumString(tailArr), Math.max(first, dig));\n total = plus(total, r.count);\n first -= 1;\n tailArr = tailArr.map(() => \"9\");\n tailArr.pop();\n tailArr.push(`${(10 - r.decrement) % 10}`);\n }\n\n return (store[dig][n] = { count: total, decrement: 10 - tailArr.pop() });\n}\n\nfunction solve(n) {\n store = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}];\n const r = solveCore(n, 0);\n return bintToString(r.count);\n}\n\nfunction* main() {\n const n = yield;\n const r = solve(n);\n console.log(r);\n process.exit(0);\n}\n\nif (!module.parent) {\n (() => {\n const q = main();\n q.next();\n require(\"readline\")\n .createInterface({\n input: process.stdin,\n output: null\n })\n .on(\"line\", line => q.next(line));\n })();\n}\n\nfunction int(n = 0) {\n return [\n n,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0\n ];\n}\nfunction plus(int1, int2) {\n let z = 0;\n return int1.map((_, i) => {\n z = z + int1[i] + int2[i];\n const r = z % 10;\n z = Math.floor(z / 10);\n return r;\n });\n}\n\nfunction bintToString(i) {\n return getNumString(Array.from(i).reverse());\n}\n\nexports.solve = solve;\n", "lang_cluster": "Javascript", "tags": ["dp"], "code_uid": "7b96995592bd0850381cdee608a3e6d5", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\n\nconst runMain = () => {\n inputString = inputString.trim().split('\\n').map(string => string.trim());\n main();\n process.exit();\n}\nconst readLine = () => inputString[currentLine++];\n\nprocess.stdin.on('data', inputStdin => inputString += inputStdin);\nprocess.stdin.on('end', runMain);\nprocess.on('SIGINT', runMain);\n\nfunction main() {\n let i = 0;\n let j = 0;\n for (let k = 0; k < 5; k++) {\n const line = readLine().split(' ').join('');\n if (line.includes('1')) {\n j = line.indexOf('1');\n break;\n }\n i++;\n }\n console.log(Math.abs(2 - i) + Math.abs(2 - j));\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "34245d46b127d97f3bc25922427126dd", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let fs = require('fs');\n \nlet txt = fs.readFileSync(0, \"utf-8\").split(/[\\r\\n]/).filter(data => {\n return data.length > 0;\n});\nfor (let index = 0; index < txt.length; index++) {\n doit(txt[index]*1+1);\n}\n \nfunction doit(num) {\n let tab = String(num).split(\"\");\n while (true) {\n let test = true;\n for (let index = tab.length - 1; index >0; index--) {\n if (tab.indexOf(tab[index]) != index) {\n test = false;\n tab = String(++num*1).split(\"\");\n break;\n }\n }\n if (test) {\n break;\n }\n }\n console.log(tab.join(\"\"));\n}", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "85beb2980b0b91c6f0ecc8a6e17e6c26", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const obj = {\n 0: 0,\n 1: 4,\n 2: 4,\n 3: 4,\n 4: 4,\n 5: 4,\n 6: 4,\n 7: 4,\n 8: 4,\n 9: 4,\n 10: 15,\n 11: 4\n };\n\n const r = +d - 10;\n console.log(obj[r] || 0);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e61209f8f017d358d2ff51f7e7e64df1", "src_uid": "5802f52caff6015f21b80872274ab16c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\r\nvar read = require('readline').createInterface({\r\n\tinput: process.stdin, output: process.stdout\r\n});\r\nvar obj; var inLine = []; var outputList = [];var retcode = new Set();\r\nread.on('line', function(input){\r\n\tvar tmp = input.split(' ');\r\n\tfor(var i = 0; i < tmp.length; i++){\r\n\t\tinLine.push(tmp[i]);\r\n\t\tif(i == tmp.length - 1){\r\n\t\t\tretcode.add(inLine.length);\r\n\t\t}\r\n\t}\r\n});\r\nread.on('close', function(){\r\n\tobj = init(inLine);\r\n\tconsole.error('\\n↑入力 ↓出力');\r\n\tMain();\r\n\tconsole.log(myconv(outputList, 9));\r\n});\r\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\r\nfunction nextArray(size, code){\r\n\tvar ret = new Array(size);\r\n\tfor(var i = 0; i < size; i++){\r\n\t\tif(code == 'int'){\r\n\t\t\tret[i] = nextInt();\r\n\t\t}else if(code == 'long'){\r\n\t\t\tret[i] = nextLong();\r\n\t\t}else if(code == 'double'){\r\n\t\t\tret[i] = nextDouble();\r\n\t\t}else{\r\n\t\t\tret[i] = next();\r\n\t\t}\r\n\t}\r\n\treturn ret;\r\n}\r\nfunction nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');} function nextDoubleArray(size){return nextArray(size, 'double');}\r\nfunction nextCharArray(){return myconv(next(),6);}\r\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());} function nextDouble(){return parseFloat(next());}\r\nfunction getCountMap(list){\r\n\tvar map = {};\r\n\tfor(var i = 0; i < list.length; i++){\r\n\t\tif(map[list[i]] == null){\r\n\t\t\tmap[list[i]] = 0;\r\n\t\t}\r\n\t\tmap[list[i]]++;\r\n\t}\r\n\treturn map;\r\n}\r\nfunction init(input){ \r\n\treturn {\r\n\t\tlist : input, index : 0, max : input.length,\r\n\t\thasNext : function(){return (this.index < this.max);},\r\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},\r\n\t\tisReturn : function(){return retcode.has(this.index);}\r\n\t};\r\n}\r\nfunction myout(s){outputList.push(s);}\r\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\r\nfunction isReturn(){return obj.isReturn();}\r\n//param \"no\" is\r\n//unknown or outlier : return i. 1: parseInt.\r\n//2: split space. 4: split space and parseInt.\r\n//6: split 1 character. 7: split 1 character and parseInt.\r\n//8: join space. 9: join nextline. 0: join no character.\r\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\r\n\r\n//Don't have to see. end------------------------------------------\r\nfunction Main(){\r\n\tvar t = nextInt();\r\n\twhile(hasNext()){\r\n\t\tvar x = nextInt();\r\n\t\tvar set = new Set([x]);\r\n\t\tvar list = nextIntArray(3);\r\n\t\tfor(var i = 0; i < 3; i++){\r\n\t\t\tx = list[x - 1];\r\n\t\t\tif(x != 0){\r\n\t\t\t\tset.add(x);\r\n\t\t\t}else{\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\tif(set.size == 3){\r\n\t\t\tmyout(\"YES\");\r\n\t\t}else{\r\n\t\t\tmyout(\"NO\");\r\n\t\t}\r\n\t}\r\n}\r\n", "lang_cluster": "Javascript", "tags": ["brute force", "greedy", "implementation", "math"], "code_uid": "60414233703030323209cf7d3f1bffc1", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\r\nprocess.stdin.setEncoding('utf-8');\r\n\r\nlet inputString = '';\r\nlet currentLine = 0;\r\n\r\nprocess.stdin.on('data', inputStdin => {\r\n inputString += inputStdin;\r\n});\r\n\r\nprocess.stdin.on('end', _ => {\r\n inputString = inputString.trim().split('\\n').map(string => {\r\n return string.trim();\r\n });\r\n\r\n main();\r\n});\r\n\r\nfunction readLine() {\r\n return inputString[currentLine++];\r\n}\r\n\r\nlet stepeni = [1, 2]\r\nlet stepen = function (n) {\r\n if (stepeni[n]) return stepeni[n];\r\n let l = stepeni.length - 1;\r\n while (l < n) {\r\n stepeni.push(2 * stepeni[l++]);\r\n }\r\n return stepeni[n];\r\n}\r\n\r\nfunction main() {\r\n inputString.slice(1).map(e => console.log((stepen(parseInt(e)) - 1)))\r\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "2ba5c1f5ff7bec03adcfb29a4c16f972", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// https://codeforces.com/problemset/problem/977/A\n// Big O:\n// n: iterations, m: length of the string\n// Time complexity: O(n*m) => O(n)\n// Space complexity: O(n*m) => O(n)\n\nconst readline = require(\"readline\");\n\nfunction substract(number, iterations) {\n\n let result = number;\n while (iterations > 0) {\n const lastDigit = getLastDigit(result);\n if (lastDigit == 0) {\n result = removeLastDigit(result);\n } else {\n result -= 1;\n }\n\n iterations--;\n }\n\n return result;\n}\n\nfunction getLastDigit(number) {\n const { numberAsString, numberLength } = getNumberStringValues(number);\n const lastDigit = numberAsString.charAt(numberLength - 1);\n return parseInt(lastDigit);\n}\n\nfunction removeLastDigit(number) {\n const { numberAsString, numberLength } = getNumberStringValues(number);\n const numberWithoutLastDigit = numberAsString.substring(0, numberLength - 1);\n return parseInt(numberWithoutLastDigit);\n}\n\nfunction getNumberStringValues(number) {\n const numberAsString = number.toString();\n const numberLength = numberAsString.length;\n return { numberAsString, numberLength }\n}\n\n// Read input\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.question(\"\", function (line) {\n const input = line.split(\" \");\n const number = parseInt(input[0]);\n const iterations = parseInt(input[1]);\n console.log(substract(number, iterations));\n\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0b9c91c939c487964f396d5d95ae9352", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\r\n \r\nprocess.stdin.resume();\r\nprocess.stdin.setEncoding('utf-8');\r\n \r\nlet inputString = '';\r\nlet currentLine = 0;\r\n \r\nprocess.stdin.on('data', inputStdin => {\r\n inputString += inputStdin;\r\n});\r\n \r\nprocess.stdin.on('end', _ => {\r\n inputString = inputString.trim().split('\\n').map(string => {\r\n return string.trim();\r\n });\r\n \r\n main(); \r\n});\r\n \r\nfunction readline() {\r\n return inputString[currentLine++];\r\n}\r\n \r\n \r\nfunction main(){\r\n var tests = parseInt(readline());\r\n for (let t = 0;t < tests; ++t) {\r\n var nm = readline().split(\" \").map(x => parseInt(x));\r\n var mn = readline().split(\" \").map(x => parseInt(x));\r\n let sum = 0;\r\n nm.forEach((x)=> {\r\n sum += x;\r\n })\r\n mn.forEach((x)=> {\r\n sum += x;\r\n })\r\n if (sum == 0) {\r\n console.log(0);\r\n } else if (sum == 4) {\r\n console.log(2);\r\n } else {\r\n console.log(1);\r\n }\r\n }\r\n \r\n}\r\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "dbad4e3d5e79a9fa6b5137f92787b77d", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n \nlet inputString = '';\nlet currentLine = 0;\n \nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n \nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n \nfunction readLine() {\n return inputString[currentLine++];\n}\n \nfunction main() {\n let str = readLine()\n let arr = []\n \n str.split(\"\").forEach(s => {\n if (arr.indexOf(s) === -1) arr.push(s)\n })\n \n if (arr.length % 2 === 0) console.log(\"CHAT WITH HER!\")\n else console.log(\"IGNORE HIM!\")\n \n}", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "2fa6dcd88d6673fec7e2750212f7f378", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let number = parseInt(readLine());\n for (let i = 1; i <= number; i++) {\n if (isLucky(i) && number % i === 0) {\n console.log('YES');\n return;\n }\n }\n console.log('NO');\n}\n\nfunction isLucky(n) {\n let nString = n.toString();\n let nArray = nString.split('');\n let final = [];\n for (let i = 0; i < nArray.length; i++) {\n if (nArray[i] === '4' || nArray[i] === '7') {\n final.push(nArray[i]);\n }\n }\n if (final.length === nArray.length) {\n return true;\n } else {\n return false;\n }\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "number theory"], "code_uid": "8027c31439acad65b5757a3caaf25894", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n\tvar N = nextInt();\n\tvar list = nextIntArray();\n\tvar output = [];\n\tfor(var i = N - 1; i >= 0; i--){\n\t\tif(output.indexOf(list[i]) == -1){\n\t\t\toutput.unshift(list[i]);\n\t\t}\n\t}\n\tmyout(output.length);\n\tmyout(myconv(output, 8));\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "dc80d211cf89949dc71433b6dd7d1f38", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var line_number = 0;\nconst cs = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nvar lines = {};\ncs.on(\"line\", (input) => {\n if (input == \"\") {\n cs.close();\n }\n lines[line_number] = input.split(\" \");\n line_number += 1;\n}).on(\"close\", () => {\n main();\n process.exit();\n});\n\nfunction isOp(str) {\n return str.length === 1 && str.match(/[<=>]/);\n}\nfunction isChr(str) {\n return str.length === 1 && str.match(/[a-z]/i);\n}\nfunction isInt(str) {\n return str.length === 1 && !isNaN(str);\n}\n\nfunction print(str) {\n console.log(str);\n}\n\nfunction exit(status = 0) {\n process.exit(status);\n}\n\nfunction predict(test) {\n let op = \"\";\n let ops = [];\n let opVariables = [];\n let limits = [];\n for (let t of test) {\n // console.log(t);\n for (let i = 0; i < t.length; i++) {\n if (isOp(t[i])) {\n op = t[i];\n if (isOp(t[i + 1])) {\n op += t[i + 1];\n i += 1;\n }\n ops.push(op);\n op = \"\";\n } else if (isChr(t[i])) {\n // console.log(t[i])\n op = t[i];\n for (var j = i + 1; j < t.length; j++) {\n if (isChr(t[j]) || isInt(t[j])) {\n op += t[j];\n i = j;\n } else break;\n }\n opVariables.push(op);\n op = \"\";\n } else {\n if (i == 0 || (i > 0 && isOp(t[i - 1]))) {\n op = t[i];\n let j = i + 1;\n for (; j < t.length; j++) {\n if (isInt(t[j])) {\n op += t[j];\n i = j;\n } else break;\n }\n limits.push(op);\n op = \"\";\n }\n }\n }\n }\n\n let min = limits[0];\n let max = limits[1];\n\n let pvs = ops.map((o, i) => [o, opVariables[i]]);\n\n for (let pv of pvs) {\n if (pv[1] == undefined) {\n pv[1] = max;\n }\n // print(`${min} ${pv[0]} ${pv[1]} ?`)\n if (eval(`${min}${pv[0]}${pv[1]}`)) {\n // print(` ${min} ${pv[0]} ${pv[1]} true`)\n min = pv[1];\n } else {\n print(\"input error\");\n exit();\n }\n }\n}\n\nvar n;\nfunction main() {\n n = parseInt(lines[0][0],10)\n predict([\"1<=n<=50\"])\n\n let color = lines[1][0]\n let count = 0\n for (let i = 0; i < n; i++) {\n if (color[i] == color[i+1]) {\n count += 1\n }\n }\n print(count)\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "6d13c8c2847becb4922e7d9b08794659", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStd => {\n\tinputString += inputStd;\n});\nprocess.stdin.on('end', _ => {\n\tinputString = inputString.trim().split('\\n').map( str => {\n\t\treturn str.trim();\n\t});\n\tmain();\n});\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\nfunction main() {\n\tconst arr = readLine().split(' ').map(Number);\n\tconst [m, n, a] = arr;\n\t\n\tlet x = m / a;\n\tif(m % a) ++x;\n\n\tlet y = n / a;\n\tif(n % a) ++y;\n\n\tconsole.log(parseInt(x) * parseInt(y));\n}\n\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "7d0ab9c0b5b5b9771a52be8916fa707d", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input.push(line);\n});\n\n\nRL.on('close', () => {\n let {0:x, 1:y, 2:z} = {...input[0].split(' ')};\n x = parseInt(x); y = parseInt(y); z = parseInt(z);\n\n console.log(\n (x > y && x - z > y) ? '+' :\n (x > y && x - z == y) ? '?' : \n (y > x && y - z > x) ? '-' : \n (y > x && y - z == x) ? '?' :\n (y == x && z == 0) ? '0' : '?'\n )\n});\n\n\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "2eb05cda56ea53bfdfd8c09112df1f90", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet inputString = \"\";\nlet currentLine = 0;\n\nprocess.stdin.on(\"data\", (inputStdin) => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((string) => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n let matrix = [];\n for(let i=0;i<5;i++){\n matrix.push(readline()\n .split(\" \")\n .map((x) => +x));\n }\n\n \n \n beautifulMatrix(matrix);\n}\n\nfunction beautifulMatrix(matrix) {\n for (let row = 0; row < matrix.length; row++) {\n for (let column = 0; column < matrix[row].length; column++) {\n if (matrix[row][column] == 1) {\n console.log(Math.abs(2 - row) + Math.abs(2 - column));\n return Math.abs(2 - row) + Math.abs(2 - column);\n }\n }\n }\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "a39f116c2cb4f5d5ea9570a96312a54b", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n');\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr('time : ' + end + 'ms');\n myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var one = nextIntArray();\n var k2 = one[0];\n var k3 = one[1];\n var k5 = one[2];\n var k6 = one[3];\n var output = 0;\n while(k2 > 0 && k5 > 0 && k6 > 0){\n output += 256;\n k2--;\n k5--;\n k6--;\n }\n while(k2 > 0 && k3 > 0){\n output += 32;\n k2--;\n k3--;\n }\n myout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "9312d01b5598e78bae899995ee03d2ed", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function _defineProperties(t,e){for(var r=0;rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}var fs=require(\"fs\"),configPath=\"./compe.config.json\";function proc(t,e){if(global.MOD_=998244353,global.MOD_CUT=444595123,fs.existsSync(configPath)){if(!fs.existsSync(e))return void console.log(\"Input directory does not exist\");var r=fs.readFileSync(e,{encoding:\"utf-8\"}),n=0;r=r.split(/ |\\n|\\r/g);for(var i,o=[],s=_createForOfIteratorHelperLoose(r);!(i=s()).done;){var a=i.value;a.length>0&&o.push(a)}global.rnum=function(t){return t?o.slice(n,n+=t).map((function(t){return+t})):+o[n++]},global.rstr=function(t){return t?o.slice(n,n+=t):o[n++]},global.rbig=function(t){return t?o.slice(n,n+=t).map((function(t){return BigInt(t)})):BigInt(o[n++])},global.print=function(){for(var t=arguments.length,e=new Array(t),r=0;r0&&n.push(o)}global.rnum=function(t){return t?n.slice(e,e+=t).map((function(t){return+t})):+n[e++]},global.rstr=function(t){return t?n.slice(e,e+=t):n[e++]},global.rbig=function(t){return t?n.slice(e,e+=t).map((function(t){return BigInt(t)})):BigInt(n[e++])};var s=\"\";global.print=function(){for(var t=arguments.length,e=new Array(t),r=0;rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}Object.defineProperty(exports,\"__esModule\",{value:!0});var ErrorGenerator,ForOfAdaptor=function(t){function e(t,e){this.it_=t,this.last_=e}var r=e.prototype;return r.next=function(){if(this.it_.equals(this.last_))return{done:!0,value:void 0};var t=this.it_;return this.it_=this.it_.next(),{done:!1,value:t.value}},r[t]=function(){return this},e}(Symbol.iterator),Container=function(t){function e(){}var r=e.prototype;return r.empty=function(){return 0===this.size()},r.rbegin=function(){return this.end().reverse()},r.rend=function(){return this.begin().reverse()},r[t]=function(){return new ForOfAdaptor(this.begin(),this.end())},r.toJSON=function(){for(var t,e=[],r=_createForOfIteratorHelperLoose$1(this);!(t=r()).done;){var n=t.value;e.push(n)}return e},e}(Symbol.iterator),NativeArrayIterator=function(){function t(t,e){this.data_=t,this.index_=e}var e=t.prototype;return e.index=function(){return this.index_},e.prev=function(){return--this.index_,this},e.next=function(){return++this.index_,this},e.advance=function(t){return this.index_+=t,this},e.equals=function(t){return this.data_===t.data_&&this.index_===t.index_},e.swap=function(t){var e=[t.data_,this.data_];this.data_=e[0],t.data_=e[1];var r=[t.index_,this.index_];this.index_=r[0],t.index_=r[1]},_createClass$1(t,[{key:\"value\",get:function(){return this.data_[this.index_]}}]),t}(),SetContainer=function(t){function e(e){var r;return(r=t.call(this)||this).data_=e(_assertThisInitialized(r)),r}_inheritsLoose$1(e,t);var r=e.prototype;return r.assign=function(t,e){this.clear(),this.insert(t,e)},r.clear=function(){this.data_.clear()},r.begin=function(){return this.data_.begin()},r.end=function(){return this.data_.end()},r.has=function(t){return!this.find(t).equals(this.end())},r.size=function(){return this.data_.size()},r.push=function(){for(var t=arguments.length,e=new Array(t),r=0;r (index = \"+n+\").\")},t.excessive_index=function(t,r,n,i){return new OutOfRange(\"Error on \"+e(t)+\".\"+r+\"(): parametric index is equal or greater than size -> (index = \"+n+\", size: \"+i+\").\")},t.not_my_iterator=function(t,r){return new InvalidArgument(\"Error on \"+e(t)+\".\"+r+\"(): parametric iterator is not this container's own.\")},t.erased_iterator=function(t,r){return new InvalidArgument(\"Error on \"+e(t)+\".\"+r+\"(): parametric iterator, it already has been erased.\")},t.negative_iterator=function(t,r,n){return new OutOfRange(\"Error on \"+e(t)+\".\"+r+\"(): parametric iterator is directing negative position -> (index = \"+n+\").\")},t.iterator_end_value=function(t,r){void 0===r&&(r=\"end\");var n=e(t);return new OutOfRange(\"Error on \"+n+\".Iterator.value: cannot access to the \"+n+\".\"+r+\"().value.\")},t.key_nout_found=function(t,r,n){throw new OutOfRange(\"Error on \"+e(t)+\".\"+r+\"(): unable to find the matched key -> \"+n)}}(ErrorGenerator||(ErrorGenerator={}));var IAssociativeContainer,UniqueSet=function(t){function e(){return t.apply(this,arguments)||this}_inheritsLoose$1(e,t);var r=e.prototype;return r.count=function(t){return this.find(t).equals(this.end())?0:1},r.insert=function(){for(var e,r=arguments.length,n=new Array(r),i=0;i1?e-1:0),n=1;n=1&&r[0]instanceof Array?(i=function(){var e=r[0];t.push.apply(t,e)},o=r.slice(1)):r.length>=2&&r[0].next instanceof Function&&r[1].next instanceof Function?(i=function(){var e=r[0],n=r[1];t.assign(e,n)},o=r.slice(2)):(i=null,o=r),{ramda:i,tail:o}}}(IAssociativeContainer||(IAssociativeContainer={}));var is_node_=null;function is_node(){return null===is_node_&&(is_node_=\"object\"==typeof global&&\"object\"==typeof global.process&&\"object\"==typeof global.process.versions&&void 0!==global.process.versions.node),is_node_}function _Get_root(){return null===__s_pRoot&&void 0===(__s_pRoot=is_node()?global:self).__s_iUID&&(__s_pRoot.__s_iUID=0),__s_pRoot}var ITreeContainer,__s_pRoot=null;function get_uid(t){if(t instanceof Object){if(!1===t.hasOwnProperty(\"__get_m_iUID\")){var e=++_Get_root().__s_iUID;Object.defineProperty(t,\"__get_m_iUID\",{value:function(){return e}})}return t.__get_m_iUID()}return void 0===t?-1:0}function equal_to(t,e){return t=t?t.valueOf():t,e=e?e.valueOf():e,t instanceof Object&&t.equals instanceof Function?t.equals(e):t===e}function less(t,e){return t=t.valueOf(),e=e.valueOf(),t instanceof Object?t.less instanceof Function?t.less(e):get_uid(t)3?o-3:0),a=3;a=1&&(i=h.tail[0])}r(i),null!==n&&n()},t.emplacable=function(t,e,r){var n=e.prev(),i=n.equals(t.end())||t.value_comp()(n.value,r);return i=i&&(e.equals(t.end())||t.value_comp()(r,e.value))}}(ITreeContainer||(ITreeContainer={}));var INIT_VALUE=2166136261,MULTIPLIER=16777619,Pair=function(){function t(t,e){this.first=t,this.second=e}var e=t.prototype;return e.equals=function(t){return equal_to(this.first,t.first)&&equal_to(this.second,t.second)},e.less=function(t){return!1===equal_to(this.first,t.first)?less(this.first,t.first):less(this.second,t.second)},e.hashCode=function(){return hash(this.first,this.second)},t}(),UniqueTreeSet=function(t){function e(){return t.apply(this,arguments)||this}_inheritsLoose$1(e,t);var r=e.prototype;return r.find=function(t){var e=this.lower_bound(t);return!e.equals(this.end())&&this._Key_eq(t,e.value)?e:this.end()},r.equal_range=function(t){var e=this.lower_bound(t);return new Pair(e,!e.equals(this.end())&&this._Key_eq(t,e.value)?e.next():e)},r.value_comp=function(){return this.key_comp()},r._Key_eq=function(t,e){return!this.key_comp()(t,e)&&!this.key_comp()(e,t)},r._Insert_by_key=function(t){var e=this.lower_bound(t);return!e.equals(this.end())&&this._Key_eq(e.value,t)?new Pair(e,!1):(e=this.data_.insert(e,t),this._Handle_insert(e,e.next()),new Pair(e,!0))},r._Insert_by_hint=function(t,e){if(ITreeContainer.emplacable(this,t,e)){var r=this.data_.insert(t,e);return this._Handle_insert(r,r.next()),r}return this._Insert_by_key(e).first},e}(UniqueSet),ListIterator=function(){function t(t,e,r){this.prev_=t,this.next_=e,this.value_=r}t._Set_prev=function(t,e){t.prev_=e},t._Set_next=function(t,e){t.next_=e};var e=t.prototype;return e.prev=function(){return this.prev_},e.next=function(){return this.next_},e._Try_value=function(){if(void 0===this.value_&&!0===this.equals(this.source().end()))throw ErrorGenerator.iterator_end_value(this.source())},e.equals=function(t){return this===t},_createClass$1(t,[{key:\"value\",get:function(){return this._Try_value(),this.value_}}]),t}(),Repeater=function(){function t(t,e){this.index_=t,this.value_=e}var e=t.prototype;return e.index=function(){return this.index_},e.next=function(){return++this.index_,this},e.equals=function(t){return this.index_===t.index_},_createClass$1(t,[{key:\"value\",get:function(){return this.value_}}]),t}();function advance(t,e){if(0===e)return t;if(t.advance instanceof Function)return t.advance(e);var r;if(e<0){if(!(t.prev instanceof Function))throw new InvalidArgument(\"Error on std.advance(): parametric iterator is not a bi-directional iterator, thus advancing to negative direction is not possible.\");r=function(t){return t.prev()},e=-e}else r=function(t){return t.next()};for(;e-- >0;)t=r(t);return t}var ListContainer=function(t){function e(){var e;return(e=t.call(this)||this).end_=e._Create_iterator(null,null),e.clear(),e}_inheritsLoose$1(e,t);var r=e.prototype;return r.assign=function(t,e){this.clear(),this.insert(this.end(),t,e)},r.clear=function(){ListIterator._Set_prev(this.end_,this.end_),ListIterator._Set_next(this.end_,this.end_),this.begin_=this.end_,this.size_=0},r.resize=function(t){var e=t-this.size();e>0?this.insert(this.end(),e,void 0):e<0&&this.erase(advance(this.end(),-e),this.end())},r.begin=function(){return this.begin_},r.end=function(){return this.end_},r.size=function(){return this.size_},r.push_front=function(t){this.insert(this.begin_,t)},r.push_back=function(t){this.insert(this.end_,t)},r.pop_front=function(){if(!0===this.empty())throw ErrorGenerator.empty(this.end_.source().constructor.name,\"pop_front\");this.erase(this.begin_)},r.pop_back=function(){if(!0===this.empty())throw ErrorGenerator.empty(this.end_.source().constructor.name,\"pop_back\");this.erase(this.end_.prev())},r.push=function(){for(var t=arguments.length,e=new Array(t),r=0;r=0;--o){var s=this.tryEntries[o],a=s.completion;if(\"root\"===s.tryLoc)return i(\"end\");if(s.tryLoc<=this.prev){var u=n.call(s,\"catchLoc\"),h=n.call(s,\"finallyLoc\");if(u&&h){if(this.prev=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,\"finallyLoc\")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if(\"throw\"===n.type){var i=n.arg;k(r)}return i}}throw new Error(\"illegal catch attempt\")},delegateYield:function(t,r,n){return this.delegate={iterator:z(t),resultName:r,nextLoc:n},\"next\"===this.method&&(this.arg=e),v}},t}(t.exports);try{regeneratorRuntime=e}catch(t){\"object\"==typeof globalThis?globalThis.regeneratorRuntime=e:Function(\"r\",\"regeneratorRuntime = r\")(e)}})),Deque=function(t){function e(t){this.head=0,this.tail=0,this.mask=1,this.list=new Array(2),t&&this.extend(t)}var r=e.prototype;return r.extend=function(t){for(var e,r=_createForOfIteratorHelperLoose(t);!(e=r()).done;){var n=e.value;this.push(n)}return this},r.extendFront=function(t){for(var e,r=_createForOfIteratorHelperLoose(t);!(e=r()).done;){var n=e.value;this.pushFront(n)}return this},r._resize=function(t,e){var r=this.head,n=this.mask;if(this.head=0,this.tail=t,this.mask=e-1,0!==r){for(var i=new Array(e),o=0;o=r||t<-r)throw new RangeError(\"deque index out of range\");return i[(t>=0?e:n)+t&this.mask]},r.indexOf=function(t,e){void 0===e&&(e=0);for(var r=this.head,n=this.list,i=this.size,o=this.mask,s=e>=0?e:e<-i?0:i+e;s>>1&&this._resize(this.size,this.list.length>>>1),t},r.popFront=function(){if(this.head===this.tail)throw new RangeError(\"pop from an empty deque\");var t=this.list[this.head];return this.list[this.head]=void 0,this.head=this.head+1&this.mask,this.size>>1&&this._resize(this.size,this.list.length>>>1),t},r.delete=function(t){if(t>=this.size||t<0)throw new RangeError(\"deque index out of range\");for(var e=this.head+t&this.mask;e!==this.tail;){var r=e+1&this.mask;this.list[e]=this.list[r],e=r}return this.tail=this.tail-1&this.mask,this.size>>1&&this._resize(this.size,this.list.length>>>1),this},r.reverse=function(){for(var t=this.head,e=this.tail,r=this.size,n=this.mask,i=0;i<~~(r/2);i++){var o=e-i-1&n,s=t+i&n,a=this.list[o];this.list[o]=this.list[s],this.list[s]=a}return this},r.rotate=function(t){void 0===t&&(t=1);var e=this.head,r=this.tail;if(0===t||e===r)return this;if(this.head=e-t&this.mask,this.tail=r-t&this.mask,t>0)for(var n=1;n<=t;n++){var i=e-n&this.mask,o=r-n&this.mask;this.list[i]=this.list[o],this.list[o]=void 0}else for(var s=0;s>t;s--){var a=r-s&this.mask,u=e-s&this.mask;this.list[a]=this.list[u],this.list[u]=void 0}return this},r.entries=runtime_1.mark((function t(){var e,r,n,i,o;return runtime_1.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=this.head,r=this.size,n=this.list,i=this.mask,o=0;case 2:if(!(o=1){var e;if(\"object\"==typeof t)throw new Error(\"The value can not be object\");var r=[t,[]],n=0,i=1;r[0]=new Array((e=(arguments.length<=1?0:arguments.length-1)-1+1)<1||arguments.length<=e?void 0:arguments[e]);for(var o=0;o=0;s--){if(!Number.isInteger(s+1<1||arguments.length<=s+1?void 0:arguments[s+1]))throw new Error(\"Please pass integer arguments for array size\");r[i]=new Array(s+1<1||arguments.length<=s+1?void 0:arguments[s+1]);for(var a=0;a<(s+1<1||arguments.length<=s+1?void 0:arguments[s+1]);a++)r[i][a]=r[n].slice();var u=[i,n];n=u[0],i=u[1]}return r[n]}},vectorArray=function(t){for(var e=new Array(t),r=0;rthis.p[e]){var r=[e,t];t=r[0],e=r[1]}return this.p[t]+=this.p[e],this.p[e]=t,!0},e.size=function(t){return t=this.group(t),-this.p[t]},t}(),PriorityQueue=function(){function t(t){this.comparator=t||function(t,e){return t0&&(r=e>>1,!this.comparator(this.elem[e],this.elem[r]));)this.swap(e,r),e=r},e.pop=function(){var t=this.top,e=this.elem.pop(),r=this.size;if(0==r)return t;this.elem[0]=e;for(var n=0,i=0,o=0,s=0;n=0;t=(t&t+1)-1)e=this.updateMethod(e,this.cont[t]);return e},e.update=function(t,e){for(;t<=this.elemCount;t|=t+1)this.cont[t]=this.updateMethod(this.cont[t],e)},t}(),SegmentTree=function(){function t(t,e,r,n){if(void 0===n&&(n=null),this.identityValue=e,this.merger=r,this.elemCount=t,this.log=Math.ceil(Math.log2(t)),this.size=1<=1;o--)this.internalUpdate(o)}}var e=t.prototype;return e.internalUpdate=function(t){this.cont[t]=this.merger(this.cont[t<<1],this.cont[t<<1|1])},e.set=function(t,e){t+=this.size,this.cont[t]=e;for(var r=1;r<=this.log;r++)this.internalUpdate(t>>r)},e.get=function(t){return t?this.cont[t+this.size]:this.cont.slice(this.size,this.size+this.elemCount)},e.query=function(t,e){void 0===t&&(t=0),void 0===e&&(e=this.elemCount-1),e++;var r=this.identityValue,n=this.identityValue;for(t+=this.size,e+=this.size;t>=1,e>>=1;return this.merger(r,n)},e.all=function(){return this.cont[1]},t}(),LazySegmentTree=function(){function t(t,e,r,n,i,o,s){if(void 0===s&&(s=null),this.identityValue=e,this.merger=r,this.identityLazy=n,this.pusher=i,this.modifier=o,this.log=Math.ceil(Math.log2(t)),this.size=1<=1;u--)this.internalUpdate(u)}}var e=t.prototype;return e.internalUpdate=function(t){this.cont[t]=this.merger(this.cont[t<<1],this.cont[t<<1|1])},e.internalModify=function(t,e){e!==this.identityLazy&&(this.cont[t]=this.modifier(this.cont[t],e),t=1;r--)this.internalPush(t>>r);this.cont[t]=e;for(var n=1;n<=this.log;n++)this.internalUpdate(t>>n)},e.get=function(t){t+=this.size;for(var e=this.log;e>=1;e--)this.internalPush(t>>e);return this.cont[t]},e.query=function(t,e){e++,t+=this.size,e+=this.size;for(var r=this.log;r>=1;r--)t>>r<>r),e>>r<>r);for(var n=this.identityValue,i=this.identityValue;t>=1,e>>=1;return this.merger(n,i)},e.all=function(){return this.cont[1]},e.update=function(t,e,r){e++,t+=this.size,e+=this.size;for(var n=this.log;n>=1;n--)t>>n<>n),e>>n<>n);for(var i=t,o=e;t>=1,e>>=1;t=i,e=o;for(var s=1;s<=this.log;s++)t>>s<>s),e>>s<>s)},t}(),defaultComparator=function(t,e){return t>>1)],e)?r=o+1:n=o;return r},upperBound=function(t,e,r,n,i){var o;for(void 0===r&&(r=0),void 0===n&&(n=0),void 0===i&&(i=defaultComparator),n||(n=t.length);r>>1)])?n=o:r=o+1;return r},binarySearch=function(t,e,r){for(var n,i=null;t<=e;)r(n=t+e>>1)?(i=n,e=n-1):t=n+1;return i},ternarySearch=function(t,e,r,n,i){var o,s;if(void 0===n&&(n=!1),void 0===i&&(i=200),n)for(;i--;)s=e-(e-t)/3,r(o=t+(e-t)/3)>1),r(i-1)>1),r(a-1)>u?(h=u,t=a+1):e=a-1;return h},Graph=function(){function t(t){this.g=vectorArray(t+1),this.vis=multiArray(!1,t+1),this.par=multiArray(-1,t+1)}var e=t.prototype;return e.addEdge=function(t,e,r){this.g[t].push({to:e,prop:r})},e.addBiEdge=function(t,e,r){this.addEdge(t,e,r),this.addEdge(e,t,r)},e.reset=function(){this.vis=multiArray(!1,this.g.length),this.par=multiArray(-1,this.g.length)},t}(),dfs=function(t,e,r,n){var i=new Deque;for(i.push(e);i.size;){var o=i.back;if(t.vis[o])n(o,t),i.pop();else{t.vis[o]=!0,r(o,t);for(var s,a=_createForOfIteratorHelperLoose(t.g[o]);!(s=a()).done;){var u=s.value;t.vis[u.to]||(t.par[u.to]=o,i.push(u.to))}}}},bfs=function(t,e,r){var n=new Deque;if(n.push(e),Array.isArray(e))for(var i,o=_createForOfIteratorHelperLoose(e);!(i=o()).done;){var s=i.value;t.vis[s]=!0,n.push(s)}else t.vis[e]=!0,n.push(e);for(;n.size;){var a=n.pop();r(a,t);for(var u,h=_createForOfIteratorHelperLoose(t.g[a]);!(u=h()).done;){var l=u.value;t.vis[l.to]||(t.par[l.to]=a,n.push(l.to),t.vis[l.to]=!0)}}},mst=function(t){for(var e=0,r=[],n=[],i=0;ii[r]+f.prop.weight&&(i[f.to]=i[r]+f.prop.weight,t.par[f.to]=r,o[f.to]||(o[f.to]=!0,s.push(f.to)))}}return{parArray:t.par,distArray:i}},dijkstra=function(t,e){t.reset();var r=new PriorityQueue((function(t,e){return t.dist>e.dist})),n=Number.MAX_SAFE_INTEGER,i=multiArray(n,t.g.length);if(Array.isArray(e))for(var o,s=_createForOfIteratorHelperLoose(e);!(o=s()).done;){var a=o.value;r.push({node:a,dist:0}),i[a]=0}else r.push({node:e,dist:0}),i[e]=0;for(;r.size;){var u=r.pop();if(i[u.node]===u.dist)for(var h,l=_createForOfIteratorHelperLoose(t.g[u.node]);!(h=l()).done;){var c=h.value;i[c.to]>i[u.node]+c.prop.weight&&(i[c.to]=i[u.node]+c.prop.weight,t.par[c.to]=u.node,r.push({node:c.to,dist:i[c.to]}))}}return{parArray:t.par,distArray:i}},setMod=function(t){global.MOD_=t,global.MOD_CUT=1099511627776%t},add=function(){for(var t=arguments.length,e=new Array(t),r=0;r=1;n--)e[0]+=e[n],e[0]=e[0]>=global.MOD_?e[0]-global.MOD_:e[0];return e[0]},sub=function(t,e){return(t+=global.MOD_-e)>=global.MOD_?t-global.MOD_:t},mul=function(){for(var t=arguments.length<=0?void 0:arguments[0],e=1;e>20)*((e<0||arguments.length<=e?void 0:arguments[e])>>20)*global.MOD_CUT+(4293918720&t)*(1048575&(e<0||arguments.length<=e?void 0:arguments[e]))+(1048575&t)*(e<0||arguments.length<=e?void 0:arguments[e]))%global.MOD_;return t},pow=function(t,e){for(var r=1;e;)1&e&&(r=mul(r,t)),t=mul(t,t),e>>>=1;return r},inv=function(t){for(var e,r=1,n=0,i=global.MOD_;i;n=(o=[r,n-e*r])[0],r=o[1],o){var o,s;i=(s=[t,i-(e=i/t|0)*t])[0],t=s[1]}return r<0?r+global.MOD_:r},binomSetup=function(t,e){void 0===t&&(t=2e5),void 0===e&&(e=!1),global.factorial=Array(t+1).fill(1),global.invFactorial=Array(t+1).fill(1);for(var r=1;r<=t;r++)global.factorial[r]=mul(global.factorial[r-1],r);global.invFactorial[t]=inv(global.factorial[t]);for(var n=t-1;n>=1;n--)global.invFactorial[n]=mul(global.invFactorial[n+1],n+1);if(e){if(t>5e3)throw new Error(\"Fast Binomial is only available for under 5000 range\");global.fastBinomEnabled=!0,global.fastBinom=multiArray(0,t+1,t+1);for(var i=0;i<=t;i++){global.fastBinom[i][0]=1;for(var o=1;o<=i;o++)global.fastBinom[i][o]=add(global.fastBinom[i-1][o-1],global.fastBinom[i-1][o])}}},binom=function(t,e){return e>t?0:global.fastBinomEnabled?global.fastBinom[t][e]:mul(global.factorial[t],global.invFactorial[e],global.invFactorial[t-e])},fact=function(t){return global.factorial[t]},Tree=function(t){function e(e,r){var n;return(n=t.call(this,e)||this).root=1,n.root=r,n.childCount=Array(e+1).fill(1),n.distRoot=Array(e+1).fill(0),n.distance=Array(e+1).fill(0),n}_inheritsLoose(e,t);var r=e.prototype;return r.setupDist=function(){var t=this;dfs(this,this.root,(function(e,r){for(var n,i=_createForOfIteratorHelperLoose(r.g[e]);!(n=i()).done;){var o=n.value;o.to!=r.par[e]&&(o.prop&&(t.distance[o.to]=t.distance[e]+o.prop.weight),t.distRoot[o.to]=t.distRoot[e]+1)}}),(function(e,r){for(var n,i=_createForOfIteratorHelperLoose(r.g[e]);!(n=i()).done;){var o=n.value;o.to!=r.par[e]&&(t.childCount[e]+=t.childCount[o.to])}}))},r.setupLCA=function(){this.setupDist();var t=31-Math.clz32(this.g.length);this.log=t,this.parentLift=Array(t+1),this.parentLift[0]=this.par;for(var e=1;e<=t;e++){this.parentLift[e]=Array(this.g.length).fill(-1);for(var r=0;r=0;n--)this.distRoot[t]-(1<=this.distRoot[e]&&(t=this.parentLift[n][t]);if(t===e)return t;for(var i=this.log;i>=0;i--)this.parentLift[i][t]!=this.parentLift[i][e]&&(t=this.parentLift[i][t],e=this.parentLift[i][e]);return this.parentLift[0][t]},e}(Graph);\r\n\r\nfunction main() {\r\n // write your code from here\r\n let [n, x] = rnum(2);\r\n let dp = multiArray(0, n + 1, x + 1);\r\n let p = multiArray(0, n + 1, x + 1);\r\n dp[0][0] = 1;\r\n for (let i = 0; i <= n; i ++) {\r\n for (let j = 1; j <= x; j ++) {\r\n p[i][j] = pow(j, i);\r\n }\r\n }\r\n binomSetup(500, true);\r\n for (let i = 2; i <= n; i ++) {\r\n for (let j = 1; j < i; j ++) {\r\n dp[i][j] = mul(binom(n, i), sub(p[i][j], p[i][j - 1]));\r\n }\r\n }\r\n for (let i = 2; i <= n; i ++) {\r\n for (let j = 1; j <= x; j ++) {\r\n for (let k = 0; i + k <= n && i + j + k - 1 <= x; k ++) {\r\n dp[i + k][i + j + k - 1] = add(dp[i + k][i + j + k - 1], mul(dp[i][j], binom(n - i, k), p[k][i + k - 1]));\r\n }\r\n }\r\n }\r\n let ans = 0;\r\n for (let i = 1; i <= x; i ++)\r\n ans = add(ans, dp[n][i]);\r\n print(ans);\r\n}\r\nproc(main, 'input.txt');\r\n\r\n\r\n// Generated with compe.js - https://github.com/polarity-cf/compe.js", "lang_cluster": "Javascript", "tags": ["math", "dp", "combinatorics"], "code_uid": "279a4466d3dc91ab82c13a14c612d0a2", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const vowels = ['a', 'e', 'i', 'o', 'u', 'y'];\nprocess.stdin.on('data', input => {\n console.log(formatString(input.toString().trim()));\n});\n\nfunction formatString(str) {\n const arr = Array.from(str);\n\n return arr.reduce((acc, curr) => {\n curr = curr.toLowerCase();\n if (!vowels.includes(curr)) {\n acc.push('.', curr);\n }\n\n return acc;\n }, []).join('')\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "66f58d2c3106cac30ca01d76cf7f562c", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const n = parseInt(readLine());\n const numbers = [47, 74, 744, 474, 4, 7, 77, 44, 444, 777, 447, 477, 747, 774];\n let found = false;\n for (let i = 0; i < numbers.length; i++) {\n if (n % numbers[i] === 0) {\n found = true;\n break;\n }\n }\n if (found) {\n console.log(\"YES\");\n } else {\n console.log(\"NO\");\n }\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "number theory"], "code_uid": "7434da103aee0eb8822a229a462ce953", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar stdin = [];\nrl.on('line', function (line) {stdin.push(line);});\nrl.on('close', main);\n\n//\n//\n\n\nfunction main() {\n var input = stdin[0]\n var res = '+'\n var arr = input.split(\" \")\n res = arr\n var x = parseInt(arr[0])\n var y = parseInt(arr[1])\n var z = parseInt(arr[2])\n\n var plus = x\n var minus = y\n \n if (plus > minus) {\n res = '+'\n } else if (minus > plus) {\n res = '-'\n } else if (minus == plus) {\n res = '0'\n }\n\n plus = plus + z\n minus = minus + z\n\n if (res == '+') {\n if (minus >= x) {\n res = '?'\n }\n } else if (res == '-') {\n if (plus >= y) {\n res = '?'\n }\n } else if (res == '0') {\n if (z != '0') {\n res = '?'\n }\n }\n\n\n console.log(res)\n return\n}", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "d4a45dffa07dfc293c667b5444e342a9", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = ''\nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os')\n const lines = i.split(EOL) /*your input text, split by lines*/\n let count = lines[0];\n\n \tlet putted = 0;\n\n\twhile (count > 0) {\n\t if (count % 2 == 1) {\n\t putted += 1;\n\t }\n\t count = parseInt(count / 2)\n\t}\n\n\tconsole.log(putted);\n})\n\n", "lang_cluster": "Javascript", "tags": ["bitmasks"], "code_uid": "39e89786ea76e10270e0c9baa877d773", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = ''\nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os')\n const lines = i.split(EOL) \n console.log(divideEvenly(lines[0]));\n});\n \nfunction divideEvenly(w){\n if (w < 3 || w > 100) return 'NO';\n if (w % 2 === 0 ) return 'YES'\n return 'NO';\n}\n ", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "c93d82a9b998cc2f352ad82d8c8b3b8b", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (str) => {\n if (c === 0) {\n c++;\n return;\n }\n\n let ans = 0;\n let max = Math.floor(str.length / 11);\n\n for (let i = 0; i < str.length; i++) {\n if (str[i] === '8') {\n ans = Math.min(max, ans + 1);\n }\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "9a4881c725775315f1f0ccd02aed2466", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let data = '';\nprocess.stdin.on('data', c => data += c);\n\nconst sol = () => {\n\tlet line = data.trim().split(/\\n/);\n\tlet n = Number(line[0]);\n\tlet t = line[1].split(/\\s/).map(v => parseInt(v,10));\n\tlet s = 15;\n\tfor(let i of t){\n\t\tif (i <= s) {\n\t\t\ts = i + 15;\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n\tconsole.log((s >= 90)?90:s);\n};\n\nprocess.stdin.on('end',sol);", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f4c0464f9194c6734faa030a43b7ac25", "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet a, b, c;\nrl.on('line', line => {\n [a, b, c] = line.split(' ').map(i => parseInt(i));\n}).on('close', () => {\n console.log(Math.ceil(a / c) * Math.ceil(b / c));\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "c7363d6bafa06be37acfa9d2d5a61d5c", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(str) {\n let input = str.trim();\n let strFlag = 'NO';\n let count = 0;\n for (let str of input) {\n if (str == 4 || str == 7) {\n count++;\n }\n }\n\n if (count === 4 || count === 7) {\n strFlag = 'YES';\n }\n return strFlag.toString();\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "da67bd51921be59aafc60b1367b99abe", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet firstWord \nlet secondWord \nrl.on(\"line\",(input)=>{\n if(!firstWord) {\n firstWord = (input.split(\" \").toString()).toLowerCase();\n //console.log(typeof(firstWord))\n }\n else {(!secondWord) \n secondWord = (input.split(\" \").toString()).toLowerCase();\n if(firstWord>secondWord) console.log(1)\n else if(firstWord {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let n = parseInt(readLine());\n let s = readLine();\n let count = 0;\n for (let i = 0; i < n; i++) {\n if (s[i] == s[i + 1])\n count++;\n }\n console.log(count);\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "fb733c2b58b6574ad9a0b90932dae34b", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function _defineProperties(t,r){for(var e=0;et.length)&&(r=t.length);for(var e=0,i=new Array(r);e=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}var fs=require(\"fs\"),configPath=\"./compe.config.json\";function proc(t,r){if(global.MOD_=998244353,global.MOD_CUT=444595123,fs.existsSync(configPath)){if(!fs.existsSync(r))return void console.log(\"Input directory does not exist\");var e=fs.readFileSync(r,{encoding:\"utf-8\"}),i=0;e=e.split(/ |\\n|\\r/g);for(var n,o=[],s=_createForOfIteratorHelperLoose(e);!(n=s()).done;){var a=n.value;a.length>0&&o.push(a)}global.rnum=function(t){return t?o.slice(i,i+=t).map((function(t){return+t})):+o[i++]},global.rstr=function(t){return t?o.slice(i,i+=t):o[i++]},global.rbig=function(t){return t?o.slice(i,i+=t).map((function(t){return BigInt(t)})):BigInt(o[i++])},global.print=function(){for(var t=arguments.length,r=new Array(t),e=0;e0&&i.push(o)}global.rnum=function(t){return t?i.slice(r,r+=t).map((function(t){return+t})):+i[r++]},global.rstr=function(t){return t?i.slice(r,r+=t):i[r++]},global.rbig=function(t){return t?i.slice(r,r+=t).map((function(t){return BigInt(t)})):BigInt(i[r++])};var s=\"\";global.print=function(){for(var t=arguments.length,r=new Array(t),e=0;e=0;--o){var s=this.tryEntries[o],a=s.completion;if(\"root\"===s.tryLoc)return n(\"end\");if(s.tryLoc<=this.prev){var h=i.call(s,\"catchLoc\"),l=i.call(s,\"finallyLoc\");if(h&&l){if(this.prev=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&i.call(n,\"finallyLoc\")&&this.prev=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),O(e),v}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var i=e.completion;if(\"throw\"===i.type){var n=i.arg;O(e)}return n}}throw new Error(\"illegal catch attempt\")},delegateYield:function(t,e,i){return this.delegate={iterator:S(t),resultName:e,nextLoc:i},\"next\"===this.method&&(this.arg=r),v}},t}(t.exports);try{regeneratorRuntime=r}catch(t){\"object\"==typeof globalThis?globalThis.regeneratorRuntime=r:Function(\"r\",\"regeneratorRuntime = r\")(r)}})),Deque=function(t){function r(t){this.head=0,this.tail=0,this.mask=1,this.list=new Array(2),t&&this.extend(t)}var e=r.prototype;return e.extend=function(t){for(var r,e=_createForOfIteratorHelperLoose(t);!(r=e()).done;){var i=r.value;this.push(i)}return this},e.extendFront=function(t){for(var r,e=_createForOfIteratorHelperLoose(t);!(r=e()).done;){var i=r.value;this.pushFront(i)}return this},e._resize=function(t,r){var e=this.head,i=this.mask;if(this.head=0,this.tail=t,this.mask=r-1,0!==e){for(var n=new Array(r),o=0;o=e||t<-e)throw new RangeError(\"deque index out of range\");return n[(t>=0?r:i)+t&this.mask]},e.indexOf=function(t,r){void 0===r&&(r=0);for(var e=this.head,i=this.list,n=this.size,o=this.mask,s=r>=0?r:r<-n?0:n+r;s>>1&&this._resize(this.size,this.list.length>>>1),t},e.popFront=function(){if(this.head===this.tail)throw new RangeError(\"pop from an empty deque\");var t=this.list[this.head];return this.list[this.head]=void 0,this.head=this.head+1&this.mask,this.size>>1&&this._resize(this.size,this.list.length>>>1),t},e.delete=function(t){if(t>=this.size||t<0)throw new RangeError(\"deque index out of range\");for(var r=this.head+t&this.mask;r!==this.tail;){var e=r+1&this.mask;this.list[r]=this.list[e],r=e}return this.tail=this.tail-1&this.mask,this.size>>1&&this._resize(this.size,this.list.length>>>1),this},e.reverse=function(){for(var t=this.head,r=this.tail,e=this.size,i=this.mask,n=0;n<~~(e/2);n++){var o=r-n-1&i,s=t+n&i,a=this.list[o];this.list[o]=this.list[s],this.list[s]=a}return this},e.rotate=function(t){void 0===t&&(t=1);var r=this.head,e=this.tail;if(0===t||r===e)return this;if(this.head=r-t&this.mask,this.tail=e-t&this.mask,t>0)for(var i=1;i<=t;i++){var n=r-i&this.mask,o=e-i&this.mask;this.list[n]=this.list[o],this.list[o]=void 0}else for(var s=0;s>t;s--){var a=e-s&this.mask,h=r-s&this.mask;this.list[a]=this.list[h],this.list[h]=void 0}return this},e.entries=runtime_1.mark((function t(){var r,e,i,n,o;return runtime_1.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=this.head,e=this.size,i=this.list,n=this.mask,o=0;case 2:if(!(o1?r-1:0),i=1;ithis.p[r]){var e=[r,t];t=e[0],r=e[1]}return this.p[t]+=this.p[r],this.p[r]=t,!0},r.size=function(t){return t=this.group(t),-this.p[t]},t}(),PriorityQueue=function(){function t(t){this.comparator=t||function(t,r){return t0&&(e=r>>1,!this.comparator(this.elem[r],this.elem[e]));)this.swap(r,e),r=e},r.pop=function(){var t=this.top,r=this.elem.pop(),e=this.size;if(0==e)return t;this.elem[0]=r;for(var i=0,n=0,o=0,s=0;i=0;t=(t&t+1)-1)r=this.updateMethod(r,this.cont[t]);return r},r.update=function(t,r){for(;t<=this.elemCount;t|=t+1)this.cont[t]=this.updateMethod(this.cont[t],r)},t}(),SegmentTree=function(){function t(t,r,e,i){if(void 0===i&&(i=null),this.identityValue=r,this.merger=e,this.elemCount=t,this.log=Math.ceil(Math.log2(t)),this.size=1<=1;o--)this.internalUpdate(o)}}var r=t.prototype;return r.internalUpdate=function(t){this.cont[t]=this.merger(this.cont[t<<1],this.cont[t<<1|1])},r.set=function(t,r){t+=this.size,this.cont[t]=r;for(var e=1;e<=this.log;e++)this.internalUpdate(t>>e)},r.get=function(t){return t?this.cont[t+this.size]:this.cont.slice(this.size,this.size+this.elemCount)},r.query=function(t,r){void 0===t&&(t=0),void 0===r&&(r=this.elemCount-1),r++;var e=this.identityValue,i=this.identityValue;for(t+=this.size,r+=this.size;t>=1,r>>=1;return this.merger(e,i)},r.all=function(){return this.cont[1]},t}(),LazySegmentTree=function(){function t(t,r,e,i,n,o,s){if(void 0===s&&(s=null),this.identityValue=r,this.merger=e,this.identityLazy=i,this.pusher=n,this.modifier=o,this.log=Math.ceil(Math.log2(t)),this.size=1<=1;h--)this.internalUpdate(h)}}var r=t.prototype;return r.internalUpdate=function(t){this.cont[t]=this.merger(this.cont[t<<1],this.cont[t<<1|1])},r.internalModify=function(t,r){r!==this.identityLazy&&(this.cont[t]=this.modifier(this.cont[t],r),t=1;e--)this.internalPush(t>>e);this.cont[t]=r;for(var i=1;i<=this.log;i++)this.internalUpdate(t>>i)},r.get=function(t){t+=this.size;for(var r=this.log;r>=1;r--)this.internalPush(t>>r);return this.cont[t]},r.query=function(t,r){r++,t+=this.size,r+=this.size;for(var e=this.log;e>=1;e--)t>>e<>e),r>>e<>e);for(var i=this.identityValue,n=this.identityValue;t>=1,r>>=1;return this.merger(i,n)},r.all=function(){return this.cont[1]},r.update=function(t,r,e){r++,t+=this.size,r+=this.size;for(var i=this.log;i>=1;i--)t>>i<>i),r>>i<>i);for(var n=t,o=r;t>=1,r>>=1;t=n,r=o;for(var s=1;s<=this.log;s++)t>>s<>s),r>>s<>s)},t}(),defaultComparator=function(t,r){return t>>1)],r)?e=o+1:i=o;return e},upperBound=function(t,r,e,i,n){var o;for(void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=defaultComparator),i||(i=t.length);e>>1)])?i=o:e=o+1;return e},binarySearch=function(t,r,e){for(var i,n=null;t<=r;)e(i=t+r>>1)?(n=i,r=i-1):t=i+1;return n},ternarySearch=function(t,r,e,i,n){var o,s;if(void 0===i&&(i=!1),void 0===n&&(n=200),i)for(;n--;)s=r-(r-t)/3,e(o=t+(r-t)/3)>1),e(n-1)>1),e(a-1)>h?(l=h,t=a+1):r=a-1;return l},Graph=function(){function t(t){this.g=multi([],t+1),this.vis=multi(!1,t+1),this.par=multi(-1,t+1)}var r=t.prototype;return r.addEdge=function(t,r,e){this.g[t].push({to:r,prop:e})},r.addBiEdge=function(t,r,e){this.addEdge(t,r,e),this.addEdge(r,t,e)},r.reset=function(){this.vis=multi(!1,this.g.length),this.par=multi(-1,this.g.length)},t}(),dfs=function(t,r,e,i){var n=new Deque;for(n.push(r);n.size;){var o=n.back;if(t.vis[o])i(o,t),n.pop();else{t.vis[o]=!0,e(o,t);for(var s,a=_createForOfIteratorHelperLoose(t.g[o]);!(s=a()).done;){var h=s.value;t.vis[h.to]||(t.par[h.to]=o,n.push(h.to))}}}},bfs=function(t,r,e){var i=new Deque;if(i.push(r),Array.isArray(r))for(var n,o=_createForOfIteratorHelperLoose(r);!(n=o()).done;){var s=n.value;t.vis[s]=!0,i.push(s)}else t.vis[r]=!0,i.push(r);for(;i.size;){var a=i.pop();e(a,t);for(var h,l=_createForOfIteratorHelperLoose(t.g[a]);!(h=l()).done;){var u=h.value;t.vis[u.to]||(t.par[u.to]=a,i.push(u.to),t.vis[u.to]=!0)}}},mst=function(t){for(var r=0,e=[],i=[],n=0;nn[e]+c.prop.weight&&(n[c.to]=n[e]+c.prop.weight,t.par[c.to]=e,o[c.to]||(o[c.to]=!0,s.push(c.to)))}}return{parArray:t.par,distArray:n}},dijkstra=function(t,r){t.reset();var e=new PriorityQueue((function(t,r){return t.dist>r.dist})),i=Number.MAX_SAFE_INTEGER,n=multi(i,t.g.length);if(Array.isArray(r))for(var o,s=_createForOfIteratorHelperLoose(r);!(o=s()).done;){var a=o.value;e.push({node:a,dist:0}),n[a]=0}else e.push({node:r,dist:0}),n[r]=0;for(;e.size;){var h=e.pop();if(n[h.node]===h.dist)for(var l,u=_createForOfIteratorHelperLoose(t.g[h.node]);!(l=u()).done;){var f=l.value;n[f.to]>n[h.node]+f.prop.weight&&(n[f.to]=n[h.node]+f.prop.weight,t.par[f.to]=h.node,e.push({node:f.to,dist:n[f.to]}))}}return{parArray:t.par,distArray:n}},setMod=function(t){global.MOD_=t,global.MOD_CUT=1099511627776%t},add=function(){for(var t=arguments.length,r=new Array(t),e=0;e=1;i--)r[0]+=r[i],r[0]=r[0]>=global.MOD_?r[0]-global.MOD_:r[0];return r[0]},sub=function(t,r){return(t+=global.MOD_-r)>=global.MOD_?t-global.MOD_:t},mul=function(){for(var t=arguments.length<=0?void 0:arguments[0],r=1;r>20)*((r<0||arguments.length<=r?void 0:arguments[r])>>20)*global.MOD_CUT+(4293918720&t)*(1048575&(r<0||arguments.length<=r?void 0:arguments[r]))+(1048575&t)*(r<0||arguments.length<=r?void 0:arguments[r]))%global.MOD_;return t},pow=function(t,r){for(var e=1;r;)1&r&&(e=mul(e,t)),t=mul(t,t),r>>>=1;return e},inv=function(t){for(var r,e=1,i=0,n=global.MOD_;n;i=(o=[e,i-r*e])[0],e=o[1],o){var o,s;n=(s=[t,n-(r=n/t|0)*t])[0],t=s[1]}return e<0?e+global.MOD_:e},binomSetup=function(t,r){void 0===t&&(t=2e5),void 0===r&&(r=!1),global.factorial=Array(t+1).fill(1),global.invFactorial=Array(t+1).fill(1);for(var e=1;e<=t;e++)global.factorial[e]=mul(global.factorial[e-1],e);global.invFactorial[t]=inv(global.factorial[t]);for(var i=t-1;i>=1;i--)global.invFactorial[i]=mul(global.invFactorial[i+1],i+1);if(r){if(t>2e3)throw new Error(\"Fast Binomial is only available for under 2000 range\");global.fastBinomEnabled=!0,global.fastBinom=multi(0,t+1,t+1);for(var n=0;n<=t;n++){global.fastBinom[n][0]=1;for(var o=1;o<=n;o++)global.fastBinom[n][o]=add(global.fastBinom[n-1][o-1],global.fastBinom[n-1][o])}}},binom=function(t,r){return r>t?0:global.fastBinomEnabled?global.fastBinom[t][r]:mul(global.factorial[t],global.invFactorial[r],global.invFactorial[t-r])},fact=function(t){return global.factorial[t]},Tree=function(t){function r(r,e){var i;return(i=t.call(this,r)||this).root=1,i.root=e,i.childCount=Array(r+1).fill(1),i.distRoot=Array(r+1).fill(0),i.distance=Array(r+1).fill(0),i}_inheritsLoose(r,t);var e=r.prototype;return e.setupDist=function(){var t=this;dfs(this,this.root,(function(r,e){for(var i,n=_createForOfIteratorHelperLoose(e.g[r]);!(i=n()).done;){var o=i.value;o.to!=e.par[r]&&(o.prop&&(t.distance[o.to]=t.distance[r]+o.prop.weight),t.distRoot[o.to]=t.distRoot[r]+1)}}),(function(r,e){for(var i,n=_createForOfIteratorHelperLoose(e.g[r]);!(i=n()).done;){var o=i.value;o.to!=e.par[r]&&(t.childCount[r]+=t.childCount[o.to])}}))},e.setupLCA=function(){this.setupDist();var t=31-Math.clz32(this.g.length);this.log=t,this.parentLift=Array(t+1),this.parentLift[0]=this.par;for(var r=1;r<=t;r++){this.parentLift[r]=Array(this.g.length).fill(-1);for(var e=0;e=0;i--)this.distRoot[t]-(1<=this.distRoot[r]&&(t=this.parentLift[i][t]);if(t===r)return t;for(var n=this.log;n>=0;n--)this.parentLift[n][t]!=this.parentLift[n][r]&&(t=this.parentLift[n][t],r=this.parentLift[n][r]);return this.parentLift[0][t]},r}(Graph);exports.DSU=DSU,exports.Deque=Deque,exports.FenwickTree=FenwickTree,exports.Graph=Graph,exports.LazySegmentTree=LazySegmentTree,exports.PriorityQueue=PriorityQueue,exports.SegmentTree=SegmentTree,exports.SparseTable=SparseTable,exports.Tree=Tree,exports.add=add,exports.bfs=bfs,exports.binarySearch=binarySearch,exports.binom=binom,exports.binomSetup=binomSetup,exports.dfs=dfs,exports.dijkstra=dijkstra,exports.fact=fact,exports.integralExtremumSearch=integralExtremumSearch,exports.inv=inv,exports.lowerBound=lowerBound,exports.mst=mst,exports.mul=mul,exports.multi=multi,exports.pow=pow,exports.proc=proc,exports.setMod=setMod,exports.spfa=spfa,exports.sub=sub,exports.ternarySearch=ternarySearch;\r\n\r\nfunction main() {\r\n // write your code from here\r\n let [n, x] = rnum(2);\r\n let dp = multi(0, n + 1, x + 1);\r\n let p = multi(0, n + 1, x + 1);\r\n dp[0][0] = 1;\r\n for (let i = 0; i <= n; i ++) {\r\n for (let j = 1; j <= x; j ++) {\r\n p[i][j] = pow(j, i);\r\n }\r\n }\r\n binomSetup(500, true);\r\n for (let i = 2; i <= n; i ++) {\r\n for (let j = 1; j < i; j ++) {\r\n dp[i][j] = mul(binom(n, i), sub(p[i][j], p[i][j - 1]));\r\n }\r\n }\r\n for (let i = 2; i <= n; i ++) {\r\n for (let j = 1; j <= x; j ++) {\r\n for (let k = 0; i + k <= n && i + j + k - 1 <= x; k ++) {\r\n dp[i + k][i + j + k - 1] = add(dp[i + k][i + j + k - 1], mul(dp[i][j], binom(n - i, k), p[k][i + k - 1]));\r\n }\r\n }\r\n }\r\n let ans = 0;\r\n for (let i = 1; i <= x; i ++)\r\n ans = add(ans, dp[n][i]);\r\n print(ans);\r\n}\r\nproc(main, 'input.txt');\r\n\r\n\r\n// Generated with compe.js - https://github.com/polarity-cf/compe.js", "lang_cluster": "Javascript", "tags": ["math", "dp", "combinatorics"], "code_uid": "8b7c21be98620a8b10dfba91044c8d33", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction main() {\n\tconst s = readLine().split('');\n\tconst { length } = s;\n\tconst match = 'hello'.split('');\n\tlet current = 'h';\n\tlet count = 0;\n\n\tfor (let i = 0; i < length; ++i) {\n\t\tif (s[i] === current) {\n\t\t\tcount++;\n\t\t\tcurrent = match[count];\n\t\t}\n\n\t\tif (count >= 5) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tcount === 5 ? console.log('YES') : console.log('NO');\n}\n", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "193281c5d7166975e9d93844df46b43f", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n });\n\n let tmp=0, lngth=0, str='';\n\n rl.on('line', (input) => {\n if (tmp==0) {lngth=Number(input); tmp++;}\n else {str=input; rl.close(); therest();\n return 0;}\n \n });\n\n let therest=function() {\n let res='', step=1;\n for (let i=0; i {\n // TODO: Log the answer in a database\n console.log(`Thank you for your valuable feedback: ${answer}`);\n \n rl.close();\n });*/", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "aa413a23a0fe81bd3080fc91617a2a8b", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input;\nprocess.stdin.on('data', c => input = c);\nprocess.stdin.on('end', sol);\n\nfunction f(x) {\n ++x;\n while (x % 10 === 0) {\n x /= 10;\n }\n return x;\n}\n\nfunction sol() {\n const visited = {};\n let x = Number(input);\n visited[x] = true;\n let count = 1;\n while (!visited[f(x)]) {\n x = f(x);\n visited[x] = true;\n ++count;\n }\n process.stdout.write(count.toString(), 'utf8', () => process.stdout.end());\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f56b64c5c44fbd2a1193d2cd74a1cf0a", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar ans = 0,\n metColumn = false;\n\n\nrl.on('line', (s) => {\n\n if (s == 'BBBBBBBB') \n ans++;\n else if (!metColumn) {\n //console.log(\"inside else if metColumn= &s\",metColumn)\n let helper= s.match(/B/g);\n if(helper!=null) \n ans += helper.length;\n metColumn = true;\n }\n\n}).on('close', () => {\n console.log(ans);\n rl.close();\n\n\n});", "lang_cluster": "Javascript", "tags": ["brute force", "constructive algorithms"], "code_uid": "aec1d78c96971b559895744444947cab", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction printResult(x) {\n process.stdout.write(x);\n}\n\nfunction main() {\n const arrPoints = new Array(8);\n for (let i = 0; i < 8; i++) {\n let rl = readLine().split(' ').map(Number);\n arrPoints[i] = new Point(rl[0], rl[1]);\n }\n\n // console.log('eee',arrPoints[0].x);\n // const result = eightPointSet(arrPoints);\n eightPointSet(arrPoints);\n // printResult(result.toString());\n}\n\nfunction Point(x, y)\n{\n this.x = x;\n this.y = y;\n}\n\nconst comparePoints = (a, b) => {\n if (a.x < b.x || (a.x === b.x && a.y < b.y)) {\n return -1;\n }\n if (a.x > b.x || (a.x === b.x && a.y > b.y)) {\n return 1;\n }\n return 0;\n}\n\nconst eightPointSet = (a) => {\n a.sort(comparePoints);\n if (a[0].x === a[1].x && a[1].x === a[2].x\n && a[2].x !== a[3].x\n && a[3].x === a[4].x\n && a[4].x !== a[5].x\n && a[5].x === a[6].x && a[6].x === a[7].x\n && a[0].y === a[3].y && a[3].y === a[5].y\n && a[5].y !== a[1].y\n && a[1].y === a[6].y\n && a[6].y !== a[2].y\n && a[2].y === a[4].y && a[4].y === a[7].y) {\n printResult('respectable');\n } else {\n printResult('ugly');\n }\n};\n", "lang_cluster": "Javascript", "tags": ["sortings"], "code_uid": "9b651d34314ae19ff4859f7a56087ca5", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nlet secondLine = false;\n\n\n// Create readline Interface\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet inputs = [];\n\n\n\nrl.on('line', lineInput => {\n inputs.push(lineInput);\n})\n\n// Read Inputs\nrl.on('close', () => {\n inputs = inputs[0].split(' ');\n const n = parseInt(inputs[0]);\n const m = parseInt(inputs[1]);\n let moves = 0;\n\n if (n < m)\n return console.log(-1)\n\n moves = Math.floor(n / 2) + n % 2;\n \n while (moves%m !== 0 && moves < n) {\n moves +=1;\n }\n \n console.log(moves);\n\n});", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "34fd9cb95ef34ca5858c97b2df0b5426", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\nconst luckyNumber = () => {\n let ar = [];\n let sum = 0;\n for (const x of input[0]) {\n ar.push(+x);\n }\n for (const y of ar) {\n if (y === 4 || y === 7) {\n sum ++;\n }\n }\n if (sum % 10 === 4 || sum % 10 === 7) {\n console.log('YES');\n }\n else {\n console.log('NO');\n }\n\n};\n\nreadLine.on('close', luckyNumber);", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "cb09837667b96f3399f751e22965d535", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\nconst lines = []\nrl.on('line', (input) => {\n lines.push(input);\n})\nrl.on('close', () => {\n// (function() {\n // const lines = require('fs').readFileSync('test.in', 'utf8').split('\\n')\n let l = 0;\n let t = 1//+lines[l++]\n const output = []\n for (let i = 0; i < t; i++) {\n let [n, k] = lines[l++].trim().split(' ')\n n = +n\n output[i] = solve(n, k)\n }\n console.log(output.join('\\n'))\n// })()\n})\n\nfunction solve(n, k) {\n if (k.length >= n) return 0\n let has = 0\n for (let i = 0; i < k.length; i++) {\n if (+k[i] > 1) {\n has = 1\n break\n }\n }\n if (!has) return -1\n\n let q = {}\n q[k] = 1\n has = 1\n let count = 1\n const visited = {}\n while (has) {\n const nq = {}\n has = 0\n for (let s in q) {\n const bs = BigInt(s)\n for (let i = 0; i < s.length; i++) {\n const x = BigInt(s[i])\n const nx = bs * x\n if (visited[nx]) continue\n visited[nx] = 1\n // console.log(count, nx)\n if (String(nx).length >= n) return count\n nq[nx] = 1\n has = 1\n }\n }\n q = nq\n count++\n }\n return count\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "dfs and similar", "shortest paths", "dp", "data structures"], "code_uid": "243ebd425c0ae253d0e766bb1cafe808", "src_uid": "cedcc3cee864bf8684148df93804d029", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data', input => {\n let [ l, h, a ] = input.toString().split(' ');\n let ln = l % a == 0 ? l / a : (l / a) + 1;\n let hn = h % a == 0 ? h / a : (h / a) + 1;\n\n ln = ln | 0;\n hn = hn | 0;\n\n console.log(ln * hn);\n});\n\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "7d77e31b39aceb8c660b11c3b3c67db3", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\n \nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nvar lines = [];\nrl.on('line', function(input) {\n lines.push(input);\n});\nrl.on('close', function() {\n var l = 0;\n console.log(solve(+lines[l++]))\n});\n\nfunction solve(n) {\n const dp = Array(n + 1).fill(0)\n for (let i = 1; i < n; i++) {\n for (let j = i + i; j <= n; j += i) {\n dp[j]++\n }\n }\n let sum = 1\n for (let i = 1; i <= n; i++) {\n dp[i] = add(dp[i], sum)\n sum = add(sum, dp[i])\n }\n return dp[n]\n}\n\nfunction add(a, b) {\n return (a + b) % 998244353\n}\n", "lang_cluster": "Javascript", "tags": ["math", "dp", "combinatorics"], "code_uid": "afd8f28a269f10121cc041a77209674f", "src_uid": "09be46206a151c237dc9912df7e0f057", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\nlet input = [];\nconst readline=require('readline');\nconst RL=readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nRL.on('line', (line)=>{\n input.push(line.trim());\n});\nRL.on('close', ()=>{\n let [n, k]=input[0].split(\" \");\n const arr=input[1].split(\" \");\n const scores=arr.map((str)=>{\n return Number(str);\n });\n\n let answer=0;\n const Kth=Number(k);\n scores.forEach(element => {\n if(element>0 && element>=scores[Kth-1]){\n answer++;\n }\n });\n console.log(answer);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "9a7bc2aabbcf030ecde2bf3446286869", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (str) => {\n if (c === 0) {\n c++;\n return;\n }\n\n let ans = 'YES';\n let sevens = 0;\n let fours = 0;\n\n for (let i = 0; i < str.length / 2; i++) {\n if (str[i] === '4') {\n fours++;\n }\n else if (str[i] === '7') {\n sevens++;\n }\n else {\n ans = 'NO';\n }\n }\n\n for (let i = str.length / 2; i < str.length; i++) {\n if (str[i] === '4') {\n fours--;\n }\n else if (str[i] === '7') {\n sevens--;\n }\n else {\n ans = 'NO';\n }\n }\n\n if (fours === 0 && sevens === 0) {\n console.log(ans);\n }\n else {\n console.log('NO');\n }\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "1e3a11a6c93d9e062ddb759a0d4dd82a", "src_uid": "435b6d48f99d90caab828049a2c9e2a7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// author: Oscar Ramos\n\n/// Source Code\n// const input = require('competitive-programming-js').inputReader\n// \n// const s1 = input.readLine().toLowerCase()\n// const s2 = input.readLine().toLowerCase()\n// \n// console.log(s1 < s2? -1: s1===s2? 0: 1)\n// \n\n!function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&\"object\"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,\"default\",{enumerable:!0,value:e}),2&n&&\"string\"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,\"a\",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p=\"\",t(t.s=0)}([function(e,n,t){e.exports=t(1)},function(e,n){let t,r=0,o={readLine:function(){return t[r++]}};var u=\"\";process.stdin.resume(),process.stdin.setEncoding(\"utf8\"),process.stdin.on(\"data\",(function(e){u+=e})).on(\"end\",(function(){t=u.trim().split(\"\\n\").map(e=>e.trim());const e=o.readLine().toLowerCase(),n=o.readLine().toLowerCase();console.log(e {\n inputString = inputString.trim().split('\\n').map(string => string.trim());\n main();\n process.exit();\n}\nconst readLine = () => inputString[currentLine++];\n\nprocess.stdin.on('data', inputStdin => inputString += inputStdin);\nprocess.stdin.on('end', runMain);\nprocess.on('SIGINT', runMain);\n\nfunction main() {\n const [n, m] = readLine().split(' ');\n console.log(Math.floor((n * m) / 2));\n}\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "279da2f8d5cb7bb561f05f13b6576d19", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('ascii');\nvar inputString=\"\";\nvar currentLine=0;\n\nprocess.stdin.on('data',function(data){\n\tinputString+=data;\n});\nprocess.stdin.on('end',function(){\n\tinputString=inputString.split('\\n');\n\tmain();\n});\nfunction readline(){\n\treturn inputString[currentLine++];\n}\nfunction main(){\n\t var[m,n,a]=(readline().split(' '));\n\t var ans=Math.ceil(m/a)*Math.ceil(n/a);\n\t console.log(ans);\n}\n\n\t ", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "8c09f329ec68f8918027012bbbcb7826", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var fs = require('fs')\nvar pb = fs.readFileSync(0, {encoding: \"utf8\"});\n\nvar [n, m, a] = pb.split(' ').map(x => parseInt(x, 10))\n\nconsole.log(Math.ceil(n/a) * Math.ceil(m/a))\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "016c0c1f9dfcc583ae23b55870ca2669", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n let [number, n] = readline().split(\" \").map(x => parseInt(x));\n\n for (var i = 0; i < n; i++) {\n if (number % 10 === 0) {\n number /= 10;\n } else {\n number--\n }\n }\n console.log(number);\n \n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "8759fb7ee4501777116e0c24ebf30d93", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction multiply(a, b) {\n\ta = a.toString(10).split('').reverse();\n\tb = b.toString(10).split('').reverse();\n\n\tif (a.length < b.length) {\n\t\t[a, b] = [b, a];\n\t}\n\n\tlet res = Array(a.length + b.length).fill(0);\n\tfor (let i = 0, lb = b.length; i < lb; ++i) {\n\t\tlet carry = 0;\n\t\tlet scarry = 0;\n\t\tfor (let j = 0, la = a.length; j < la; ++j) {\n\t\t\tlet m = b[i] * a[j];\n\t\t\tm += carry;\n\n\t\t\tif (m > 9) {\n\t\t\t\tlet [c, d] = m.toString(10).split('');\n\t\t\t\tres[i + j] += (scarry >> 0) + (d >> 0);\n\t\t\t\tcarry = c >> 0;\n\t\t\t} else {\n\t\t\t\tres[i + j] += (scarry >> 0) + m;\n\t\t\t\tcarry = 0;\n\t\t\t}\n\n\t\t\tif (res[i + j] > 9) {\n\t\t\t\tlet [c, d] = res[i + j].toString(10).split('');\n\t\t\t\tres[i + j] = d >> 0;\n\t\t\t\tscarry = c;\n\t\t\t} else {\n\t\t\t\tscarry = 0;\n\t\t\t}\n\t\t}\n\t\tif (carry > 0) res[a.length + i] = carry;\n\t\tif (scarry > 0) res[a.length + i] = scarry;\n\t}\n\n\tres.reverse();\n\tlet mulVal = '';\n\tlet flag = false;\n\tres.forEach(d => {\n\t\tif (!flag && d !== 0) flag = true;\n\t\tif (flag) mulVal += d;\n\t});\n\treturn mulVal;\n}\n\nfunction main() {\n\tlet [n, m] = readLine()\n\t\t.split(' ')\n\t\t.map(x => x >> 0);\n\tlet q = readLine()\n\t\t.split(' ')\n\t\t.map(x => x >> 0);\n\tq = q.map(x => (x <= m ? 0 : Math.ceil(x / m)));\n\n\tlet max = 0,\n\t\tv = 0;\n\tfor (let i = 0; i < n; ++i) {\n\t\tif (q[i] >= max) {\n\t\t\tmax = q[i];\n\t\t\tv = i + 1;\n\t\t}\n\t}\n\tconsole.log(v);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "19132f898a4330513ccbd38d503c48e1", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let newString = '';\n\nlet transformString = ( character ) => { \n if( !character.match(/[aeiouy]/gi) ){\n newString += `.${character}`;\n }\n};\nprocess.stdin.once('data', (input) => {\n Array.from( input.toString().trim().toLowerCase() ).map( ( char ) => transformString( char ) ); \n console.log(newString);\n process.exit();\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "9acb724970b79abc9dea9210486eebff", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', (inputStdin) => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', (_) => {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((string) => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\n// Make a Snippet for the code above this and then write your logic in main()\nfunction main() {\n const s = readline();\n const t = readline();\n helper(s, t);\n}\n\nfunction helper(s, t) {\n if (s.length < t.length) {\n console.log('need tree');\n return;\n }\n if (s.indexOf(t) > -1) {\n console.log('automaton');\n return;\n }\n let need_tree = false;\n let automaton = false;\n let array = false;\n\n let cntT = new Array(26).fill(0);\n for (let i = 0; i < t.length; i++) {\n cntT[t.charCodeAt(i) - 97]++;\n }\n\n let cntS = new Array(26).fill(0);\n for (let i = 0; i < s.length; i++) {\n cntS[s.charCodeAt(i) - 97]++;\n }\n\n for (let i = 0; i < 26; i++) {\n if (cntT[i] > cntS[i]) {\n need_tree = true;\n break;\n }\n if (cntT[i] < cntS[i]) {\n automaton = true;\n }\n }\n\n if (need_tree) {\n console.log('need tree');\n return;\n }\n\n let match = -1;\n let found = 0\n for (let i = 0; i < t.length; i++) {\n found = s.indexOf(t.charAt(i), match + 1)\n if (found > match) {\n match = found;\n } else {\n array = true;\n break;\n }\n }\n\n if (automaton && array) {\n console.log('both');\n return;\n }\n if (automaton) {\n console.log('automaton');\n return;\n }\n console.log('array');\n return;\n}\n\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "577ac8431cbe74dbbc13bf67bc597240", "src_uid": "edb9d51e009a59a340d7d589bb335c14", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nconst solve = (row, col) => {\n if (row === 1 || col === 1) {\n return 1;\n }\n\n return solve(row - 1, col) + solve(row, col - 1);\n}\n\nrl.on('line', (d) => {\n console.log(solve(+d, +d));\n\n // const matrix = new Array(+d).fill(1).map(x => new Array(+d).fill(1));\n // let ans = 0;\n\n // for (let i = 0; i < matrix.length; i++) {\n // for (let j = 0; j < matrix[i].length; j++) {\n // let v = 0;\n // if (Number.isInteger(matrix[i][j - 1])) {\n // v += matrix[i][j - 1];\n // }\n\n // if (matrix[i - 1] && Number.isInteger(matrix[i - 1][j])) {\n // v += matrix[i - 1][j]\n // }\n\n // matrix[i][j] = Math.max(1, v);\n // ans += matrix[i][j];\n // }\n // }\n\n // console.log(matrix);\n // console.log(matrix[matrix.length - 1][matrix.length - 1]);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "aecc69f4b20f72ef369dfa40cf2cfb68", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n let ans = 'NO';\n let count = 0;\n\n for (let i = 0; i < d.length; i++) {\n if (d[i] === '7' || d[i] === '4') {\n count++;\n }\n }\n\n if (count === 7 || count === 4) {\n ans = 'YES';\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "effda2cebde962aa8a9749e1567546fd", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\nreadline.question(\"\", (word) => {\n let Ca=0,Sm=0;\n for(let i of word){\n if(i==i.toUpperCase()){\n Ca++;\n }else{\n Sm++;\n }\n }\n if(Ca>Sm){\n console.log(word.toUpperCase());\n }else{\n console.log(word.toLowerCase());\n }\n readline.close()\n})", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "ba00b69437ab015419abdddd6071d16a", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nlet readline = require('readline').createInterface({\n input: process.stdin,\n});\n\nreadline.on('line', (line) => {\n let [a, b, c, d] = line.split(' ').map(Number);\n [a, b, c] = [a, b, c].sort((x,y)=> x-y)\n console.log(\n Math.max(0, d - (b - a)) + Math.max(0, d - (c - b))\n )\n});\n\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "7d43dd58fbacdce94a9ca1d989d23b51", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst r = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet n,k;\nlet input;\nr.on('line', (line) => {\n if (!n) { \n [n,k] = line.split(\" \").map(n=>+n);\n }\n else {\n let nums = line.split(\" \").map(n => +n);\n let marks = nums[k-1];\n console.log(nums.filter(n => n >= marks && n > 0 ).length);\n }\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "db6fee79323ccf69a56a18656c8c063b", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n logic(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction output(x) {\n process.stdout.write(x); // without auto '\\n' (newline)\n //console.log(x); // with auto '\\n' (newline)\n}\n\n\nfunction logic() {\n const line = readline();\n \n const params = line.split(' ');\n const number = parseInt(params[0]);\n const iterations = parseInt(params[1]);\n \n let result = number;\n for (let i=1; i <= iterations; i++) {\n \n if (result/10 !== parseInt(result/10)) {\n result--;\n }\n else {\n result /= 10;\n }\n }\n\n output(String(result));\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3f573ddb528be78a43bae0b068c9b7e9", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar inputs = [];\nconst PI = parseInt;\n\nfunction main() {\n const [f, t] = inputs[0].split(\" \").map(_ => parseInt(_));\n\n let reach = false;\n let min = Number.MAX_VALUE;\n const rec = (from, lvl) => {\n //console.log(from, lvl);\n if(from > t) return;\n if (reach === true) return;\n if (from === t) { reach = true; min = Math.min(min, lvl); return; };\n rec(from * 3, lvl + 1), rec(from * 2, lvl + 1);\n };\n rec(f, 0)\n console.log((reach) ? min : -1);\n}\n\nreadline.on('line', (input) => { inputs.push(input); });\nreadline.on('close', main)", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "bf83f5676cf573b4382782aa4a3f6420", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\n// thats all what you have to write to get input from stdin, using readLine.\n\n\n// Main code runs in main();\n\n\nfunction main() {\nconst num = readline().split(\" \").map(x => parseInt(x))\nlet k = parseInt(num[1]);\nlet x = `${num[0]}`.split('');\nfor (let i=0;i input.push(line));\n\nreadLine.on('close', () => {\n let [n] = input[0].split(' ').map(x => parseInt(x));\n const matrix = [];\n\n for (let i = 0; i < n; i += 1) matrix.push(Array(n).fill(1));\n\n for (let i = 1; i < n; i += 1) {\n for (let j = 1; j < n; j += 1) {\n matrix[i][j] = matrix[i][j-1]+matrix[i-1][j];\n }\n }\n\n console.log(matrix[n-1][n-1]);\n}); \n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "7ed303c4019f87a71c841b0813e50657", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nlet input = ''\nlet solution = function(x, arr) {\n let memo = {}\n let recur = function(n) {\n if (memo[n] != null) return memo[n]\n if (n < 0) return Number.MIN_SAFE_INTEGER\n if (n === 0) return 0\n let max = Number.MIN_SAFE_INTEGER\n for (let j of arr) {\n max = Math.max(max, 1 + recur(n - j))\n }\n memo[n] = max\n return max\n }\n return recur(x)\n}\nrl.on('line', (line) => {\n input += line\n input = input.split(' ').map(x => parseInt(x))\n\n let n = input[0]\n let arr = input.slice(0)\n console.log(solution(n, arr))\n})", "lang_cluster": "Javascript", "tags": ["brute force", "dp"], "code_uid": "8c079286f7065d19a840a50e84ac1be7", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let shoesArray = readLine().split(' ').map(Number);\n let selecTed = []; // [1, 7, 3, 3]\n for (let i = 0; i < shoesArray.length; i++) {\n if (selecTed.indexOf(shoesArray[i]) === -1) {\n selecTed.push(shoesArray[i]);\n }\n }\n let result = shoesArray.length - selecTed.length;\n console.log(result);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "7223e1059f9cc92f879055d2d519ca60", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n let [k, r] = d.split(' ').map(Number);\n let ans = 0;\n let coin = 10;\n let c = 1;\n let v = k;\n\n while (true) {\n if (v % coin === 0 || v % coin === r) {\n break;\n }\n else {\n ans++;\n v = k * c;\n c++;\n }\n }\n\n console.log(Math.max(1, ans));\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "274cec4ce6059509a85021674f46703a", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\n// thats all what you have to write to get input from stdin, using readLine.\n\n\n// Main code runs in main();\n\n\nfunction main() {\nconst num = readline().split(\" \").map(x => parseInt(x))\nlet k = parseInt(num[1]);\nlet n = parseInt(num[0]);\nfor(let i=0;i i += c)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os')\n const lines = i.split(EOL) /*your input text, split by lines*/\n const [n, k] = lines[0].split(' ').map(r => parseInt(r))\n const scores = n > 0 ? lines[1].split(' ').map(r => parseInt(r)) : []\n const v = scores[k - 1]\n const count = scores.reduce((s, r) => r >= v && r > 0 ? s + 1 : s, 0)\n \n console.log(count);\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "5cdaa500855884fceb4db6bd4208a7f7", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var fs = require('fs');\nvar input = fs.readFileSync(0, 'utf8').trim().split('\\n');\nvar currentline = 0;\nfunction readline() {\n return input[currentline++];\n}\nvar T = readline();\nfor (var i = 0; i < T; i++) {\n var n = parseInt(readline());\n var ans = 0;\n for (var j = 0; j * j <= n; j++)\n ans++;\n for (var j = 0; j * j * j <= n; j++)\n ans++;\n for (var j = 0; j * j * j * j * j * j <= n; j++)\n ans--;\n console.log(ans - 1);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "39656b91b08ee960a798a38009016cf4", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (w) => {\n let lowerCount = 0;\n let upperCount = 0;\n\n for (let i = 0; i < w.length; i++) {\n if (w.charCodeAt(i) > 64 && w.charCodeAt(i) < 97) {\n upperCount++;\n }\n else {\n lowerCount++;\n }\n }\n\n if (upperCount > lowerCount) {\n console.log(w.toUpperCase());\n }\n else {\n console.log(w.toLowerCase());\n }\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "1cc341d9ddc4d4ee0fa0bd9edde46896", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\nconst matrix = () => {\n let oneStringRow;\n let oneColumn;\n let steps;\n for (let i = 0; i < input.length; i++) {\n if (input[i].includes('1')) {\n oneStringRow = i;\n oneColumn = input[i].indexOf('1') / 2;\n }\n }\n steps = Math.abs(2 - oneStringRow) + Math.abs(2 - oneColumn);\n console.log(steps);\n};\nreadLine.on('close', matrix);", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "625ffa976e54398beb26da4ec469f19e", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const start=(main, readlineFun, printFun) => {\n if (readlineFun && printFun) {\n main(readlineFun, printFun);\n return;\n }\n\n process.stdin.resume();\n process.stdin.setEncoding(\"utf8\");\n\n let input = \"\",\n readline,\n print;\n\n process.stdin.on(\"data\", function(chunk) {\n input += chunk;\n });\n\n process.stdin.on(\"end\", function() {\n input = input.split(\"\\n\");\n print = function(data) {\n process.stdout.write(data + \"\\n\");\n };\n let inputLineIndex = 0;\n readline = function() {\n return inputLineIndex >= input.length\n ? undefined\n : input[inputLineIndex++];\n };\n process.exit(main(readline, print) || 0);\n });\n} \n function main(readline, print) {\n let a = readline().split(\" \");\n print(Math.ceil(a[0] / a[2]) * Math.ceil(a[1] / a[2]));\n} \n start(main);", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "72569519c336492444039e0b1aae37f2", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var read = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\nvar obj;\nvar inLine = [];\nread.on('line', function (input) { inLine.push(input); });\nread.on('close', function () {\n obj = init(inLine);\n myerr(\"-----start-----\");\n var start = new Date();\n Main();\n var end = new Date() - start;\n myerr(\"----- end -----\");\n myerr(\"Time: \" + (end) + \"ms\");\n myerr(\"Memory: \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction nextInt() { return myconv(next(), 1); }\nfunction nextStrArray() { return myconv(next(), 2); }\nfunction nextIntArray() { return myconv(next(), 4); }\nfunction nextCharArray() { return myconv(next(), 6); }\nfunction next() { return obj.next(); }\nfunction hasNext() { return obj.hasNext(); }\nfunction init(input) {\n var returnObj = {\n list: input, index: 0, max: input.length,\n hasNext: function () { return (this.index < this.max); },\n next: function () { if (!this.hasNext()) { throw \"ArrayIndexOutOfBoundsException\"; } else { var returnInput = this.list[this.index]; this.index++; return returnInput; } }\n };\n return returnObj;\n}\nfunction myout(s) { console.log(s); }\nfunction myerr(s) { console.error(\"debug:\" + require(\"util\").inspect(s, false, null)); }\nfunction myconv(i, no) { try { switch (no) { case 1: return parseInt(i); case 2: return i.split(\" \"); case 4: return i.split(\" \").map(Number); case 6: return i.split(\"\"); case 7: return i.split(\"\").map(Number); case 8: return i.join(\" \"); case 9: return i.join(\"\\n\"); case 0: return i.join(\"\"); default: return i; } } catch (e) { return i; } }\n\n\nfunction Main() {\n var n = nextIntArray();\n\n return myout(Math.floor((n[0] * n[1]) / 2));\n} // Use Terminal to debug, not Debug Console!", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "d4dd76e7eec25ab52391a6f21d60cd30", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString='';\nlet currentLine=0;\nprocess.stdin.on('data',inputStdin=>{\n inputString+=inputStdin;\n});\nprocess.stdin.on('end',_=>{\n inputString=inputString.trim().split(\"\\n\").map(string=>{\n return string.trim();\n });\n main();\n});\nfunction readLine()\n{\n return inputString[currentLine++]; \n}\nfunction ans(s)\n{\n let zer=[-1,-1],tw=-1,se=-1,fi=-1,fnz=-1;\n for(let i=1;i=0;--i)\n {\n if(s[i]=='7')\n {\n se=i;\n break;\n }\n }\n for(let i=s.length-1;i>=0;--i)\n {\n if(s[i]=='2')\n {\n tw=i;\n break;\n }\n }\n for(let i=s.length-1;i>=0;--i)\n {\n if(s[i]=='5')\n {\n fi=i;\n break;\n }\n }\n let k=0;\n for(let i=s.length-1;i>=0;--i)\n {\n if(s[i]=='0')\n {\n zer[k++]=i;\n if(k==2)\n break;\n }\n }\n zer.length=k;\n if(fi==-1)\n {\n if(zer.length<2)\n return -1;\n return (2*s.length-3-zer[0]-zer[1]);\n }\n else\n {\n let ac=[];\n if(zer.length>=2)\n {\n ac.push(2*s.length-3-zer[0]-zer[1]);\n }\n if((zer.length>=1)&&(fi!=-1))\n {\n ac.push(2*s.length-3-zer[0]-fi+(fi>zer[0]?1:0)+(fi===0?(zer[0]==1?0:fnz):0));\n }\n if((tw!=-1)&&(fi!=-1))\n {\n ac.push(2*s.length-3-tw-fi+(tw>fi?1:0)+(Math.min(fi,tw)===0?fnz:0));\n }\n if((se!=-1)&&(fi!=-1))\n {\n ac.push(2*s.length-3-se-fi+(se>fi?1:0)+(Math.min(fi,se)===0?fnz:0));\n }\n if(ac.length!==0)\n return Math.min.apply(Math,ac);\n else\n return -1;\n }\n}\nfunction main()\n{\n let n=readLine().trim();\n console.log(ans(n));\n}", "lang_cluster": "Javascript", "tags": ["brute force", "greedy"], "code_uid": "de620e580ba2c47935db03be665a672c", "src_uid": "ea1c737956f88be94107f2565ca8bbfd", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let s = readLine();\n let ans = 0;\n for (var i = 0; i < s.length; i++) {\n let oke = 1;\n for (var j = 7; j > 0; j--) {\n if (s[i + 7 - j] != s[i]) {\n oke = 0;\n break;\n }\n }\n if (oke == 1) {\n ans++;\n break;\n }\n }\n if (ans == 1) {\n console.log('YES')\n } else console.log('NO')\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "d41bfe2fd2f2f620e4db75dde174ed60", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Is your horseshoe on the other hoof?\n\nconst {EOL} = require('os');\n\nlet inp = '';\n\nprocess.stdin.on('data', c => inp += c);\n\nprocess.stdin.on('end', () => {\n let lines = inp.split(EOL)[0].split(' ');\n \n process.stdout.write((lines.length - (new Set(lines)).size) + '');\n\n return;\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "6ef7bea5c22d43e9d45405fed336de7d", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n const k = input[0];\n const l = input[1];\n const answ = [];\n\n for (let i = 0; i < k.length; i += 1) {\n if (k[i] !== l[i]) answ.push(1);\n else answ.push(0);\n }\n\n console.log(answ.join(''));\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "1b8e84ee24d435cfde4bddd86607391e", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\nconst check = year => \n String(year)[0] !== String(year)[1] && String(year)[1] !== String(year)[2] && String(year)[3] !== String(year)[2]\n && String(year)[0] !== String(year)[2] && String(year)[1] !== String(year)[3] && String(year)[0] !== String(year)[3];\n\nreadLine.on('close', () => {\n let answer = 0;\n let year = parseInt(input[0]) + 1;\n\n while (!check(year)) {\n year += 1;\n }\n\n console.log(year);\n});", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "19f725843f678f06a9fff362f04b8aac", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "function main() {\n var n = +nxt(), m = +nxt(), k = +nxt() - 1;\n function ok(val) {\n var u = Math.min(k + val - 1, n - 1) - k + 1;\n var v = k - Math.max(k - val + 1, 0) + 1;\n var s1 = (val + val - u + 1) * u / 2;\n var s2 = (val + val - v + 1) * v / 2;\n return (s1 + s2 - val + n - u - v + 1) <= m;\n }\n var l = 1, r = m;\n while (l < r) {\n var mid = l + ((r - l + 1) >> 1);\n if (ok(mid)) l = mid;\n else r = mid - 1;\n }\n print(l);\n}\n\nvar line = null, linepos = 0;\nfunction nxt() {\n if (!line || linepos === line.length) {\n line = readline().split(' ');\n linepos = 0;\n }\n return line[linepos++];\n}\n\nif (typeof readline == 'undefined') {\n process.stdin.resume();\n process.stdin.setEncoding('ascii');\n \n var input_stdin = \"\";\n process.stdin.on('data', function (data) { input_stdin += data; });\n process.stdin.on('end', function () {\n // input_stdin = input_stdin.split(/\\s/);\n input_stdin = input_stdin.split('\\n');\n var curline = 0;\n readline = () => input_stdin[curline++];\n if (typeof print === 'undefined') print = console.log;\n main();\n });\n} else main();\n", "lang_cluster": "Javascript", "tags": ["greedy", "binary search"], "code_uid": "294cad82105cda705f7326b2f4215dda", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const arr = readLine()\n .split(\"+\")\n .map((n) => parseInt(n));\n console.log(arr.sort().join(\"+\"));\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "0c358550ff6462893ff7966bd9fd6260", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n let [n, v] = d.split(' ').map(Number);\n let ans = Math.min(n - 1, v);\n let price = 1;\n n -= v + 1;\n\n while (n > 0) {\n price++;\n ans += price;\n\n n--;\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math", "greedy", "dp"], "code_uid": "ff1e1cade76c6099558d5889ec79c723", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let data = '';\nprocess.stdin.on('data', c => data += c);\n\nconst solution = () => {\n\tlet a = data.trim().split(/\\n/g).map(v => v[0]).join('');\n\tlet f = ['rss', 'prr', 'spp'];\n\tlet m = ['srs', 'rpr', 'psp'];\n\tlet s = ['ssr', 'rrp', 'pps'];\n\tlet ans = '';\n\tswitch(true) {\n\t\tcase f.includes(a): ans = \"F\";\n\t\t\tbreak;\n\t\tcase m.includes(a): ans = \"M\";\n\t\t\tbreak;\n\t\tcase s.includes(a): ans = \"S\";\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tans = \"?\";\n\t}\n\tconsole.log(ans);\n\t\n\t\n};\n\n\nprocess.stdin.on('end', solution);", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "230082228a3c29c20251fa78101ced0a", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.setEncoding('utf8');\nlet input = [];\nprocess.stdin.on('readable', () => {\n const chunk = process.stdin.read();\n if (chunk !== null) {\n let re = /\\n\\s*| /;\n input = chunk.split(re).slice(0, 6);\n console.log(snowball.apply(null, input.map(value => parseInt(value))));\n process.exit(0);\n }\n});\n\nfunction snowball(weight, height, u1, d1, u2, d2) {\n let w = weight, h = height;\n for (; h >= 0; h--) {\n w += h;\n if (h == d1) w = Math.max(w - u1, 0);\n if (h == d2) w = Math.max(w - u2, 0);\n }\n return w;\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "64feb73fdd400302845a03a813a8fe41", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nfunction readLines(number, cb) {\n const lines = [];\n rl.on('line', function(line) {\n lines.push(line);\n if (lines.length === number) {\n rl.close();\n cb(lines);\n }\n });\n};\n\nfunction readLines(number, cb) {\n const lines = [];\n rl.on('line', function(line) {\n lines.push(line);\n if (lines.length === number) {\n rl.close();\n cb(lines);\n }\n });\n};\n\nfunction doIt(lines) {\n const snowBall = lines[0].split(\" \").map(x => parseInt(x));\n const stoneOne = lines[1].split(\" \").map(x => parseInt(x));\n const stoneTwo = lines[2].split(\" \").map(x => parseInt(x));\n\n let snowW = snowBall[0];\n let snowH = snowBall[1];\n \n for (let i = snowH; i>=0; i--) {\n snowW = snowW+i;\n if (i === stoneOne[1]) {\n snowW -= stoneOne[0];\n }\n\n if (i === stoneTwo[1]) {\n snowW -= stoneTwo[0];\n }\n if (snowW < 0)\n snowW = 0;\n }\n console.log(snowW);\n}\n\nreadLines(3, doIt);", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "51304ad4988c1835dd7dafc8ee0c6108", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Boy or Girl\n\nconst {EOL} = require('os');\n\nlet inp = '';\n\nprocess.stdin.on('data', c => inp += c);\n\nprocess.stdin.on('end', () => {\n process.stdout.write(((new Set(inp.split(EOL)[0].split(''))).size % 2) ? \"IGNORE HIM!\" : \"CHAT WITH HER!\");\n\n return;\n});", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "19e3683c3d5f70023c6399075ee91688", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', function(line){\n let r = `0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999`.charAt(+line);\n console.log(r);\n process.exit(0);\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "11434e846b20d87793cfb287fd7b161f", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet k, l, m, n, d;\nlet ans = 0;\n\nrl.on('line', (data) => {\n if (c === 0) {\n k = +data;\n c++;\n return;\n }\n\n if (c === 1) {\n l = +data;\n c++;\n return;\n }\n\n if (c === 2) {\n m = +data;\n c++;\n return;\n }\n\n if (c === 3) {\n n = +data;\n c++;\n return;\n }\n\n if (c === 4) {\n d = +data;\n c++;\n }\n\n for (let i = 1; i <= d; i++) {\n if (i % k === 0 || i % l === 0 || i % m === 0 || i % n === 0) {\n ans++;\n }\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "e3003136fbd14ee1865f4c832535b5d0", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data', input => {\n const [n, m, a] = String(input).split(' ').map(i => parseInt(i));\n\n n_neded = 0;\n m_neded = 0;\n\n if (n % a != 0) {\n n_neded = Math.floor(n / a) + 1;\n } else {\n n_neded = Math.floor(n / a);\n }\n\n if (m % a != 0) {\n m_neded = Math.floor(m / a) + 1;\n } else {\n m_neded = Math.floor(m / a);\n }\n\n console.log(n_neded * m_neded);\n }\n)", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "8bb0b7fe2d5e406293cab72914292751", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function solve(input, target) {\n const D = [];\n for (let i = 0; i < target.length; i++) {\n D.push([]);\n }\n for (let i = 0; i < input.length; i++) {\n D[0][i] = input[i] === target[0] ? 1 : 0;\n }\n for (let j = 1; j < target.length; j++) {\n for (let i = 0; i < input.length; i++) {\n if (input[i] !== target[j]) {\n D[j][i] = 0;\n continue;\n }\n D[j][i] = D[j - 1].slice(0, i).reduce((acc, v) => acc + v, 0);\n }\n }\n return D.pop().reduce((acc, v) => acc + v);\n}\n\nfunction* main() {\n const input = yield;\n const r = solve(input, \"QAQ\");\n console.log(r);\n process.exit(0);\n}\n\nif (!module.parent) {\n (() => {\n const q = main();\n q.next();\n require(\"readline\")\n .createInterface({\n input: process.stdin,\n output: null\n })\n .on(\"line\", line => q.next(line));\n })();\n}\nexports.solve = solve;\n", "lang_cluster": "Javascript", "tags": ["brute force", "dp"], "code_uid": "da54c90fc5b3b4ce9f770d4dc9df341b", "src_uid": "8aef4947322438664bd8610632fe0947", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function solution(num){ \n var sf = num.match(/SF/g), fs = num.match(/FS/g)\n return (sf? sf.length: 0) > (fs? fs.length: 0)? \"YES\": \"NO\"\n}\nprocess.stdin.addListener(\"data\", (data)=>{\n var num = data.toString().replace(/\\d+\\s+/, \"\");\n console.log(solution(num))\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "27eb74397e0fcb532ccf460d42c7945b", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = ''\nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os')\n const lines = i.split(EOL)\n \n const weight = parseInt(lines[0]);\n const answer = (weight <= 2 || weight % 2 !== 0) ? \"NO\" : \"YES\";\n console.log(answer);\n})", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "44a97e881ba6dbc712b04f98154758c0", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const matrix = [];\n for (let i = 0; i < 3; i++) {\n let row = readLine()\n .split(\" \")\n .map((n) => parseInt(n) % 2);\n matrix.push(row);\n }\n const dp = [...Array(3).fill(0)].map((_) => Array(3).fill(0));\n\n function addToAdjacent(row, col, val) {\n dp[row][col] += val;\n if (row + 1 < 3) {\n dp[row + 1][col] += val;\n }\n if (row - 1 >= 0) {\n dp[row - 1][col] += val;\n }\n if (col + 1 < 3) {\n dp[row][col + 1] += val;\n }\n if (col - 1 >= 0) {\n dp[row][col - 1] += val;\n }\n }\n\n for (let row = 0; row < 3; row++) {\n for (let col = 0; col < 3; col++) {\n addToAdjacent(row, col, matrix[row][col]);\n }\n }\n\n for (let row = 0; row < 3; row++) {\n let _row = \"\";\n for (let col = 0; col < 3; col++) {\n const val = dp[row][col];\n if (val % 2 === 0) _row += \"1\";\n else _row += \"0\";\n }\n\n console.log(_row);\n }\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "ed88f5edb64d2f8849fe3d3b6af9e9e1", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n\tvar s = nextCharArray();\n\tvar N = s.length;\n\tvar output = [];\n\tif(N % 2 == 0){\n\t\twhile(s.length > 0){\n\t\t\toutput.unshift(s.pop());\n\t\t\toutput.unshift(s.shift());\n\t\t}\n\t}else{\n\t\twhile(s.length > 1){\n\t\t\toutput.unshift(s.shift());\n\t\t\toutput.unshift(s.pop());\n\t\t}\n\t\toutput.unshift(s.pop());\n\t}\n\tmyout(myconv(output, 0));\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "d7a0beb4a5e2b532afb26f73799c1a28", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n });\n\n let l=0;\n rl.on('line', (input) => {\n if (l==0) {l++}\n else {\n rl.close(); \n let strArray = input.split(\" \")\n let s = strArray.map(function(item) {\n return parseInt(item, 10);\n });\n s = s.sort(function sortNumber(a,b) {\n return a - b;\n })\n let res=0;\n for(let i=0;i0) {\n res+=d\n }\n }\n console.log(res)\n return 0;\n}\n});\n", "lang_cluster": "Javascript", "tags": ["sortings"], "code_uid": "195c0497d9c1b2adffbf2c261c23afb1", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let t = readLine()\n let str = readLine()\n let count = 0\n \n for (let i = 0; i < str.length-1; i++) {\n if (str[i+1] === str[i]) count += 1\n }\n \n console.log(count)\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3ff1211dd775116fa731f2d8e2de48ad", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n const n = +stdin[0];\n var a = [];\n for (var z = 0; z < 20; z++) {\n a[z] = []\n for (var i = 0; i < 500000; i++) {\n a[z][i] = i * z;\n }\n }\n var s = 0;\n for (var z = 0; z < 20; z++) {\n for (var i = 0; i < 500000; i++) {\n s += a[z][i];\n }\n }\n console.log(n * 3 / 2);\n}\n\nconst readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\n\nvar stdin = [];\n\nrl.on('line', function (line) {stdin.push(line);});\nrl.on('close', main);\n", "lang_cluster": "Javascript", "tags": ["math", "number theory"], "code_uid": "3c47079ef625f89670c8210cef09f384", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let readline = require('readline');\nlet intInput = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n});\nlet arr;\n\nintInput.on('line', (line) => {\n\tarr = line.split(\" \").map(s => +s)\n});\nintInput.on('close', () => {\n\tlet result = 'No';\n\tlet [memb, pen, note] = arr;\n\tif ( pen >= memb && note >= memb ) {\n\t\tresult = 'Yes'\n\t}\n\tconsole.log(result);\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f080bd3f89770c4ad0c239c73dc6e6a2", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n \nconst input = [];\nreadLine.on('line', line => input.push(line));\n \nreadLine.on('close', () => {\nlet charA = input[0].match(/(a)/g)\ncharA = charA ? charA.length : 1\nconst allChars = input[0].length\nconst anyCars = allChars - charA\nlet _result = allChars\nif (anyCars >= charA)\n _result = (charA * 2) - 1\nconsole.log(_result)\n})", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "026ea77ffeea22b91c4c4089eb51fb9d", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n const [n, x] = input[0].split(' ').map(x => parseInt(x));\n\n let answ = 0\n for (let i = 1; i <= n; i += 1) {\n if (x % i === 0 && x/i <= n) answ += 1;\n }\n\n console.log(answ);\n}); ", "lang_cluster": "Javascript", "tags": ["implementation", "number theory"], "code_uid": "59fa257c7238f16c94bfbeec92f8589a", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet steps = 0;\n\nrl.on('line', n => {\n if (n < 5) {\n console.log(++steps);\n rl.close();\n } else {\n steps += n / 5;\n console.log(Number.isInteger(steps) ? steps : Math.floor(steps) + 1);\n rl.close();\n }\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "c045e5c2b3232e37bb0beb885a04dc36", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var line_number = 0;\nconst cs = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nvar lines = {};\ncs.on(\"line\", (input) => {\n if (input == \"\") {\n cs.close();\n }\n lines[line_number] = input.split(\" \");\n line_number += 1;\n}).on(\"close\", () => {\n main();\n process.exit();\n});\n\nfunction isOp(str) {\n return str.length === 1 && str.match(/[<=>]/);\n}\nfunction isChr(str) {\n return str.length === 1 && str.match(/[a-z]/i);\n}\nfunction isInt(str) {\n return str.length === 1 && str.match(/[0-9*]/);\n}\n\nfunction print(str) {\n console.log(str);\n}\n\nfunction exit(status = 0) {\n process.exit(status);\n}\n\nfunction predict(test) {\n let op = \"\";\n let ops = [];\n let opVariables = [];\n let limits = [];\n for (let t of test) {\n // console.log(t);\n for (let i = 0; i < t.length; i++) {\n if (isOp(t[i])) {\n op = t[i];\n if (isOp(t[i + 1])) {\n op += t[i + 1];\n i += 1;\n }\n ops.push(op);\n op = \"\";\n } else if (isChr(t[i])) {\n // console.log(t[i])\n op = t[i];\n for (var j = i + 1; j < t.length; j++) {\n if (isChr(t[j]) || isInt(t[j])) {\n op += t[j];\n i = j;\n } else break;\n }\n opVariables.push(op);\n op = \"\";\n } else {\n if (i == 0 || (i > 0 && isOp(t[i - 1]))) {\n op = t[i];\n let j = i + 1;\n for (; j < t.length; j++) {\n if (isInt(t[j])) {\n op += t[j];\n i = j;\n } else break;\n }\n limits.push(op);\n op = \"\";\n }\n }\n }\n }\n\n let min = limits[0];\n let max = limits[1];\n\n let pvs = ops.map((o, i) => [o, opVariables[i]]);\n\n for (let pv of pvs) {\n if (pv[1] == undefined) {\n pv[1] = max;\n }\n // print(`${min} ${pv[0]} ${pv[1]} ?`)\n if (eval(`${min}${pv[0]}${pv[1]}`)) {\n // print(` ${min} ${pv[0]} ${pv[1]} true`)\n min = pv[1];\n } else {\n print(\"input error\");\n exit();\n }\n }\n}\n\nvar n;\nfunction main() {\n n = BigInt(lines[0][0])\n predict([\"1<=n<=10**18\"]);\n // print(n);\n let c = 0\n do {\n x = n % 10n;\n if (x == 4 || x == 7) {\n c += 1;\n }\n } while ((n = BigInt(n / 10n)) != 0);\n\n if( c == 4 || c == 7) {\n print(\"YES\")\n }\n else{\n print(\"NO\")\n }\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e52741565a1f6251ccdfb3a036930513", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', (input) => {\n //console.log(`Received: ${input}`);\n arr = input.split(' ');\n\n console.log(Math.floor(arr[0] * arr[1] / 2));\n\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "c41a04c88c17e9ed35404ceb476c5145", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function test(str){\n var l = str.match(/a/g).length;\n return (l + (str.length - l > l-1 ? l-1 : str.length - l)); \n}\n\nvar readline = (()=>{\n process.stdin.resume();\n process.stdin.setEncoding('utf-8');\n \n let inputString = '';\n let currentLine = 0;\n \n process.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n });\n \n process.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n });\t\n \n function readline() {\n return inputString[currentLine++];\n }\n return readline;\n})()\n \n\nfunction main() {\n console.log(test(readline()))\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "1372f555ac440cfda17d157216b60d0e", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\n//readline.question(\"a? b? c?\\n\",(abc)=>{\nreadline.question(\"\",(abc)=>{\n //console.clear();\n abc=abc.split(\" \");\n let x=Math.ceil(abc[0]/abc[2]);\n let y=Math.ceil(abc[1]/abc[2]);\n console.log(y*x);\n readline.close();\n})", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "fd75b9a9cc23000026f6621b52bee036", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let n = parseInt(readLine());\n let ans = 0;\n if (n % 2 == 0) {\n console.log(n / 2);\n } else {\n console.log(-(n + 1) / 2);\n }\n}", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "0f2032b965b9a5dfbbbfbf4bea1a4008", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nconst readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nfunction input(){\n return new Promise ( (resolve , error) => {\n readline.question('', (data) => {\n readline.close();\n resolve(data);\n })\n });\n}\n\nasync function main(){\n n = await input();\n if(n == 2 || n % 2 == 1){\n console.log('NO');\n } else {\n console.log('YES');\n }\n}\n\nmain();", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "0e56d6aac346661e7da96ac0996e31fa", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const [a, b, c] = d.split(' ').map(Number);\n let ans = c*2 + Math.min(a, b) * 2;\n\n if (a !== b) {\n ans++;\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "d23c686bbd8f37a7883e689aa380630a", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var n, p, cnt=1;\nvar a=[];\nconst readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\nreadline.question(``, (a) => {\n \n p = a.length;\n for (var i = 0; i < p; ++i)\n {\n if(cnt>=7) {\n \tbreak;\n }\n else if(a[i]===a[i+1]) {\n \tcnt++;\n }\n else if(a[i]!=a[i+1]) {\n \tcnt=1;\n }\n }\n if(cnt===7) console.log(\"YES\");\n else console.log(\"NO\");\n readline.close()\n})", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "af81208c453782e60b6fcd7c38628b64", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main(input) {\n \n let a,b,c,d =[];\n let l,i=1,v=1;\n input =input.split(/\\n/g);\n a = input[0].split(' ');\n l = a.length;\n \n \n c=first(Number(a[1]),Number(a[2]),Number(a[0]));\n d=second(Number(a[3]),Number(a[4]),Number(a[0]));\n l=c.length\n \n while(i1){\n t++;\n y[t]=--b;\n }\n else if(b!=d){\n b=d;\n y[++t]=b;\n }\n else{\n \n }\n }\n return y;\n}\n\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input;\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "bf4b9261bb4efe5de1d728752b9f8b95", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\n\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nvar n,k;\nvar expect = \"begin\";\nvar scores = [];\nrl.on(\"line\", function(line) {\n if ( expect == \"begin\"){\n n = parseInt(line.split(\" \")[0]);\n k = parseInt(line.split(\" \")[1]);\n expect = \"scores\";\n } else if (expect ==\"scores\"){\n scores = line.split(\" \");\n rl.close();\n }\n}).on(\"close\", function(){\n if(scores[0] != 0) {\n if(scores[k-1]> 0){\n while (scores[k-1] == scores[k]) {\n k++;\n }\n }else {\n while (scores[k-1] == 0) {\n k--;\n }\n } \n console.log(k);\n } else {\n console.log(0);\n }\n \n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "d21fb554f82ef9b4ed20fccd45b1d81d", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', line => {\n const input = line.split(' ');\n console.log(solution(Number(input[0]), Number(input[1])));\n});\n\n\nfunction solution(weightLimak, weightBob) {\n let count = 0;\n while(weightLimak <= weightBob) {\n count++;\n weightLimak *= 3;\n weightBob *= 2;\n }\n\n return count;\n}\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "68d7b5198d6c81732ff61123ec5b6c5b", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\nvar input = '';\nvar inputResolve;\nvar inputPromise = new Promise(resolve => inputResolve = resolve);\nprocess.stdin.on('data', c => input += c);\nprocess.stdin.on('end', () => {\n inputResolve();\n});\nfunction gcd(a, b) {\n if (b == 0)\n return a;\n if (a < b)\n return gcd(b, a);\n return gcd(b, a % b);\n}\n(async () => {\n // var time = Date.now();\n await inputPromise;\n var inputs = input.split(/\\r?\\n/);\n var [a, b] = inputs[0].split(' ').map(v => +v);\n var c = gcd(7 - Math.max(a, b), 6);\n console.log((7 - Math.max(a, b)) / c + '/' + 6 / c);\n})();\n", "lang_cluster": "Javascript", "tags": ["math", "probabilities"], "code_uid": "5926a6b951e7acc7f9c834c5b390763b", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "function ProblemSolver() {\n this.HAS_TEST_CASES = false ;\n this.INPUT_FILE_NAME = \"sample.in\" ;\n this.OUTPUT_FILE_NAME = \"sample.out\" ;\n this.DO_OUTPUT_TO_FILE = false ;\n this.CLEAR_ARRAY_PER_CASE = false ;\n\n this.solveCase = function() {\n var res , i , j , fl , cn , a , b , c ;\n res = 0 ;\n \n if( this.a2 + this.a3 <= this.a1 && this.b2 + this.b3 <= this.b1 ) {\n res = 1 ;\n }\n if( this.a2 + this.a3 <= this.b1 && this.b2 + this.b3 <= this.a1 ) {\n res = 1 ;\n }\n \n if( this.a2 + this.b3 <= this.a1 && this.b2 + this.a3 <= this.b1 ) {\n res = 1 ;\n }\n if( this.a2 + this.b3 <= this.b1 && this.b2 + this.a3 <= this.a1 ) {\n res = 1 ;\n }\n \n if( Math.max( this.a2 , this.a3 ) <= this.a1 && this.b2 + this.b3 <= this.b1 ) {\n res = 1 ;\n }\n if( Math.max( this.a2 , this.a3 ) <= this.b1 && this.b2 + this.b3 <= this.a1 ) {\n res = 1 ;\n }\n \n if( Math.max( this.a2 , this.b3 ) <= this.a1 && this.b2 + this.a3 <= this.b1 ) {\n res = 1 ;\n }\n if( Math.max( this.a2 , this.b3 ) <= this.b1 && this.b2 + this.a3 <= this.a1 ) {\n res = 1 ;\n }\n \n if( Math.max( this.b2 , this.a3 ) <= this.a1 && this.a2 + this.b3 <= this.b1 ) {\n res = 1 ;\n }\n if( Math.max( this.b2 , this.a3 ) <= this.b1 && this.a2 + this.b3 <= this.a1 ) {\n res = 1 ;\n }\n \n if( Math.max( this.b2 , this.b3 ) <= this.a1 && this.a2 + this.a3 <= this.b1 ) {\n res = 1 ;\n }\n if( Math.max( this.b2 , this.b3 ) <= this.b1 && this.a2 + this.a3 <= this.a1 ) {\n res = 1 ;\n }\n \n if( res == 1 ) {\n print( \"YES\" ) ;\n }\n else {\n print( \"NO\" ) ;\n }\n } ;\n\n this.init = function() {\n this.lim1 = 100010 ;\n this.lim2 = 110 ;\n this.cc = 1 ;\n this.ind = 1 ;\n this.n = 0 ;\n this.cn = 0 ;\n this.declareAndFillArrays() ;\n } ;\n\n this.getInput = function( irObj ) {\n var hasMoreInput , i ;\n hasMoreInput = true ;\n try {\n \tthis.a1 = irObj.nextInt() ;\n \tthis.b1 = irObj.nextInt() ;\n \tthis.a2 = irObj.nextInt() ;\n \tthis.b2 = irObj.nextInt() ;\n \tthis.a3 = irObj.nextInt() ;\n \tthis.b3 = irObj.nextInt() ;\n }\n catch( ex ) {\n hasMoreInput = false ;\n }\n return hasMoreInput ;\n } ;\n\n this.clearArraysPerCase = function() {\n var i ;\n this.arr = new Array() ;\n this.adjList = new Array() ;\n for( i = 0 ; i < this.lim1 ; i++ ) {\n this.arr.push( 0 ) ;\n this.adjList.push( new Array() ) ;\n }\n } ;\n\n this.clearPerCase = function() {\n this.cn = 0 ;\n this.cc++ ;\n if( this.CLEAR_ARRAY_PER_CASE == true ) {\n this.clearArraysPerCase() ;\n }\n } ;\n\n this.declareAndFillArrays = function() {\n var i , j ;\n this.srr = new Array() ;\n this.vis = new Array() ;\n this.arr = new Array() ;\n this.brr = new Array() ;\n this.memo = new Array() ;\n this.done = new Array() ;\n this.adjList = new Array() ;\n for( i = 0 ; i < this.lim1 ; i++ ) {\n this.srr.push( '' ) ;\n this.vis.push( 0 ) ;\n this.arr.push( 0 ) ;\n this.brr.push( 0 ) ;\n this.adjList.push( new Array() ) ;\n }\n for( i = 0 ; i < this.lim2 ; i++ ) {\n this.memo.push( new Array() ) ;\n this.done.push( new Array() ) ;\n for( j = 0 ; j < this.lim2 ; j++ ) {\n this.memo[ i ].push( -1 ) ;\n this.done[ i ].push( 0 ) ;\n }\n }\n } ;\n\n this.init() ;\n}\n\nfunction InputReader() {\n var self = this ;\n this.allLines = new Array() ;\n this.currrentLineNumber = 0 ;\n this.currrentCharacterIndex = 0 ;\n this.callBackFunction = null ;\n this.parentContext = null ;\n\n this.readAllLines = function() {\n var singleLine ;\n while( true ) {\n try {\n singleLine = readline() ;\n if( singleLine == null ) {\n break ;\n }\n }\n catch( ex ) {\n break ;\n }\n this.allLines.push( singleLine ) ;\n }\n } ;\n \n this.readAllLinesFromRhino = function() {\n var brObj , line ;\n importPackage( java.io ) ;\n importPackage( java.lang ) ;\n brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;\n this.allLines = [] ;\n while( true ) {\n line = brObj.readLine() ;\n if( line == null ) {\n break;\n }\n this.allLines.push( line ) ;\n }\n } ;\n \n this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {\n self.chunkData += chunk ;\n } ;\n\n this.readEndFromNodeJsJudgeServer = function() {\n self.parseRawData( self.chunkData ) ;\n self.parentContext.runCases() ;\n } ;\n \n this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {\n this.parentContext = parentContext ;\n process.stdin.resume() ;\n process.stdin.setEncoding( 'utf8' ) ;\n this.chunkData = '' ;\n process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;\n process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;\n } ;\n\n this.parseRawData = function( data ) {\n var len , i , currentString ;\n len = data.length ;\n currentString = '' ;\n this.allLines = [] ;\n for( i = 0 ; i < len ; i++ ) {\n if( data[ i ] == '\\r' ) {\n }\n else if( data[ i ] == '\\n' ) {\n this.allLines.push( currentString ) ;\n currentString = '' ;\n }\n else {\n currentString += data[ i ] ;\n }\n }\n if( currentString != '' ) {\n this.allLines.push( currentString ) ;\n }\n } ;\n\n this.readAllLinesFromFile = function( inputFileName ) {\n var currentDirectory , fsObj , inputFilePath , rawData ;\n fsObj = require( 'fs' ) ;\n currentDirectory = __dirname ;\n if( currentDirectory.indexOf( 'D:' ) != -1 ) {\n //on windows\n inputFilePath = currentDirectory + '\\\\' + inputFileName ;\n }\n else {\n //on linux\n inputFilePath = currentDirectory + '/' + inputFileName ;\n }\n rawData = fsObj.readFileSync( inputFilePath , \"utf8\" ) ;\n this.parseRawData( rawData ) ;\n } ;\n\n this.next = function( flag ) {\n var len , i , startIdx , res , endIdx ;\n if( flag == 0 ) {\n if( this.currrentCharacterIndex != 0 ) {\n this.currrentLineNumber++ ;\n this.currrentCharacterIndex = 0 ;\n }\n res = '' ;\n len = this.allLines[ this.currrentLineNumber ].length ;\n if( typeof( len ) == 'function' ) {\n len = this.allLines[ this.currrentLineNumber ].length() ;\n }\n for( i = this.currrentCharacterIndex ; i < len ; i++ ) {\n res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;\n }\n this.currrentLineNumber++ ;\n this.currrentCharacterIndex = 0 ;\n return res ;\n }\n while( true ) {\n if( this.currrentLineNumber >= this.allLines.length ) {\n throw new Error( 'No more tokens available!' ) ;\n }\n startIdx = -1 ;\n len = this.allLines[ this.currrentLineNumber ].length ;\n if( typeof( len ) == 'function' ) {\n len = this.allLines[ this.currrentLineNumber ].length() ;\n }\n for( i = this.currrentCharacterIndex ; i < len ; i++ ) {\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {\n startIdx = i ;\n break ;\n }\n }\n if( startIdx == -1 ) {\n this.currrentLineNumber++ ;\n this.currrentCharacterIndex = 0 ;\n continue ;\n }\n res = '' ;\n endIdx = len - 1 ;\n for( i = startIdx ; i < len ; i++ ) {\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {\n endIdx = i ;\n break ;\n }\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {\n res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;\n }\n else {\n res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;\n }\n }\n this.currrentCharacterIndex = endIdx ;\n if( endIdx == len - 1 ) {\n this.currrentLineNumber++ ;\n this.currrentCharacterIndex = 0 ;\n }\n return res ;\n }\n } ;\n\n this.nextInt = function() {\n return parseInt( this.next( 1 ) ) ;\n } ;\n\n this.nextDouble = function() {\n return parseFloat( this.next( 1 ) ) ;\n } ;\n\n this.nextString = function() {\n return this.next( 1 ) ;\n } ;\n\n this.nextLine = function() {\n return this.next( 0 ) ;\n } ;\n}\n\nfunction FileOutputHandler() {\n this.resultantStringArray = new Array() ;\n\n this.addNewLine = function( newString ) {\n this.resultantStringArray.push( newString ) ;\n } ;\n\n this.clearPercase = function() {\n this.resultantStringArray = new Array() ;\n } ;\n\n this.flushOutOutputToFile = function( outputFileName ) {\n var i , sz , res , currentDirectory , fsObj , outputFilePath ;\n res = '' ;\n sz = this.resultantStringArray.length ;\n for( i = 0 ; i < sz ; i++ ) {\n if( i != 0 ) {\n res += '\\n' ;\n }\n res += this.resultantStringArray[ i ] ;\n }\n fsObj = require( 'fs' ) ;\n currentDirectory = __dirname ;\n if( currentDirectory.indexOf( 'D:' ) != -1 ) {\n //on windows\n outputFilePath = currentDirectory + '\\\\' + outputFileName ;\n }\n else {\n //on linux\n outputFilePath = currentDirectory + '/' + outputFileName ;\n }\n fsObj.writeFileSync( outputFilePath , res ) ;\n this.clearPercase() ;\n } ;\n}\n\nfunction CodeExecutioner() {\n this.irObj = new InputReader() ;\n this.psObj = new ProblemSolver() ;\n this.fohObj = new FileOutputHandler() ;\n\n this.runCases = function() {\n\t\tvar testCases , hasMoreTestCases , i ;\n if( this.psObj.HAS_TEST_CASES == true ) {\n testCases = this.irObj.nextInt() ;\n for( i = 0 ; i < testCases ; i++ ) {\n this.psObj.clearPerCase() ;\n this.psObj.getInput( this.irObj ) ;\n this.psObj.solveCase() ;\n }\n }\n else {\n while( true ) {\n this.psObj.clearPerCase() ;\n hasMoreTestCases = this.psObj.getInput( this.irObj ) ;\n if( hasMoreTestCases == false ) {\n break;\n }\n this.psObj.solveCase() ;\n }\n }\n if( this.psObj.DO_OUTPUT_TO_FILE == true ) {\n this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME ) ;\n }\n } ;\n\n this.detectEnvironmentType = function() {\n var environmentType = null ;\n try {\n if( importPackage != null ) {\n environmentType = 'rhino' ;\n }\n }\n catch( ex1 ) {\n try {\n //for nodejs local server check\n if( __dirname != null && ( __dirname.indexOf( 'D:') != -1 || __dirname.indexOf( '/media/') != -1 ) ) {\n environmentType = 'local-node-js' ;\n }\n else {\n environmentType = 'server-node-js' ;\n }\n }\n catch( ex2 ) {\n try {\n if( readline == null || typeof( readline ) != 'function' ) {\n environmentType = 'server-node-js' ;\n }\n else {\n try {\n if( Map != null ) {\n environmentType = 'spider-monkey' ;\n }\n else {\n environmentType = 'javascript-v8' ;\n }\n }\n catch( ex3 ) {\n environmentType = 'javascript-v8' ;\n }\n }\n }\n catch( ex3 ) {\n environmentType = 'server-node-js' ;\n }\n }\n }\n return environmentType ;\n } ;\n\n this.configureStreamsAndReadInput = function() {\n var localContext , isNodeJsJudgeServer , environmentType ;\n isNodeJsJudgeServer = false ;\n environmentType = this.detectEnvironmentType() ;\n if( environmentType == 'local-node-js' ) {\n try {\n if( print == null || typeof( print ) != 'function' ) {\n print = console.log ;\n }\n }\n catch( ex ) {\n print = console.log ;\n }\n if( this.psObj.DO_OUTPUT_TO_FILE == true ) {\n localContext = this.fohObj ;\n print = function() {\n localContext.addNewLine.apply( localContext , arguments ) ;\n }\n }\n this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME ) ;\n this.runCases() ;\n }\n else if( environmentType == 'server-node-js' ) {\n try {\n if( print == null || typeof( print ) != 'function' ) {\n print = console.log ;\n }\n }\n catch( ex ) {\n print = console.log ;\n }\n this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;\n }\n else if( environmentType == 'javascript-v8' ) {\n this.irObj.readAllLines() ;\n this.runCases() ;\n }\n else if( environmentType == 'rhino' ) {\n this.irObj.readAllLinesFromRhino() ;\n this.runCases() ;\n }\n else if( environmentType == 'spider-monkey' ) {\n this.irObj.readAllLines() ;\n this.runCases() ;\n }\n } ;\n \n this.configureStreamsAndReadInput() ;\n}\n\nnew CodeExecutioner() ;\n", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation"], "code_uid": "1ef6ccc142dafd36504cdd1a5f74bc81", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "(()=>{\"use strict\";var t={675:(t,e)=>{Object.defineProperty(e,\"__esModule\",{value:!0}),Array.prototype.sortAsc=function(){return this.sort(((t,e)=>t-e))},Array.prototype.sortDesc=function(){return this.sort(((t,e)=>e-t))},Array.prototype.max=function(){return Math.max(...this)},Array.prototype.min=function(){return Math.min(...this)},Array.prototype.sum=function(){let t=0;for(let e=0;e{if(l)return s=o.default.readFileSync(\"input.txt\").toString().trim().split(\"\\n\").map((t=>t.trim())),t(),o.default.writeFileSync(\"output.txt\",a),console.log(a),void(o.default.readFileSync(\"expected.txt\").toString().trim()==a.trim()&&console.log(\"✅ AC!\"));process.stdin.resume(),process.stdin.setEncoding(\"utf-8\"),process.stdin.on(\"data\",(t=>{u+=t})),process.stdin.on(\"end\",(e=>{s=u.trim().split(\"\\n\").map((t=>t.trim())),t(),console.log(a)}))};function f(){return s[i++]}function p(){return f().split(\" \").map((t=>parseFloat(t)))}function d(){return f().split(\"\")}e.default={runMain:c,runEachTest:t=>{c((()=>{let[e]=p();for(;e>0;)t(),e--}))},readline:f,nextNumbers:p,nextNumbersMatrix:function(t){let e=[];for(let r=0;r{t.exports=require(\"fs\")}},e={};!function r(n){if(e[n])return e[n].exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,r),o.exports}(965)})();", "lang_cluster": "Javascript", "tags": ["math", "combinatorics"], "code_uid": "0a914005d9c428d2b1d2726a21174b73", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nlet _inputLines;\nlet _lineNumber = 0;\nlet inputReader = _inputReader ();\n\nfunction _main() {\n\t\n\t_inputLines = _inputData.trim().split('\\n').map((string) => {\n\t\treturn string.trim();\n\t});;\n\tlet n = inputReader.readNumber();\n\tlet a =1,b=1,c=0;\n\tlet flag = true;\n\twhile(n--){\n\t\tlet num = inputReader.readNumber();\n\t\tif(num===1){\n\t\t\tif(a===1){\n\t\t\t\tif(b===1){\n\t\t\t\t\tb=0;\n\t\t\t\t\tc=1;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tc=0;\n\t\t\t\t\tb=1;\n\t\t\t\t}\n\t\t\t} \n\t\t\telse{\n\t\t\t\tflag=false;\n\t\t\t}\n\t\t} \n\t\telse if(num===2){\n\t\t\tif(b===1){\n\t\t\t\tif(a===1){\n\t\t\t\t\ta=0;\n\t\t\t\t\tc=1;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tc=0;\n\t\t\t\t\ta=1;\n\t\t\t\t}\n\t\t\t} \n\t\t\telse{\n\t\t\t\tflag=false;\n\t\t\t}\n\t\t} \n\t\tif(num===3){\n\t\t\tif(c===1){\n\t\t\t\tif(b===1){\n\t\t\t\t\tb=0;\n\t\t\t\t\ta=1;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ta=0;\n\t\t\t\t\tb=1;\n\t\t\t\t}\n\t\t\t} \n\t\t\telse{\n\t\t\t\tflag=false;\n\t\t\t}\n\t\t}\n\t}\n\t\n\t\n\t\n\tif(flag)\n\t\tconsole.log(\"YES\");\n\telse\n\t\tconsole.log(\"NO\");\n\t//console.log(obj);\n\t\n\n}\n\nvar _inputData = '';\nfunction cacheInput(data) {\n\t_inputData += data;\n}\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf8');\nprocess.stdin.on('data', cacheInput).on('end', _main);\n\nfunction _inputReader () {\n\tfunction readNumber(){\n\t\treturn Number(_inputLines[_lineNumber++]);\n\t}\n\t\t\n\t\n\treturn {\n\t\treadNumber,\n\t}\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "cebcea9e3c57735d5439826a9a002ba5", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict'\n\nconst {EOL} = require('os')\n\nlet ipt = ''\nprocess.stdin.on('data', s => ipt += s)\nprocess.stdin.on('end', () => {\n let n = +ipt.split(EOL)[0]\n\n const N = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard']\n\n let i = -1\n while (n - 5 * Math.pow(2, ++i) > 0) n -= 5 * Math.pow(2, i)\n let j = 1\n while (n - j * Math.pow(2, i) > 0) j++\n console.log(N[j - 1])\n})", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "8365990818f02023d54c96bd2102a0c3", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n\tvar N = nextInt();\n\tvar s = next();\n\tvar output = 0;\n\tfor(var i = 0; i < N; i++){\n\t\tif(s[i] == \"U\" && s[i + 1] == \"R\" || s[i] == \"R\" && s[i + 1] == \"U\"){\n\t\t\toutput++;\n\t\t\ti++;\n\t\t}else{\n\t\t\toutput++;\n\t\t}\n\t}\n\tmyout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "7a5b5cf9ba060d5fd3cc812d3681a3f4", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inp = 0\nprocess.stdin.on(\"data\",input=>{\n inp = input\n})\nprocess.stdin.on(\"end\",input=>{\n \n main();\n \n})\n\n\n\n\nfunction main(){\nif(inp%2===0&&inp!=2){console.log(\"YES\")} else {console.log(\"NO\")}}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "d31c0d924b6a64e69d045d19fe8006be", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet inputString = \"\";\nlet currentLine = 0;\n\nprocess.stdin.on(\"data\", (inputStdin) => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((string) => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n \n const x = readline()\n .split(\" \")\n .map((x) => +x);\n \n \n\n \n \n \n carrotCakes(x[0],x[1],x[2],x[3]);\n}\n\nfunction carrotCakes(n, t, k, d) {\n\n let t1 = (n * t) / k;\n\n let tt1 = 0;\n let cakesBox2 = 0;\n let ovenTimer11 = 0;\n\n while (cakesBox2 < n) {\n if (ovenTimer11 === t - 1) {\n ovenTimer11 = 0;\n cakesBox2 += k;\n } else {\n ovenTimer11++;\n }\n\n tt1++;\n }\n\n // let t2 = t1 / 2 + d - Math.abs(t - d);\n\n // let k1 = Math.floor(d * k) / t;\n\n // let k1 = (d * k) / t;\n\n // let t2 = ((n - k1) * t) / (2 * k) + d;\n\n // let t2 = d < t ? ((n - k1) * t) / (2 * k) + d : t1 / 2 + d;\n // console.log(t1, t1);\n\n let t2 = 0;\n let cakesBox = 0;\n let ovenTimer1 = 0;\n let ovenTimer2 = 0;\n\n while (cakesBox < n) {\n if (ovenTimer1 === t - 1) {\n ovenTimer1 = 0;\n cakesBox += k;\n } else {\n ovenTimer1++;\n }\n\n if (t2 >= d) {\n if (ovenTimer2 === t - 1) {\n ovenTimer2 = 0;\n cakesBox += k;\n } else {\n ovenTimer2++;\n }\n }\n t2++;\n }\n\n console.log(t2 < tt1 ? \"YES\" : \"NO\");\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "581b1a30a47577bcdb93fa7f8d8c9273", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "(()=>{\"use strict\";var t={312:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,\"__esModule\",{value:!0});const u=r(n(747));let o=\"\",s=[],i=0,l=\"\";const a=\"local\"===process.argv[2];function c(){return s[i++]}e.default={runMain:t=>{if(a)return s=u.default.readFileSync(\"input.txt\").toString().trim().split(\"\\n\").map((t=>t.trim())),t(),void u.default.writeFileSync(\"output.txt\",l);process.stdin.resume(),process.stdin.setEncoding(\"utf-8\"),process.stdin.on(\"data\",(t=>{o+=t})),process.stdin.on(\"end\",(e=>{s=o.trim().split(\"\\n\").map((t=>t.trim())),t(),console.log(l)}))},readline:c,nextNumbers:function(){return c().split(\" \").map((t=>parseFloat(t)))},put:function(t){l+=t},puts:function(t){l+=t+\"\\n\"},debug:function(t){a&&console.log(t)}}},965:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,\"__esModule\",{value:!0});const u=r(n(312));u.default.runMain((function(){const[t,e,n]=u.default.nextNumbers();u.default.puts(Math.ceil(t/n)*Math.ceil(e/n))}))},747:t=>{t.exports=require(\"fs\")}},e={};!function n(r){if(e[r])return e[r].exports;var u=e[r]={exports:{}};return t[r].call(u.exports,u,u.exports,n),u.exports}(965)})();", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "626f02344d07723e7d24c344cb2d1507", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst z=2 ;\nconst x=1;\nconst c=100\nconst rl = readline.createInterface({\n input: process.stdin\n});\nrl.on('line', (input) => {\n if (input.trim()>=x && input.trim()<=c){\n if (input.trim() % z != 0 || input.trim()==2 )\n {\n console.log(\"NO\");\n }\n else\n {\n console.log(\"YES\");\n }\n}\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "2ec0ee113d8211ea9f05fc068a69e3a8", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.setEncoding('utf8');\n\nprocess.stdin.on('readable', () => {\n let input = process.stdin.read();\n input = input.trim();\n\n if (input !== null) {\n let AAAAAAAAAAAAAs = 0;\n let NotAAAAAAAAAAs = [];\n\n for (let i = 0; i < input.length; i++) {\n if (input[i] == 'a') AAAAAAAAAAAAAs++;\n else NotAAAAAAAAAAs.push(i);\n }\n\n input = input.split('');\n\n while (AAAAAAAAAAAAAs <= NotAAAAAAAAAAs.length) {\n input.splice(input.indexOf(NotAAAAAAAAAAs[0]), 1);\n NotAAAAAAAAAAs.shift();\n }\n\n process.stdout.write(`${input.length}\\n`);\n process.exit(0);\n }\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "cac6ba83ac39268408d0f8a76f2edb89", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar idx = 0;\nvar out = 0;\nvar totalScores = 0;\nvar passScore = 0;\nrl.on(\"line\", (theLine) => {\n if (idx === 0) {\n var lines = theLine.split(\" \");\n totalScores = parseInt(lines[0]);\n passScore = parseInt(lines[1])-1;\n } \n else {\n var scores = theLine.split(\" \");\n var currentCount = 0;\n if (totalScores > 0) {\n scores.forEach(element => {\n if ((parseInt(element) > 0) && (parseInt(element) >= parseInt(scores[passScore])))\n out++;\n });\n } \n }\n idx++;\n if (idx > 1) \n {\n rl.close();\n console.log(out.toString());\n }\n \n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "2860803ac26987c8fe6b7ca923c30107", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data',c=>{[n,m,a]=c.toString().split(' ');\nx=Math.ceil;\nconsole.log(x(n/a)*x(m/a))})", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "53c65b8aaa0f4e6b999a0c898dbd76b8", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet standardInputString = '';\nlet currentLine = 0;\n\nfunction readLine() {\n return standardInputString[currentLine++];\n}\n\nprocess.stdin.on('data', rawData=> {\n standardInputString += rawData;\n})\n\nprocess.stdin.on('end', _ => {\n standardInputString = standardInputString.trim().split('\\n').map(line=> {\n return line.trim();\n })\n main();\n})\n\nfunction main() {\n let message = Array.from(readLine());\n const word = Array.from('hello');\n let counter = 0;\n if(!message.join(\"\").includes('h')) {\n console.log('NO');\n return;\n }\n for(let i = message.indexOf('h'); i < message.length; i++) {\n if(message[i] === word[counter]) {\n if((word.length - 1) === counter) {\n console.log(\"YES\");\n return;\n }\n counter++;\n }\n }\n console.log(\"NO\")\n}", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "07e56e2af3120fef9962b18ab8f163be", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let table = [0];\nlet j = \"\";\nfor(let i=0;i<55;i++)\n{\n j+= \"1\"\n table[i+1] = BigInt(j);\n} \n\nlet dp = {};\n\n\nlet i = ''\nprocess.stdin.on('data', c => i += c);\nprocess.stdin.on('end', () => {\n const {EOL} = require('os')\n const lines = i.split(EOL)\n console.log(calc(BigInt(lines[0])));\n});\n\nfunction abs(x)\n{\n return (x>=0)?x:0n-x;\n}\n\nfunction max(v1,v2)\n{\n return (v1>v2)?v1:v2;\n}\n\nfunction min(v1,v2)\n{\n return (v1>v2)?v2:v1;\n}\n\n\nfunction calc(x)\n{\n if (x==0) return 0;\n \n let str = x.toString();\n if (dp[str]) return dp[str]; \n let n = str.length;\n \n let v1 = abs(table[n+1]-x);\n let v2 = abs(table[n]-x);\n \n let ret;\n \n let diff = abs(v1-v2);\n let mx = max(v1,v2);\n let ratio = Number(diff * 100n / mx) / 100;\n if (ratio<=0.1)\n {\n ret = min(n+1+calc(v1),n+calc(v2));\n }\n else\n {\n if (v1 {\n let params = line.split(\" \");\n let smaller = parseInt(params[0]);\n if (parseInt(params[1]) <= parseInt(params[0])) smaller = params[1];\n if (smaller % 2 == 0) console.log(\"Malvika\");\n else console.log(\"Akshat\");\n});\n\nrl.on(\"close\", () => {});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "ac3e4e242b0b54bbf53221335ce9f885", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let readline = require('readline');\nlet intInput = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n});\nlet input;\nintInput.on('line', (line) => {\n\tinput = line.split(\" \");\n});\nintInput.on('close', () => {\n\tlet a = Number(input[0]);\n\tlet b = Number(input[1]);\n\tlet c = 0\n\twhile (a <= b) {\n\t\ta = a * 3;\n\t\tb = b * 2;\n\t\tc++\n\t}\n\tconsole.log(c)\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "040d7a07a4182177e0a9b74422b006c6", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\")\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet colouredStones;\nlet instructions;\nlet currentStoneCounter = 0\n\nrl.on(\"line\", (input) => {\n if (!colouredStones) {\n colouredStones = input.split(\" \").toString();\n // console.log(colouredStones, typeof (colouredStones))\n } else {\n instructions = input.split(\" \").toString()\n for (let index = 0; index < instructions.length; index++) {\n if (instructions[index] == colouredStones[currentStoneCounter]) {\n currentStoneCounter++\n }\n }\n console.log(currentStoneCounter+1)\n rl.close();\n }\n\n\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "362a3fbb687112ed09ea98e6c901b956", "src_uid": "f5a907d6d35390b1fb11c8ce247d0252", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function howMany(dim, x) {\n // let pairs = [];\n \n let amt = 0;\n\n const max = Math.min(x, dim);//Make sure both factors are in the table\n for (let i = 1; i <= max; i++) {//Find all factor pairs of X\n const pair = x / i;\n if (Math.floor(pair) == pair && pair <= dim) {//If a pair has been found\n amt++;\n // pairs.push([i, pair]);\n }\n }\n // console.log(pairs);\n // amt *= 2; //Only half the table is evaluated, to be more efficient\n return amt;\n}\n\nprocess.stdin.addListener(\"data\", data => {\n const nums = data.toString().split(\" \").map(n => parseInt(n));\n console.log(howMany(nums[0], nums[1]));\n});\n", "lang_cluster": "Javascript", "tags": ["implementation", "number theory"], "code_uid": "09e7fdcd055c35ad6e07db6cdd19ab86", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n \nconst input = [];\nreadLine.on('line', line => input.push(line));\n \nreadLine.on('close', () => {\n const [a1, a2, a3] = input[0].split(' ').map(x => parseInt(x));\n const [b1, b2, b3] = input[1].split(' ').map(x => parseInt(x));\n const [n] = input[2].split(' ').map(x => parseInt(x));\n\n let sum = Math.ceil((a1+a2+a3)/5) + Math.ceil((b1+b2+b3)/10);\n if (sum <= n) console.log('YES');\n else console.log('NO');\n}); ", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "86632af8a328d51a33a86894349623a9", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', (input) => {\n //console.log(input);\n //ar = input.split(' ');\n\n\n let a = Math.floor(input / 2);\n let b = input - a;\n let ar = a.toString().split(\"\")\n\n let total = 0;\n let ten = 0;\n\n for (let i = ar.length - 1; i>0; i--) {\n let fix = 9 - parseInt(ar[i], 10);\n ar[i] = 9;\n b -= fix * (Math.pow(10, ten));\n ten++;\n }\n let br = b.toString().split(\"\")\n\n ar.forEach(elem => {\n total += parseInt(elem, 10);\n });\n br.forEach(elem => {\n total += parseInt(elem, 10);\n });\n\n console.log(total);\n\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "d539649ca1f05d055790f21df2d58a10", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function processData(input) {\n\t// time Complexity O(n)\n\t//Enter your code here\n\tvar data = input.split(\"\\n\");\n\tvar [n, k] = data[0].split(\" \").map(a => parseInt(a));\n\tvar arr = data[1].split(\" \").map(a => parseInt(a));\n\tvar target = arr[k - 1];\n\tarr.sort((a, b) => b - a);\n\tvar count = 0;\n\tfor (var i = 0; i < arr.length; i++) {\n\t\tif (arr[k - 1] != 0) {\n\t\t\tif (arr[i] >= target) {\n\t\t\t\tcount++;\n\t\t\t}\n\t\t} else {\n\t\t\tif (arr[i] > target) {\n\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}\n\tconsole.log(count);\n}\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"ascii\");\n_input = \"\";\nprocess.stdin.on(\"data\", function(input) {\n\t_input += input;\n});\n\nprocess.stdin.on(\"end\", function() {\n\tprocessData(_input);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "bced2ca8b5cd6369c0c0285759e232d5", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n let str = input[0];\n\n for (let i = 0; i < str.length; i += 1) {\n if (str[i] === 'H' || str[i] === 'Q' || str[i] === '9') {\n console.log('YES'); process.exit();\n }\n }\n\n console.log('NO');\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f347151a1e404e5ab498d8d2a3afa8ba", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nfunction createReadLine() {\n process.stdin.resume();\n process.stdin.setEncoding('utf-8');\n\n let inputString = '';\n let currentLine = 0;\n\n process.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n });\n\n process.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n });\n\n function readline() {\n return inputString[currentLine++];\n }\n\n return readline;\n}\n\nconst readline = createReadLine();\n\nfunction readInts(){\n return readline().split(' ').map((value => Number.parseInt(value)));\n}\n\nfunction readFloats(){\n return readline().split(' ').map((value => Number.parseFloat(value)));\n}\n\nfunction readStr() {\n return readline();\n}\n\nfunction readInt(){\n return Number.parseInt(readline());\n}\n\nfunction readFloat(){\n return Number.parseFloat(readline());\n}\n\n\n\nfunction main() {\n const str = readStr();\n const result = solve(str);\n console.log(result);\n}\n\nfunction solve(str){\n str = [...str]\n const subStr = [...'QAQ']\n const resultArr = new Array(subStr.length).fill(0).map(() => new Array(str.length).fill(0));\n str.forEach((s, index) => {\n if(s === subStr[0]){\n resultArr[0][index] = 1\n } else {\n resultArr[0][index] = 0\n }\n })\n\n for (let i = 1; i < subStr.length; i ++){\n for (let j = 0; j < str.length; j ++){\n if(str[j] === subStr[i]){\n let sum = 0;\n for (let k = 0; k < j; k ++) {\n sum += resultArr[i-1][k]\n }\n resultArr[i][j] = sum;\n }\n }\n }\n let sum = 0;\n resultArr[subStr.length - 1].forEach(v => sum += v)\n return sum;\n}\n\nmodule.exports.solve = solve;\n", "lang_cluster": "Javascript", "tags": ["brute force", "dp"], "code_uid": "778b3e51d6f4fe7688050e3e0d2c6160", "src_uid": "8aef4947322438664bd8610632fe0947", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\nconst lines = []\nrl.on('line', (input) => {\n lines.push(input);\n})\nrl.on('close', () => {\n// (function() {\n // const lines = require('fs').readFileSync('test.in', 'utf8').split('\\n')\n let l = 0;\n let t = +lines[l++]\n const output = []\n for (let i = 0; i < t; i++) {\n const n = +lines[l++]\n output[i] = solve(n)\n }\n console.log(output.join('\\n'))\n// })()\n})\n\nfunction solve(n) {\n let a = 0\n let b = 0\n let c = 0\n for (let i = 1; i < 32000; i++) {\n if (i * i <= n) a++\n if (Math.pow(i, 3) <= n) b++\n if (Math.pow(i, 6) <= n) c++\n }\n return a + b - c\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "adbf2def1e15474da056e4528215bc95", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = ''\nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os')\n const lines = i.split(EOL) /*your input text, split by lines*/\n let vasayInput = lines[0].split(\" \").map( element => {\n return parseInt(element)\n })\n let redSocksCount = vasayInput[0]\n let blueSocksCount = vasayInput[1]\n distributeSocks(redSocksCount, blueSocksCount)\n})\n\nfunction distributeSocks(redSocks, blueSocks) {\n let hipsterDaySocksCount = Math.min(redSocks, blueSocks)\n\n let remainingBlueSocks = blueSocks - hipsterDaySocksCount\n let remainingRedSocks = redSocks - hipsterDaySocksCount\n\n let normalDaysSocks = 0\n \n normalDaysSocks += parseInt(remainingBlueSocks / 2)\n normalDaysSocks += parseInt(remainingRedSocks / 2)\n\n console.log(hipsterDaySocksCount + \" \" + normalDaysSocks)\n}", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "86de29831f00ad25accb694460a43604", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n');\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr('time : ' + end + 'ms');\n myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var one = nextIntArray();\n var max = Math.max(one[0], one[1]);\n var ok = 6 - max + 1;\n myout((ok / gcd(ok, 6)) + \"/\" + (6 / gcd(ok, 6)));\n}\nfunction gcd(m, n) {return n != 0 ? gcd(n, m % n) : m;}", "lang_cluster": "Javascript", "tags": ["math", "probabilities"], "code_uid": "46cb495aeb30842d0eec23a48844a02f", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const stdin = process.stdin;\nstdin.setEncoding( 'utf8' );\nstdin.on( 'data', function( rawInput ){\n const inputLines = rawInput.split('\\n');\n const n = parseInt(inputLines[0]);\n const result = solve(n);\n console.log(result? \"YES\": \"NO\");\n});\n\nfunction solve(totalWeight) {\n if (totalWeight < 4) {\n return false;\n }\n return totalWeight % 2 === 0;\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "97c9064ad9def606c9d31776296f5209", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.question('', (input) => {\n let weight = Number(input);\n \n if (weight % 2 == 0 && weight > 2) {\n console.log(\"YES\");\n } else {\n console.log(\"NO\");\n }\n\n rl.close();\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "97f6fecc0c9d3043517a5338d7692e7b", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\r\n\r\nprocess.stdin.resume();\r\nprocess.stdin.setEncoding('utf-8');\r\n\r\nlet inputString = '';\r\nlet currentLine = 0;\r\n\r\nprocess.stdin.on('data', inputStdin => {\r\n inputString += inputStdin;\r\n});\r\n\r\nprocess.stdin.on('end', _ => {\r\n inputString = inputString.trim().split('\\n').map(string => {\r\n return string.trim();\r\n });\r\n\r\n main();\r\n});\r\n\r\nfunction readline() {\r\n return inputString[currentLine++];\r\n}\r\n\r\nfunction main() {\r\n let noOfTestCases = Number(readline());\r\n let testCaseArray = [];\r\n for (let i = 0; i < noOfTestCases; i++) {\r\n testCaseArray.push(readline());\r\n }\r\n let maxValue = Math.max(...testCaseArray);\r\n let array = calArray(maxValue);\r\n for (let i = 0; i < noOfTestCases; i++) {\r\n numberOfValues(array, testCaseArray[i])\r\n }\r\n}\r\n\r\n\r\n\r\nfunction calArray(maxValue) {\r\n let set = new Set();\r\n let i = 1;\r\n while (maxValue >= i * i) {\r\n const square = i * i;\r\n const cube = i * i * i;\r\n set.add(square);\r\n if (cube <= maxValue) set.add(cube);\r\n i++;\r\n }\r\n return Array.from(set).sort((a, b) => a - b);\r\n}\r\n\r\nfunction numberOfValues(array, num) {\r\n let i = 0;\r\n while (array[i] <= num) {\r\n i++;\r\n }\r\n console.log(i);\r\n}\r\n\r\n\r\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "5ca67e2ef9219a4e9f8aa9847d24f9f6", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst r = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n });\n\nr.on('line',(line)=>{\n console.log(compute(line));\n });\n\nfunction* range(start, end) {\n while (start <= end) yield start++;\n}\n\nfunction getTimeIndex(str) {\n let [h,m] = str.split(\":\").map(n => +n);\n return h * 60 + m;\n}\nfunction isPalindrome(str)\n{\n return str === (str.split(\"\").reverse().join(\"\"))\n}\nlet hours = [...range(0, 23)].map(n => n < 10 ? \"0\" + n : \"\" + n);\nlet minutes = [...range(0, 59)].map(n => n < 10 ? \"0\" + n : \"\" + n);\n\nlet time = hours.reduce((ac, h) => {\n minutes.forEach(m => ac.push(h + \":\" + m));\n return ac;\n}, []);\nlet times = [...time, ...time];\n\nfunction compute(str) {\n let startIndex = getTimeIndex(str)+1;\n while( startIndex < times.length)\n {\n if(isPalindrome(times[startIndex]))\n return times[startIndex];\n \n startIndex++;\n }\n\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "dfd5ba92501e87f552ef2ff72691fff7", "src_uid": "158eae916daa3e0162d4eac0426fa87f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nasync function algo() {\n const n = await int()\n let count = 1\n for(let i = 2; i <= n / 2; i ++) {\n if ((n - i) % i == 0) count ++\n }\n console.log(count)\n}\n\n\n// read the input\nconst _lines = []\nlet _lineIndex = 0\nlet _ended = false\nconst _rl = readline.createInterface(process.stdin)\n_rl.on('line', line => _lines.push(line))\n_rl.on('end', () => (ended = true))\nconst wait = ms => new Promise(resolve => setTimeout(resolve, ms))\nconst line = async () => {\n while (!_ended && _lines.length <= _lineIndex) await wait(10)\n const result = _lines[_lineIndex].trim()\n _lines[_lineIndex] = null\n _lineIndex++\n return result\n}\nconst words = async () => (await line()).split(' ')\nconst chars = async () => (await line()).split('')\nconst int = async () => parseInt(await line())\nconst ints = async () => (await words()).map(x => parseInt(x))\nconst big = async () => BigInt(await line())\nconst bigs = async () => (await words()).map(x => BigInt(x))\n\nalgo()", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "54aba379de00775a4c6aeed0ed9201b5", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () =>\n{\n // const nums = input[1].split(' ').map(x => parseInt(x));\n\n let myString = input[0];\n\n\n let bySet= new Set ()\n\nfor (let i = 0; i < myString.length; i++) {\n bySet.add (myString[i])\n \n}\n \n\n\n if (bySet.size%2==0) {\n console.log('CHAT WITH HER!');\n \n }else {\n console.log('IGNORE HIM!')\n }\n\n});", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "21c0320695b88a10c5f00978d8d49476", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let money = readline().split(' ');\n money = parseInt(money);\n\n minNumBills(money);\n};\n\nfunction minNumBills(amt){\n let bills = [1, 5, 10, 20, 100];\n\n let idx = bills.length - 1;\n let billCount = 0;\n\n while(amt > 0 && idx >= 0){\n let cur = bills[idx];\n if(amt < cur){\n idx--;\n continue;\n }\n amt = amt - cur;\n billCount++;\n\n if(amt < cur) idx --;\n }\n console.log(billCount);\n return billCount;\n}", "lang_cluster": "Javascript", "tags": ["greedy", "dp"], "code_uid": "bab3a28a121744676c3b6d5db82cfd80", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar count = 0;\nvar k;\nvar places;\n\nrl.on('line', line => {\n if (count === 0) {\n k = line.split(' ')[1];\n count++;\n return;\n }\n\n if (count === 1) {\n places = line.split(' ').map(item => parseInt(item));\n rl.close();\n }\n});\n\nrl.on('close', () => {\n var targetScore = places[k-1];\n var result = 0;\n\n while(result !== places.length) {\n var manScore = places[result];\n\n if (manScore === 0 || manScore < targetScore) break;\n\n result ++;\n }\n\n console.log(result);\n\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "31ff6a554494c9ca426fc3b78268fa1e", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n\n// Write your code here\nfunction nameLookUp(arr) {\n let nLines = arr.trim().split('\\n');\n let firstStr = nLines[0].trim().toLowerCase();\n let secondStr = nLines[1].trim().toLowerCase();\n let comparison = 0;\n if(firstStr > secondStr){\n comparison = 1;\n }\n if(firstStr < secondStr){\n comparison = -1;\n }\n return comparison.toString();\n\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "d66243fd0d9729a10efb41ed3b9dfde7", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet w, h;\nlet u1, u2, d1, d2;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n [w, h] = d.split(' ').map(Number);\n return;\n }\n\n if (c === 1) {\n c++;\n [u1, d1] = d.split(' ').map(Number);\n return;\n }\n\n [u2, d2] = d.split(' ').map(Number);\n\n c++;\n});\n\nrl.on('close', () => {\n let ans = w;\n\n while (h > 0) {\n ans += h;\n\n if (h === d1) {\n ans -= u1;\n }\n\n if (h === d2) {\n ans -= u2;\n }\n\n if (ans < 0) {\n ans = 0;\n }\n\n h--;\n }\n\n console.log(Math.max(0, ans));\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "704b6aac0efe80d9327c5147239d6cab", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = ''\nprocess.stdin.on('data', c => input += c)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os')\n const lines = input.split(EOL)\n const testCount = parseInt(lines[0]);\n lines.shift();\n\n for(let i=0;i num == '1');\n if(!numbers.length) console.log(0)\n else if(numbers.length == 4) console.log(2)\n else console.log(1)\n }\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "1c4f6c5855ac5ab98c1a68d0a6a9e740", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// https://codeforces.com/problemset/problem/977/B\n// Big O:\n// Time complexity: O(n)\n// Space complexity: O(n)\n\nconst readline = require(\"readline\");\n\n// Read input\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet stringLength;\nrl.on('line', (input) => {\n if (stringLength) {\n console.log(findMostCommonGram(input, stringLength));\n rl.close();\n } else {\n stringLength = input;\n }\n});\n\n// Problem\nfunction findMostCommonGram(string, stringLength) {\n let mostCommonGram = \"\";\n let mostCommonGramOccurrences = 0;\n const gramOccurrences = {};\n\n for (let i = 0; i < stringLength - 1; i++) {\n const twogram = string[i] + string[i + 1];\n const occurrences = gramOccurrences[twogram] ? gramOccurrences[twogram] + 1 : 1;\n if (occurrences > mostCommonGramOccurrences) {\n mostCommonGram = twogram;\n mostCommonGramOccurrences = occurrences;\n }\n\n gramOccurrences[twogram] = occurrences;\n }\n\n return mostCommonGram;\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "dea39e92cba6f0037c4f33d85e5cf0a3", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\nconst elephant = () => {\n let steps = Math.floor(input[0]/5);\n if (input[0]% 5 !== 0) {\n steps++;\n }\n console.log(steps);\n};\n\nreadLine.on('close', elephant);", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "35167857cf0e428df0202e48aa373f4a", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let buf='';\r\n\r\nprocess.stdin.on('readable',function(){\r\n let chunk=process.stdin.read();\r\n if(chunk) buf+=chunk.toString();\r\n})\r\n\r\nprocess.stdin.on('end',function(){\r\n let line=buf.split(' ');\r\n let n=parseInt(line[0]),m=parseInt(line[1]);\r\n if(m!==1)\r\n {\r\n // console.log(n,m-1);\r\n let a=BigInt(n);\r\n let b=BigInt(m-1);\r\n let ans=a*b;\r\n // ans=ans.toString();\r\n // let res='';\r\n // for(let i=0;i {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let t = readLine();\n t = parseInt(t);\n while(t--) {\n let line = readLine();\n line = line.split(\" \");\n let n = parseInt(line[0]);\n let ans = null;\n\t\tif (n == 1) {\n\t\t\tans = 1;\n\t\t} else if (n == 11) {\n\t\t\tans = 3;\n\t\t} else if (n == 111) {\n\t\t\tans = 6;\n\t\t} else if (n == 1111) {\n\t\t\tans = 10;\n\t\t} else {\n\t\t\tlet cnt = n.toString().split(\"\").length;\n\t\t\tlet k = n % 10;\n\t\t\tans = ( k - 1) * 10;\t\n\t\t\tif (cnt == 1) {\n\t\t\t\tans = ans + 1;\n\t\t\t} else if (cnt == 2) {\n\t\t\t\tans = ans + 3;\n\t\t\t} else if (cnt == 3) {\n\t\t\t\tans = ans + 6;\n\t\t\t} else if (cnt == 4) {\n\t\t\t\tans = ans + 10;\n\t\t\t} \n\t\t}\n\t\t\n console.log(ans);\n }\n}", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "641d5954ed187235c82e36fdb2e504c3", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n');\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr('time : ' + end + 'ms');\n myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var one = nextIntArray();\n if(one[0] <= one[1] && one[0] <= one[2]){\n \tmyout(\"Yes\");\n }else{\n \tmyout(\"No\");\n }\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "08ce2bc03c27e0f3ac3cf6a47f66b967", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = '';\n\nprocess.stdin.on('data', c => i += c);\nprocess.stdin.on('end', () => {\n const {EOL} = require('os');\n const lines = i.split(EOL);\n var t = lines[0]\n for(j = 1; j <= t; j++){\n var s = 0\n var n = lines[j]\n for(k = 0; k < n; k++){\n s += s + 1\n }\n console.log(s )\n }\n});\n ", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "8c2ddb00427ab3708c89d4f7f354ae5d", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var N = nextInt() + 1;\n while(true){\n var s = myconv(N.toString(), 0);\n var used = new Set();\n for(var i = 0; i < s.length; i++){\n used.add(s[i]);\n }\n if(used.size == 4){\n break;\n }\n N++;\n }\n myout(N);\n \n}\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "549530903886ae74f99866b8599c52a2", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet limak = 0;\nlet bob = 0;\nlet years = 0;\nrl.on(\"line\",(input)=>{\n limak = parseInt(input.split(\" \")[0])\n bob = parseInt(input.split(\" \")[1])\n while(limak<=bob){\n bob*=2\n limak*=3\n years++\n }\n console.log(years)\n rl.close();\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "2e1cd945c1bc6341fb46512073e0bcbe", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\n\n\n\nrl.on('line', function (input) {\n // myArr = input.split(' ').map(item => {return parseInt(item);});\nvar N = parseInt(input); \nvar Primes = [];\nfor(var i = 2; i <= N; i++)\n if (IsPrime(i)) Primes.push(i); \n \nvar ans = 0;\nfor (var i = 1; i <= N; i++)\n if (IsAlmostPrime(i, Primes)) ans++;\n \n \nconsole.log(ans);\n\n rl.close();\n})\n\n\n//******************************MY FUNCTIONS */\n\nfunction IsPrime(n)\n{\n if (n == 2 ) return true;\n if (n <= 1|| n%2==0)\n return false;\n //for (int i = 2; i <= n/2; i++)\n // if (n % i == 0)\n // return false;\n var limit = parseInt(Math.sqrt(n));\n for (var i = 3; i <= limit; i+=2) \n if (n % i == 0)\n return false;\n\n return true; \n}\n\nfunction IsAlmostPrime(n, pNums)\n{ \n var countDivisor = 0;\n for (var i = 0; i < pNums.length; i++)\n {\n if (n % pNums[i] == 0) countDivisor++;\n if (pNums[i] > n / 2) break;\n }\n return countDivisor == 2;\n}\n", "lang_cluster": "Javascript", "tags": ["number theory"], "code_uid": "1b89aafd700c6e17a1c518c8d7f84614", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const stdin = process.stdin;\nstdin.setEncoding(\"utf8\");\nstdin.on(\"data\", function(rawInput) {\n const inputLines = rawInput.split(/\\s+/);\n const n = parseInt(inputLines[0]);\n const result = solve(n);\n console.log(result);\n});\n\nfunction solve(n) {\n let a = Math.floor(n / 2);\n let b = n - a;\n\n while (getGCD(a, b) != 1) {\n a--;\n b++;\n }\n\n return `${a} ${b}`;\n}\n\nfunction getGCD(a, b) {\n while (b != 0) {\n const tmp = a % b;\n a = b;\n b = tmp;\n }\n return a;\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "68f9cda33190e073d9e0750aa360e833", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet inputString = \"\";\nlet currentLine = 0;\n\nprocess.stdin.on(\"data\", (inputStdin) => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((string) => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n const x = readline();\n const x2 = readline();\n \n stonesOnTheTable(x2);\n}\n\n\nfunction stonesOnTheTable(palette) {\n let colorsCount = 0;\n\n for (let i = 0; i < palette.length - 1; i++) {\n const curr = palette[i];\n const next = palette[i + 1];\n\n if (/[RGB]/.test(curr) && /[RGB]/.test(next) && curr === next)\n colorsCount++;\n }\n console.log(colorsCount);\n\n return colorsCount;\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e53df0b9b2fdfb426cfa8b7c40f30829", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const state = { stdin: Buffer.alloc(0) };\nconst consume = (chunk) =>\n (state.stdin = Buffer.concat(\n [state.stdin, chunk],\n state.stdin.length + chunk.length\n ));\nconst commit = (answer) => process.stdout.write(answer);\n//\nconst main = (args) => {\n let data = parseInt(state.stdin.toString(\"utf8\"));\n let solution = \"NO\";\n// if (data < 1 || data > 100) return commit(solution);\n\n for (let i = 1; i < data; i++) {\n let part = (data - i) % 2 ===0;\n if (i % 2 === 0 && part) {\n solution = \"YES\";\n commit(solution);\n return;\n }\n }\n commit(solution);\n};\n\nprocess.stdin.on(\"data\", consume).on(\"end\", main);\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "35bf6717c1e4040ff8e7c5a6b45ac285", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\")\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet arrOfShoes\nlet similarCounter = 0\n\nrl.on(\"line\", (input) => {\n if (!arrOfShoes) {\n arrOfShoes = input.split(\" \").map(Number)\n }\n if (arrOfShoes) {\n arrOfShoes.forEach((shoe,index) => {\n if(arrOfShoes.includes(shoe,index+1)){\n similarCounter++\n }\n });\n console.log(similarCounter)\n rl.close();\n\n }\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "15179e46edba74d61f3e30f5f4fb8cdb", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\n// const fs = require('fs');\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n var matrix = [];\n for (var i = 0; i < 5; i++) {\n let arr = readLine()\n .split(' ')\n .map(value => parseInt(value));\n matrix.push(arr);\n }\n\n let coordinate = [];\n\n for (var i = 0; i < 5; i++) {\n if (matrix[i].indexOf(1) != -1) {\n coordinate.push(i);\n coordinate.push(matrix[i].indexOf(1));\n }\n }\n\n let ans = Math.abs(2 - coordinate[0]) + Math.abs(2 - coordinate[1]);\n console.log(ans);\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "92b088122b453666b37b3f4e539d7d45", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let word = readLine();\n let wordArray = word.split('');\n let smallLetters = [];\n let CapitalLetters = [];\n for (let i = 0; i < wordArray.length; i++) {\n if (\n wordArray[i] === wordArray[i].toUpperCase() &&\n wordArray[i] !== wordArray[i].toLowerCase()\n ) {\n CapitalLetters.push(wordArray[i]);\n } else {\n smallLetters.push(wordArray[i]);\n }\n }\n if (CapitalLetters.length > smallLetters.length) {\n console.log(word.toUpperCase());\n } else {\n console.log(word.toLowerCase());\n }\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "0cc7e21681717d3eb32c4a8b2771337c", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n});\n\nconst getNumber = (k) => {\n let str = '';\n let i = 1;\n\n while (str.length < k) {\n str += i;\n i += 1;\n }\n\n return str[k - 1];\n};\n\nreadline.on('line', (line) => {\n const k = Number(line);\n\n console.log(getNumber(k));\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "62f0502d8ecc416587f9ea714bfc2b89", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "/**\n * Created by ishanarora on 30/11/18.\n */\n\nconst stdin = process.openStdin();\nlet content = ``;\nstdin.addListener('data', d => {\n content += d.toString();\n});\n\nstdin.addListener('end', () => {\n content = content.split(\"\\n\");\n console.log(countrySide(parseInt(content[0]), (content[1].split(\" \"))));\n});\n\nfunction countrySide(count, samples) {\n\n let lastElement = parseInt(samples.pop());\n\n if (lastElement == 0) {\n return 'UP'\n }\n\n if (lastElement == 15) {\n return 'DOWN'\n }\n\n let secondLast = samples.pop();\n if (secondLast === undefined) {\n return -1;\n }else{\n secondLast = parseInt(secondLast);\n }\n\n\n let initialDecision = 'DOWN'\n\n if (lastElement > secondLast) {\n initialDecision = 'UP';\n }\n\n return initialDecision;\n}\n\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "10c4ccb1135c7957243e88338827c9b5", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet currentLine = 0;\nlet inputString = \"\";\n\nprocess.stdin.on(\"data\", (raw_data) => {\n inputString += raw_data;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((line) => {\n return line.trim();\n });\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n/******** Main function*************/\n\nfunction main() {\n var [n, k] = readLine().split(\" \").map(Number);\n\n while (k > 0) {\n var num = n.toString().split(\"\").map(Number);\n if (num[num.length - 1] === 0) {\n n = n / 10;\n } else {\n n = n - 1;\n }\n k--;\n }\n console.log(n);\n}\n\n/**\n * if the last digit of the number is non-zero,\n * she decreases the number by one;\n *\n * if the last digit of the number is zero,\n * she divides the number by 10 (i.e. removes the last digit).\n */\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "de9c55084a37d9e259e4da918eac477d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var read = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\nvar obj;\nvar inLine = [];\nread.on('line', function (input) { inLine.push(input); });\nread.on('close', function () {\n obj = init(inLine);\n myerr(\"-----start-----\");\n var start = new Date();\n Main();\n var end = new Date() - start;\n myerr(\"----- end -----\");\n myerr(\"Time: \" + (end) + \"ms\");\n myerr(\"Memory: \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction nextInt() { return myconv(next(), 1); }\nfunction nextStrArray() { return myconv(next(), 2); }\nfunction nextIntArray() { return myconv(next(), 4); }\nfunction nextCharArray() { return myconv(next(), 6); }\nfunction next() { return obj.next(); }\nfunction hasNext() { return obj.hasNext(); }\nfunction init(input) {\n var returnObj = {\n list: input, index: 0, max: input.length,\n hasNext: function () { return (this.index < this.max); },\n next: function () { if (!this.hasNext()) { throw \"ArrayIndexOutOfBoundsException\"; } else { var returnInput = this.list[this.index]; this.index++; return returnInput; } }\n };\n return returnObj;\n}\nfunction myout(s) { console.log(s); }\nfunction myerr(s) { console.error(\"debug:\" + require(\"util\").inspect(s, false, null)); }\nfunction myconv(i, no) { try { switch (no) { case 1: return parseInt(i); case 2: return i.split(\" \"); case 4: return i.split(\" \").map(Number); case 6: return i.split(\"\"); case 7: return i.split(\"\").map(Number); case 8: return i.join(\" \"); case 9: return i.join(\"\\n\"); case 0: return i.join(\"\"); default: return i; } } catch (e) { return i; } }\n\n\nfunction Main() {\n var in1 = nextIntArray();\n var n = in1[0];\n var k = in1[1] - 1;\n\n var in2 = nextIntArray();\n\n var winning_score = in2[k];\n \n var n_winners = 0;\n for (var i = 0; i < in2.length; i++) {\n if (winning_score <= in2[i] && in2[i] > 0) {\n n_winners++;\n }\n }\n\n return myout(n_winners);\n} // Use Terminal to debug, not Debug Console!", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "9f4f55cbcf9249c40ab5801163ed85d7", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\n\"use strict\";\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet inputString = \"\";\nlet currentLine = 0;\n\nprocess.stdin.on(\"data\", (inputStdin) => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((string) => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n const x = readline();\n const y = readline();\n petyaAndStrings(x,y);\n}\n\n\nfunction petyaAndStrings(a, b) {\n if (a.toLowerCase() > b.toLowerCase()) {\n console.log(1);\n return 1;\n } else if (a.toLowerCase() < b.toLowerCase()) {\n console.log(-1);\n return -1;\n } else {\n console.log(0);\n return 0;\n }\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "790b7434921e6e4004c88dacbe3186e5", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "/**\n * \nA word or a sentence in some language is called a pangram if all the characters of the alphabet of this \nlanguage appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.\n\nYou are given a string consisting of lowercase and uppercase Latin letters.\n Check whether this string is a pangram. We say that the string contains a letter of the Latin alphabet \n if this letter occurs in the string in uppercase or lowercase.\n \n */\n'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n pangram(inputString[0], inputString[1]);\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction pangram(stringLength, word) {\n\n\n let line = readline()\n let alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');\n let stringToMap = {};\n let occurance = {};\n word = word.toLowerCase();\n\n for (let index = 0; index < stringLength; index++) {\n stringToMap[word[index]] = 1;\n }\n\n for (let index = 0; index < alphabet.length; index++) {\n if (stringToMap[alphabet[index]])\n occurance[alphabet[index]] = 1\n }\n\n if (Object.keys(occurance).length == alphabet.length)\n console.log('YES');\n\n else\n console.log('NO');\n}\n\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "81a56bfa29c434c8633beff2f6d6defb", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Input\n'use strict';\n \nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n \nlet inputString = '';\nlet currentLine = 0;\n \nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n \nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n \nfunction readline() {\n return inputString[currentLine++];\n}\n \n//main\nfunction main() {\n var [n,m,a] = readline().split(\" \").map(e=>parseInt(e));\n var nbn = n%a === 0 ? n/a : Math.floor(n/a)+1, nbm = m%a === 0 ? m/a : Math.floor(m/a)+1;\n console.log(nbn*nbm);\n \n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "bb11d7af311680c00f8857b0d8dc5650", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n const [n, m, k] = d.split(' ').map(Number);\n let inc = 1;\n\n let x, y;\n isDone :{\n for (let i = 0; i < n; i++) {\n for (let j = 0; j < m; j++) {\n for (let z = 0; z < 2; z++) {\n if (inc === k) {\n x = i + 1;\n y = j + 1;\n break isDone;\n }\n\n inc++;\n }\n }\n }\n }\n\n console.log(x, y, k % 2 ? 'L' : 'R');\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "b2597631a3b5bf33da8e018604340086", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n let w = readline();\n w = parseInt(w);\n\n if (w%2 === 0 && w > 2) {\n console.log('YES');\n } else {\n console.log('NO');\n }\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "9c1f76d2ef86132b140e6f4fc42bca0a", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(arr) {\n let nMatrix = arr.split('+');\n for (let i = 1; i < nMatrix.length; i++) {\n let min = +nMatrix[i];\n let j = i - 1;\n while (j >= 0 && +nMatrix[j] > min) {\n nMatrix[j + 1] = +nMatrix[j];\n j--;\n }\n nMatrix[j + 1] = min;\n }\n return nMatrix.join('+').toString();\n\n}", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "d48c77dedf265ec739dc392cbb4428c3", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var N = nextInt();\n myout(Math.ceil(N / 5));\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "c133d9269081be464859ecb2270f4218", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar input = [];\nrl.on('line', function (line) {input.push(line);});\nrl.on('close', function() {\n let year = input[0];\n year = Number(year) + 1;\n year = year.toString().split('');\n let result = '';\n \n while([...new Set(year)].length !== year.length) {\n year = Number(year.join('')) + 1;\n year = year.toString().split('');\n }\n \n console.log(year.join(''));\n});\n\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "b683311ce5a55e7bd42b79b58ea1adcf", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n↑入力 ↓出力');\n Main();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var x = nextInt();\n if(x % 4 == 1){\n myout(\"0 A\");\n }else if(x % 4 == 2){\n myout(\"1 B\");\n }else if(x % 4 == 3){\n myout(\"2 A\");\n }else if(x % 4 == 0){\n myout(\"1 A\");\n }\n}", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "aaed250926f6c67c3faaf7d90ab6ac87", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data', (data) => {\n let result = 0;\n const array = data.toString().trim().split('')\n Promise.all(array.reverse().map(datum => {\n result += 10 - datum - 1;\n return Promise.resolve();\n })).then(() => {\n console.log(result + +array[array.length - 1] + Boolean(array.length - 1))\n });\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "d706c6e5dfbc9accfeeb5b0d909692c7", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n \nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n const firstStr = input.pop().toLowerCase();\n const secondStr = input.pop().toLowerCase();\n\n for (let i = 0; i < firstStr.length; i += 1) {\n if (firstStr.charCodeAt(i) > secondStr.charCodeAt(i)) {\n console.log(-1);\n return;\n } else if (firstStr.charCodeAt(i) < secondStr.charCodeAt(i)) {\n console.log(1);\n return;\n }\n }\n\n console.log(0);\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "72c7335ce3fec13b3b4f33c53613f8a0", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function IO(rs, ws, readSize = 1024) {\n let buffer = Buffer.from([]);\n let nextLineIndex;\n let line;\n let chunk;\n\n return {\n rl() {\n while(true) {\n newLineIndex = buffer.indexOf('\\n');\n\n if (newLineIndex === -1 && rs.readableLength === 0) {\n newLineIndex = buffer.length;\n }\n\n if (newLineIndex !== -1) {\n line = buffer.slice(0, newLineIndex);\n\n buffer = buffer.slice(newLineIndex + 1);\n\n return line.toString('utf-8');\n }\n\n if (rs.readableLength === 0) {\n return null\n }\n\n chunk = rs.read(Math.min(readSize, rs.readableLength));\n\n if (!chunk) { return null; }\n\n buffer = Buffer.concat([ buffer, chunk ]);\n }\n },\n\n wr(str) {\n return ws.write(str);\n },\n\n wl(str) {\n return ws.write(str + '\\n');\n }\n };\n}\n\nprocess.stdin.once('readable', () => sol(IO(process.stdin, process.stdout)));\n\nfunction sol({ rl, wr, wl }) {\n let [n, k] = rl().split(' ').map(Number);\n\n while(true) {\n if (k === 0){\n return wl(n);\n }\n\n if (n % 10 === 0) n /= 10;\n else n -= 1;\n\n k -= 1;\n }\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "5282839bb6ae4d65ae0e382f6cdf85eb", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet max;\nlet arr1, arr2;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n max = +d;\n return;\n }\n\n if (c === 1) {\n arr1 = d.split(' ').map(Number);\n c++;\n return;\n }\n\n arr2 = d.split(' ').map(Number);\n\n c++;\n});\n\nrl.on('close', () => {\n let common = 0;\n\n for (let i = 0; i < arr1.length; i++) {\n common += arr1[i] && arr2[i];\n }\n\n let sum1 = arr1.reduce((a, x) => a + x, 0) - common;\n let sum2 = arr2.reduce((a, x) => a + x, 0) - common;\n let ans = sum1 > sum2 ? 1 : -1;\n\n for (let i = 1; i <= max; i++) {\n if (sum1 * i > sum2) {\n ans = i;\n break;\n }\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "8f9115b31d391921d2ee7f3f652894d9", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\n// 자음\nvar j = [ 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z', 'n' ];\n\n// 모음\nvar m = [ 'a', 'o', 'u', 'i', 'e' ];\n\n// 반드시 자음 + 모음\n// 모음 + (자 or 모), n + (자 or 모)\n\nrl.on('line', function(line) {\n\tif(!line) {\n\t\tprocess.exit()\n }\n\n var w = line;\n var v = true;\n\n for(var i = 0; i < w.length; i++) {\n if(w[i] === 'n') {\n continue;\n }\n\n if(j.indexOf(w[i]) > -1) {\n // w[i]가 자음\n if(m.indexOf(w[i + 1]) === -1) {\n v = false;\n break;\n }\n\n continue;\n }\n }\n\n console.log(v ? 'YES' : 'NO');\n})\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "9339b5e389b7528e462010636c32beb7", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "var n = readline().trim() + \"\";\n\nfunction sumOfDigitsInNumber(k){\n var s = 0;\n var a = k.split(\"\").map((h) => {s += +h;})\n return s;\n}\n\nfunction doingSmthWithNumberIDontKnowWhy(n){\n var k = n.split(\"\").reverse();\n var min = false;\n for(var i = 0; i < k.length; i++){\n if(k[i] != \"9\" && !min && i != k.length - 1){\n k[i] = 9;\n min = true;\n }else if(min){\n if(k[i] == \"0\"){\n k[i] = 9;\n }else{\n k[i] = (+k[i] - 1) + \"\";\n break;\n }\n }\n }\n \n if(k[k.length - 1] == \"0\"){\n k = k.reverse().join(\"\").substr(1, k.length);\n }else{\n k = k.reverse().join(\"\");\n }\n \n return (k == n ? \"-\" : k);\n}\n\nvar a = [];\nvar r = 0;\nvar t = n;\nvar max = 0;\nwhile(t != \"-\"){\n a[r] = [t, sumOfDigitsInNumber(t)];\n t = doingSmthWithNumberIDontKnowWhy(t);\n r++;\n}\n\n\na.sort((a, b) => {\n if(a[1] < b[1]){\n return 1\n }else{\n return -1;\n }\n return 0;\n})\n\nvar b = [];\nvar j = 0;\nfor(var i = 0; i < r; i++){\n if(a[0][1] == a[i][1]){\n b[j] = a[i];\n j++;\n if(max < a[i][0].length){\n max = a[i][0].length;\n }\n }\n}\n\nvar c = [];\nr = 0;\nfor(var i = 0; i < j; i++){\n if(b[i][0].length == max){\n c[r] = a[i];\n r++;\n }\n}\n\n\nfor(var i = 0; i < max; i++){\n var max_digit = 0;\n \n for(var j = 0; j < r; j++){\n if(+c[j][0][i] > max_digit) max_digit = +c[j][0][i];\n }\n \n \n max_digit = max_digit + \"\";\n for(var j = 0; j < r; j++){\n if(c[j][0][i] != max_digit){\n c.splice(j, 1);\n r--;\n }\n }\n \n}\n\nprint(c[0][0]);", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "01c184bc0ffca3f704d0398792ac2b56", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let data = '';\nprocess.stdin.on('data', c => data += c);\nconst solution = () => {\n\tlet line = data.split('\\n');\n\tlet n = parseInt(line[0], 10);\n\tlet a = line[1].replace(/RU|UR/g,\"D\").trim();\n\tconsole.log(a.length);\n\t\n};\n\n\nprocess.stdin.on('end', solution);", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3cd06315bc8ac6189c38f13b677d9b83", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function countMarkers(w1, h1, w2, h2){\n let totalBoxes2 = w2 + (2 * h2) + 2; // ((w2+2) * (h2+1)) - (w2 * h2); \n let totalBoxes1 = w1 + (2 * h1) + 2; // ((w1+2) * (h1+1)) - (w1 * h1); \n let rightAllOff = w1 - w2;\n return totalBoxes1 + totalBoxes2 + rightAllOff;\n\n}\n\nfunction processData(input) {\n //Enter your code here\n // const readline = require('readline');\n var numbers = input.split(\" \").map(function(x) { return +x; });\n\n console.log(countMarkers(numbers[0], numbers[1], numbers[2], numbers[3]))\n\n} \n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"ascii\");\n_input = \"\";\nprocess.stdin.on(\"data\", function (input) {\n _input += input;\n});\n\nprocess.stdin.on(\"end\", function () {\n processData(_input);\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "88131b16d8d9824da7bf6ff62e0ddfb4", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require(\"readline\");\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nvar expect = 'n';\nrl.on(\"line\",function(line){\n if(expect == 'n'){\n expect = 'stones';\n }else {\n var s = line;\n var j = 0;\n for (var i = 0; i< s.length; i++){\n if(s[i] == s[i+1]){\n j++;\n }\n }\n console.log(j);\n process.exit(0);\n }\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "89e423e36f99783a49f9e8e470a6c87f", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const mainFunction = (lines) => {\n let arr = lines[1].split(\" \").map(Number).sort((a, b) => a - b);\n arr = [...new Set(arr)]\n //console.log(arr)\n for(let i = 1; i < arr.length - 1; i++) {\n if( Math.abs(arr[i-1]-arr[i]) == Math.abs(arr[i+1]-arr[i]) && Math.abs(arr[i-1]-arr[i]) == 1 \n && [...new Set([arr[i-1], arr[i], arr[i+1]])].length == 3){\n //console.log([arr[i-1], arr[i], arr[i+1]])\n console.log(\"YES\"); return 0;\n }\n }\n console.log(\"NO\");\n}\n\nconst { EOL } = require('os')\nconst fs = require(\"fs\");\nif (__filename.substr(9, 4) != \"azer\") {\n let yourInput = ''\n process.stdin.on('data', i => yourInput += i)\n process.stdin.on('end', () => mainFunction(yourInput.split(EOL)))\n} else {\n mainFunction(fs.readFileSync('input.txt', 'utf8').split(EOL))\n}", "lang_cluster": "Javascript", "tags": ["brute force", "sortings", "implementation"], "code_uid": "3dd7af2031b99091ae685cf8e868f0e1", "src_uid": "d6c876a84c7b92141710be5d76536eab", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\n\nreadLine.on('line', line => input.push(line));\n\nfunction sort(arr) {\n for (let i = 1; i < arr.length; i += 1) {\n for (let j = i; j > 0; j -= 1) {\n if (arr[j] < arr[j-1]) [arr[j], arr[j-1]] = [arr[j-1], arr[j]]; \n }\n }\n}\n\nreadLine.on('close', () => {\n const nums = input[0].split('+').map(x => parseInt(x));\n sort(nums);\n\n console.log(nums.join('+'));\n});", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "bfd818a8525da6789d4a9a3fd8890171", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const [n, k, l, c, d, p, nl, np] = readLine()\n .split(\" \")\n .map((n) => parseInt(n));\n\n console.log(Math.floor(Math.min((k * l) / nl, c * d, p / np) / n));\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "d432180d976e8e587eb1d8756d4a3d6d", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction printResult(x) {\n process.stdout.write(x);\n}\n\nfunction main() {\n const k = parseInt(readLine(), 10);\n const arr = readLine().split(' ').map(Number);\n\n const result = businessTrip(k, arr);\n printResult(result.toString());\n}\n\nconst compare = (a, b) => b - a;\n\nconst businessTrip = (k, a) => {\n a.sort(compare);\n\n if (k === 0) return k;\n let sum = 0;\n for (let i = 0; i < 12; i++) {\n if (sum + a[i] < k) {\n sum += a[i];\n } else {\n return i + 1;\n }\n }\n\n return -1;\n};", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "c0e80e816b00cca04b3ba3d628e5eea8", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\n\nlet inputs = [];\n\nconst rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n});\n\nrl.on(\"line\", line => inputs.push(line));\n\nrl.on(\"close\", () => solution(inputs));\n\nfunction solution([_, data]) {\n\tconst columns = data.split(\" \").map(Number);\n\tconst ans = columns.sort((a, b) => a - b);\n\treturn console.log(...ans);\n};\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "591d17ea035db4eaa92797042215007a", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (str) => {\n console.log(str.split('WUB').filter(x => x.length > 0).join(' '));\n});\n", "lang_cluster": "Javascript", "tags": ["strings"], "code_uid": "21df8c87c13f0588093e2fac2fc84908", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet k, l, m, n, d;\n\nrl.on('line', (data) => {\n if (c === 0) {\n k = +data;\n c++;\n return;\n }\n\n if (c === 1) {\n l = +data;\n c++;\n return;\n }\n\n if (c === 2) {\n m = +data;\n c++;\n return;\n }\n\n if (c === 3) {\n n = +data;\n c++;\n return;\n }\n\n if (c === 4) {\n d = +data;\n c++;\n }\n\n let ans = 0;\n for (let i = 1; i <= d; i++) {\n if (i % k === 0 || i % l === 0 || i % m === 0 || i % n === 0) {\n ans++;\n }\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "b1dd5a719730401a2f44b9a5a43a973c", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Helpful Maths\n\nconst {EOL} = require('os');\n\nlet inp = '';\n\nprocess.stdin.on('data', c => inp += c);\n\nprocess.stdin.on('end', () => {\n process.stdout.write(inp.split(EOL)[0].split('+').sort((a, b) => (+a) - (+b)).join('+'));\n \n return;\n});", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "d0776ff7e70c1012d47e3b0ffd9caf8a", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n var arr=stdin[0].split(' ').map(a => Number(a)),m=arr[0];\n for(var i=0;i= this.allLines.length ) {\n throw new Error( 'No more tokens available!' ) ;\n }\n startIdx = -1 ;\n len = this.allLines[ this.currrentLineNumber ].length ;\n if( typeof( len ) == 'function' ) {\n len = this.allLines[ this.currrentLineNumber ].length() ;\n }\n for( i = this.currrentCharacterIndex ; i < len ; i++ ) {\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {\n startIdx = i ;\n break ;\n }\n }\n if( startIdx == -1 ) {\n this.currrentLineNumber++ ;\n this.currrentCharacterIndex = 0 ;\n continue ;\n }\n res = '' ;\n endIdx = len - 1 ;\n for( i = startIdx ; i < len ; i++ ) {\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {\n endIdx = i ;\n break ;\n }\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {\n res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;\n }\n else {\n res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;\n }\n }\n this.currrentCharacterIndex = endIdx ;\n if( endIdx == len - 1 ) {\n this.currrentLineNumber++ ;\n this.currrentCharacterIndex = 0 ;\n }\n return res ;\n }\n } ;\n\n this.nextInt = function() {\n return parseInt( this.next( 1 ) ) ;\n } ;\n\n this.nextDouble = function() {\n return parseFloat( this.next( 1 ) ) ;\n } ;\n\n this.nextString = function() {\n return this.next( 1 ) ;\n } ;\n\n this.nextLine = function() {\n return this.next( 0 ) ;\n } ;\n}\n\nfunction FileOutputHandler() {\n this.resultantStringArray = new Array() ;\n\n this.addNewLine = function( newString ) {\n this.resultantStringArray.push( newString ) ;\n } ;\n\n this.clearPercase = function() {\n this.resultantStringArray = new Array() ;\n } ;\n\n this.flushOutOutputToFile = function( outputFileName ) {\n var i , sz , res , currentDirectory , fsObj , outputFilePath ;\n res = '' ;\n sz = this.resultantStringArray.length ;\n for( i = 0 ; i < sz ; i++ ) {\n if( i != 0 ) {\n res += '\\n' ;\n }\n res += this.resultantStringArray[ i ] ;\n }\n fsObj = require( 'fs' ) ;\n currentDirectory = __dirname ;\n if( currentDirectory.indexOf( 'D:' ) != -1 ) {\n //on windows\n outputFilePath = currentDirectory + '\\\\' + outputFileName ;\n }\n else {\n //on linux\n outputFilePath = currentDirectory + '/' + outputFileName ;\n }\n fsObj.writeFileSync( outputFilePath , res ) ;\n this.clearPercase() ;\n } ;\n}\n\nfunction CodeExecutioner() {\n this.irObj = new InputReader() ;\n this.psObj = new ProblemSolver() ;\n this.fohObj = new FileOutputHandler() ;\n\n this.runCases = function() {\n\t\tvar testCases , hasMoreTestCases , i ;\n if( this.psObj.HAS_TEST_CASES == true ) {\n testCases = this.irObj.nextInt() ;\n for( i = 0 ; i < testCases ; i++ ) {\n this.psObj.clearPerCase() ;\n this.psObj.getInput( this.irObj ) ;\n this.psObj.solveCase() ;\n }\n }\n else {\n while( true ) {\n this.psObj.clearPerCase() ;\n hasMoreTestCases = this.psObj.getInput( this.irObj ) ;\n if( hasMoreTestCases == false ) {\n break;\n }\n this.psObj.solveCase() ;\n }\n }\n if( this.psObj.DO_OUTPUT_TO_FILE == true ) {\n this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME ) ;\n }\n } ;\n\n this.detectEnvironmentType = function() {\n var environmentType = null ;\n try {\n if( importPackage != null ) {\n environmentType = 'rhino' ;\n }\n }\n catch( ex1 ) {\n try {\n //for nodejs local server check\n if( __dirname != null && ( __dirname.indexOf( 'D:') != -1 || __dirname.indexOf( '/media/') != -1 ) ) {\n environmentType = 'local-node-js' ;\n }\n else {\n environmentType = 'server-node-js' ;\n }\n }\n catch( ex2 ) {\n try {\n if( readline == null || typeof( readline ) != 'function' ) {\n environmentType = 'server-node-js' ;\n }\n else {\n try {\n if( Map != null ) {\n environmentType = 'spider-monkey' ;\n }\n else {\n environmentType = 'javascript-v8' ;\n }\n }\n catch( ex3 ) {\n environmentType = 'javascript-v8' ;\n }\n }\n }\n catch( ex3 ) {\n environmentType = 'server-node-js' ;\n }\n }\n }\n return environmentType ;\n } ;\n\n this.configureStreamsAndReadInput = function() {\n var localContext , isNodeJsJudgeServer , environmentType ;\n isNodeJsJudgeServer = false ;\n environmentType = this.detectEnvironmentType() ;\n if( environmentType == 'local-node-js' ) {\n try {\n if( print == null || typeof( print ) != 'function' ) {\n print = console.log ;\n }\n }\n catch( ex ) {\n print = console.log ;\n }\n if( this.psObj.DO_OUTPUT_TO_FILE == true ) {\n localContext = this.fohObj ;\n print = function() {\n localContext.addNewLine.apply( localContext , arguments ) ;\n }\n }\n this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME ) ;\n this.runCases() ;\n }\n else if( environmentType == 'server-node-js' ) {\n try {\n if( print == null || typeof( print ) != 'function' ) {\n print = console.log ;\n }\n }\n catch( ex ) {\n print = console.log ;\n }\n this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;\n }\n else if( environmentType == 'javascript-v8' ) {\n this.irObj.readAllLines() ;\n this.runCases() ;\n }\n else if( environmentType == 'rhino' ) {\n this.irObj.readAllLinesFromRhino() ;\n this.runCases() ;\n }\n else if( environmentType == 'spider-monkey' ) {\n this.irObj.readAllLines() ;\n this.runCases() ;\n }\n } ;\n \n this.configureStreamsAndReadInput() ;\n}\n\nnew CodeExecutioner() ;\n", "lang_cluster": "Javascript", "tags": ["math", "greedy", "implementation"], "code_uid": "f1704dbc59e33c968556b50d812a9aab", "src_uid": "3cd092b6507079518cf206deab21cf97", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n});\n\nvar str = [];\nvar conts = 0;\n\nfunction main() {\n\trl.question('', (answer) => {\n\t\tif (answer.length) {\n\t\t\tstr.push(answer.toUpperCase());\n\t\t\tconts++;\n\t\t\tif(conts == 2){\n\t\t\t\trl.close();\n\t\t\t\tsolve();\n\t\t\t} else main();\n\t\t}\n\t});\n}\nfunction solve() {\n\tif(str[0] == str[1]) console.log(0);\n\telse if(str[0] < str[1]) console.log(-1);\n\telse console.log(1);\n}\nmain();", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "9a5b224f8ebb3427da17c2f8dfdc36a5", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction print(s) {\n process.stdout.write(`${s}`);\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n // input\n let [n, t, k, d] = readline().split(' ').map(x => parseInt(x));\n const t1 = Math.ceil(n / k) * t;\n let built = false;\n let st = 0;\n let dt = t;\n while (n > 0) {\n if (st > d && !built) {\n built = true;\n dt = Math.ceil(st - d);\n st += t - dt;\n n -= k;\n } else if (built) {\n st += t - dt;\n n -= k;\n }\n if (n > 0) {\n st += dt;\n n -= k;\n }\n }\n // output\n print(st < t1 ? 'YES' : 'NO');\n}\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "25f3836b405b788ee3ec258d6daf9892", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nconst readLine=()=> inputString[currentLine++];\n/* ================================================ \n Main Solution Starts Here \n===================================================*/\n\nconst main=()=>{\n\tlet x=readLine().split('+').map(n=>+n)\n\tx=x.sort().toString()\n\tlet str=''\n\tfor(let i=0;i {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n// utils\nconst MOD = 1e9 + 7;\nconst mod = (n) => ((n % MOD) + MOD) % MOD;\nconst add = (a, b) => mod(mod(a) + mod(b));\nconst sub = (a, b) => mod(mod(a) - mod(b));\nfunction mul() {\n for (var a = arguments, r = a[0], i = a.length; --i; )\n r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;\n return r;\n}\nfunction inv(b) {\n for (var a = MOD, u = 0, v = 1, t; b; v = t)\n (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);\n u %= MOD;\n return u < 0 ? u + MOD : u;\n}\nfunction pow(base, n) {\n if (n === 0) return 1;\n let p = pow(base, Math.floor(n / 2));\n let res = mul(mod(p), mod(p));\n if (n % 2 === 1) res = mul(mod(res), base);\n return res;\n}\nfunction highestOneBit(i) {\n i |= i >> 1;\n i |= i >> 2;\n i |= i >> 4;\n i |= i >> 8;\n i |= i >> 16;\n return i - (i >>> 1);\n}\nfunction permutation(arr, len, store = \"\", permutations = []) {\n if (store.length === len) {\n permutations.push(store);\n return;\n }\n for (let i = 0; i < arr.length; i++) {\n const newArr = [...arr];\n const newChar = newArr.splice(i, 1);\n permutation(newArr, len, store.concat(newChar), permutations);\n }\n return permutations;\n}\n\nfunction main() {\n let [count100, count200] = [0, 0];\n const len = +readLine();\n const arr = readLine()\n .split(\" \")\n .map((n) => {\n n = parseInt(n);\n if (n === 100) count100++;\n else count200++;\n return n;\n });\n\n const sum = arr.reduce((total, num) => total + num, 0);\n\n if (Math.floor(sum / 2) % 2 !== 0 || count100 % 2 !== 0 || (count200 === len && count200 % 2 !== 0)) {\n console.log(\"NO\");\n } else {\n console.log(\"YES\");\n }\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "a1008c860394a7eb8c837d26a4be1974", "src_uid": "9679acef82356004e47b1118f8fc836a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\n\nconst readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nreadline.on('line', line => {\n readline.close(), console.log(capsLocks(line));\n});\nconst capsLocks = (word) => {\n const upperCase = /^[A-ZÑ]+$/g;\n\n if (word.length > 1) {\n const first = word.charAt(0);\n const last = word.slice(1);\n\n if (upperCase.test(word))\n return word.toLowerCase();\n else if (upperCase.test(last) && !upperCase.test(first))\n return first.toUpperCase() + last.toLowerCase();\n else\n return word;\n }\n else\n if (!upperCase.test(word))\n return word.toUpperCase();\n else\n return word.toLowerCase();\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "f37825e0a88439ca54745a40a6ff0387", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let fs = require(\"fs\");\n\nlet txt = fs.readFileSync(0, \"utf-8\").split(\"\\r\\n\").filter(data => {\n return data.length > 0;\n});\nfor (let i = 0; i < txt.length; i++) {\n let info = txt[i].split(\" \");\n doit(info[0] * 1, info[1] * 1, info[2] * 1);\n}\n\nfunction doit(m, n, a) {\n console.log(Math.ceil(m / a) * Math.ceil(n / a));\n\n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "0cc534b00b1d748701a69560afdf3270", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n \nconst input = [];\nreadLine.on('line', line => input.push(line));\n \nreadLine.on('close', () => {\n const n = +input.shift();\n const s = new Set(input[0].toLowerCase());\n console.log(s.size === 26 ? 'YES' : 'NO');\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "a72323a43fcc19ce7ffd49f859732d6a", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(str) {\n let inputs = str.trim().split('\\n');\n let dragons = inputs.slice(0, inputs.length - 1);\n let totalDragons = +inputs[inputs.length - 1];\n let damagedDragons = [];\n\n for (let row of dragons) {\n for (let i = 1; i <= totalDragons; i++) {\n let multiple = row * i;\n if (multiple <= totalDragons) {\n damagedDragons.push(multiple);\n }\n }\n }\n damagedDragons = [...new Set(damagedDragons)].length;\n return damagedDragons.toString();\n}\n", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "8f9538e825592dc35b32b0dfbe2bc19b", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nlet inputs = [];\n\n// Create readline Interface\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\n// Read Inputs\nrl.on('line', inputLine => {\n const n = parseInt(inputLine);\n\n if (n >= 0) {\n return console.log(n)\n } else {\n let digits = Math.abs(n).toString().split('');\n const lastNum = digits[digits.length - 1];\n const numBeforeLast = digits[digits.length - 2];\n if (lastNum > numBeforeLast) {\n const temp = digits.slice(0);\n const idxOfLast = temp.length - 1;\n temp.splice(idxOfLast, 1)\n return console.log(`-${temp.join('')}`)\n } else {\n const temp = digits.slice(0);\n const idxBeforeLast = temp.length - 2;\n temp.splice(idxBeforeLast, 1)\n\n if (temp.join('') == 0)\n return console.log(temp.join(''))\n\n return console.log(`-${temp.join('')}`)\n }\n\n return console.log(`-${digits.join('')}`)\n\n }\n\n});", "lang_cluster": "Javascript", "tags": ["implementation", "number theory"], "code_uid": "da02b10217506fafb171ee2083c111bf", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\n\nlet a, b, c;\nrl.on('line', (line) => {\n [a, b, c] = line.split(' ').map(i => parseInt(i));\n}).on('close', () => {\n process.stdout.write(\"\" + Math.ceil(a / c) * Math.ceil(b / c));\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "0756b9bc1d00b67756c49ac9a7d48ae4", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let [n, s] = require('fs')\n .readFileSync(0, 'ascii')\n .split('\\n')\n .filter(line => !/^\\s*$/.test(line));\n\nlet min = 0;\nlet sum = 0;\nfor (const c of s) {\n if (c == '+') {\n sum++;\n } else if (c == '-') {\n sum--;\n if (sum < min)\n min = sum;\n }\n}\n\nconsole.log(sum - min);\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "26ba4542c48aed98c41c5e4f07d0e0d5", "src_uid": "a593016e4992f695be7c7cd3c920d1ed", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const n1 = readLine();\n const n2 = readLine();\n let n = \"\";\n for (let i = 0; i < n1.length; i++) {\n const bit = +n1[i] ^ +n2[i];\n n += `${bit}`;\n }\n console.log(n);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "9a582cfe41abe9c53c0d1c46ded3adb4", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', input => {\n let sum = 0\n n = +input\n for (let i = 0; i < n; i++) {\n sum += (n - i) * i\n }\n console.log(sum + n)\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "21fa7d7033fddc770b57c8077cc2b384", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require(\"readline\");\n\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nfunction ans(line) {\n return line\n .toLowerCase()\n .split(\"\")\n .map(function(e) {\n if (\"aeioyu\".includes(e)) return \"\";\n else return \".\" + e;\n })\n .join(\"\");\n}\n\nrl.on(\"line\", function(line) {\n console.log(ans(line));\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "fa277f8afbc3d0e9c4c88b8f6d845733", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "(()=>{\"use strict\";var t={675:(t,e)=>{Object.defineProperty(e,\"__esModule\",{value:!0}),Array.prototype.sortAsc=function(){return this.sort(((t,e)=>t-e))},Array.prototype.sortDesc=function(){return this.sort(((t,e)=>e-t))},Array.prototype.max=function(){return Math.max(...this)},Array.prototype.min=function(){return Math.min(...this)},Array.prototype.sum=function(){let t=0;for(let e=0;e{if(l)return i=o.default.readFileSync(\"input.txt\").toString().trim().split(\"\\n\").map((t=>t.trim())),t(),void o.default.writeFileSync(\"output.txt\",a);process.stdin.resume(),process.stdin.setEncoding(\"utf-8\"),process.stdin.on(\"data\",(t=>{u+=t})),process.stdin.on(\"end\",(e=>{i=u.trim().split(\"\\n\").map((t=>t.trim())),t(),console.log(a)}))};function c(){return i[s++]}function p(){return c().split(\" \").map((t=>parseFloat(t)))}function d(){return c().split(\"\")}e.default={runMain:f,runEachTest:t=>{f((()=>{let[e]=p();for(;e>0;)t(),e--}))},readline:c,nextNumbers:p,nextNumbersMatrix:function(t){let e=[];for(let r=0;r{t.exports=require(\"fs\")}},e={};!function r(n){if(e[n])return e[n].exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,r),o.exports}(965)})();", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "f98f1dc8e7f060f0bffb45a116ffe899", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet standardInputString= '';\nlet currentLine = 0;\n\nfunction readLine(){\n return standardInputString[currentLine++];\n}\n\nprocess.stdin.on('data', rawData =>{\n standardInputString += rawData;\n});\n\nprocess.stdin.on('end', _ =>{\n standardInputString= standardInputString.trim().split('\\n').map(line =>{\n return line.trim();\n });\n\n main();\n})\n\n\n\nfunction main(){\n let [n] = readLine().split(' ').map(Number);\n\n let line = readLine().split(' ').map(Number);\n\n\n let consecutives = 0;\n\n let result = 0;\n line.unshift(0);\n line.push(1001);\n\n for(let i =1; i<=n; i++){\n if(line[i]-1 ===line[i-1]&& line[i+1] -1 === line[i]){\n consecutives++;\n }\n else{\n consecutives = 0;\n }\n result = Math.max(result, consecutives);\n }\n console.log(result);\n }\n", "lang_cluster": "Javascript", "tags": ["greedy", "implementation"], "code_uid": "04f455cac730a095df7b752c0cd07cae", "src_uid": "858b5e75e21c4cba6d08f3f66be0c198", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Interface of codeforces.com\nconst readline = require('readline');\nconst matrix = [];\n\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', lineInput => {\n makeMatrix(lineInput)\n});\n\nrl.on('close', () => console.log(solution(matrix)));\n\n\nfunction makeMatrix(line) {\n const row = line.split(' ').map(char => Number(char));\n matrix.push(row);\n}\n\n\nfunction solution(matrix) {\n// Get the matrix from the input and put it into a data structure\n// Count the minimum number needed to make the matrix beautiful\n const index = getIndex(matrix);\n return (Math.abs(2 - index[0]) + Math.abs(2 - index[1]));\n\n}\n\n\n// Finds and returns the index of '1'\nfunction getIndex(matrix) {\n let x = 0, y = 0;\n for (let i = 0; i < matrix.length; i++) {\n for (let j = 0; j < matrix.length; j++) { \n if (matrix[i][j] === 1) {\n return [i, j];\n }\n }\n }\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "64edeb11387f1bb9b9116798494b8963", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n \nprocess.stdin.on('data', (input) => {\n process.stdout.write(input.match(/h+.*e+.*l+.*l+.*o+.*/g) ? 'YES' : 'NO');\n});", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "82e663b38c69ea13698d99c95fdaf526", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', line => {\n line\n .split(' ')\n .map(Number)\n .reduce((a, b) => {\n a > b ? console.log(`${b} ${Math.floor((a - b) / 2)}`) : console.log(`${a} ${Math.floor((b - a) / 2)}`);\n });\n}).on('close', () => {\n process.exit(0);\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "3da9fc35ac0f35a4c796e1820bbf171e", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nlet _inputLines;\nlet _lineNumber = 0;\nlet inputReader = _inputReader ();\n\nfunction _main() {\n\t\n\t_inputLines = _inputData.trim().split('\\n').map((string) => {\n\t\treturn string.trim();\n\t});;\n\tlet str = inputReader.readLine();\n\tlet n = inputReader.readNumber();\n\tlet arr = [];\n\t\n\tlet bool = false;\n\tfor (let i = 0; i < n; i++) {\n\t\tarr[i] = inputReader.readLine();\n\t\tif (arr[i] === str) {\n\t\t\tbool = true;\n\t\t}\n\t}\n\t\n\tif (n === 1) {\n\t\tlet str1 = \"\" + arr[0] + arr[0];\n\t\tif (str[0] == str1[1] && str[1] == str1[2]) {\n\t\t\tbool = true;\n\t\t}\n\t\t//console.log(str1,str1[1],str[0]);\n\t} else if (!bool) {\n\t\tfor (let i = 0; i < n; i++) {\n\t\t\tfor (let j = 0; j < n; j++) {\n\t\t\t\tlet res = arr[i] + arr[j];\n\t\t\t\tif (str[0] == res[1] && str[1] == res[2]) {\n\t\t\t\t\tbool = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (bool) break;\n\t\t}\n\t}\n\tif (bool) {\n\t\tconsole.log(\"YES\");\n\t} else {\n\t\tconsole.log(\"NO\");\n\t}\n\n}\n\nvar _inputData = '';\nfunction cacheInput(data) {\n\t_inputData += data;\n}\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf8');\nprocess.stdin.on('data', cacheInput).on('end', _main);\n\nfunction _inputReader () {\n\tfunction readNumber(){\n\t\treturn Number(_inputLines[_lineNumber++]);\n\t}\n\t\t\n\tfunction readLine(){\n\t\treturn _inputLines[_lineNumber++];\n\t}\n\t\t\n\t\n\treturn {\n\t\treadNumber,\n\t\treadLine,\n\t}\n}", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "05b564b89ee06be1ae54ee3aef5a595f", "src_uid": "cad8283914da16bc41680857bd20fe9f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadline.on('line', line => input.push(line));\n\nreadline.on('close', () => {\n let [number, count] = input[0].split(' ').map(v => parseInt(v));\n while (count--) {\n if (number % 10 === 0) {\n number /= 10;\n continue;\n }\n number--;\n }\n\n console.log(number);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "1a787a827952dd3f5ba7c4c7270ffc35", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = '';\n\nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os');\n const lines = i.split(EOL);\n var t = lines[0].split('');\n var sum = 0;\n for(var j=0;j {\n let ans = true;\n\n for (let i = 2; i*i <= n; i++) {\n if (n % i === 0) {\n return false;\n }\n }\n\n return ans;\n}\n\nrl.on('line', (d) => {\n const [n, m] = d.split(' ').map(Number);\n let ans = 'NO';\n\n for (let i = n + 1; i <= m; i++) {\n if (isPrime(i) && i !== m) {\n break;\n }\n\n if (isPrime(i) && i === m) {\n ans = 'YES';\n break;\n }\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "582fe2064cdaad39c54cac6b77f49850", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function keyboard(direction, string) {\n let keyboard = \"qwertyuiopasdfghjkl;zxcvbnm,./\".split(\"\");\n let result = \"\";\n let indicator = direction === \"R\" ? -1 : 1;\n for (let i = 0; i < string.length; i++) {\n result += keyboard[keyboard.indexOf(string[i]) + indicator];\n }\n console.log(result);\n}\n\nconst readline = require(\"readline\");\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet arr = [];\nrl.on(\"line\", (line) => {\n arr.push(line);\n});\n\nrl.on(\"close\", () => {\n keyboard(arr[0], arr[1]);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "ff74e98b080b20f8ef234866212e41e7", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nlet stdin = [];\nrl.on('line', function (line) {stdin.push(line);});\nrl.on('close', main);\n\n// let stdin = [\n// // '512 4',\n// // '1000000000 9',\n// ]\n// main();\n\nfunction main() {\n let [n, k] = stdin[0].split(' ');\n for (let i = 1; i<=Number(k); i++) {\n const lastDigit = n[n.length - 1];\n if(lastDigit !== '0') {\n n = String(Number(n) - 1);\n } else {\n n = n.slice(0, -1);\n }\n }\n console.log(n)\n}\n\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f02a6c68cf01cf99392e42e403c7854c", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// author: Oscar Ramos\n\n/// Source Code\n// const input = require('competitive-programming-js').inputReader\n// const { forn } = require('../utils/utils')\n// \n// const [n, k] = input.readNumberArray()\n// \n// const a = input.readNumberArray()\n// \n// a.sort((x, y) => y-x)\n// \n// let cnt = 0\n// forn(n, idx => {\n// if(a[idx] > 0 && a[idx] >= a[k-1])\n// cnt++\n// })\n// \n// console.log(cnt)\n// \n\n!function(t){var n={};function r(e){if(n[e])return n[e].exports;var o=n[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=t,r.c=n,r.d=function(t,n,e){r.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:e})},r.r=function(t){\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(t,\"__esModule\",{value:!0})},r.t=function(t,n){if(1&n&&(t=r(t)),8&n)return t;if(4&n&&\"object\"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(r.r(e),Object.defineProperty(e,\"default\",{enumerable:!0,value:t}),2&n&&\"string\"!=typeof t)for(var o in t)r.d(e,o,function(n){return t[n]}.bind(null,o));return e},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,\"a\",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p=\"\",r(r.s=1)}([function(t,n){t.exports=function(t){return null!=t&&\"object\"==typeof t&&!0===t[\"@@functional/placeholder\"]}},function(t,n,r){t.exports=r(2)},function(t,n,r){let e,o=0,u={readNumberArray:function(){return e[o++].split(\" \").map(t=>Number(t))}};var i=\"\";process.stdin.resume(),process.stdin.setEncoding(\"utf8\"),process.stdin.on(\"data\",(function(t){i+=t})).on(\"end\",(function(){e=i.trim().split(\"\\n\").map(t=>t.trim());const{forn:t}=r(3),[n,o]=u.readNumberArray(),c=u.readNumberArray();c.sort((t,n)=>n-t);let f=0;t(n,t=>{c[t]>0&&c[t]>=c[o-1]&&f++}),console.log(f)}))},function(t,n,r){const e=r(4);t.exports={forn:(t,n)=>e(0,t).map(t=>n(t)),fornm:(t,n,r)=>e(0,t).map(t=>e(0,n).map(n=>r(t,n))),matrix:(t,n,r)=>e(0,t).map(()=>e(0,n).map(()=>r))}},function(t,n,r){var e=r(5),o=r(7),u=e((function(t,n){if(!o(t)||!o(n))throw new TypeError(\"Both arguments to range must be numbers\");for(var r=[],e=t;e {\n inputs.push(lineInput);\n})\n\n// Read Inputs\nrl.on('close', () => {\n const line1 = inputs[0].split(' ');\n const r = parseInt(line1[0]);\n const c = parseInt(line1[1]);\n\n const rows = [];\n let clearRows = 0;\n let clearCols = 0; \n\n // rows\n for (let i = 1; i < r + 1; i++) {\n const row = inputs[i];\n rows.push(row)\n if (!row.split('').includes('S'))\n clearRows++;\n }\n\n // // cols\n for (let i = 0; i < c; i++) {\n let f = 0;\n for (let j = 0; j < r; j++) {\n const box = rows[j].split('')[i];\n if (box === 'S') { f = 1; break; }\n }\n if (!f)\n clearCols++;\n }\n let overlaps = clearCols * clearRows;\n let maximumCakes = ((clearCols * r) + (clearRows * c)) - overlaps\n\n console.log(maximumCakes)\n\n});\n\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "25e80799450382d20713546b78e3a23c", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction print(s) {\n process.stdout.write(`${s}`);\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n // input\n let n = readline();\n const numbers = readline().split(' ').map(x => parseInt(x))\n .sort((a, b) => a - b);\n\n // output\n print(numbers.join(' '));\n}\n\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "e67fdc9a1cadb366782f1b556df05b01", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nreadline.on(\"line\", (line) => {\n const N = +line.split(\" \")[0];\n const M = +line.split(\" \")[1];\n const A = +line.split(\" \")[2];\n readline.close();\n main(N, M, A);\n return;\n});\n\nconst main = (w, h, A) => {\n const ceilsForWidth = Math.ceil(w / A);\n const ceilsForHeight = Math.ceil(h / A);\n console.log(ceilsForWidth * ceilsForHeight);\n};\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "e43818e0b8f9ebebe21455a5e1d4e021", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var read = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\nvar obj;\nvar inLine = [];\nread.on('line', function (input) { inLine.push(input); });\nread.on('close', function () {\n obj = init(inLine);\n myerr(\"-----start-----\");\n var start = new Date();\n Main();\n var end = new Date() - start;\n myerr(\"----- end -----\");\n myerr(\"Time: \" + (end) + \"ms\");\n myerr(\"Memory: \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction nextInt() { return myconv(next(), 1); }\nfunction nextStrArray() { return myconv(next(), 2); }\nfunction nextIntArray() { return myconv(next(), 4); }\nfunction nextCharArray() { return myconv(next(), 6); }\nfunction next() { return obj.next(); }\nfunction hasNext() { return obj.hasNext(); }\nfunction init(input) {\n var returnObj = {\n list: input, index: 0, max: input.length,\n hasNext: function () { return (this.index < this.max); },\n next: function () { if (!this.hasNext()) { throw \"ArrayIndexOutOfBoundsException\"; } else { var returnInput = this.list[this.index]; this.index++; return returnInput; } }\n };\n return returnObj;\n}\nfunction myout(s) { console.log(s); }\nfunction myerr(s) { console.error(\"debug:\" + require(\"util\").inspect(s, false, null)); }\nfunction myconv(i, no) { try { switch (no) { case 1: return parseInt(i); case 2: return i.split(\" \"); case 4: return i.split(\" \").map(Number); case 6: return i.split(\"\"); case 7: return i.split(\"\").map(Number); case 8: return i.join(\" \"); case 9: return i.join(\"\\n\"); case 0: return i.join(\"\"); default: return i; } } catch (e) { return i; } }\n\n\nfunction Main() {\n var str1 = next();\n var str2 = next();\n\n myout(str1.localeCompare(str2, 'en', { sensitivity: 'base' }));\n \n} // Use Terminal to debug, not Debug Console!", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "a9ffaaafb39814895254f8ec6ea20ca2", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let string = ''\nprocess.stdin.setEncoding('ASCII')\nprocess.stdin.on('data', (data) => string += data)\n\nconst gcd = (a, b) => {\n if (a % b == 0) return b;\n return gcd(b, a % b);\n}\n\nconst main = (input) => {\n let n = Number(input[0]);\n let list = input[1].split(' ').map(Number), ans = list[0];\n for (let i = 1; i < list.length; ++i) ans = gcd(ans, list[i]);\n console.log( ans * n );\n}\n\nprocess.stdin.on('end', () => main(string.trim().split('\\n')))\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "3475e52b1ac825b3ffd7cc89bd0747ab", "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = '';\nprocess.stdin.on('data', (c) => {\n i += c;\n});\nprocess.stdin.on('end', () => {\n const { EOL } = require('os');\n const lines = i.split(EOL);\n getMaxMin(...lines[0].split(' '));\n});\n\n\nfunction getMaxMin(n, l, r) {\n n = parseInt(n, 10);\n l = parseInt(l, 10);\n r = parseInt(r, 10);\n // get max\n let unique = 1;\n const arr = [];\n let curr = 1;\n while (unique < r && arr.length < n) {\n unique++;\n arr.push(curr);\n curr *= 2;\n }\n\n while (arr.length < n) {\n arr.push(curr);\n }\n\n const max = arr.reduce((a, b) => a + b);\n\n let index = arr.length - 1;\n\n // first pass\n while (index > 0 && arr[index] === curr) {\n arr[index] = 1;\n index--;\n if (arr[index] !== curr && unique === l) {\n arr[index + 1] = curr;\n }\n }\n\n unique--;\n\n while (index > 0 && unique > l && arr[index] !== 1) {\n arr[index] = 1;\n unique--;\n index--;\n }\n\n const min = arr.reduce((a, b) => a + b);\n console.log(`${min} ${max}`);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "270b972727e4042640a0cb72688c2ab7", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main(input) {\n \n var a,b,c;\n var d =[];\n var x=[];\n input =input.split(/\\n/g);\n var arr = input[0].split(' ').map(Number);\n \n x[0]=arr[0];\n x[1]=arr[1];\n x[2]=arr[2];\n //console.log(x);\n var dis=arr[3];\n \n x.sort(function(a, b){return a - b});\n //console.log(x);\n\n d[0]=Math.abs(x[0]-x[1]);\n d[1]=Math.abs(x[0]-x[2]);\n d[2]=Math.abs(x[1]-x[2]);\n //console.log(d);\n var m = Math.min(...d);\n //console.log(m)\n if(m>=dis){\n console.log(0);\n return;\n }\n \n var time=0;\n if(d[0] Number(num));\n let minSocks = Math.min(...inputs);\n let maxSocks = Math.max(...inputs);\n let wearSameSocks = Math.floor((maxSocks - minSocks) / 2) > 0 ? Math.floor((maxSocks - minSocks) / 2) : 0;\n\n return minSocks + ' ' + wearSameSocks.toString();\n}\n\n\n\n\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "fe21f66fa05b9ad8771f5bb477d455fd", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let data = '';\nprocess.stdin.on('data', c => data += c);\n\nfunction* nextLine() {\n\tlet lines = data.trim().split(/\\n/g);\n\tfor(let l of lines){\n\t\tyield l.trim();\n\t}\n}\n\nlet nl = nextLine();\n\nnl.elem = function(funParse) {\n\t\treturn funParse(this.next().value);\t\n\t};\n\nnl.array = function(funParse) {\n\t\treturn this.next().value.split(/\\s/g).map(funParse||(x => x));\n\t};\n\t\nnl.num = function() {\n\t\treturn nl.elem(Number);\n\t};\n\t\nnl.nums = function() {\n\t\treturn nl.array(Number);\n\t};\n\t\nnl.line = function() {\n\t\treturn this.next().value;\n\t};\n\t\nconst sol = () => {\n let a = [];\n\tfor(let i = 0; i < 6; i++){\n a.push(nl.num());\n }\n let sum = 0;\n if (a[5] > a[4]){\n let x = Math.min(a[1],a[2],a[3]);\n sum += x * a[5];\n sum += Math.min(a[0],a[3] - x) * a[4];\n } else {\n let x = Math.min(a[0],a[3]);\n sum += x * a[4];\n sum += Math.min(a[1],a[2],a[3] - x) * a[5];\n }\n\tconsole.log(sum);\n\n};\n\nprocess.stdin.on('end', sol);\n", "lang_cluster": "Javascript", "tags": ["math", "greedy", "brute force"], "code_uid": "6149590f3acdfe670817d9a9b1061d27", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\n\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nfunction ans(line) {\n\n}\n\nString.prototype.answerString = function () {\n line = this.valueOf();\n return line.toLowerCase().split('').map((e) => {return 'aeiouy'.includes(e) ? '':`.${e}`}).join('');\n}\n\nrl.on('line', function (line) {\n console.log(line.answerString());\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "fd3c4f424ef8a202433c624e79564835", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var stdin = \"\";\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"ascii\");\nprocess.stdin.on(\"data\", function(data) {\n stdin += data;\n});\nprocess.stdin.on(\"end\", function() {\n main(stdin);\n});\n\nconst debug = 0;\nvar log = console.log;\nvar dbg = debug ? console.log : _ => {};\n\n/////////////// ignore above this line ////////////////////\n\nfunction main(stdin) {\n if (stdin > 3) {\n log(stdin % 2 ? \"NO\" : \"YES\");\n } else {\n log(\"NO\");\n }\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "673f1ca2d70492001a027560140c1f1f", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (str) => {\n if (c === 0) {\n c++;\n return;\n }\n\n let v = 0;\n let inc = 1;\n let ans = '';\n\n while (v < str.length) {\n ans += str[v];\n v += inc;\n inc++;\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "650a7233ac92a06286fe181ce00aae5b", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nreadline.question('', w => {\n if (w <= 2 || w % 2 !== 0) {\n console.log(\"NO\");\n } else {\n console.log(\"YES\");\n }\n readline.close();\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "644847b0fbbf7ffe00c57cd04d9aacf2", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = ''\n\nprocess.stdin.on('data',c => {\n i += c\n})\n\nprocess.stdin.on('end', () => {\n const { EOL } = require('os')\n const lines = i.split(EOL) /*your input text, split by lines*/\n\n let inputData = lines[0].split(\" \")\n let tableSize = parseInt(inputData[0])\n let desiredNumber = parseInt(inputData[1])\n let numberOfOccurrence = 0\n\n for(i = 1; i <= tableSize; i++) {\n if ( desiredNumber / i <= tableSize && desiredNumber % i === 0 ) {\n numberOfOccurrence++\n }\n }\n console.log(numberOfOccurrence)\n})", "lang_cluster": "Javascript", "tags": ["implementation", "number theory"], "code_uid": "60f22a9920e24a055401a088e90fb650", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\n\nlet inputs = [];\n\n// Create readline Interface\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\n\n// Read Inputs\nrl.on('line', lineInput => {\n inputs.push(lineInput);\n})\n\n\n// Excute algorithm\nrl.on('close', () => {\n let statement = inputs[0].split('+');\n statement.sort((a, b) => a - b);\n console.log(statement.join('+'))\n})", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "fb0252bc6fcd509e0c93bab79547ad95", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = '';\nprocess.stdin.on('data', c => i += c);\nprocess.stdin.on('end', () => {\n const {EOL} = require('os');\n const lines = i.split(EOL) ;/*your input text, split by lines*/\n const k = lines[0];\n const arr = lines.slice(1, lines.length).filter(l => l).map(l => parseInt(l));\n\n if ((arr.reduce((a, v) => a + v, 0) % 360) === 0) {\n \tconsole.log(\"YES\");\n \treturn;\n }\n\n \tfunction subseqs(arr, k) {\n\t\t\tconst n = arr.length;\n\t\t\tconst res = [];\n\t\t\tlet j = 0;\n\n\t\t\tfor (let mask = 0; mask < (1 << n); mask++) {\n\t\t\t\tlet num = 0;\n\n\t\t\t\tfor (let i = 0; i < n; i++) {\n\t\t\t\t\tif (mask & (1 << i)) {\n\t\t\t\t\t\tnum++;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (num === k) {\n\t\t\t\t\tres[j] = [0, 0];\n\n\t\t\t\t\tfor (let i = 0; i < n; i++) {\n\t\t\t\t\t\tif (mask & (1 << i)) {\n\t\t\t\t\t\t\tres[j][0] = (res[j][0] + arr[i]) % 360;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tres[j][1] = (res[j][1] + arr[i]) % 360;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tj++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn res;\n\t\t}\n\n\tfor (let i = 1; i < arr.length / 2 + 1; i++) {\n\t\tfor (const ss of subseqs(arr, i)) {\n\t\t\tif (ss[0] === ss[1]) {\n\t\t\t\tconsole.log(\"YES\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\tconsole.log(\"NO\");\n});\n\n// const lines = `15\n// 168\n// 168\n// 168\n// 168\n// 168\n// 168\n// 168\n// 168\n// 168\n// 168\n// 168\n// 168\n// 168\n// 168\n// 168`.split('\\n');\n//\n// const k = lines[0];\n// const arr = lines.slice(1, lines.length).filter(l => l).map(l => parseInt(l));\n//\n// if ((arr.reduce((a, v) => a + v, 0) % 360) === 0) {\n// \tconsole.log(\"YES\");\n// \tproccess.exit(0);\n// }\n//\n// function subseqs(arr, k) {\n// \tconst n = arr.length;\n// \tconst res = [];\n// \tlet j = 0;\n//\n// \tfor (let mask = 0; mask < (1 << n); mask++) {\n// \t\tlet num = 0;\n//\n// \t\tfor (let i = 0; i < n; i++) {\n// \t\t\tif (mask & (1 << i)) {\n// \t\t\t\tnum++;\n// \t\t\t}\n// \t\t}\n//\n// \t\tif (num === k) {\n// \t\t\tres[j] = [0, 0];\n//\n// \t\t\tfor (let i = 0; i < n; i++) {\n// \t\t\t\tif (mask & (1 << i)) {\n// \t\t\t\t\tres[j][0] = (res[j][0] + arr[i]) % 360;\n// \t\t\t\t} else {\n// \t\t\t\t\tres[j][1] = (res[j][1] + arr[i]) % 360;\n// \t\t\t\t}\n// \t\t\t}\n//\n// \t\t\tj++;\n// \t\t}\n// \t}\n//\n// \treturn res;\n// }\n//\n// for (let i = 1; i < arr.length; i++) {\n// \tfor (const ss of subseqs(arr, i)) {\n// \t\tif (ss[0] === ss[1]) {\n// \t\t\tconsole.log(\"YES\");\n// \t\t\tproccess.exit(0);\n// \t\t}\n// \t}\n// }\n//\n// console.log(\"NO\");\n//\n", "lang_cluster": "Javascript", "tags": ["brute force", "dp", "bitmasks"], "code_uid": "e6dddb91d9987a46c2733f4e66a31300", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n \nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n \nlet inputString = '';\nlet currentLine = 0;\n \nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n \nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n \nfunction readLine() {\n return inputString[currentLine++];\n}\n \n \nfunction main() {\n const parameterVariable = readLine();\n const line2 = readLine();\n \n if(parameterVariable > 2 && parameterVariable % 2 === 0) console.log('YES')\n else console.log('NO')\n \n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "ab3c91184097e9badfad8eb3800d726a", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet l = 0;\nrl.on('line', (input) => {\n rl.close();\n let inp = input.split(\"\")\n let res = \"\"\n if (inp.length >= 2 && inp.length % 2 === 1) {\n res += inp[Math.floor((inp.length / 2))]\n } else if (inp.length >= 2 && inp.length % 2 === 0) {\n res += inp[Math.floor((inp.length / 2) - 1)]\n }\n let ln = inp.length % 2 === 1 ? inp.length / 2 : inp.length / 2\n ln = Math.floor(ln)\n let inc = inp.length % 2 === 1 ? 0 : 1\n for (let i = 1; i < ln; i++) {\n res += inp[ln + i - inc]\n res += inp[ln - i - inc]\n }\n res += inp[inp.length - 1]\n if (inp.length > 1 && inp.length % 2 == 1) {\n res += inp[0]\n }\n console.log(res)\n return 0;\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "b766279b12768f70b793036568633607", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n');\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr('time : ' + end + 'ms');\n myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var tmp = nextIntArray();\n var one = tmp[0] * 2 + tmp[1] * 2;\n var two = tmp[0] + tmp[1] + tmp[2];\n var three = tmp[0] * 2 + tmp[2] * 2;\n var four = tmp[1] * 2 + tmp[2] * 2;\n myout(Math.min.apply(null, [one, two, three, four]));\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e10d0114981f8d32b0736728471989d1", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nlet stickLength;\nlet lines=0;\nrl.on('line', (input,index) => {\n let res=input.split(\" \");\n\n stickLength=Number(res[0]);\n\n lines++;\n}).on('close', () => {\n getRectangleStick(stickLength);\n});\n\n\n\nfunction getRectangleStick(stickLength) {\n if(stickLength<=2000000000 && stickLength%2 === 0){\n if(stickLength%4===0){\n console.log(Math.trunc((stickLength-1)/4));\n }else{\n console.log(Math.trunc(stickLength/4));\n }\n }else{\n console.log(0);\n }\n}", "lang_cluster": "Javascript", "tags": ["math", "combinatorics"], "code_uid": "b1cfae1ab7ba711941ba6c1fbad5c898", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function rem(a, b) {\n if (b <= 0) {\n throw Error('divisor must be positive');\n } else {\n const r = (a % b);\n return (r < 0) ? (r + b) : r;\n }\n}\n\nfunction quot(a, b) {\n if (b <= 0) {\n throw Error('divisor must be positive');\n } else {\n const r = rem(a, b);\n const q = ((a - r) / b);\n return q;\n }\n}\n\nfunction ceil(a, b) {\n const r = rem(a, b);\n const q = quot(a, b);\n return (r === 0) ? q : (q + 1);\n}\n\nfunction solve(n, m, a) {\n const x = ceil(n, a);\n const y = ceil(m, a);\n const result = (x * y);\n return result;\n}\n\nfunction main(lines) {\n for (const line of lines) {\n let t = line.trim();\n if (line.length > 0) {\n const [n, m, a] = t.split(/\\s+/).map(Number);\n const result = solve(n, m, a);\n console.log(result);\n }\n }\n}\n\nasync function processLinesFromStream(rs, pf) {\n const content = [];\n rs.setEncoding(\"utf-8\");\n for await (let chunk of rs) {\n content.push(chunk);\n }\n const lines = content.join('').split(/\\n/);\n const result = pf(lines);\n return result;\n}\n\nprocessLinesFromStream(process.stdin, main);\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "4f0c2023ab3a0cf3a2e407075fa514a4", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const rl = require('readline')\n .createInterface({ input: process.stdin, output: process.stdout })\nconst write = (...args) => {\n process.stdout.write(args.join(' '));\n}\n\nconst lines = [];\nrl.on('line', line => {\n lines.push(line);\n});\n\nrl.on('close', main);\nlet rli = 0;\n\nfunction readline() {\n return lines[rli++];\n}\n \nfunction main() {\n const year = parseInt(readline());\n for(let i = 1; ; ++i){\n const numbers = (year+i).toString().split('');\n const set = (new Set())\n .add(numbers[0])\n .add(numbers[1])\n .add(numbers[2])\n .add(numbers[3]);\n if(set.size === numbers.length) {\n write(numbers.join(''));\n break;\n }\n }\n}\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "60ab4a989f76cd647719128c03a4a4d0", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n let [w, h, k] = d.split(' ').map(Number);\n let ans = 0;\n\n while (k > 0) {\n k--;\n\n ans += (w * 2) + (h * 2) - 4;\n w -= 4;\n h -= 4;\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "fe9849ec7ac187061af19525c54797d0", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\n\nvar answer = 0;\nvar counter = 0;\nvar check = true;\n\nrl.on(\"line\", input => {\n \n counter = 0;\n for (var i = 0; i < input.length; i++) {\n \n if (input[i] == \"B\") {\n counter++;\n }\n }\n\n if (counter == 8) {\n answer++;\n } \n else if (check && counter > 0) {\n answer += counter;\n check = false;\n }\n \n \n}).on(\"close\", () => {\n console.log(answer);\n });\n", "lang_cluster": "Javascript", "tags": ["brute force", "constructive algorithms"], "code_uid": "8cf92d6b4ed1b5f3e39043ea1483c053", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "// Polyfill for NodeJS\nif (undefined == readline) {\n\tvar rLines = require('fs').readFileSync(\"/dev/stdin\", \"utf8\").split(\"\\n\"), \n\t\trIndex = 0,\n\t\treadline = function() {\n\t\t\trIndex ++\n\t\t\treturn rLines[rIndex - 1]\n\t\t}\n}\nif (undefined == print) {\n\tvar print = console.log\n}\n\n// Useful Read functions\nvar int = function() {\n\treturn parseInt(readline())\n}\n\nvar ints = function() {\n\treturn readline().split(' ')\n\t\t.map(function(x) {\n\t\t\treturn parseInt(x)\n\t\t})\n}\n\n// The answer\n\nvar ns = ints(),\n\ta = ns[0],\n\tb = ns[1]\n\ti = 0\n\nwhile (a <= b) {\n\ta = a * 3\n\tb = b * 2\n\ti ++\n}\n\nprint(i)", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "36b27bf37d476135eac6ee4d484a4ec5", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\n// thats all what you have to write to get input from stdin, using readLine.\n\n\n// Main code runs in main();\n\n\nfunction main(){\n\n let line = readline();\n let distincs = [];\n for (let index = 0; index < line.length; index++) {\n const element = line[index];\n if(distincs.indexOf(element) == -1)\n {\n distincs.push(element);\n }\n\n }\n if(distincs.length % 2 == 0)\n {\n process.stdout.write(\"CHAT WITH HER!\");\n }else{\n process.stdout.write(\"IGNORE HIM!\");\n}\n \n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "cf2fb0bceaec5aeb845b31c49af278e9", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nlet _inputLines;\nlet _lineNumber = 0;\nlet inputReader = _inputReader ();\n\nfunction _main() {\n\t\n\t_inputLines = _inputData.trim().split('\\n').map((string) => {\n\t\treturn string.trim();\n\t});\n\t\n\tlet t = inputReader.readNumber();\n\twhile(t--){\n\t let n = inputReader.readNumber();\n\t\n\t let ans = ((n%10)-1)*10;\n\t \n\t let temp = n;\n\t let i = 1;\n\t while(temp > 0) {\n\t ans = ans+i;\n\t temp = Math.floor(temp/10);\n\t i++;\n\t }\n\t console.log(ans);\n\t}\n\n}\n\nvar _inputData = '';\nfunction cacheInput(data) {\n\t_inputData += data;\n}\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf8');\nprocess.stdin.on('data', cacheInput).on('end', _main);\n\nfunction _inputReader () {\n\tfunction readNumber(){\n\t\treturn Number(_inputLines[_lineNumber++]);\n\t}\n\t\t\n\t\n\treturn {\n\t\treadNumber,\n\t}\n}", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "75aebec75880b15b4eaba621b308e5f7", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\r\n\r\nfunction solve(a) {\r\n let cnt = 0;\r\n for (let i = 0; i < 2; i++) {\r\n for (let j = 0; j < 2; j++) cnt += a[i][j];\r\n }\r\n if (cnt === 0) return 0;\r\n if (a[0][0] === 1 && a[1][1] && a[0][1] === 1 && a[1][0] === 1) return 2;\r\n return 1;\r\n}\r\n\r\nasync function main(read) {\r\n try {\r\n let t = Number(await read());\r\n let res = new Array(t);\r\n for (let i = 0; i < t; i++) {\r\n const a = [];\r\n let tmp = 2;\r\n while (tmp--) {\r\n a.push((await read()).split(' ').map(Number));\r\n }\r\n res[i] = solve(a);\r\n }\r\n return res.join('\\n');\r\n } catch (error) {\r\n console.log(error);\r\n }\r\n}\r\n\r\nlet inputs,\r\n str = '';\r\nfunction read() {\r\n return inputs.next().value.trim();\r\n}\r\nprocess.stdin.resume();\r\nprocess.stdin.setEncoding('utf8');\r\nprocess.stdin.on('data', input => str += input);\r\nprocess.stdin.on('end', async () => {\r\n inputs = str.split('\\n').values();\r\n const output = await main(read);\r\n process.stdout.write(output);\r\n});\r\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "45776e812a2b25dad0903ca2d93a19a6", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict'\n\nconst {EOL} = require('os')\n\nlet ipt = ''\nprocess.stdin.on('data', s => ipt += s)\nprocess.stdin.on('end', () => {\n const ils = ipt.split(EOL).slice(0, -1)\n let [n, s, k] = ils[0].split(' ').map(v => parseInt(v))\n let d = ils[1] == 'to head' ? 'l' : 'r'\n let C = ils[2].split('')\n\n let i = true\n for (let m = 0; m < C.length; m++) {\n let h = C[m]\n if (h == 0) {\n if (s < k && s > 1) s--\n else if (s > k && s < n) s++\n } else { // 1\n i = false\n }\n\n if (d == 'l') {\n if (k > 1) k--\n else {\n d = 'r'\n k++\n }\n } else { // r\n if (k < n) k++\n else {\n d = 'l'\n k--\n }\n }\n\n if (h == 1) {\n i = true\n s = d == 'l' ? n : 1\n }\n\n if (s == k) return console.log('Controller', m + 1)\n }\n console.log('Stowaway')\n})", "lang_cluster": "Javascript", "tags": ["greedy", "dp", "games"], "code_uid": "51f733b9f07658c0f9cea9c5761a10a0", "src_uid": "2222ce16926fdc697384add731819f75", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet lineNum = 0;\nlet countOfData = null;\nlet data = [];\nreadline.on('line', line => {\n lineNum++;\n if(lineNum === 1) {\n countOfData = +line;\n return;\n }\n\n data.push(line);\n \n if(lineNum - 1 === countOfData) {\n goToSolution(data);\n }\n \n});\n\nfunction goToSolution(data) { \n data.forEach(num => {\n let count = 0;\n for(let i = 1; i <= 9; i++) {\n let step = '';\n for(let j = 0; j < 4; j++) {\n step += i;\n count += step.length;\n if(num == step) break;\n }\n if(num == step) break;\n }\n console.log(count);\n })\n}\n\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "1755d798ee8a255a03e0c89c94a0c4ec", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = '';\nprocess.stdin.on('data', (c) => {\n i += c;\n});\nprocess.stdin.on('end', () => {\n const { EOL } = require('os');\n const lines = i.split(EOL);\n const binary = lines[0];\n if (binary === '0') {\n console.log(0);\n } else {\n let count = 0;\n for (let i = 0; i < binary.length; i++) {\n if (binary[i] === '1') {\n count++;\n }\n if (count >= 2) {\n console.log(Math.ceil(binary.length / 2));\n return;\n }\n }\n console.log(Math.ceil((binary.length - 1) / 2));\n }\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "9b958a5b6c91e6e3bc023268f32be2e3", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction readAsInt(){\n return parseInt(readline());\n}\n\nfunction readAsIntList(){\n return readline().split(' ').filter(i => i).map(i => parseInt(i));\n}\n\n\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n let s = readline();\n let l = s.replace(/[^a-z]+/g,'').length;\n let u = s.replace(/[^A-Z]+/g,'').length;\n console.log((l > u || l === u) ? s.toLowerCase() : s.toUpperCase());\n}\n \n\n\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "a1647234e1606f958ac3a067f9c09ec0", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', line => {\n solution(line);\n});\n\nfunction solution(name) {\n const charMap = {};\n for (const char of name) {\n if (charMap[char] === undefined) {\n charMap[char] = true;\n }\n }\n\n if (Object.keys(charMap).length % 2 === 0) {\n console.log('CHAT WITH HER!');\n } else {\n console.log('IGNORE HIM!');\n }\n}", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "3194c93d27db27bff857bf8e418ed425", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n \nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n \nlet inputString = '';\nlet currentLine = 0;\n \nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n \nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n \nfunction readline() {\n return inputString[currentLine++];\n}\n/**\n6\n6 1\n100010\n6 2\n000000\n5 1\n10101\n3 1\n001\n2 2\n00\n1 1\n0\n\n\n**/\n\nfunction gcd(a, b) {\n if (!b) {\n return a;\n }\n\n return gcd(b, a % b);\n};\n\nfunction main() { \n let n = BigInt(readline());\n\n // for(let i=0;i count && i < n) {\n if(i === 1 && a[i-1] === '0' && a[i] === '0') {\n count++;\n a[i-1] = \"1\";\n continue;\n }\n\n if(a[i + 1] === n) {\n if(a[i] === \"0\" && a[i-1] === \"0\") {\n count++;\n }\n\n continue;\n }\n\n if(a[i] === \"0\" && a[i-1] === \"0\" && a[i+1] === \"0\") {\n count++;\n a[i] = \"1\";\n }\n\n i++;\n }\n\n console.log(count);\n}\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "constructive algorithms", "math", "greedy", "strings"], "code_uid": "dbc9fb2b153bd0027b3136c6f1865c9f", "src_uid": "8001a7570766cadcc538217e941b3031", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\nlet input = []\n\nrl.on('line', line => {\n input = line.split(' ').map(x => parseInt(x))\n const output = solution(input[0])\n console.log(output)\n})\n\nrl.on('close', () => {\n // console.log(input)\n})\n\n///end of interface\n\nconst solution = (n) => {\n\tlet intQuotient = Math.floor(n/5);\n\tlet reminder = n % 5;\n\tlet res = intQuotient + (reminder ? 1 : 0);\n\treturn res;\n};\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "b44402dada2f38a3f6bc5809b10544d1", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const n = [...d];\n const a = +d;\n const b = +(n.slice(0, n.length - 2).join('') + n.slice(n.length - 1).join(''));\n const c = +(n.slice(0, n.length - 1).join(''));\n const ans = Math.max(a, b, c);\n\n if (ans === -0) {\n console.log(0);\n }\n else {\n console.log(ans);\n }\n\n});\n", "lang_cluster": "Javascript", "tags": ["implementation", "number theory"], "code_uid": "d06dff77bfb4a437704c99aaac169912", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\n\nrl.on('line', (d) => {\n let [a, b] = d.split(' ').map(Number);\n let ans = 0;\n\n while (a <= b) {\n a *= 3;\n b *= 2;\n ans++;\n }\n\n console.log(ans);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "eb1bfb4b9cd69b2f9aa6af90dc501c6c", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n });\n\n let l=0;\n rl.on('line', (input) => {\n if (l==0) {l++}\n else {\n let b= \"\"\n rl.close(); \n for(let i=0,c=0;i parseInt(x));\n}\n\nconst readLine = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nreadLine.on(\"line\", (line) => {\n input.push(line);\n});\n\nreadLine.on(\"close\", () => {\n const str = input[0].toLowerCase();\n let world = 0;\n let find = false;\n\n for (const char of str.split(\"\")) {\n if (char === \"h\" && world === 0) {\n world += 1;\n } \n if (char === \"e\" && world === 1) {\n world += 1;\n }\n if (char === \"l\" && world >= 2) {\n world += 1;\n }\n if (char === \"o\" && world >= 4) {\n world += 1;\n find = true;\n break;\n }\n }\n\n console.log(find ? \"YES\" : \"NO\");\n});\n", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "ae241f40ddbc79a957c38eb3a7b9ef85", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "readline = require('readline')\nlet stdinInput = '';\n\n// //file\n// var fs = require('fs');\n// const inputfile = '_in.txt';\n// const outputfile = '_out.txt';\n// fs.writeFileSync(outputfile, '');\n// var myInterface = readline.createInterface({\n// input: fs.createReadStream(inputfile),\n// });\n// myInterface.on('line', function (line) {\n// stdinInput += line+'\\n';\n// }).on('close', () => {\n// main(); \n// process.exit(0);\n// })\n /*\n * Api Scanner\n */\n class Scanner {\n constructor() {\n this.index = -1;\n this.lines = stdinInput.trim().split('\\n'); // eslint-disable-line\n }\n \n nextLine() {\n this.index += 1;\n return this.lines[this.index].trim();\n }\n nextArray(fn) {\n const array = this.nextLine().split(' ');\n return fn === String ? array : array.map(fn);\n }\n \n hasNext() {\n return this.index < this.lines.length;\n }\n }\n \n process.stdin.resume();\n process.stdin.setEncoding('utf-8');\n process.stdin.on('data', (input) => { stdinInput += input; });\n process.stdin.on('end', () => { main(); });\n\nlet s;\nfunction main() {\n const is = new Scanner();\n \n let hello = ['h', 'e', 'l', 'l', 'o'];\n s = is.nextLine();\n \n let index = 0;\n let check = 0;\n for(let i=0; i (input > 2 && input % 2 == 0) ? console.log('YES') : console.log('NO'));\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "797a1804c5b246620dfe64e5d9da1744", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const init = () => {\n process.stdin.resume();\n process.stdin.setEncoding('utf-8');\n\n let inputString = '';\n let currentLine = 0;\n\n process.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n });\n\n process.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main(); \n });\n\n global.readline = () => {\n return inputString[currentLine++];\n }\n};\n\nif (typeof readline === 'undefined') {\n init();\n}\n\n// Make a Snippet for the code above this and then write your logic in main();\n\nconst print = (...args) => {\n console.log(...args);\n};\n\nconst subtract = (n) => {\n if (n % 10 === 0) return n /= 10;\n return n - 1;\n};\n\nconst main = () => {\n let [n, k] = readline().split(' ').map(x => parseInt(x));\n while (k--) {\n n = subtract(n);\n }\n print(n);\n};\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0056708b058dcdfde502a57ac734c6e1", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\n/**\n * \n * @param {*} str \n * @param {*} seperator \n */\nfunction splitter(str, seperator = '') {\n return str.trim().split(seperator);\n}\n\n/**\n * \n * @param {*} arr \n */\nfunction strToNumArr(arr = []) {\n return arr.map(num => Number(num));\n}\n\n/**\n * \n * @param {*} num1 \n * @param {*} num2 \n */\nfunction matrixArray(num1, num2) {\n return Array(num1).fill(Array(num2));\n}\n\nlet log = function () {\n return Function.prototype.bind.call(console.log, console, '');\n}();\n\nfunction removeEmptyItem(arr, index) {\n return arr.slice(0, index).concat(arr.slice(index + 1, arr.length));\n}\n\nfunction range(min, max) {\n\n let arr = [];\n for (let index = min; index < max; index++) {\n arr.push(index);\n\n }\n return arr;\n}\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(str) {\n\n let n = +str.trim();\n let count = 0;\n for (let i = 1; i <= Math.floor(n / 2); i++) {\n\n if (n % i == 0) {\n count++;\n }\n }\n return count.toString();\n}\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "1f16a22fd402c64b1e5bcfdf30f6509d", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n var arr = stdin[0].split(' ').map(Number);\n const n = arr.splice(0, 1)[0];\n var v1 = arr[0], v2 = arr[1], t1 = arr[2], t2 = arr[3];\n var second1 = (n - 2) * v1 + (v1 + t1) * 2;\n var second2 = (n - 2) * v2 + (v2 + t2) * 2;\n if (second1 < second2) {\n console.log('First');\n } else if (second1 > second2) {\n console.log('Second');\n } else {\n console.log('Friendship');\n }\n}\n\nconst readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar stdin = [];\nrl.on('line', function (line) {\n stdin.push(line);\n});\nrl.on('close', main);", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "86188e14d186037b6110726c34cc22f1", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n const n = parseInt(input[0]);\n const nums = input[1].split(' ').map(x => parseInt(x));\n\n nums.sort((a, b) => a - b);\n console.log(nums.join(' '));\n});", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "707e91c06a9ce750a1bc2c0a25075780", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar s1, s2, indicator = 0,ans=\"YES\";\nrl.on('line', (input) => {\n if (indicator == 0) {\n s1 = input;\n indicator++;\n } else {\n s2=input;\n var s1len = s1.length;\n var s2len = s2.length;\n if (s2len == s1len) {\n for (let i = 0, j = s2len - 1; i < s1len; i++, j--) {\n if(s1[i]!=s2[j]){\n ans=\"NO\";\n break;\n }\n }\n }\n else\n ans=\"NO\";\n console.log(ans);\n }\n \n \n\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "31d680ecbd8509d0c08d8813b4237897", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\nconst word = () => {\n let ar = [];\n for (const x of input[0]) {\n ar.push(x);\n }\n let upper = 0;\n let lower = 0;\n for (const y of ar) {\n if (y === y.toUpperCase() ) {\n upper++;\n }\n else {\n lower++;\n }\n }\n console.log(upper > lower ? input[0].toUpperCase() : input[0].toLowerCase());\n};\n\nreadLine.on('close', word);\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "a03f9f14b0c68055da9208b7626165d1", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "/*\n* У Давида есть четыре мешка с конфетами. В i-м из них лежит ai\n* конфет. Также у Давида есть два друга. Он хочет отдать каждый мешок одному из двух друзей.\n* Возможно ли так распределить мешки, чтобы два друга получили одинаковое общее число конфет?\n* Обратите внимание, что вы не можете оставить мешки себе или выбросить их,\n* каждый мешок должен быть отдан одному из двух друзей.\n* Входные данные:\n* В первой строке записаны четыре целых числа a1, a2, a3 и a4 (1 ≤ ai ≤ 100) — количества конфет в каждом мешке.\n* Пример входных данных: 1 7 11 5\n* Выходные данные:\n* Выведите YES || NO\n*/\n\nlet readline = require('readline');\nlet rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', function(line){\n let candies = [];\n\n // Сумма элементов массива.\n function sum(arr){\n let sum = 0;\n arr.forEach(function (elem) {\n sum = sum + parseInt(elem);\n });\n if (sum)\n return sum;\n else\n return 0;\n }\n\n // Преобразуем элементы массива к числу.\n line.split(\" \").forEach(function (elem) {\n candies.push(parseInt(elem));\n });\n\n // console.log(sum(candies), sum(candies)%2);\n\n // Если число конфет нечётное, задача невыполнима.\n if (!sum(candies) % 2){\n console.log('NO');\n return 'NO';\n }else{\n // Если число конфет чётное, проверяем сумму в мешках 1-3. 72 52 62 62 sum = 248 half = 124\n // 124 - 52 = 72 3 14 36 53 sum 106 half 53 => slice half/ \n let half = sum(candies) / 2;\n\n if (candies.includes(half)) {\n console.log('YES');\n return 'YES';\n }\n let i = 0;\n while( i < candies.length){\n let sum = candies[i];\n for (let j = 0; j < candies.length; j++){\n if (sum === half){\n console.log('YES');\n return 'YES';\n } else if (j !== i){\n sum = sum + candies[j];\n }\n j++;\n }\n i++;\n }\n console.log('NO');\n return 'NO';\n }\n});", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "c8bf722e8fee5b6aec5529b0956675e2", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\nconst lines = []\nrl.on('line', (input) => {\n lines.push(input);\n})\nrl.on('close', () => {\n// (function() {\n // const lines = require('fs').readFileSync('test.in', 'utf8').split('\\n')\n let l = 0;\n let t = 1//+lines[l++]\n for (let i = 0; i < t; i++) {\n const n = +lines[l++]\n console.log(solve(n))\n }\n// })()\n})\n\nfunction solve(n) {\n let ans = 6\n const base = 4\n // let count = 1\n let prev = 4\n for (let i = 2; i <= n; i++) {\n // base = mul(base, 4)\n\n // count = count * 2\n // ans = mul(ans, pow(base, count)\n\n prev = mul(prev, prev)\n ans = mul(ans, prev)\n }\n return ans\n}\nfunction add(a, b) {\n return (a + b) % (1e9 + 7)\n}\nfunction mul(a, b) {\n let r = 0\n let base = a\n while (b) {\n if (b & 1) {\n r = add(r, base)\n }\n b >>= 1\n base = add(base, base)\n }\n return r\n}\nfunction pow(a, b) {\n let r = 1\n let base = a\n while (b) {\n if (b & 1) {\n r = mul(r, base)\n }\n b >>= 1\n base = mul(base, base)\n }\n return r\n}\n", "lang_cluster": "Javascript", "tags": ["math", "combinatorics"], "code_uid": "cc6fb03a05449739e03ac2342e77b3f0", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data',c=>{a=c.toString().split(' ');console.log(Math.ceil(a[0]/a[2]) * Math.ceil(a[1]/a[2]))})\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "d12eb9c6afca28398825b41740c4c9e3", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadline.on('line', line => { input.push(line); });\n\nreadline.on('close', () => {\n const [n, m] = input[0].split(' ').map(Number);\n let min;\n if (n <= m) min = n;\n else min = m;\n\n if (min % 2 === 1) console.log('Akshat');\n else console.log('Malvika'); \n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "8aa1ed2429d288b6386589e775b25521", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n let [n, a, b] = readLine().split(' ').map(Number);\n // let c = n - b;\n\n let final = n - Math.max(a + 1, n - b) + 1;\n console.log(final);\n // console.log(n - c + 1);\n // if (c === a) {\n // console.log(n - c);\n // } else {\n // console.log(n - c + 1);\n // }\n //\n // let start = n - a;\n // let end = n - start + 1;\n // if (end <= b) {\n // console.log(end);\n // } else if (start === c) {\n // console.log(n - c);\n // } else {\n // console.log(n - c + 1);\n // }\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "5dc6e76b383dbb3d0cccf043185cf8ca", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nlet count = 0;\nlet n, k;\n\nrl.on('line', (data) => {\n if (count === 0) {\n [n, k] = data.split(' ').map(Number);\n }\n else {\n const p = data.split(' ').map(Number);\n const score = p[k - 1];\n\n const ans = p.filter(x => x >= score && x != 0);\n console.log(ans.length);\n }\n\n count++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "ecd36aebb2dff7842d6d4bf8938a91a0", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction print(s) {\n process.stdout.write(`${s}`);\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n // input\n const a = readline();\n const set = new Set();\n\n for (let i = 0; i < a.length; i++) {\n set.add(a.charAt(i));\n }\n // output\n print(set.size % 2 === 0 ? 'CHAT WITH HER!' : 'IGNORE HIM!');\n}\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "444b57f8b8ed1b05148d1506bf21dc21", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n let str = input[0];\n const nums = {};\n\n for (let i = 0; i < str.length; i += 1) {\n if (str[i] === '4' || str[i] === '7') \n nums[str[i]] === undefined ? nums[str[i]] = 1 : nums[str[i]] += 1;\n }\n\n const sum = (nums['7'] === undefined ? 0 : nums['7']) + (nums['4'] === undefined ? 0 : nums['4']);\n console.log( (sum === 4 || sum === 7) ? \"YES\" : \"NO\" )\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0805f288403afb403d93498256f6ff99", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n const [w, L, v1, v2] = d.split(' ').map(Number);\n const ans = (L - w) / (v1 + v2);\n\n console.log(ans.toFixed(6));\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "0e2d9894e6ecb21f7a23c11bdc322882", "src_uid": "f34f3f974a21144b9f6e8615c41830f5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict'\n\nconst {EOL} = require('os')\n\nlet ipt = ''\nprocess.stdin.on('data', s => ipt += s)\nprocess.stdin.on('end', () => {\n const n = +ipt.split(EOL)[0]\n \n console.log(n / 2 * 3)\n})", "lang_cluster": "Javascript", "tags": ["math", "number theory"], "code_uid": "6eb570f9b5930c4dc64d98c5bd8b5a17", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var N = nextInt();\n var output = 0;\n var list = new Array(N);\n for(var i = 0; i < N; i++){\n var tmp = nextIntArray();\n list[i] = {\n \thome : tmp[0],\n \tguest : tmp[1]\n };\n }\n for(var i = 0; i < N; i++){\n for(var j = 0; j < N; j++){\n if(i != j){\n if(list[i].home == list[j].guest){\n output++;\n }\n }\n }\n }\n myout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "34846476010f406c1860bdb3743d5c67", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n var arr=stdin[0].split(' ').map(a => Number.parseInt(a)),s;\n s=(arr[0] <=arr[1] && arr[0]<=arr[2]) ? 'Yes' : 'No';\n console.log(s);\n}\n\nconst readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar stdin = [];\nrl.on('line', function (line) {stdin.push(line);});\nrl.on('close', main);\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0574b29f1dae65c52a0d7b692b3c2f42", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n// utils\nconst MOD = 1e9 + 7;\nconst mod = (n) => ((n % MOD) + MOD) % MOD;\nconst add = (a, b) => mod(mod(a) + mod(b));\nconst sub = (a, b) => mod(mod(a) - mod(b));\nfunction mul() {\n for (var a = arguments, r = a[0], i = a.length; --i; )\n r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;\n return r;\n}\nfunction inv(b) {\n for (var a = MOD, u = 0, v = 1, t; b; v = t)\n (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);\n u %= MOD;\n return u < 0 ? u + MOD : u;\n}\nfunction pow(base, n) {\n if (n === 0) return 1;\n let p = pow(base, Math.floor(n / 2));\n let res = mul(mod(p), mod(p));\n if (n % 2 === 1) res = mul(mod(res), base);\n return res;\n}\nfunction highestOneBit(i) {\n i |= i >> 1;\n i |= i >> 2;\n i |= i >> 4;\n i |= i >> 8;\n i |= i >> 16;\n return i - (i >>> 1);\n}\nfunction permutation(arr, len, store = \"\", permutations = []) {\n if (store.length === len) {\n permutations.push(store);\n return;\n }\n for (let i = 0; i < arr.length; i++) {\n const newArr = [...arr];\n const newChar = newArr.splice(i, 1);\n permutation(newArr, len, store.concat(newChar), permutations);\n }\n return permutations;\n}\n\nfunction main() {\n const len = +readLine();\n const str = readLine();\n const [leftPart, rightPart] = [[], []];\n let flag = true;\n\n for (let i = 0; i < str.length; i++) {\n if (i < len) {\n leftPart.push(+str[i]);\n } else {\n rightPart.push(+str[i]);\n }\n }\n\n leftPart.sort((a, b) => a - b);\n rightPart.sort((a, b) => a - b);\n\n if (leftPart[0] < rightPart[0]) {\n for (let i = 0; i < leftPart.length; i++) {\n if (leftPart[i] >= rightPart[i]) {\n flag = false;\n break;\n }\n }\n } else if (leftPart[0] === rightPart[0]) {\n flag = false;\n } else {\n for (let i = 0; i < leftPart.length; i++) {\n if (leftPart[i] <= rightPart[i]) {\n flag = false;\n break;\n }\n }\n }\n if (flag) console.log(`YES`);\n else console.log(`NO`);\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "greedy"], "code_uid": "9a88d21577fe5e3bd674dcb8862940b7", "src_uid": "e4419bca9d605dbd63f7884377e28769", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet count = 0;\n\nrl.on('line', (d) => {\n if (count === 0) {\n count++;\n return;\n }\n\n const arr = d.split(' ').map(Number);\n let b = 0;\n let c = 0;\n\n for (let i = 0; i < arr.length; i++) {\n if (arr[i] < 0) {\n c += arr[i];\n }\n else {\n b += arr[i];\n }\n }\n\n console.log(b - c);\n\n count++;\n});\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "86d5e2da24a937d1fe2c2e1c5af39108", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n// 9- 8- 8- 7- 7- 7- 7- 7- 7- 6- 5- 3- 2- 2- 2 2- 2- 2 1- 1- 1 0- 0-\n\n// 7 4 2 - - - - - \n// value = 3\n// arr[minIndx] = 4\n// min = 1\n// 4 - - -\n\n// 9 8 8 7 6 5 4 2 1 0\n// 7 7 7 2 1 0\n// 7 7 2 2 1 \n// 1 1\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet arr = []\nlet input = []\nlet n;\nvar readline = require('readline')\n\nprocess.stdin.on('data', inputStdin => {\n input += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n input = input.trim().split('\\n').map(string => {\n return string.trim();\n });\n n = input[0]\n arr = input[1].split(\" \")\n arr = arr.map(s=>parseInt(s))\n main(); \n});\nfunction main() {\n // console.log(\"len\",arr.length)\n let visted = {};\n arr.sort(function(a, b){return b-a});\n// arr.reverse();\n // arr.map(s=>console.log(typeof s))\n\n function findMinDifference(value) {\n let min = 100000000;\n let minIndex;\n for (let i = 0; i < arr.length; i++) {\n if (visted[i]) continue;\n if (Math.abs(arr[i] - value) < min ) {\n min = Math.abs(arr[i] - value);\n minIndex = i;\n }\n }\n visted[minIndex] = true;\n return arr[minIndex];\n }\n let pils = 1;\n let boxesCanHold = arr[0]; // 9\n visted[0] = true;\n\n for (let i = 0; i < arr.length; i++) {\n if (visted[i]) continue;\n if(boxesCanHold ==0){\n boxesCanHold = arr[i];\n visted[i] = true;\n ++pils;\n }\n if(boxesCanHold!=0){\n let nextStrength = findMinDifference(boxesCanHold-1);\n boxesCanHold = nextStrength >= boxesCanHold ? --boxesCanHold : nextStrength; \n }\n if (boxesCanHold == 0 && Object.keys(visted).length != arr.length) {\n // console.log(\"here\")\n i = 0;\n }\n else if(i < arr.length-1 && Object.keys(visted).length != arr.length){\n i = 0;\n }\n\n }\n console.log(pils );\n\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "greedy"], "code_uid": "257c756d02e0745572f59c6847c78169", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.question('', (answer) => {\n const argumentsArray = answer.split(' ');\n let number = argumentsArray[0];\n const times = argumentsArray[1];\n\n for(i = 0; i < times; i++){\n if(number % 10 == 0) {\n number /= 10;\n } else {\n number--;\n }\n }\n\n console.log(number);\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "ddc6b30cdf260abe02a7f26e5cc6681e", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n logic(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction output(x) {\n process.stdout.write(x); // without auto '\\n' (newline)\n //console.log(x); // with auto '\\n' (newline)\n}\n\n\nfunction logic() {\n const line = readline();\n \n const params = line.split(' ');\n const number = parseInt(params[0]);\n const iterations = parseInt(params[1]);\n \n let result = number;\n for (let i=1; i <= iterations; i++) {\n \n if (result % 10) {\n result--;\n }\n else {\n result /= 10;\n }\n }\n\n output(String(result));\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0f5a6eb6355fbfc01a50a78acd1024da", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n');\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr('time : ' + end + 'ms');\n myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var s = next();\n var output = 0;\n var list = \"abcdefghijklmnopqrstuvwxyz\";\n var index = 0;\n for(var i = 0; i < s.length; i++){\n \tvar nextIndex = list.indexOf(s[i]);\n \tvar mae = Math.abs(nextIndex - index);\n \tvar ato = ((26 - nextIndex) + index);\n \tvar center = ((26 - index) + nextIndex);\n \toutput += Math.min.apply(null, [mae, ato, center]);\n \tindex = nextIndex;\n }\n myout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "54e4e9db47fcb44294a7763b972481b7", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let nd = readLine()\n .split(' ')\n .map(value => parseInt(value, 10))\n\n let a = nd[0];\n let b = nd[1];\n let ans = 0;\n if (a == b) {\n console.log(1);\n } else {\n while (a <= b) {\n ans++;\n a *= 3;\n b *= 2;\n }\n console.log(ans);\n }\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "58667a42d8d5dee248011b74654d92eb", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false,\n});\n\nlet c = 0;\nlet n, d;\n\nrl.on(\"line\", (data) => {\n if (c === 0) {\n [n, d] = data.split(\" \").map(Number);\n c++;\n return;\n }\n\n const arr = data.split(\" \").map(Number);\n const waitTime = (arr.length - 1) * 10;\n const sum = arr.reduce((a, b) => a + b, 0);\n const remmainMinutes = d - sum;\n\n if (sum + waitTime > d) {\n console.log(-1);\n } else {\n console.log(Math.floor(remmainMinutes / 5));\n }\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["greedy", "implementation"], "code_uid": "3c0705c84d54694629f9b8279da1e70f", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nconst { EOL } = require('os');\n\nlet i = '';\nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n let lines = i.split(EOL);\n \n tester(lines[0]); \n});\n\nfunction tester(num) {\n let strs = String(num);\n let countHappyNumbers = 0;\n \n for (let i = 0; i < strs.length; i++) {\n let str = strs.charAt(i);\n\n isHappyNumber(str) && countHappyNumbers++;\n }\n \n console.log(isHappyNumber(countHappyNumbers) ? 'YES' : 'NO');\n}\n\nfunction isHappyNumber(n) {\n return Number(n) === 4 || Number(n) === 7; \n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "40c9393cea062b910382d5b5d55b6632", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let readline = require('readline');\nlet rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout,\n\tterminal: false\n});\n \nrl.on('line', function(line) {\n\tDominoPiling(line);\n \n\trl.close();\n});\n \n//M N\nlet DominoPiling = (line) => {\n\tlet input = line.split(' ');\n\tlet M = input[0] * 1;\n\tlet N = input[1] * 1;\n \n\tlet num1 = M % 2 === 0 ? M / 2 : (M - 1) / 2;\n\tif (num1 === M / 2) {\n\t\tconsole.log(num1 * N);\n\t} else {\n\t\tconsole.log(num1 * N + Math.floor(N / 2));\n\t}\n};", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "66948fff92d5c091a3e2c18e5b7d47c1", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst INPUT = 'test.in';\nconst LOCAL = process.env.ENABLE_LOCAL_ENV === 'true';\nconst log = (...args) => {\n LOCAL && console.log(...args)\n};\nlet rl;\nlet lineNr = 0;\n\n/**\n * MAIN\n */\n(async () => {\n const promises = await setup(INPUT);\n await Promise.all(promises);\n})();\n\n\nfunction setup() {\n const promises = []\n rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false,\n });\n\n rl.on('line', (line) => {\n promises.push(work(line, lineNr));\n lineNr++;\n });\n\n rl.on('error', (err) => {\n log('Error:', err);\n });\n\n return new Promise(res => {\n rl.on('close', () => {\n res(promises)\n log('Done!');\n });\n });\n}\n\nasync function work(line, lineNr) {\n const solutionForLine = await solve(line.trim());\n const responseLine = `${solutionForLine}\\n`;\n process.stdout.write(responseLine);\n}\n\n/**\n * \n * Solution goes below\n * \n */\nfunction solve(line) {\n const [a, b, c, d] = line.split(' ').map(v => parseInt(v));\n // console.log(a,b,c,d)\n if (isTriangle(a, b, c, d)) return 'TRIANGLE';\n if (isSegment(a, b, c, d)) return 'SEGMENT';\n return 'IMPOSSIBLE';\n}\n\nfunction isTriangle(a, b, c, d) {\n // abc, abd, bcd, acd\n if (a + b > c && a + c > b && b + c > a) return true;\n if (a + b > d && a + d > b && b + d > a) return true;\n if (c + b > d && c + d > b && b + d > c) return true;\n if (c + a > d && c + d > a && a + d > c) return true;\n}\n\nfunction isSegment(a, b, c, d) {\n if (a + b >= c && a + c >= b && b + c >= a) return true;\n if (a + b >= d && a + d >= b && b + d >= a) return true;\n if (c + b >= d && c + d >= b && b + d >= c) return true;\n if (c + a >= d && c + d >= a && a + d >= c) return true;\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "geometry"], "code_uid": "fd8272aabf6f47f95c3907e91ca28409", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nlet secondLine = false;\n\n\n// Create readline Interface\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet inputs = [];\n\n\n\nrl.on('line', lineInput => {\n inputs.push(lineInput);\n})\n\n// Read Inputs\nrl.on('close', () => {\n inputs = inputs[0].split(' ');\n const n = parseInt(inputs[0]);\n const m = parseInt(inputs[1]);\n let moves = 0;\n\n if (n < m)\n return console.log(-1)\n\n moves = Math.floor(n / 2) + n % 2;\n \n while (moves%m != 0 && moves < n) {\n moves +=1;\n }\n \n console.log(moves);\n\n});", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "79ff24bba9515c265430850052471481", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "function ProblemSolver() {\n this.HAS_TEST_CASES = false;\n this.INPUT_FILE_NAME = \"test.in\";\n this.OUTPUT_FILE_NAME = \"out.txt\";\n this.DO_OUTPUT_TO_FILE = false;\n this.CLEAR_ARRAY_PER_CASE = false;\n\n this.solveCase = function() {\n var res , i , j , fl , cn , temp ;\n res = 'YES' ;\n this.s = this.s.toLowerCase() ;\n for( i = 0 ; i < this.n ; i++ ) {\n \tthis.arr[ this.s.charCodeAt( i ) ]++ ;\n }\n for( i = 'a'.charCodeAt( 0 ) ; i <= 'z'.charCodeAt( 0 ) ; i++ ) {\n \tif( this.arr[ i ] == 0 ) {\n \t\tres = 'NO' ;\n \t\tbreak ;\n \t}\n }\n print( res );\n };\n\n this.init = function() {\n this.lim1 = 100010;\n this.lim2 = 110;\n this.cc = 1;\n this.ind = 1;\n this.n = 0;\n this.cn = 0;\n this.declareAndFillArrays();\n };\n\n this.getInput = function( irObj ) {\n var hasMoreInput , i;\n hasMoreInput = true;\n try {\n this.n = irObj.nextInt();\n this.s = irObj.nextLine();\n }\n catch( ex ) {\n hasMoreInput = false;\n }\n return hasMoreInput;\n };\n\n this.clearArraysPerCase = function() {\n var i;\n this.arr = new Array();\n this.adj_list = new Array();\n for( i = 0 ; i < this.lim1 ; i++ ) {\n this.arr.push( 0 );\n this.adj_list.push( new Array() );\n }\n };\n\n this.clearPerCase = function() {\n this.cn = 0;\n this.cc++;\n if( this.CLEAR_ARRAY_PER_CASE == true ) {\n this.clearArraysPerCase() ;\n }\n };\n\n this.declareAndFillArrays = function() {\n var i , j;\n this.srr = new Array();\n this.vis = new Array();\n this.arr = new Array();\n this.brr = new Array();\n this.memo = new Array();\n this.done = new Array();\n this.adj_list = new Array();\n for( i = 0 ; i < this.lim1 ; i++ ) {\n this.srr.push( \"\" );\n this.vis.push( 0 );\n this.arr.push( 0 );\n this.brr.push( 0 );\n this.adj_list.push( new Array() );\n }\n for( i = 0 ; i < this.lim2 ; i++ ) {\n this.memo.push( new Array() );\n this.done.push( new Array() );\n for( j = 0 ; j < this.lim2 ; j++ ) {\n this.memo[ i ].push( -1 );\n this.done[ i ].push( 0 );\n }\n }\n };\n\n this.init();\n}\n\nfunction InputReader() {\n var self = this ;\n this.allLines = new Array();\n this.currrentLineNumber = 0;\n this.currrentCharacterIndex = 0;\n this.callBackFunction = null ;\n this.parentContext = null ;\n\n this.readAllLines = function() {\n var singleLine;\n while( true ) {\n try {\n singleLine = readline();\n if( singleLine == null ) {\n break;\n }\n }\n catch( ex ) {\n break;\n }\n this.allLines.push( singleLine );\n }\n };\n \n this.readAllLinesFromRhino = function() {\n var brObj , line ;\n importPackage( java.io ) ;\n importPackage( java.lang ) ;\n brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;\n this.allLines = [] ;\n while( true ) {\n line = brObj.readLine() ;\n if( line == null ) {\n break;\n }\n this.allLines.push( line ) ;\n }\n };\n \n this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {\n self.chunkData += chunk ;\n };\n\n this.readEndFromNodeJsJudgeServer = function() {\n self.parseRawData( self.chunkData ) ;\n self.parentContext.runCases() ;\n };\n \n this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {\n this.parentContext = parentContext ;\n process.stdin.resume() ;\n process.stdin.setEncoding( 'utf8' ) ;\n this.chunkData = '' ;\n process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;\n process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;\n };\n\n this.parseRawData = function( data ) {\n var len , i , currentString;\n len = data.length;\n currentString = \"\";\n this.allLines = [] ;\n for( i = 0 ; i < len ; i++ ) {\n if( data[ i ] == '\\r' ) {\n }\n else if( data[ i ] == '\\n' ) {\n this.allLines.push( currentString );\n currentString = \"\";\n }\n else {\n currentString += data[ i ];\n }\n }\n if( currentString != \"\" ) {\n this.allLines.push( currentString );\n }\n };\n\n this.readAllLinesFromFile = function( inputFileName ) {\n var currentDirectory , fsObj , inputFilePath , rawData;\n fsObj = require( 'fs' );\n currentDirectory = __dirname;\n inputFilePath = currentDirectory + \"\\\\\" + inputFileName;\n rawData = fsObj.readFileSync( inputFilePath , \"utf8\" );\n this.parseRawData( rawData );\n };\n\n this.next = function( flag ) {\n var len , i , startIdx , res , endIdx;\n if( flag == 0 ) {\n \tif( this.currrentCharacterIndex != 0 ) {\n \t\tthis.currrentLineNumber++;\n \tthis.currrentCharacterIndex = 0;\n \t}\n res = \"\";\n len = this.allLines[ this.currrentLineNumber ].length;\n if( typeof( len ) == 'function' ) {\n len = this.allLines[ this.currrentLineNumber ].length() ;\n }\n for( i = this.currrentCharacterIndex ; i < len ; i++ ) {\n res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;\n }\n this.currrentLineNumber++;\n this.currrentCharacterIndex = 0;\n return res;\n }\n while( true ) {\n if( this.currrentLineNumber >= this.allLines.length ) {\n throw new Error( \"No more tokens available!\" );\n }\n startIdx = -1;\n len = this.allLines[ this.currrentLineNumber ].length;\n if( typeof( len ) == 'function' ) {\n len = this.allLines[ this.currrentLineNumber ].length() ;\n }\n for( i = this.currrentCharacterIndex ; i < len ; i++ ) {\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {\n startIdx = i;\n break;\n }\n }\n if( startIdx == -1 ) {\n this.currrentLineNumber++;\n this.currrentCharacterIndex = 0;\n continue;\n }\n res = \"\";\n endIdx = len - 1 ;\n for( i = startIdx ; i < len ; i++ ) {\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {\n endIdx = i;\n break;\n }\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {\n res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;\n }\n else {\n res += '' + this.allLines[ this.currrentLineNumber ].charAt( i );\n }\n }\n this.currrentCharacterIndex = endIdx;\n if( endIdx == len - 1 ) {\n this.currrentLineNumber++;\n this.currrentCharacterIndex = 0;\n }\n return res;\n }\n };\n\n this.nextInt = function() {\n return parseInt( this.next( 1 ) );\n };\n\n this.nextDouble = function() {\n return parseFloat( this.next( 1 ) );\n };\n\n this.nextString = function() {\n return this.next( 1 );\n };\n\n this.nextLine = function() {\n return this.next( 0 );\n };\n}\n\nfunction FileOutputHandler() {\n this.resultantStringArray = new Array();\n\n this.addNewLine = function( newString ) {\n this.resultantStringArray.push( newString );\n };\n\n this.clearPercase = function() {\n this.resultantStringArray = new Array();\n };\n\n this.flushOutOutputToFile = function( outputFileName ) {\n var i , sz , res , currentDirectory , fsObj , outputFilePath;\n res = \"\";\n sz = this.resultantStringArray.length;\n for( i = 0 ; i < sz ; i++ ) {\n if( i != 0 ) {\n res += \"\\n\";\n }\n res += this.resultantStringArray[ i ];\n }\n fsObj = require( 'fs' );\n currentDirectory = __dirname;\n outputFilePath = currentDirectory + \"\\\\\" + outputFileName;\n fsObj.writeFileSync( outputFilePath , res );\n this.clearPercase();\n };\n}\n\nfunction CodeExecutioner() {\n this.irObj = new InputReader();\n this.psObj = new ProblemSolver();\n this.fohObj = new FileOutputHandler();\n\n this.runCases = function() {\n if( this.psObj.HAS_TEST_CASES == true ) {\n testCases = this.irObj.nextInt();\n for( i = 0 ; i < testCases ; i++ ) {\n this.psObj.clearPerCase();\n this.psObj.getInput( this.irObj );\n this.psObj.solveCase();\n }\n }\n else {\n while( true ) {\n this.psObj.clearPerCase();\n hasMoreTestCases = this.psObj.getInput( this.irObj );\n if( hasMoreTestCases == false ) {\n break;\n }\n this.psObj.solveCase();\n }\n }\n if( this.psObj.DO_OUTPUT_TO_FILE == true ) {\n this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );\n }\n };\n\n this.detectEnvironmentType = function() {\n var environmentType = null ;\n try {\n if( importPackage != null ) {\n environmentType = 'rhino' ;\n }\n }\n catch( ex1 ) {\n try {\n //for nodejs local server check\n if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {\n environmentType = 'local-node-js' ;\n }\n }\n catch( ex2 ) {\n try {\n if( readline == null || typeof( readline ) != 'function' ) {\n environmentType = 'server-node-js' ;\n }\n else {\n environmentType = 'javascript-v8' ;\n }\n }\n catch( ex3 ) {\n environmentType = 'server-node-js' ;\n }\n }\n }\n return environmentType ;\n };\n\n this.configureStreamsAndReadInput = function() {\n var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , environmentType ;\n isNodeJsJudgeServer = false ;\n environmentType = this.detectEnvironmentType() ;\n if( environmentType == 'local-node-js' ) {\n try {\n if( print == null || typeof( print ) != 'function' ) {\n print = console.log;\n }\n }\n catch( ex ) {\n print = console.log;\n }\n if( this.psObj.DO_OUTPUT_TO_FILE == true ) {\n localContext = this.fohObj;\n print = function() {\n localContext.addNewLine.apply( localContext , arguments );\n }\n }\n this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );\n this.runCases() ;\n }\n else if( environmentType == 'server-node-js' ) {\n try {\n if( print == null || typeof( print ) != 'function' ) {\n print = console.log;\n }\n }\n catch( ex ) {\n print = console.log;\n }\n this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;\n }\n else if( environmentType == 'javascript-v8' ) {\n this.irObj.readAllLines();\n this.runCases() ;\n }\n else if( environmentType == 'rhino' ) {\n this.irObj.readAllLinesFromRhino();\n this.runCases() ;\n }\n };\n \n this.configureStreamsAndReadInput();\n}\n\nnew CodeExecutioner();\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "4c5c251b40d1a7d4bec61fa6cdc6b77d", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// NYAN NYAN\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n// ░░░░░░░░░░▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄░░░░░░░░░\n// ░░░░░░░░▄▀░░░░░░░░░░░░▄░░░░░░░▀▄░░░░░░░\n// ░░░░░░░░█░░▄░░░░▄░░░░░░░░░░░░░░█░░░░░░░\n// ░░░░░░░░█░░░░░░░░░░░░▄█▄▄░░▄░░░█░▄▄▄░░░\n// ░▄▄▄▄▄░░█░░░░░░▀░░░░▀█░░▀▄░░░░░█▀▀░██░░\n// ░██▄▀██▄█░░░▄░░░░░░░██░░░░▀▀▀▀▀░░░░██░░\n// ░░▀██▄▀██░░░░░░░░▀░██▀░░░░░░░░░░░░░▀██░\n// ░░░░▀████░▀░░░░▄░░░██░░░▄█░░░░▄░▄█░░██░\n// ░░░░░░░▀█░░░░▄░░░░░██░░░░▄░░░▄░░▄░░░██░\n// ░░░░░░░▄█▄░░░░░░░░░░░▀▄░░▀▀▀▀▀▀▀▀░░▄▀░░\n// ░░░░░░█▀▀█████████▀▀▀▀████████████▀░░░░\n// ░░░░░░████▀░░███▀░░░░░░▀███░░▀██▀░░░░░░\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n\n// 백준의 노드 버전이 너무 낮아 babel 사용. \n// 풀이는 solve() 함수에 있음.\n\nconst CODEFORCES_NODE = \"cf\";\nconst CODEFORCES_V8 = \"cf-v8\";\nconst BEAKJOON = \"bj\";\nconst TEST = \"test\";\n// var SITE = BEAKJOON;\nvar SITE = CODEFORCES_NODE;\nvar DEBUG = false; \n\nif(SITE == BEAKJOON){\n if (!String.prototype.startsWith) {\n String.prototype.startsWith = function(search, pos) {\n return this.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;\n };\n }\n if (!String.prototype.endsWith) {\n String.prototype.endsWith = function(search, this_len) {\n if (this_len === undefined || this_len > this.length) {\n this_len = this.length;\n }\n return this.substring(this_len - search.length, this_len) === search;\n };\n }\n if (!String.prototype.repeat) {\n String.prototype.repeat = function(count) {\n 'use strict';\n if (this == null) {\n throw new TypeError('can\\'t convert ' + this + ' to object');\n }\n var str = '' + this;\n count = +count;\n if (count != count) {\n count = 0;\n }\n if (count < 0) {\n throw new RangeError('repeat count must be non-negative');\n }\n if (count == Infinity) {\n throw new RangeError('repeat count must be less than infinity');\n }\n count = Math.floor(count);\n if (str.length == 0 || count == 0) {\n return '';\n }\n // Ensuring count is a 31-bit integer allows us to heavily optimize the\n // main part. But anyway, most current (August 2014) browsers can't handle\n // strings 1 << 28 chars or longer, so:\n if (str.length * count >= 1 << 28) {\n throw new RangeError('repeat count must not overflow maximum string size');\n }\n var maxCount = str.length * count;\n count = Math.floor(Math.log(count) / Math.log(2));\n while (count) {\n str += str;\n count--;\n }\n str += str.substring(0, maxCount - str.length);\n return str;\n }\n }\n}\n\nString.prototype.replaceAt=function(index, replacement) {\n return this.substr(0, index) + replacement+ this.substr(index + replacement.length);\n}\n\nFunction.prototype.repeat = function(times){\n for(let i = 0; i < times; i++){\n this();\n }\n}\n\nArray.prototype.getMaxConsecutiveSum = function(defaultValue = -Infinity){\n const N = this.length;\n let maxsum = defaultValue;\n let cursum = defaultValue;\n let cur;\n for(var ii = 0; ii < N; ii++){\n cur = this[ii];\n if(cursum + cur > 0){\n if(cur > cursum + cur){\n cursum = cur;\n } else cursum += cur;\n } else {\n cursum = cur;\n if(maxsum < cursum){\n maxsum = cursum;\n }\n }\n if(maxsum < cursum){\n maxsum = cursum;\n }\n }\n this.maxConsecutiveSum = maxsum;\n return maxsum;\n}\n\ntry {\n require('manakin').global;\n // require (\"babel-polyfill\");\n} catch (error) {\n\n}\ntry {\n process.argv.forEach(function (val, index, array) {\n if (val.startsWith(\"site\")) {\n switch (val.split(\"=\")[1]) {\n case \"test\":\n // console.log('change site to test')\n SITE = TEST;\n break;\n case \"cf-node\":\n // console.log('change site to cf')\n SITE = CODEFORCES_NODE;\n break;\n case \"cf\":\n // console.log('change site to cf')\n SITE = CODEFORCES_NODE;\n break;\n case \"cf-v8\":\n // console.log('change site to cf')\n SITE = CODEFORCES_V8;\n break;\n case \"bj\":\n // console.log('change site to bj')\n SITE = BEAKJOON;\n break;\n }\n }\n if (val.startsWith(\"debug\")) {\n switch (val.split(\"=\")[1]) {\n case \"true\":\n DEBUG = true;\n break;\n case \"false\":\n DEBUG = false;\n break;\n }\n }\n });\n} catch (error) {\n}\n\nlet inputFilePath = '';\nswitch(SITE){\n case TEST:\n const config = require('config');\n var fs = require(\"fs\");\n var path = require('path');\n inputFilePath = config.get('INPUTFILEPATH') || path.resolve(__dirname, \"input.txt\");\n break;\n default:\n inputFilePath = './input.txt';\n break;\n}\nconst INPUTFILEPATH = inputFilePath;\n\n// if (!String.prototype.endsWith) {\n// \tString.prototype.endsWith = function(search, this_len) {\n// \t\tif (this_len === undefined || this_len > this.length) {\n// \t\t\tthis_len = this.length;\n// \t\t}\n// \t\treturn this.substring(this_len - search.length, this_len) === search;\n// \t};\n// }\n// if (!Array.prototype.includes) {\n// Array.prototype.includes = function (target) {\n// return this.indexOf(target) !== -1\n// }\n// }\n\nconst newLine = '\\n';\nvar ans;\nvar inputText = \"\";\nvar lineCount = 0;\nvar lines;\nvar input;\nvar readline;\nvar getlines;\nvar lineOpen = false;\nvar readingLine = '';\n\nvar clockStart;\nvar clock;\n\nvar print;\nprint = console.log;\nvar it;\nvar step;\nfunction EnableLogging(){\n it = console.info;\n step = console.success;\n}\nfunction DisableLogging(){\n it = function it(params) {\n return 0;\n }\n step = it;\n}\nif (DEBUG) {\n EnableLogging();\n clock = function(start) {\n if ( !start ) return process.hrtime();\n var end = process.hrtime(start);\n return Math.round((end[0]*1000) + (end[1]/1000000));\n }\n} else {\n DisableLogging();\n}\n\n// prepares test data. to replace line input, assign arrays to lines variable.\nfunction prepareTestData() {\n // it(lines);\n\n // lines = ['custom line 1', 'custom line 2'];\n}\n\n// executes exactly once for both test and run. execution time will be included to elapsed time. \nconst prepareSolve = () => {\n \n}\n\nfunction power(x, y) { //분할 정복을 이용하여 x^y 구하기\n let ret = 1;\n while (y > 0) {\n if (y % 2) {\n ret *= x;\n ret %= P;\n }\n x *= x;\n x %= P;\n y /= 2;\n }\n return ret;\n}\n\nfunction createArray(lengths) {\n var arr = new Array(lengths || 0),\n i = lengths;\n if (arguments.length > 1) {\n var args = Array.prototype.slice.call(arguments, 1);\n while (i--) arr[lengths - 1 - i] = createArray.apply(this, args);\n }\n return arr;\n}\n\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ MAIN SOLVE FUNCTION ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n\nfunction solve(){\n let [n, k] = readInts();\n while(k > 0){\n if(n % 10 == 0) {\n n /= 10;\n } else n--;\n k--;\n }\n\n print(n);\n\n}\n\n// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n\nfunction resetRead(){\n lineCount = 0;\n}\n\nfunction checkMemoryUsage() {\n it(process.memoryUsage());\n}\n\nfunction readOne(separator=' ') {\n if(lineOpen && readingLine != null){\n // if(lineOpen){\n // it(readingLine);\n let splitPos = readingLine.search(separator)\n \n let ret = readingLine.slice(0, splitPos);\n if(splitPos == -1){\n // it('close');\n ret = readingLine;\n readingLine = '';\n lineOpen = false;\n }\n readingLine = readingLine.substr(splitPos + 1)\n // it(ret, readingLine, splitPos);\n return ret;\n } else {\n readingLine = readline();\n lineOpen = true;\n if(readingLine == null) return '';\n return readOne(separator);\n }\n}\n\nfunction readInts() {\n try {\n lineOpen = false;\n return readline()\n .split(\" \")\n .map(x => parseInt(x));\n } catch (error) {\n console.error(error);\n return null;\n }\n}\n\nswitch (SITE) {\n case TEST:\n var fs = require(\"fs\");\n var path = require('path');\n // input = fs.createReadStream(path.resolve(__dirname, \"input.txt\"), {\n // encoding: \"utf8\"\n // });\n input = fs.createReadStream(INPUTFILEPATH, {\n encoding: \"utf8\"\n });\n\n function inputListener(line) {\n console.log(line);\n if(line.startsWith('end')){\n console.log('end');\n closing();\n }\n if (!line) {\n closing();\n }\n lineCount++;\n inputText += line + \"\\r\\n\";\n }\n\n\n function readlines() {\n const readline = require(\"readline\");\n const rl = readline.createInterface({\n input,\n output: process.stdout,\n terminal: false\n });\n rl.on(\"line\", inputListener);\n rl.on('close', closing);\n }\n\n getlines = function* (inputText) {\n var lines = inputText.split(/\\r?\\n/);\n for (let line of lines) {\n yield line + newLine;\n }\n }\n\n readline = function () {\n return lines.next().value.trim();\n }\n\n readlines();\n\n break;\n\n case CODEFORCES_NODE:\n input = process.stdin;\n\n function inputListener(line) {\n if (!line) {\n closing();\n }\n lineCount++;\n inputText += line + \"\\r\\n\";\n }\n\n function readlines() {\n const readline = require(\"readline\");\n const rl = readline.createInterface({\n input,\n output: process.stdout,\n terminal: false\n });\n rl.on(\"line\", inputListener);\n rl.on('close', closing);\n }\n\n getlines = function* (inputText) {\n var lines = inputText.split(/\\r?\\n/);\n for (let line of lines) {\n yield line + newLine;\n }\n }\n\n readline = function () {\n return lines.next().value.trim();\n }\n\n readlines();\n\n break;\n case BEAKJOON:\n var fs = require('fs');\n if (DEBUG) {\n // input = fs.readFileSync('./input.txt').toString();\n inputText = fs.readFileSync(INPUTFILEPATH).toString();\n \n } else {\n inputText = fs.readFileSync('/dev/stdin').toString();\n }\n\n readline = function () {\n lineCount++;\n let line = lines[lineCount - 1];\n if (line)\n return lines[lineCount - 1].trim();\n else return null;\n }\n\n getlines = function (inputText) {\n lineCount = 0;\n return inputText.split(/\\r?\\n/);\n }\n\n // lines = getlines(input);\n closing();\n break;\n default:\n break;\n}\n\nfunction closing() {\n if(DEBUG){\n DisableLogging();\n const prepareClock = clock();\n lines = getlines(inputText);\n prepareSolve();\n const prepareClockElapsedTime = clock(prepareClock);\n EnableLogging();\n prepareTestData();\n solve();\n resetRead();\n console.warn('performance check');\n DisableLogging();\n clockStart = clock();\n // lines = getlines(inputText);\n solve();\n console.warn(`${clock(clockStart) + prepareClockElapsedTime} ms`);\n EnableLogging();\n process.exit();\n } else {\n lines = getlines(inputText);\n prepareSolve();\n solve();\n process.exit();\n }\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "c08043d04eaf423aaca97612a18323ea", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nlet input = [];\nrl.on('line', (inputString) => {\n let [x, y] = inputString.split(' ').map(v => parseInt(v));\n input = input.concat([x, y]);\n if (input.length == 6) {\n let [w, h, u1, d1, u2, d2] = input;\n for (; h >= 0; h--) {\n w += h;\n if (h == d1) w -= u1;\n if (h == d2) w -= u2;\n w = Math.max(w, 0);\n }\n console.log(w);\n process.exit();\n }\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "b080e186a9464b0e1761967abc6ae355", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inp = 0\nprocess.stdin.on(\"data\",input=>{\n inp = input\n})\nprocess.stdin.on(\"end\",input=>{\n inp = inp.split(\" \")\n \n \n main();\n \n})\n\n\n\n\nfunction main(){\n \n let ust = Math.ceil(inp[0]/inp[2])\n let alt = Math.ceil(inp[1]/inp[2])\n let toplam = ust*alt\n console.log(toplam)\n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "247ee0396bed6df2ac0d3212ec98e9ff", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', (inputStd) => {\n inputString += inputStd;\n});\nprocess.stdin.on('end', function () {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((str) => {\n return str.trim();\n });\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let string = readLine();\n let stringArray = string.split('');\n for (let i = 0; i < stringArray.length; i++) {\n if (stringArray[i] === '+') {\n stringArray.splice(i, 1);\n i--;\n }\n }\n stringArray = stringArray.sort((a, b) => {\n return a - b;\n });\n for (let i = 0; i < stringArray.length - 1; i++) {\n stringArray[i] = stringArray[i] + '+';\n }\n let final = stringArray.join('');\n console.log(final);\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "e868752054ce33a5540710a24776c760", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = ''\nprocess.stdin.on('data', c => i += c)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os')\n const lines = i.split(EOL) /*your input text, split by lines*/\n operate(lines); \n});\n\n\nfunction operate(lines){\n line1=lines[0].split(' ');\n n=line1[0];\n k=line1[1];\n x=0;\n i=0;\n s=1;\n while(s>0){\n i++;\n x+=i;\n m=x-k;\n s=n-m-i;\n }\n console.log(m);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "binary search"], "code_uid": "2fa68997930d9ac0bf8eec3de122e73f", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (str) => {\n console.log(26* (str.length + 1) - str.length);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "strings"], "code_uid": "45be7dd7f9d9de58e18597f97f3a5cd3", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction readint() {\n let line = readline().split(' ').map(function(num) {\n return parseInt(num);\n });\n return line;\n}\n\nfunction readfloat() {\n let line = readline().split(' ').map(function(num) {\n return parseFloat(num);\n });\n return line;\n}\n\nfunction print(x) {\n console.log(x);\n}\n\nfunction write(x) {\n process.stdout.write(x);\n}\nfunction main() {\n let [n] = readint();\n let s = readline();\n s = s.toLocaleLowerCase();\n let alphabet = new Set();\n for(const val of s) {\n alphabet.add(val);\n }\n if(alphabet.size == 26) print(\"YES\")\n else print(\"NO\");\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "639cee07c6fd11ef4f4f729a4dada4f9", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\n\nconst runMain = () => {\n inputString = inputString.trim().split('\\n').map(string => string.trim());\n main();\n process.exit();\n}\nconst readLine = () => inputString[currentLine++];\n\nprocess.stdin.on('data', inputStdin => inputString += inputStdin);\nprocess.stdin.on('end', runMain);\nprocess.on('SIGINT', runMain);\n\nfunction main() {\n const s = readLine().split('').reverse().join();\n const t = readLine().split('').join();\n console.log(s === t ? 'YES' : 'NO');\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "fadc7c295d951092c6a320a203e2c7f8", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\n'use strict';\n//const fs = require('fs');\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n// Complete the extraLongFactorials function below.\nfunction extraLongFactorials(n) {\n var ans = [n];\n var num = n;\n for (var i = num - 1; i >= 1; i--) {\n if (num % i === 0) {\n ans.push(i);\n num = i;\n }\n }\n console.log(ans.join(' '));\n return ans;\n}\nfunction main() {\n // const ws = fs.createWriteStream(process.env.OUTPUT_PATH);\n const n = parseInt(readLine(), 10);\n\n const result = extraLongFactorials(n);\n // ws.write(result.join(' ') + '\\n');\n\n // ws.end();\n}\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "86c66f737b24d579b941992e698f3c74", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\n\nconst runMain = () => {\n inputString = inputString.trim().split('\\n').map(string => string.trim());\n main();\n process.exit();\n}\nconst readLine = () => inputString[currentLine++];\n\nprocess.stdin.on('data', inputStdin => inputString += inputStdin);\nprocess.stdin.on('end', runMain);\nprocess.on('SIGINT', runMain);\n\nfunction main() {\n let s = readLine();\n let n = 0;\n s.split('').forEach(el => {\n if (el === el.toUpperCase()) {\n n++;\n }\n });\n if (n > s.length / 2) {\n console.log(s.toUpperCase());\n } else {\n console.log(s.toLocaleLowerCase());\n }\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "1bf2735eb3afa5af26999f4031618355", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var standard_input = process.stdin;\n\n// Set input character encoding.\nstandard_input.setEncoding('utf-8');\n\n// When user input data and click enter key.\nstandard_input.on('data', function (s) {\ns=s.trim().split('')\n const n = s.reduce((a,c)=> \n{\n//console.log(a,c);\nreturn a + 9-Number(c)\n}\n,(1 < s.length || s[0] === '0' ? 1 : 0) + Number(s[0]));\n console.log(n);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "b44ce65265cc73692e78d5f3f533bbe9", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var one = nextIntArray();\n var h1 = one[1];\n var w1 = one[0];\n var h2 = one[3];\n var w2 = one[2];\n var output = ((h1 + 2) * (w1 + 2) - (h1 * w1)) + ((h2 + 2) * (w2 + 2) - (h2 * w2));\n myerr(output);\n output -= Math.min(w1 + 2, w2 + 2) * 2;\n myout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "7dbd3ad12523764be89b980c4beb88da", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nconst readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nreadline.question('', (m) => {\n m = m.split(' ').map(Number);\n const ln = m[0];\n const slices = m.slice(1);\n let res = [];\n let x = Math.trunc(ln/slices[0]+1);\n let y = Math.trunc(ln/slices[1]+1);\n\n for (let i=0; i<=x; i++){\n for (let j=0; j<=y; j++){\n let k = (ln-i*slices[0]-j*slices[1])/slices[2];\n if (Number.isInteger(k) && k>=0)\n {\n res.push(k + i + j);\n }\n }\n }\n res.sort(function(a, b){return b-a});\n console.log(res[0]);\n});\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "dp"], "code_uid": "40fb2cd6880aaea466089e6a5493114e", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nlet standardInputString = \"\";\nlet currentLine = 0;\n\nfunction readLine() {\n return standardInputString[currentLine++];\n}\n\nprocess.stdin.on(\"data\", (rawData) => {\n standardInputString += rawData;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n standardInputString = standardInputString\n .trim()\n .split(\"\\n\")\n .map((line) => line.trim());\n\n main();\n});\n\nfunction main() {\n const [m, n, a] = readLine()\n .split(\" \")\n .map((e) => parseInt(e));\n\n console.log(Math.ceil(m / a) * Math.ceil(n / a));\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "3251587492addf850264544614987f35", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var inputs = null;\n//inputs = ['8'];\nfunction main(inputs) {\n var w = parseInt(inputs[0]);\n if (w == 2)\n solution('NO');\n for (var i = 2; i < 50; i += 2) {\n if (w % 2 == 0)\n solution('YES');\n }\n solution('NO');\n}\n///////////////////////////////////////////////////////////////////////////////////////\nif (!inputs) {\n var input_1 = '';\n process.stdin.on('data', function (char) { return input_1 += char; });\n process.stdin.on('end', function () {\n var EOL = require('os').EOL;\n var inputs = input_1.split(EOL).slice(0, -1);\n main(inputs);\n });\n}\nelse\n main(inputs);\nfunction solution(data) {\n console.log(data);\n process.exit(0);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "68f6e0122284235ab132f9bdaf3e3755", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n const string = readline().toLowerCase();\n let pointer = 'a';\n let round = 0 ;\n for (let i =0 , c = string.length ; i < c ; i++) {\n let clockwise =(Math.abs(parseInt(pointer.charCodeAt(0)) - parseInt(string[i].charCodeAt(0))));\n let counterclockwise = Math.abs(26 - clockwise);\n round += (clockwise < counterclockwise) ? clockwise : counterclockwise\n pointer = string[i]\n }\n console.log(round)\n}\n\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "061cb34dcf2c1950e4a54f09fa58fa79", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nasync function algo() {\n const table = await line()\n const cards = await line()\n console.log(cards.includes(table[0]) || cards.includes(table[1]) ? 'YES' : 'NO')\n}\n\n\n// read the input\nconst _lines = []\nlet _lineIndex = 0\nlet _ended = false\nconst _rl = readline.createInterface(process.stdin)\n_rl.on('line', line => _lines.push(line))\n_rl.on('end', () => (ended = true))\nconst wait = ms => new Promise(resolve => setTimeout(resolve, ms))\nconst line = async () => {\n while (!_ended && _lines.length <= _lineIndex) await wait(10)\n const result = _lines[_lineIndex].trim()\n _lines[_lineIndex] = null\n _lineIndex++\n return result\n}\nconst words = async () => (await line()).split(' ')\nconst chars = async () => (await line()).split('')\nconst int = async () => parseInt(await line())\nconst ints = async () => (await words()).map(x => parseInt(x))\nconst big = async () => BigInt(await line())\nconst bigs = async () => (await words()).map(x => BigInt(x))\n\nalgo()", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "ebd1901153ad0518e28ccd3fb19fd5b7", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var N = nextInt();\n var list = new Array(N);\n for(var i = 0; i < N; i++){\n list[i] = new Array(N).fill(0);\n if(i == 0){\n list[i] = new Array(N).fill(1);\n }\n list[i][0] = 1;\n }\n for(var i = 1; i < N; i++){\n for(var j = 1; j < N; j++){\n list[i][j] = list[i][j - 1] + list[i - 1][j];\n }\n }\n myout(list[N - 1][N - 1]);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "39680119ac516830452069c28c859f54", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString\n .trim()\n .split('\\n')\n .map(string => {\n return string.trim();\n });\n\n process.stdout.write(main(inputString));\n process.exit();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nconst main = ([inputString]) => {\n return parseInt(inputString) % 2 === 0 && parseInt(inputString) > 2\n ? 'YES'\n : 'NO';\n};\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "1cb290f752f5c5c5ef38985bf4cc56c5", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet data = [];\nrl.on('line', (input) => {\n data.push(input);\n});\n\nrl.on('close', () => {\n solve(data);\n});\n\nfunction solve(data) {\n\n [n, k] = data[0].split(\" \").map(x => parseInt(x));\n // console.log(n);\n // console.log(k);\n a = data[1].split(\" \").map(x => parseInt(x));\n cutoff = a[k-1];\n\n count = 0;\n for (let i = a.length-1; i >= 0; i--) {\n if (a[i] > 0 && a[i] >= cutoff) {\n break;\n } else {\n count++;\n }\n }\n\n console.log(a.length - count);\n\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "ebb4c29b345b2ec87e123828940e1214", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet n, k;\n\nrl.on('line', (d) => {\n if (c === 0) {\n [n, k] = d.split(' ').map(Number);\n c++;\n return;\n }\n\n const chars = [...d];\n chars.sort();\n const alpha = 'abcdefghijklmnopqrstuvwxyz';\n\n let ans = -1;\n const str = [chars[0]];\n\n for (let i = 0; i < n; i++) {\n let prev = str[str.length - 1];\n let distance = Math.abs(alpha.indexOf(prev) - alpha.indexOf(chars[i]));\n\n if (distance < 2) {\n continue;\n }\n\n str.push(chars[i]);\n\n if (str.length === k) {\n break;\n }\n }\n\n if (str.length >= k) {\n ans = 0;\n for (let i = 0; i < k; i++) {\n ans += alpha.indexOf(str[i]) + 1;\n }\n }\n\n console.log(ans);\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "5a00062b42af6046b3caa5b374721cb3", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input.push(line);\n});\n\n\nRL.on('close', () => {\n let {0:a, 1:b, 2:c} = {...input[0].split(' ')};\n a = parseInt(a); b = parseInt(b); c = parseInt(c);\n\n if(Math.abs(a - b) <= 1) {\n console.log(a + b + (c*2));\n } else {\n console.log(a + b + (c*2) - Math.abs(a-b) + 1);\n }\n});\n\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "bcdd20fb0027b214856e923ed83a5b80", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nrl.on('line', (inputString) => {\n let numberOfSquares = parseInt(inputString);\n rl.close();\n console.log(findTheNumberOfLinesForLady(numberOfSquares));\n});\n\nfunction findTheNumberOfLinesForLady(forTheNumberOfSquaress) {\n let a = Math.sqrt(forTheNumberOfSquaress);\n let b = Math.trunc(a);\n if (a == b) return (a + a);\n if (b * (b + 1) >= forTheNumberOfSquaress) return b + b + 1;\n return b + b + 2;\n}", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms", "binary search"], "code_uid": "8e6ba40763bb6c34028e8a4d0f6e9a50", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "require('readline').createInterface({\n input: process.stdin,\n}).on('line', (line) => { \n const nums = line.trim().split(' ').map(s => parseInt(s))\n let Limak = nums[0];\n let Bob = nums[1];\n\n let years = 0;\n\n while(Limak <= Bob){\n Limak *= 3;\n Bob *= 2\n years++;\n }\n\n process.stdout.write(years + '\\n');\n process.exit();\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "635c153831369de91cfaea3cbc2e8bdc", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume()\nprocess.stdin.setEncoding('utf-8')\n\nlet inputLength = 0\nlet input = ''\nconst aphabets = 'abcdefghijklmnopqrstuvwxyz';\nprocess.stdin.on(\"data\", function(chunk) {\n input += chunk\n})\n\nprocess.stdin.on(\"end\", function(){\n let sentence = input.split('\\n').slice(1).join(\"\")\n \nlet result = \"YES\"\n\nfor(let i = 0;i {\n main(line);\n scanner.close();\n});\n\nfunction main(line) {\n var x = parseInt(line);\n var arr = [4, 7, 47, 74, 44, 444, 447, 474, 477, 777, 774, 744];\n var flag = false;\n for (var i = 0; i < arr.length; i++) {\n if (x % arr[i] === 0) {\n flag = true;\n }\n }\n if (flag === true) {\n console.log(\"YES\\n\");\n } else {\n console.log(\"NO\\n\");\n }\n}", "lang_cluster": "Javascript", "tags": ["brute force", "number theory"], "code_uid": "2b8862383b709a639042f9b2866bd2d0", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nfunction main() {\n\tlet s = readLine().split('');\n\tlet l = 0,\n\t\tu = 0;\n\ts.forEach(c => (c.charCodeAt(0) >= 65 && c.charCodeAt(0) < 97 ? u++ : l++));\n\tif (l >= u) console.log(s.join('').toLowerCase());\n\telse console.log(s.join('').toUpperCase());\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "42b1c52eb970f9bd5e65e2e9a5b23ff5", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var line_number = 0\nconst cs = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar lines = {}\ncs.on(\"line\", (input) => {\n if (input == '') {\n cs.close()\n }\n lines[line_number] = input.split(\" \")\n line_number += 1\n}).on('close', () => {\n main()\n process.exit()\n})\n\nfunction isOp(str) {\n return str.length === 1 && str.match(/[<=>]/)\n}\nfunction isChr(str) {\n return str.length === 1 && str.match(/[a-z]/i)\n}\nfunction isInt(str) {\n return str.length === 1 && !isNaN(str)\n}\n\nfunction print(str) {\n console.log(str)\n}\n\nfunction predict(test) {\n let op=''\n let ops=[]\n let opVariables = [];\n let limits = []\n for (let t of test) {\n // console.log(t);\n for(let i=0; i0 && isOp(t[i-1])) ) {\n op = t[i]\n let j = i + 1\n for(; j [o, opVariables[i]])\n\n for(let pv of pvs) {\n if (pv[1] == undefined) {\n pv[1] = max\n }\n // print(`${min} ${pv[0]} ${pv[1]} ?`)\n if (eval(`${min}${pv[0]}${pv[1]}`)) {\n // print(` ${min} ${pv[0]} ${pv[1]} true`)\n min = pv[1]\n } else {\n print(\"input error\");\n process.exit();\n }\n }\n}\n\nvar m;\nvar n;\nfunction main() {\n m = parseInt(lines[0][0], 10)\n n = parseInt(lines[0][1], 10)\n\n predict([\"1<=m<=n<=16\"])\n number = Math.floor((m*n)/2)\n print(number)\n}\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "5828d550c713eab0c39abc8a9f8376d6", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let inp = readline().split(\" \");\n\n let n = Number(inp[0]) || 0;\n let k = Number(inp[1]) || 0;\n\n let out = 0;\n if (n >= k) { \n let scores = readline().split(\" \");\n for (let i = 0; i < scores.length; i++) { \n if (Number(scores[i]) >= Number(scores[k-1])) {\n \n if (Number(scores[i])> 0)\n out++\n } else {\n break;\n }\n }\n }\n console.log(out)\n\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "02a0d7c85a317afeb7fc62080d893f45", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n\nfunction splbsi(line) {\n return line.split(\" \").map((x) => parseInt(x));\n}\n\nconst readLine = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nreadLine.on(\"line\", (line) => {\n input.push(line);\n});\n\nreadLine.on(\"close\", () => {\n const str = input[0].toLowerCase();\n const bad = new Set(); bad.add('a').add('o').add('y').add('e').add('u').add('i');\n\n const res = [];\n for (const char of str.split('')) {\n if (!bad.has(char)) res.push(`.${char}`);\n }\n\n console.log(res.join(''));\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "c10c9979f31c030d9d020d7f044314c5", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const matrix = new Array(+d).fill(1).map(x => new Array(+d).fill(1));\n let ans = 0;\n\n for (let i = 0; i < matrix.length; i++) {\n for (let j = 0; j < matrix[i].length; j++) {\n let v = 0;\n if (Number.isInteger(matrix[i][j - 1])) {\n v += matrix[i][j - 1];\n }\n\n if (matrix[i - 1] && Number.isInteger(matrix[i - 1][j])) {\n v += matrix[i - 1][j]\n }\n\n matrix[i][j] = Math.max(1, v);\n ans += matrix[i][j];\n }\n }\n\n console.log(matrix[matrix.length - 1][matrix.length - 1]);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "0b7a9c98b3f537a582e659365900e969", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadline.on('line', line => input.push(line));\n\nreadline.on('close', () => {\n let [word] = input;\n let l = (word.match(/[a-z]/g) || []).length;\n if (l >= word.length / 2) console.log(word.toLowerCase());\n else console.log(word.toUpperCase());\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "70f84f190bf28fa41990a4bcff893c8a", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nconst readLine=()=> inputString[currentLine++];\n/* ================================================ \n Main Solution Starts Here \n===================================================*/\n\nconst main=()=>{\n\tlet t=readLine().split(\"WUB\")\n\tlet newString=''\n\tt.forEach(char=>{\n\t\tif(char!='')\n\t\t\tnewString+=char+' '\n\t})\nconsole.log(newString)\n}", "lang_cluster": "Javascript", "tags": ["strings"], "code_uid": "12375757c24ca942e476fd6f15a84672", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// https://codeforces.com/problemset/problem/977/B\n// Big O:\n// Time complexity:\n// Space complexity:\n\nconst readline = require(\"readline\");\n\n// Read input\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet stringLength;\nrl.on('line', (input) => {\n if (stringLength) {\n console.log(findMostCommonGram(input, stringLength));\n rl.close();\n } else {\n stringLength = input;\n }\n});\n\n// Problem\nfunction findMostCommonGram(string, stringLength) {\n let mostCommonGram = \"\";\n let mostCommonGramOccurrences = 0;\n const gramOccurrences = {};\n\n for (let i = 0; i < stringLength - 1; i++) {\n const twogram = string[i] + string[i + 1];\n const occurrences = gramOccurrences[twogram] ? gramOccurrences[twogram] : 0;\n const currentOcurrences = occurrences + 1;\n if (currentOcurrences > mostCommonGramOccurrences) {\n mostCommonGram = twogram;\n mostCommonGramOccurrences = currentOcurrences;\n }\n\n gramOccurrences[twogram] = currentOcurrences;\n }\n\n return mostCommonGram;\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "753f07943704520f4ee71090f0c6921e", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar GCD = function (a, b) {\n if (b == 0) return a;\n return GCD(b, a % b);\n}\n\nvar sumInBase = function (num, base) {\n ans = 0;\n while (num != 0) {\n ans += num % base;\n // num /= base;\n num=parseInt(num/base);\n }\n return ans;\n}\n\nrl.on('line', (input) => {\n var ans = 0;\n var N = parseInt(input);\n for (base = 2; base < N; base++)\n ans += sumInBase(N, base);\n var temp = GCD(ans, N - 2);\n\n console.log(\"%d/%d\", ans / temp, (N - 2) / temp);\n rl.close;\n\n\n});", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "83ae045996963a51bc568d21e70856ed", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nvar dp = {};\n\nfunction fibonacci(n) {\n\tif (n === 0) return 0;\n\tif (n === 1) return 1;\n\n\tif (dp[n] !== undefined) return dp[n];\n\tlet result = fibonacci(n - 1) + fibonacci(n - 2);\n\treturn (dp[n] = result);\n}\n\nfunction main() {\n\tlet n = readLine().split('');\n\tlet f = true;\n\tfor (let i = 0, l = n.length; i < l; ) {\n\t\tif (n[i] === '1' && n[i + 1] === '4' && n[i + 2] === '4') {\n\t\t\ti += 3;\n\t\t} else if (n[i] === '1' && n[i + 1] === '4') {\n\t\t\ti += 2;\n\t\t} else if (n[i] === '1') {\n\t\t\ti++;\n\t\t} else {\n\t\t\tf = false;\n\t\t\tbreak;\n\t\t}\n\t}\n\tf ? console.log('YES') : console.log('NO');\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "greedy"], "code_uid": "cc5e1dc3608e081acee7de8ec0c17d5a", "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n\tinput: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n\tobj = init(inLine);\n\tconsole.error('\\n↑入力 ↓出力');\n\tMain();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n\treturn {\n\t\tlist : input, index : 0, max : input.length,\n\t\thasNext : function(){return (this.index < this.max);},\n\t\tnext : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n\t};\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n\tvar one = nextIntArray();\n\tvar W = one[0];\n\tvar H = one[1];\n\tvar K = one[2];\n\tvar output = 0;\n\tfor(var i = 0; i < K; i++){\n\t\toutput += 2 * (W - 4 * i) + 2 * (H - 2 - 4 * i);\n\t}\n\tmyout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "22a6650dfdde078a7fc0e243be4ddafc", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet currentLine = 0;\nlet inputString = \"\";\n\nprocess.stdin.on(\"data\", (raw_data) => {\n inputString += raw_data;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((line) => {\n return line.trim();\n });\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n/******** Main function*************/\n\nfunction main() {\n var [n, k] = readLine().split(\" \").map(Number);\n\n var arr = readLine().split(\" \").map(Number);\n\n var count = 0;\n for (var m = 0; m < n; m++) {\n if (arr[k - 1] <= arr[m] && arr[m] > 0) {\n count++;\n }\n }\n console.log(count);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "39d17bf93914b80278e2fc39950860e7", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Problem # : 4A\n// Created on : 2019-01-15 00:36:24\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf8\");\n\nvar input = \"\",\n readline,\n print;\n\nprocess.stdin.on(\"data\", function(chunk) {\n input += chunk;\n});\n\nprocess.stdin.on(\"end\", function() {\n input = input.split(\"\\n\");\n print = function(data) {\n process.stdout.write(data + \"\\n\");\n };\n var inputLineIndex = 0;\n readline = function() {\n return inputLineIndex >= input.length ? undefined : input[inputLineIndex++];\n };\n process.exit(main() || 0);\n});\n\nfunction main() {\n // Your code here\n let l = readline();\n let n = Number(l);\n if (n > 2 && n % 2 == 0) {\n print(\"YES\");\n } else {\n print(\"NO\");\n }\n\n return 0;\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "9b59af5c8e71e331471ac9241a9337a8", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({ input: process.stdin });\n\nfunction f(n) {\n let res = n;\n let i = 2;\n while(n > 1) {\n if(n % i === 0) {\n res += ` ${n / i}`;\n n /= i;\n i = 2;\n } else {\n i++;\n }\n }\n return res;\n}\n\nrl.question('', str => {\n console.log(f(str));\n\n rl.close();\n process.stdin.destroy();\n});\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "69993762b8327a940192ce7723f14199", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let arr = readLine().split(' ').map(value => parseInt(value));\n let newArr = [...new Set(arr)];\n console.log(arr.length - newArr.length);\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "4ac1c46c2ce145e3bf1c4f62e9fde0c2", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n // if(Array.isArray(inputString)) inputString = inputString.join('\\n');\n inputString += inputStdin;\n // inputString = inputString.trim().split('\\n').map(string => {\n // return string.trim();\n // });\n \n // main(); \n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction readAsInt(){\n return parseInt(readline());\n}\n\nfunction readAsIntList(){\n return readline().trim().split(' ').filter(i => i).map(i => parseInt(i));\n}\n\n\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n let year = readline().trim().split('').filter(i => i).map(i => parseInt(i));\n const Year1 = [...year].join('') * 1;\n const getNextYear = (y,x, list) => {\n for(let i = y[x]; i<=9; i++) {\n if(!list.includes(i)){\n y[x] = i;\n if(x<3){\n let yy = getNextYear(y,x+1,[...list, i]);\n if(yy) {\n return yy;\n }else{\n y[x+1] = 0;\n }\n }else if(y.join('') * 1 > Year1){\n return y.join('') * 1;\n }\n }else{\n for(let k = x; k <= 3; k++){\n y[k] = 0;\n }\n }\n }\n }\n console.log(getNextYear(year,0,[]));\n}\n \n\n\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "048e4e68e07e4fb732f72b2b0ba3bff9", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar check = function (x, y, z) {\n if (x + y > z && x + z > y && y + z > x)\n return 'T';\n\n if (x + y == z || x + z == y || y + z == x)\n return 'S';\n\n return 'I'\n}\n\n\n/*\ninput = \"1 2 3 4\"\nwhile(true){\n string input = Console.ReadLine();\n}\n*/\nrl.on('line', (input) => {\n let temp = input.split(' ').map(item => parseInt(item));\n let a = temp[0], b = temp[1], c = temp[2], d = temp[3];\n if (check(a, b, c) == 'T' || check(a, b, d) == 'T' || check(a, d, c) == 'T' || check(b, d, c) == 'T')\n console.log(\"TRIANGLE\");\n else if (check(a, b, c) == 'S' || check(a, b, d) == 'S' || check(a, d, c) == 'S' || check(b, d, c) == 'S')\n console.log(\"SEGMENT\");\n else\n console.log(\"IMPOSSIBLE\");\n\n rl.close();\n});\n\n/**\n *\n a b c d\n\n(a b c)\n(a b d)\n(a d c)\n(d b c)\n */", "lang_cluster": "Javascript", "tags": ["brute force", "geometry"], "code_uid": "80cee9309cfc5b0580efd39e88bfe213", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Generated by CoffeeScript 2.5.1\nvar lines, mainAux, print, readline, rl, rli, write;\n\nrl = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nprint = console.log;\n\nwrite = function(...args) {\n return process.stdout.write(args.join(' '));\n};\n\nlines = [];\n\nrl.on('line', function(line) {\n return lines.push(line);\n});\n\nrl.on('close', main);\n\nrli = 0;\n\nreadline = function() {\n return lines[rli++];\n};\n\nmainAux = function() {\n var ff, finishers, k, n, passing;\n [n, k] = readline().split(' ');\n finishers = readline().split(' ');\n passing = parseInt(finishers[k - 1]);\n ff = finishers.filter(function(f) {\n return f > 0 && f >= passing;\n });\n return print(ff.length);\n};\n\nfunction main() {\n return mainAux();\n};\n\n//# sourceMappingURL=ith-place-finishers.js.map\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "ae4e96bc9647771cfb7aa73e3e0828a9", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\n\n// const fs = require('fs');\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet inputString = \"\";\nlet currentLine = 0;\n\nprocess.stdin.on(\"data\", (inputStdin) => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .replace(/\\s*$/, \"\")\n .split(\"\\n\")\n .map((str) => str.replace(/\\s*$/, \"\"));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let s1 = readLine().toLowerCase();\n let s2 = readLine().toLowerCase();\n // let ans1 = s1.split(\"\").reduce((sum, value) => {\n // return sum + value.charCodeAt(0);\n // }, 0);\n\n // let ans2 = s2.split(\"\").reduce((sum, value) => {\n // return sum + value.charCodeAt(0);\n // }, 0);\n\n if (s1 < s2) {\n console.log(-1);\n }\n if (s1 > s2) {\n console.log(1);\n }\n if (s1 == s2) {\n console.log(0);\n }\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "423eca99ba8136cabf5cf69d0c22d75f", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n const arr = d.split(' ').map(Number);\n let idx = 1;\n let ans = Infinity;\n\n while (idx < arr.length - 1) {\n let height = -Infinity;\n\n for (let i = 0; i < arr.length - 1; i++) {\n if (idx === i) {\n continue;\n }\n\n const nextItem = i + 1 === idx ? i + 2 : i + 1;\n height = Math.max(height, arr[nextItem] - arr[i]);\n }\n\n ans = Math.min(ans, height);\n idx++;\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "ffaf6e84738935de4466317958257af1", "src_uid": "8a8013f960814040ac4bf229a0bd5437", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n const weights = readline().split(' ').map(x => parseInt(x))\n let year = 0;\n while (weights[0] <= weights[1]){\n weights[0] *=3;\n weights[1] *=2;\n year ++;\n }\n console.log(year)\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "a66659da72a45d2e6e55a37d4ff5a225", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var line_number = 0;\nconst cs = require(\"readline\").createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nvar lines = {};\ncs.on(\"line\", (input) => {\n if (input == \"\") {\n cs.close();\n }\n lines[line_number] = input.split(\" \");\n line_number += 1;\n}).on(\"close\", () => {\n main();\n process.exit();\n});\n\nfunction isOp(str) {\n return str.length === 1 && str.match(/[<=>]/);\n}\nfunction isChr(str) {\n return str.length === 1 && str.match(/[a-z]/i);\n}\nfunction isInt(str) {\n return str.length === 1 && !isNaN(str);\n}\n\nfunction print(str) {\n console.log(str);\n}\n\nfunction exit(status = 0) {\n process.exit(status);\n}\n\nfunction predict(test) {\n let op = \"\";\n let ops = [];\n let opVariables = [];\n let limits = [];\n for (let t of test) {\n // console.log(t);\n for (let i = 0; i < t.length; i++) {\n if (isOp(t[i])) {\n op = t[i];\n if (isOp(t[i + 1])) {\n op += t[i + 1];\n i += 1;\n }\n ops.push(op);\n op = \"\";\n } else if (isChr(t[i])) {\n // console.log(t[i])\n op = t[i];\n for (var j = i + 1; j < t.length; j++) {\n if (isChr(t[j]) || isInt(t[j])) {\n op += t[j];\n i = j;\n } else break;\n }\n opVariables.push(op);\n op = \"\";\n } else {\n if (i == 0 || (i > 0 && isOp(t[i - 1]))) {\n op = t[i];\n let j = i + 1;\n for (; j < t.length; j++) {\n if (isInt(t[j])) {\n op += t[j];\n i = j;\n } else break;\n }\n limits.push(op);\n op = \"\";\n }\n }\n }\n }\n\n let min = limits[0];\n let max = limits[1];\n\n let pvs = ops.map((o, i) => [o, opVariables[i]]);\n\n for (let pv of pvs) {\n if (pv[1] == undefined) {\n pv[1] = max;\n }\n // print(`${min} ${pv[0]} ${pv[1]} ?`)\n if (eval(`${min}${pv[0]}${pv[1]}`)) {\n // print(` ${min} ${pv[0]} ${pv[1]} true`)\n min = pv[1];\n } else {\n print(\"input error\");\n exit();\n }\n }\n}\n\nvar l;\nfunction main() {\n let s = lines[0][0].split('+')\n l = s.length\n predict([\"1<=l<=100\"])\n\n // print(s)\n// let cur = s[0]\n for (let i = 0; i < l; i++) {\n for(let j = i; j < l; j++) {\n if (s[i] > s[j+1]) {\n // s[j+2] = [s[j], (s[j] = s[j+2])][0];\n [s[i],s[j+1]] = [s[j+1],s[i]]\n }\n\n }\n }\n print(s.join('+'))\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "d28e2d88d5b13076dc2dc513852f5dfd", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\nconst numbers = () => {\n let ar1 = [];\n let ar2 = [];\n for (const x of input[0]) {\n ar1.push(+x);\n }\n for (const y of input[1]) {\n ar2.push(+y);\n }\n let newString = '';\n for (let i = 0; i < ar1.length; i++) {\n if (ar1[i] === ar2[i]) {\n newString += 0;\n }\n else {\n newString += 1;\n }\n }\n console.log(newString);\n};\n\nreadLine.on('close', numbers);\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "963eae1a5287558994bd2d0ca7ce43c9", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n');\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr('time : ' + end + 'ms');\n myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var one = nextIntArray();\n if((one[0] + one[1] == one[2] + one[3]) || \n (one[0] + one[2] == one[1] + one[3]) || \n (one[0] + one[3] == one[2] + one[1])){\n myout(\"YES\");\n }else if((one[0] == one[1] + one[2] + one[3]) || \n (one[1] == one[0] + one[2] + one[3]) || \n (one[2] == one[1] + one[0] + one[3]) ||\n (one[3] == one[1] + one[2] + one[0])){\n myout(\"YES\");\n }else{\n myout(\"NO\");\n }\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "9573aca932e0194bdf592ed45a4d873a", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data', (n) => {\n if (n > 3 && n % 2 === 0) console.log('YES');\n else console.log('NO');\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "fc581bbde3c5c1d39cc81ea53ca2b02f", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nlet ans = 0;\n\nrl.on('line', (d) => {\n let n = +d;\n\n if (n % 2 === 0) {\n ans = n / 2;\n }\n else {\n ans = - Math.ceil(n / 2);\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "b197608336258e9e6aa87ef4a5db10d4", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction readAsInt(){\n return parseInt(readline());\n}\n\nfunction readAsIntList(){\n return readline().split(' ').filter(i => i).map(i => parseInt(i));\n}\n\n\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n let list = readline().split('+').map(i => parseInt(i));\n list.sort();\n console.log(list.join('+'));\n}\n\n", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "b8e2726dbbeca38abfa45719198cac24", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const triangle = 'TRIANGLE';\nconst segment = 'SEGMENT';\nconst impossible = 'IMPOSSIBLE';\n\nfunction triangle_segment_impossible(a, b, c) {\n if (a <= b) {\n if (b <= c) {\n const t = a + b;\n return (t > c) ? triangle : ((t === c) ? segment : impossible);\n }\n }\n throw Error('check failed: a <= b <= c');\n};\n\nfunction solve(a, b, c, d) {\n const e = triangle_segment_impossible(a, b, c);\n const f = triangle_segment_impossible(b, c, d);\n const g = triangle_segment_impossible(a, c, d);\n const h = triangle_segment_impossible(a, b, d);\n if ((e === triangle) ||\n (f === triangle) || \n (g === triangle) ||\n (h === triangle)) {\n return triangle;\n } else if ((e === segment) ||\n (f === segment) ||\n (g === segment) ||\n (h === segment)) {\n return segment;\n } else {\n return impossible;\n }\n};\n\nfunction compare(x, y) {\n return (x < y) ? (- 1) : ((x > y) ? 1 : 0);\n};\n\nfunction main(lines) {\n const [line] = lines;\n let t = line.trim();\n const xs = t.split(/\\s+/).map(Number);\n xs.sort(compare);\n const [a, b, c, d] = xs;\n const result = solve(a, b, c, d);\n console.log(result);\n};\n\nasync function processLinesFromStream(rs, pf) {\n const content = [];\n rs.setEncoding(\"utf-8\");\n for await (let chunk of rs) {\n content.push(chunk);\n }\n const lines = content.join('').split(/\\n/);\n const result = pf(lines);\n return result;\n};\n\nprocessLinesFromStream(process.stdin, main);\n", "lang_cluster": "Javascript", "tags": ["brute force", "geometry"], "code_uid": "e7b9c8107b220b6085a9eba7f705c364", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const stdin = process.stdin;\nstdin.setEncoding( 'utf8' );\nstdin.on( 'data', function( rawInput ){\n const inputLines = rawInput.split('\\n');\n const input = parseInt(inputLines[0]);\n console.log(solve(input) ? \"YES\" : \"NO\");\n});\n\nfunction solve(totalWeight) {\n if (totalWeight < 4) {\n return false;\n }\n return totalWeight % 2 === 0;\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "f2340c3e0bf243574712e061272aa0ed", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const [a, b] = d.split(' ').map(Number);\n let playerA = 0;\n let playerB = 0;\n let draw = 0;\n\n for (let i = 1; i <= 6; i++) {\n if (Math.abs(a - i) < Math.abs(b - i)) {\n playerA++;\n }\n else if (Math.abs(a - i) > Math.abs(b - i)) {\n playerB++;\n }\n else {\n draw++;\n }\n }\n\n console.log(playerA, draw, playerB);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "295f4ef66116201d13ae55d8f4d21dbe", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n const weight = readline();\n const output = (weight > 2 && weight % 2 === 0) ? \"YES\" : \"NO\";\n console.log(output);\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "ced8cecbdadcae01653caf314dd5637d", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst rl = readline.createInterface({\n input: process.stdin\n})\n\nconst mat = []\nrl.on('line', line => {\n mat.push(line.split(' ').map(v => parseInt(v, 10)))\n})\n\nrl.on('close', () => {\n let pos\n mat.forEach((r, i) => r.forEach((v, j) => { if (v == 1) pos = [i,j] }))\n \n console.log(Math.abs(pos[0]-2)+Math.abs(pos[1]-2))\n})\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "89bc015af0cb97f218a3f6f62120b35d", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\r\n\r\nfunction solve(n, m) {\r\n const target = 10n ** (n - 1n);\r\n const queue = [[BigInt(m), 0]],\r\n cache = new Set();\r\n for (let [num, step] of queue) {\r\n const st = [];\r\n let tmp = num;\r\n while (num) {\r\n let cur = num % 10n;\r\n num = num / 10n;\r\n if (cur < 2n || st[cur]) continue;\r\n st[cur] = 1;\r\n let next = tmp * cur;\r\n if (cache.has(next)) continue;\r\n if (next >= target) {\r\n return step + 1;\r\n }\r\n cache.add(next);\r\n queue.push([next, step + 1]);\r\n }\r\n }\r\n return -1;\r\n}\r\n\r\nasync function main(read) {\r\n try {\r\n let res = [];\r\n const [n, m] = (await read()).split(' ').map(BigInt);\r\n res.push(solve(n, m));\r\n console.log(res.join('\\n'));\r\n } catch (error) {\r\n console.log(error);\r\n }\r\n}\r\n\r\nlet inputs,\r\n str = '';\r\nfunction read() {\r\n return inputs.next().value.trim();\r\n}\r\nprocess.stdin.resume();\r\nprocess.stdin.setEncoding('utf8');\r\nprocess.stdin.on('data', input => str += input);\r\nprocess.stdin.on('end', () => {\r\n inputs = str.split('\\n').values();\r\n main(read);\r\n});\r\n", "lang_cluster": "Javascript", "tags": ["brute force", "dfs and similar", "shortest paths", "dp", "data structures"], "code_uid": "fa3c0a0a103b3836ac956ca9963f5f16", "src_uid": "cedcc3cee864bf8684148df93804d029", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\r\nconst readline = require('readline');\r\nconst util = require('util');\r\nconst rl = readline.createInterface({\r\n input: process.stdin,\r\n});\r\nlet pos = 0;\r\nconst words = [];\r\nrl.on('line', (line) => {\r\n words.push.apply(words, line.split(' ').filter(s => s != ''));\r\n});\r\nrl.on('close', main);\r\nfunction check(b) {\r\n if (!b) {\r\n process.stderr.write(`${new Error().stack}\\n`);\r\n process.exit(-1);\r\n }\r\n}\r\nfunction printf(...args) {\r\n process.stdout.write(util.format(...args));\r\n}\r\nfunction nextInt() {\r\n return Math.trunc(Number(words[pos++]));\r\n}\r\nfunction nextStr() {\r\n return words[pos++];\r\n}\r\nfunction af(l) {\r\n return Array.from({ length: l });\r\n}\r\nconst INIT = -1;\r\nlet n;\r\nlet m;\r\nlet k;\r\nfunction solve() {\r\n let meven = (m % 2) == 0;\r\n let neven = (n % 2) == 0;\r\n let keven = (k % 2) == 0;\r\n if (meven && neven) {\r\n // necessary and sufficient that there are pairs of horiz to create 4x4 blocks\r\n return keven;\r\n }\r\n else if (meven) {\r\n // need at least one row of horiz, and remainder are even\r\n let rem = k - Math.trunc(m / 2);\r\n let remeven = (rem % 2) == 0;\r\n return k * 2 >= m && remeven;\r\n }\r\n else {\r\n let lim = (m - 1) * n;\r\n let used = k * 2;\r\n if (used > lim) {\r\n return false;\r\n }\r\n return keven;\r\n }\r\n}\r\nfunction main() {\r\n let tc = nextInt();\r\n while (tc-- > 0) {\r\n n = nextInt();\r\n m = nextInt();\r\n k = nextInt();\r\n if (solve()) {\r\n printf(\"YES\\n\");\r\n }\r\n else {\r\n printf(\"NO\\n\");\r\n }\r\n }\r\n}\r\n", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms"], "code_uid": "37cefe33846e02b321f366b234899145", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nconst readline = require('readline')\n\nclass ReadStream {\n lines = []\n\n currPromise = undefined\n\n readlineHandler = input => {\n this.lines.push(input)\n }\n\n constructor() {\n this.rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n });\n\n this.rl.on('line', this.readlineHandler)\n }\n\n async next() {\n this.currPromise = new Promise((resolve, reject) => {\n const tempPromise = this.currPromise ? this.currPromise : Promise.resolve()\n \n tempPromise.then(_ => {\n if (this.lines .length) {\n resolve(this.lines.shift())\n }\n else {\n this.rl.off('line', this.readlineHandler)\n this.rl.once('line', (input) => {\n resolve(input)\n this.rl.on('line', this.readlineHandler)\n })\n }\n })\n \n })\n return this.currPromise\n }\n\n nextN(n) {\n return [...new Array(n)].map(_ => this.next())\n }\n\n close() {\n this.rl.off('list', this.readlineHandler)\n this.rl.close()\n }\n}\n\n\nconst cin = new ReadStream()\n\nasync function main() {\n const [n, k] = (await cin.next()).split(' ').map(Number)\n const items = (await cin.next()).split(' ').filter((item, i, items) => {\n return Number(item) >= Number(items[k - 1]) && Number(item) > 0\n })\n\n\n console.log(items.length)\n}\n\nmain()", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "8f41dde027f6ccd3e52aa8b18725539b", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data', input => {\n let res = 'NO';\n\n if (input == 2) {\n res = 'NO';\n } else if (input % 2 == 0) {\n res = 'YES';\n }\n\n\n console.log(res);\n\n return res;\n});\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "e65356e7b98e7434ab116639e334cd5b", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nlet inputs = [];\n\n// Create readline Interface\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\n\n// Read Inputs\nrl.on('line', lineInput => {\n inputs.push(lineInput)\n})\n\nrl.on('close', () => {\n\n let arr = inputs[0].split(' ').map(num => parseInt(num));\n let m = arr[0];\n let n = arr[1];\n let step = 0;\n\n while (n != 0 && m != 0) {\n step++;\n n--;\n m--;\n }\n\n if (step != 0 && step % 2 == 0)\n return console.log(\"Malvika\")\n\n console.log(\"Akshat\")\n\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e1f5a4b779505e349ab4d8a2479c886a", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "if (process.argv[2] === \"test\") {\n solve([\"3 7\"]);\n} else {\n let i = \"\";\n process.stdin.on(\"data\", (c) => (i += c));\n process.stdin.on(\"end\", () => {\n const { EOL } = require(\"os\");\n const lines = i.split(EOL);\n\n solve(lines);\n });\n}\n\nfunction solve(lines) {\n const [m, n] = lines[0].split(\" \");\n const minus = m % 2 !== 0 && n % 2 !== 0 ? 1 : 0;\n console.log((m * n - minus) / 2);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "764a6de370ecb50ab0789c251b31b671", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Soft Drinking\n\nconst {EOL} = require('os');\n\nlet inp = '';\n\nprocess.stdin.on('data', c => inp += c);\n\nprocess.stdin.on('end', () => {\n let lines = inp.split(EOL)[0].split(' ');\n \n let n = +lines[0];\n let k = +lines[1];\n let l = +lines[2];\n let c = +lines[3];\n let d = +lines[4];\n let p = +lines[5];\n let nl = +lines[6];\n let np = +lines[7];\n\n process.stdout.write(Math.min(~~((k * l) / (n * nl)), ~~((c * d) / n), ~~(p / (n * np))) + '');\n\n return;\n});", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "4d30fbdf8333777573b74f2445f2180c", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n \nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n const situation = input[0];\n let maxOne = 0, nowOne = 0,\n maxTwo = 0, nowTwo = 0;\n\n for (let i = 0; i < situation.length; i += 1) {\n if (situation[i] === '1') {\n nowTwo = 0;\n nowOne += 1;\n if (maxOne < nowOne) maxOne = nowOne;\n } else { \n nowOne = 0;\n nowTwo += 1;\n if (maxTwo < nowTwo) maxTwo = nowTwo;\n }\n }\n console.log(maxOne >= 7 || maxTwo >= 7 ? \"YES\" : \"NO\");\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "80a2b11b9c8f25fcfb5ee586b2a62b93", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\nvar input = '';\nvar inputResolve;\nvar inputPromise = new Promise(resolve => inputResolve = resolve);\nprocess.stdin.on('data', c => input += c);\nprocess.stdin.on('end', () => {\n inputResolve();\n});\n(async () => {\n // var time = Date.now();\n await inputPromise;\n var inputs = input.split(/\\r?\\n/);\n var [n, h] = inputs[0].split(' ').map(v => +v);\n var f = [];\n for (let i = 0; i <= n; i++) {\n f[i] = [];\n for (let j = 0; j <= n; j++)\n f[i][j] = BigInt(0);\n }\n f[0][0] = BigInt(1);\n f[1][1] = BigInt(1);\n for (let i = 2; i <= n; i++) {\n for (let j = 1; j <= i; j++) {\n for (let z = 1; z <= i; z++) {\n for (let j2 = 0; j2 <= j - 1; j2++) {\n if (j2 < j - 1)\n f[i][j] = f[i][j] + f[z - 1][j2] * f[i - z][j - 1];\n else\n f[i][j] = f[i][j] + f[z - 1][j - 1] * f[i - z].slice(0, j).sum();\n }\n }\n }\n }\n console.log(f[n].slice(h).sum().toString());\n})();\nObject.defineProperty(Object.prototype, '$k', {\n value: function () { return Object.keys(this); }\n});\nObject.defineProperty(Object.prototype, '$v', {\n value: function () { return Object.values(this); }\n});\nObject.defineProperty(Object.prototype, '$kv', {\n value: function () { return Object.entries(this); }\n});\nArray.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), BigInt(0)); };\nArray.prototype.uniq = function (fn) {\n var set = new Set();\n return this.filter(v => {\n var newValue = !set.has(fn ? fn(v) : v);\n set.add(fn ? fn(v) : v);\n return newValue;\n });\n};\nArray.prototype.toObj = function (fn) {\n return this.map(v => fn(v)).reduce((p, v) => {\n p[v[0]] = v[1];\n return p;\n }, {});\n};\n", "lang_cluster": "Javascript", "tags": ["divide and conquer", "dp", "combinatorics"], "code_uid": "27169d4b0eb58117f7faf9f16d003d15", "src_uid": "faf12a603d0c27f8be6bf6b02531a931", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet l = 0;\nlet cups = []\nlet medals = []\n\nrl.on('line', (input) => {\n if (l === 0) {\n cups = input.split(' ').map(function (item) {\n return parseInt(item, 10);\n });\n } else if (l === 1) {\n medals = input.split(' ').map(function (item) {\n return parseInt(item, 10);\n });\n } else {\n function add(a, b) {\n return a + b;\n }\n rl.close();\n let shelfs = parseInt(input)\n var cupsSum = cups.reduce(add, 0);\n var medalsSum = medals.reduce(add, 0);\n shelfs-=Math.ceil(cupsSum/5)\n shelfs-=Math.ceil(medalsSum/10)\n if(shelfs>=0){\n console.log(\"YES\")\n return 0\n }\n console.log(\"NO\")\n\n return 0;\n }\n l++\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0227b4e65a231f52dd2362efab05d795", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nconst gcd = (a, b) => {\n if (b === 0) {\n return a;\n }\n\n return gcd(b, a % b);\n}\n\nrl.on('line', (d) => {\n let [a, b, n] = d.split(' ').map(Number);\n let ans = 1;\n\n while (n > 0) {\n ans = ans === 0 ? 1 : 0;\n\n if (ans === 0) {\n const r = gcd(a, n);\n n -= r;\n }\n else {\n const r = gcd(b, n);\n n -= r;\n }\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "4cda0ba9458b450afc129bdd4cfeab15", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n \nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n let [n, m] = input[0].split(' ').map(x => parseInt(x));\n let winAkshat = false;\n while (n > 0 && m > 0) {\n n -= 1; m -=1;\n winAkshat = !winAkshat;\n }\n\n console.log( winAkshat ? 'Akshat' : 'Malvika')\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "defd252d9885868714334cfb0a6eedbf", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const arr = d.split(' ').map(Number);\n let ans = 'NO';\n\n for (let i = 0; i < 2**arr.length; i++) {\n const str = i.toString(2).padStart(4, 0);\n let sum1 = 0;\n let sum2 = 0;\n\n for (let j = 0; j < str.length; j++) {\n if (str[j] === '1') {\n sum1 += arr[j];\n }\n else {\n sum2 += arr[j];\n }\n }\n\n if (sum1 === sum2) {\n ans = 'YES';\n break;\n }\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "eed37dc6951b520a3a7b6d9c18cab408", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n');\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr('time : ' + end + 'ms');\n myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var N = nextInt();\n var list = nextIntArray();\n list.sort(function(a,b){\n \treturn a - b;\n });\n var output = 0;\n for(var i = 0; i < N; i += 2){\n output += list[i + 1] - list[i];\n }\n myout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["sortings"], "code_uid": "c5949d9b24e75950653ee2452493ad36", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nrl.on('line', (input) => {\n if (input%2 === 0 && input>= 4) {console.log (\"YES\")}\n else console.log (\"NO\")\n}\n\n\n)\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "1491cd1c8cf78204e74f604743c20a8f", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n var strArr = readLine().split(\" \").map(Number);\n var a = strArr[0];\n var b = strArr[1];\n var count = 0;\n for (let i = 0; i < i + 1; i++) {\n a = a * 3;\n b = b * 2;\n if (a > b) {\n count = i + 1;\n break;\n }\n }\n console.log(count);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "c7a8dfe18471c4567e23aaee1fdb8039", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n console.log(Math.floor(stdin[0].split(' ').reduce((acc, cur) => acc * cur, 1) / 2))\n}\n\nconst readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\nvar stdin = [];\nrl.on('line', function (line) {\n stdin.push(line);\n});\nrl.on('close', main);", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "c8c574b89ee50bee3fef8ac7cd1d9f2b", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\n\nreadLine.on('close', () => {\n const [n] = input[0].split(' ').map(x => parseInt(x));\n let answer = 1;\n\n for (let i = 2; i < n/2 + 1; i += 1) {\n if ( (n - i) % i === 0) answer += 1;\n }\n\n console.log(answer)\n}); ", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "85a5d1482b2d5ded416f66b0722f342c", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var s = next();\n var u = s.toUpperCase();\n var ucount = 0;\n var l = s.toLowerCase();\n var lcount = 0;\n for(var i = 0; i < s.length; i++){\n if(s[i] != u[i] && s[i] == l[i]){\n ucount++;\n }\n if(s[i] == u[i] && s[i] != l[i]){\n lcount++;\n }\n }\n if(lcount > ucount){\n myout(u);\n }else{\n myout(l);\n }\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "1c1617ce39d0c4c8c8cde6f41a732081", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var read = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\nvar obj;\nvar inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n myerr(\"-----start-----\");\n var start = new Date();\n Main();\n var end = new Date() - start;\n myerr(\"----- end -----\");\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n var returnObj = {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(!this.hasNext()){throw \"ArrayIndexOutOfBoundsException これ以上ないよ\";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}\n };\n return returnObj;\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n\nfunction Main() {\n var t = nextInt();\n if (t % 2 === 0) {\n if (t / 2 === 1) {\n console.log(\"NO\");\n } else {\n console.log(\"YES\");\n }\n \n } else {\n console.log(\"NO\");\n }\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "c8e92b2bc86a4e53e7f164968491cbc8", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n const [n, m] = d.split(' ').map(Number);\n let ans = m;\n let iter = 1;\n\n while (ans >= iter) {\n ans -= iter;\n iter++;\n\n if (iter > n) {\n iter = 1;\n }\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "3ad438fe5e3ecb9b1b52778cf5355068", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n \nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n \nlet inputString = '';\nlet currentLine = 0;\n \nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n \nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n \nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main(){\n let a = readLine();\n let b = readLine();\n a=a.split(\"\");\n a=a.reverse(\"\");\n a=a.join(\"\");\n if(a==b){\n console.log(\"YES\");\n }\n else{\n console.log(\"NO\");\n }\n \n \n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "10ec56f5a9cd004e6db09081105cc51c", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\n\"use strict\";\nlet input = [];\nconst readline=require('readline');\nconst RL=readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nRL.on('line', (line)=>{\n input.push(line.trim());\n});\nRL.on('close', ()=>{\n const str1=input[0].toLowerCase();\n const str2=input[1].toLowerCase();\n let answer=undefined;\n if(str1==str2){\n answer=0;\n } else if(str1 {\n\tlet kth = array[1].split(' ')[array[0].split(' ')[1] * 1 - 1];\n\tlet result = array[1].split(' ').filter((el) => {\n\t\treturn el * 1 >= kth && el * 1 > 0;\n\t});\n\tconsole.log(result.length);\n};\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "27f34b7733b416e62e0abb1041fdcdc7", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', line => {\n let arrinput = line.split(' ');\n let number = arrinput[0];\n let k = arrinput[1];\n for (let i = 0; i < k; i++) {\n number = number % 10 == 0 ? number / 10 : number - 1;\n }\n console.log(number);\n}).on('close', () => {\n process.exit(0);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "168bcb413790285b0ab091271167239d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let readline = require('readline');\nlet intInput = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n});\nlet arr = [];\nlet result;\n\nintInput.on('line', (line) => {\n\tarr.push(line)\t\n});\n\nintInput.on('close', () => {\n\tlet table = arr[0].split(\"\");\n\tlet my = arr[1].split(\" \").join(\"\").split(\"\");\n\tfor (let i = 0; i < my.length; i++) {\n\t\tresult = 'NO'\n\t\tif (my[i] == table[0] || my[i] == table[1]) {\n\t\t\tresult = 'YES'\n\t\t\tbreak\n\t\t}\n\t}\n\tconsole.log(result);\n})", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "3e0563d302d8e811f34b9412156b99f5", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', function (line1) {\n let cardOnTable = line1;\n rl.on('line', function (line2) { \n let cardsInHand = line2.split(\" \");\n doIt(cardOnTable, cardsInHand)\n rl.close();\n });\n});\n\nfunction doIt(cardOnTable, cardsInHand) {\n const splitedCardOnTable = splitCard(cardOnTable);\n\n let ret = 'NO';\n for (let i = 0 ;i < cardsInHand.length; i++) {\n const splited = splitCard(cardsInHand[i]);\n if (splited[0] === splitedCardOnTable[0] || splited[1] === splitedCardOnTable[1]) {\n ret ='YES';\n break;\n }\n }\n\n console.log(ret);\n\n function splitCard(card) {\n const rank = card.substring(0,1);\n const suit = card.substring(1,2);\n return [rank, suit];\n };\n}", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "a5253fdf87f3aeb1b0e11c6aa577ee69", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n let n = parseInt(readLine());\n let arr = [];\n for (var i = 0; i < n; i++) {\n arr.push([]);\n }\n for (var i = 0; i < n; i++) {\n arr[0].push(1);\n if (i + 1 < n) arr[i + 1].push(1);\n }\n for (var i = 1; i < n; i++) {\n for (var j = 1; j < n; j++) {\n arr[i].push(arr[i - 1][j] + arr[i][j - 1]);\n }\n }\n console.log(arr[n - 1][n - 1]);\n}\n\n// arr = [\n// [1, 1, 1, 1],\n// [1, 2, 3, 4],\n// [1, 3, 6, 10],\n// [1, 4, 10, 20],\n// ]", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "561d8e1eb675b902d3eea3d007d51c03", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "///////////////////////////////// pre-define /////////////////////////////////////\r\nconst pr = console.log;\r\nconst err = console.error;\r\nconst mi = Math.min;\r\nconst mx = Math.max;\r\nconst abs = Math.abs;\r\nconst fl = Math.floor;\r\nconst ce = Math.ceil;\r\nconst sq = Math.sqrt;\r\nconst gcd = (a, b) => b == 0 ? a : gcd(b, a % b);\r\nconst lcm = (a, b) => (a / gcd(a, b)) * b;\r\nconst powmod = (a, b, mod) => {\r\n let r = 1n;\r\n while (b > 0n) {\r\n if (b % 2n == 1) r = r * a % mod;\r\n b >>= 1n;\r\n a = a * a % mod;\r\n }\r\n return r;\r\n};\r\nconst counter = (a_or_s) => {\r\n let map = new Map();\r\n for (const i of a_or_s) map.set(i, map.get(i) + 1 || 1);\r\n return map;\r\n};\r\n///////////////////////////////////////////////////////////////////////////////////\r\n\r\nconst MOD = BigInt(1e9 + 7);\r\nconst solve = (n, k) => {\r\n pr(powmod(n, k, MOD).toString());\r\n};\r\n\r\nconst main = () => {\r\n const { performance } = require('perf_hooks');\r\n let t_begin = performance.now();\r\n const readline = require('readline');\r\n const rl = readline.createInterface({\r\n input: process.stdin,\r\n output: process.stdout\r\n });\r\n let input = [];\r\n rl.on('line', (line) => {\r\n input.push(line.split(\" \").map(x => BigInt(x)));\r\n });\r\n rl.on('close', () => {\r\n let t = input[0][0];\r\n let i = 1;\r\n while (t--) {\r\n solve(input[i][0], input[i][1]);\r\n i++;\r\n }\r\n let t_end = performance.now();\r\n err(\"Run Time: \" + (t_end - t_begin) / 10 + \"ms\");\r\n });\r\n};\r\n\r\nmain()", "lang_cluster": "Javascript", "tags": ["math", "combinatorics", "bitmasks"], "code_uid": "bff3e34c68d3d17eb46a2a31ef72a334", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n const n = parseInt(d);\n const isMonth = d.split(' ').reverse()[0] === 'month';\n const isWeek = d.split(' ').reverse()[0] === 'week';\n\n if (isWeek) {\n if (n === 5 || n === 6) {\n console.log(53);\n }\n else {\n console.log(52);\n }\n }\n else {\n if (n <= 29) {\n console.log(12);\n }\n else if (n <= 30) {\n console.log(11);\n }\n else {\n console.log(7);\n }\n }\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "cd037f649daf574f8673d47d19898f68", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let fs = require('fs');\n\nlet txt = fs.readFileSync(0, \"utf-8\").split(\"\\r\\n\").filter(data => {\n return data.length > 0;\n});\n\ntxt.forEach(data => {\n let info = data.split(\" \");\n doit(info[0] * 1, info[1] * 1, info[2] * 1);\n});\n\n\nfunction doit(k, n, w) {\n let r=0;\n for (let index = 1; index <= w; index++) {\n r+=index;\n }\n r*=k;\n if(r {\n if((kilos%2==0) && (kilos>=4)){\n console.log(\"YES\")\n }else{\n console.log(\"NO\")\n }\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "f6e91bb69715640bdfadd5f153ac4ad1", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(str) {\n let inputs = str.trim();\n let upperCaseCount = inputs.replace(/[a-z]/g, '').length;\n let lowerCaseCount = inputs.replace(/[A-Z]/g, '').length;\n if (upperCaseCount == lowerCaseCount || lowerCaseCount > upperCaseCount) {\n inputs = inputs.toLowerCase();\n }\n else if (upperCaseCount > lowerCaseCount) {\n inputs = inputs.toUpperCase();\n }\n return inputs.toString();\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "fd67abd22c3c4b29410d86ef61c73db5", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet str1;\nlet str2;\n\nrl.on('line', (d) => {\n if (c === 0) {\n str1 = d;\n c++;\n }\n else {\n str2 = d;\n }\n\n c++;\n});\n\nrl.on('close', () => {\n let ans = 0;\n\n for (let i = 0; i < str2.length; i++) {\n if (str1[ans] === str2[i]) {\n ans++;\n }\n }\n\n console.log(++ans);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "61a8141bfb38eee9a76d0d63f0af48da", "src_uid": "f5a907d6d35390b1fb11c8ce247d0252", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString\n .trim()\n .split('\\n')\n .map(string => {\n return string.trim();\n });\n\n process.stdout.write(String(main(inputString)));\n process.exit();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nconst main = inputArray => {\n const [\n numberOfParticipants,\n numberOfAdvancingScores,\n ] = inputArray[0].split(' ');\n const participantScores = inputArray[1].split(' ');\n const filter0s = score => score !== '0';\n if (numberOfAdvancingScores === numberOfParticipants)\n return participantScores.filter(filter0s).length;\n\n const winners = participantScores.slice(0, numberOfAdvancingScores);\n const lastWinningScore = winners[winners.length - 1];\n if (lastWinningScore === '0') return winners.filter(filter0s).length;\n\n if (participantScores[numberOfAdvancingScores] !== lastWinningScore)\n return winners.length;\n\n for (let i = winners.length; i < participantScores.length; i += 1) {\n if (participantScores[i] === lastWinningScore) {\n winners.push(lastWinningScore);\n } else {\n break;\n }\n }\n\n return winners.length;\n};\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "8f988fd731cecdd9b706097f97347ef9", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n\n\nfunction main() {\n let count = parseInt( readLine().split(' '))\n \n let s = 0;\n while(count >= 1){\n s += count % 2;\n \n count /= 2\n count = Math.floor(count)\n \n \n \n }\n \n console.log(s)\n \n}", "lang_cluster": "Javascript", "tags": ["bitmasks"], "code_uid": "d7d7f5cdd77e5cc1ff6a95cb14ac0c46", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const standardTileArea = 2;\n\nprocess.stdin.on('data', input => {\n const inputSize = input.toString().split(' ');\n\n const tiles = (Number(inputSize[0]) * Number(inputSize[1])) / standardTileArea;\n console.log(Math.floor(tiles));\n});\n\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "459060b3ac520d36c3969dc3aedeae79", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet currLine = 0;\nlet n, k, arr;\n\nrl.on('line', (line) => {\n if (currLine === 0) {\n let temp = line.split(\" \");\n n = +temp[0];\n k = +temp[1];\n ++currLine;\n } else {\n arr = line.split(\" \");\n let count = k;\n let num = arr[--k];\n if (+num === 0) {\n count = 0;\n let tempnum = 0;\n while (tempnum < k && +arr[tempnum] != 0) {\n ++tempnum;\n ++count;\n }\n console.log(count);\n rl.close();\n return;\n }\n while (k < n && arr[++k] === num){\n ++count;\n }\n console.log(count);\n rl.close();\n return;\n }\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "25430a5e2fbd8eac05189ebb4ec31830", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const CODEFORCES_NODE = \"cf\";\nconst CODEFORCES_V8 = \"cf-v8\";\nconst BEAKJOON = \"bj\";\nconst TEST = \"test\";\nvar SITE = CODEFORCES_NODE;\nprocess.argv.forEach(function(val, index, array) {\n // console.log(index + ': ' + val);\n if (val.startsWith(\"site\")) {\n switch (val.split(\"=\")[1]) {\n case \"test\":\n // console.log('change site to test')\n SITE = TEST;\n break;\n case \"cf-node\":\n // console.log('change site to cf')\n SITE = CODEFORCES_NODE;\n break;\n case \"cf\":\n // console.log('change site to cf')\n SITE = CODEFORCES_NODE;\n break;\n case \"cf-v8\":\n // console.log('change site to cf')\n SITE = CODEFORCES_V8;\n break;\n case \"bj\":\n // console.log('change site to bj')\n SITE = BEAKJOON;\n break;\n }\n }\n});\n\nconst DEBUG = SITE == \"test\";\nconst newLine = '\\n';\nif(CODEFORCES_NODE){ //NODE doesn't have readline so make it\n var readline;\n var print;\n print = console.log;\n var it;\n}\nvar ans;\nvar text = \"\";\nvar lineCount = 0;\nvar lines;\nfunction solve() {\n const [n,b] = readInts();\n const arr = readInts();\n it(n, b);\n it(arr);\n //먼저 홀짝 쌍을 전부 세면서 동시에 cost도 셀 수 있나? \n //그렇다면 각 cuttable point에 대해 세자! \n var countingGroup = false;\n var balance = 0;\n var cutpoints = [];\n for (let i = 0; i < arr.length; i++) {\n const el = arr[i];\n if(el % 2 == 0)\n balance += 1;\n else\n balance -= 1;\n if(!countingGroup){\n //balance는 당연히 안맞을 것.\n it('counting started', i);\n countingGroup = true;\n }\n else if(countingGroup && balance == 0){\n if(i+1 == arr.length){\n break;\n }\n countingGroup = false;\n cutpoints.push({'pos': i+1, 'price': Math.abs(arr[i+1] - arr[i])});\n it('counting stopped', i);\n }\n }\n it(cutpoints);\n cutpoints.sort((x,y)=>{\n return x.price - y.price;\n });\n if(cutpoints.length == 0){\n print(0);\n return;\n }\n const prices = cutpoints.map((x)=>{return x.price;});\n it(prices);\n var cost = 0;\n var cur = 0;\n while (cost < b) {\n cost += prices[cur];\n cur++;\n if(cost > b){\n cur-=1;\n break;\n }\n if(cur == prices.length){\n break;\n }\n }\n print(cur);\n}\nfunction* getlines(text) {\n var lines = text.split(/\\r?\\n/);\n for (let line of lines) {\n yield line + newLine;\n }\n}\nfunction readline() {\n return lines.next().value.trim();\n}\nfunction readInts() {\n return readline()\n .split(\" \")\n .map(function(x) {\n return parseInt(x);\n });\n}\nvar input;\nif (DEBUG) {\n var fs = require(\"fs\");\n input = fs.createReadStream(\"input.txt\", {encoding:\"utf8\"});\n it = print;\n // lines = getlines(fs.readFileSync(\"input.txt\", \"utf8\"));\n // let data = \"\";\n // data += readline().toString();\n\n // data += readline().toString();\n // require(\"fs\").writeFile(\"output.txt\", data, \"utf8\", function(err) {\n // console.log(\"비동기적 파일 쓰기 완료\");\n // });\n // console.log(process.stdin);\n}\nelse {\n input = process.stdin;\n it = function it(params) {\n return 0;\n }\n}\nif (CODEFORCES_NODE) {\n function inputListener(line) {\n if (!line) {\n closing();\n }\n lineCount++;\n text += line + \"\\r\\n\";\n }\n function closing(){\n lines = getlines(text);\n solve();\n process.exit();\n }\n function readlines() {\n const readline = require(\"readline\");\n const rl = readline.createInterface({\n input,\n output: process.stdout,\n terminal: false\n });\n rl.on(\"line\", inputListener);\n rl.on('close', closing);\n }\n readlines();\n}\n// console.log('hallo!!!')\n", "lang_cluster": "Javascript", "tags": ["sortings", "dp", "greedy"], "code_uid": "dc771e8bb1b63b17038033ca64f75c04", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n var strArr = readLine().split(\" \").map(Number);\n var k = strArr[0];\n var n = strArr[1];\n var w = strArr[2];\n var result = k;\n for (let i = 1; i < w; i++) {\n result += k + k * i;\n }\n if (result > n) {\n console.log(result - n);\n } else {\n console.log(0);\n }\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "9241735bde4d02e288538bf49bd408cc", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline'),\n rl = readline.createInterface(process.stdin, process.stdout);\n\nvar arr = [];\n//rl.prompt();\n\nrl.on('line', function (line) {\n\n arr = line.split(' ').map(function (x) { return parseInt(x, 10) });\n\n\n\n var n = arr[0];\n var m = arr[1];\n var a = arr[2];\n\n var x = n % a == 0 ? n / a : Math.floor(n / a) + 1;\n var y = m % a == 0 ? m / a : Math.floor(m / a) + 1;\n\n console.log(x * y);\n\n rl.close();\n\n\n\n}).on('close', function () {\n\n process.exit(0);\n});\n\n\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "2c5b00538a22d2eb5c62915b6fb2619f", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', (inputStdin) => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', (_) => {\n inputString = inputString\n .trim()\n .split('\\n')\n .map((string) => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction main() {\n var song = readline();\n\n song = song.split('WUB').join(' ');\n\n console.log(song);\n}\n", "lang_cluster": "Javascript", "tags": ["strings"], "code_uid": "54a276121fca070925386319594d979a", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Alternative\n// https://www.npmjs.com/package/competitive-programming-js\n\"use strict\"\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\nlet inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', inputStdin => { inputString += inputStdin; });\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n main();\n});\nfunction input() { return inputString[currentLine++]; }\nconst println = (x = \"\") => process.stdout.write(String(x) + \"\\n\");\nconst print = x => { process.stdout.write(String(x)); }\n// >>>>>>>>>>>>> Main starts here <<<<<<<<<<<<<<\n\nconst createArray = n => {\n let ar = new Array(n).fill(0);\n println(ar);\n ar = ar.map(v => new Array(n).fill(0));\n return ar;\n}\n\nfunction main() {\n let n = parseInt(input());\n\n let ar = new Array(100).fill(0).map(v => new Array(n).fill(0));\n let val = input().split(' ').map(v => parseInt(v));\n\n for (let i = 0; i < n; ++i) {\n for (let j = 0; j < val[i]; ++j) {\n ar[j][i] = 1;\n }\n }\n // println(ar.join('\\n'));\n // println(\"-----------\");\n for (let i = n-2; i >= 0; --i) {\n for (let j = 0; j < 100; ++j) {\n if (ar[j][i] === 1 && ar[j][i+1] === 0) {\n let pos = i + 1;\n while (pos < n && ar[j][pos] === 0) {\n pos += 1;\n }\n pos -= 1;\n ar[j][pos] = 1;\n ar[j][i] = 0;\n }\n }\n // println(ar.join('\\n'));\n // println(\"-----------\");\n }\n\n let ans = new Array(n).fill(parseInt(0));\n\n for (let i = 0; i < n; ++i) {\n for (let j = 0; j < 100; ++j) {\n ans[i] += ar[j][i];\n }\n }\n\n ans.forEach(v => print(v + \" \"));\n println();\n\n\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "d344ced20c867a34cc3c1217a18df710", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout,\n\tterminal: false\n});\n \nrl.on('line', line => {\n\tconst [n, m] = line.split(' ').map(i => parseInt(i));\n\tconsole.log(Math.floor(n * m / 2));\n\trl.close();\n});", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "2a3ce76dbf62a2bf12cdc8dd613f649a", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "function ProblemSolver() {\n this.HAS_TEST_CASES = false;\n this.INPUT_FILE_NAME = \"test.in\";\n this.OUTPUT_FILE_NAME = \"out.txt\";\n this.DO_OUTPUT_TO_FILE = false;\n this.CLEAR_ARRAY_PER_CASE = false;\n\n this.solveCase = function() {\n var res , i , j , fl , cn , temp , lim , mask , mi , ma , tot ;\n res = 0 ;\n lim = ( 1 << this.n ) ;\n for( i = 0 ; i < lim ; i++ ) {\n \tmask = i ;\n \ttot = 0 ;\n \tmi = 1000000000000 ;\n \tma = -1 ;\n \tfor( j = 0 ; j < this.n ; j++ ) {\n \t\tif( ( mask & ( 1 << j ) ) != 0 ) {\n \t\t\tmi = Math.min( mi , this.arr[ j ] ) ;\n \t\t\tma = Math.max( ma , this.arr[ j ] ) ;\n \t\t\ttot += this.arr[ j ] ;\n \t\t}\n \t}\n \tif( tot >= this.l && tot <= this.r && ma - mi >= this.x ) {\n \t\tres++ ;\n \t}\n }\n print( res );\n };\n\n this.init = function() {\n this.lim1 = 100010;\n this.lim2 = 110;\n this.cc = 1;\n this.ind = 1;\n this.n = 0;\n this.cn = 0;\n this.declareAndFillArrays();\n };\n\n this.getInput = function( irObj ) {\n var hasMoreInput , i;\n hasMoreInput = true;\n try {\n this.n = irObj.nextInt();\n this.l = irObj.nextInt();\n this.r = irObj.nextInt();\n this.x = irObj.nextInt();\n this.arr = [] ;\n for( i = 0 ; i < this.n ; i++ ) {\n this.arr.push( irObj.nextInt() ) ;\n }\n }\n catch( ex ) {\n hasMoreInput = false;\n }\n return hasMoreInput;\n };\n\n this.clearArraysPerCase = function() {\n var i;\n this.arr = new Array();\n this.adjList = new Array();\n for( i = 0 ; i < this.lim1 ; i++ ) {\n this.arr.push( 0 );\n this.adjList.push( new Array() );\n }\n };\n\n this.clearPerCase = function() {\n this.cn = 0;\n this.cc++;\n if( this.CLEAR_ARRAY_PER_CASE == true ) {\n this.clearArraysPerCase() ;\n }\n };\n\n this.declareAndFillArrays = function() {\n var i , j;\n this.srr = new Array();\n this.vis = new Array();\n this.arr = new Array();\n this.brr = new Array();\n this.memo = new Array();\n this.done = new Array();\n this.adjList = new Array();\n for( i = 0 ; i < this.lim1 ; i++ ) {\n this.srr.push( \"\" );\n this.vis.push( 0 );\n this.arr.push( 0 );\n this.brr.push( 0 );\n this.adjList.push( new Array() );\n }\n for( i = 0 ; i < this.lim2 ; i++ ) {\n this.memo.push( new Array() );\n this.done.push( new Array() );\n for( j = 0 ; j < this.lim2 ; j++ ) {\n this.memo[ i ].push( -1 );\n this.done[ i ].push( 0 );\n }\n }\n };\n\n this.init();\n}\n\nfunction InputReader() {\n var self = this ;\n this.allLines = new Array();\n this.currrentLineNumber = 0;\n this.currrentCharacterIndex = 0;\n this.callBackFunction = null ;\n this.parentContext = null ;\n\n this.readAllLines = function() {\n var singleLine;\n while( true ) {\n try {\n singleLine = readline();\n if( singleLine == null ) {\n break;\n }\n }\n catch( ex ) {\n break;\n }\n this.allLines.push( singleLine );\n }\n };\n \n this.readAllLinesFromRhino = function() {\n var brObj , line ;\n importPackage( java.io ) ;\n importPackage( java.lang ) ;\n brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;\n this.allLines = [] ;\n while( true ) {\n line = brObj.readLine() ;\n if( line == null ) {\n break;\n }\n this.allLines.push( line ) ;\n }\n };\n \n this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {\n self.chunkData += chunk ;\n };\n\n this.readEndFromNodeJsJudgeServer = function() {\n self.parseRawData( self.chunkData ) ;\n self.parentContext.runCases() ;\n };\n \n this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {\n this.parentContext = parentContext ;\n process.stdin.resume() ;\n process.stdin.setEncoding( 'utf8' ) ;\n this.chunkData = '' ;\n process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;\n process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;\n };\n\n this.parseRawData = function( data ) {\n var len , i , currentString;\n len = data.length;\n currentString = \"\";\n this.allLines = [] ;\n for( i = 0 ; i < len ; i++ ) {\n if( data[ i ] == '\\r' ) {\n }\n else if( data[ i ] == '\\n' ) {\n this.allLines.push( currentString );\n currentString = \"\";\n }\n else {\n currentString += data[ i ];\n }\n }\n if( currentString != \"\" ) {\n this.allLines.push( currentString );\n }\n };\n\n this.readAllLinesFromFile = function( inputFileName ) {\n var currentDirectory , fsObj , inputFilePath , rawData;\n fsObj = require( 'fs' );\n currentDirectory = __dirname;\n inputFilePath = currentDirectory + \"\\\\\" + inputFileName;\n rawData = fsObj.readFileSync( inputFilePath , \"utf8\" );\n this.parseRawData( rawData );\n };\n\n this.next = function( flag ) {\n var len , i , startIdx , res , endIdx;\n if( flag == 0 ) {\n if( this.currrentCharacterIndex != 0 ) {\n this.currrentLineNumber++;\n this.currrentCharacterIndex = 0;\n }\n res = \"\";\n len = this.allLines[ this.currrentLineNumber ].length;\n if( typeof( len ) == 'function' ) {\n len = this.allLines[ this.currrentLineNumber ].length() ;\n }\n for( i = this.currrentCharacterIndex ; i < len ; i++ ) {\n res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;\n }\n this.currrentLineNumber++;\n this.currrentCharacterIndex = 0;\n return res;\n }\n while( true ) {\n if( this.currrentLineNumber >= this.allLines.length ) {\n throw new Error( \"No more tokens available!\" );\n }\n startIdx = -1;\n len = this.allLines[ this.currrentLineNumber ].length;\n if( typeof( len ) == 'function' ) {\n len = this.allLines[ this.currrentLineNumber ].length() ;\n }\n for( i = this.currrentCharacterIndex ; i < len ; i++ ) {\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {\n startIdx = i;\n break;\n }\n }\n if( startIdx == -1 ) {\n this.currrentLineNumber++;\n this.currrentCharacterIndex = 0;\n continue;\n }\n res = \"\";\n endIdx = len - 1 ;\n for( i = startIdx ; i < len ; i++ ) {\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {\n endIdx = i;\n break;\n }\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {\n res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;\n }\n else {\n res += '' + this.allLines[ this.currrentLineNumber ].charAt( i );\n }\n }\n this.currrentCharacterIndex = endIdx;\n if( endIdx == len - 1 ) {\n this.currrentLineNumber++;\n this.currrentCharacterIndex = 0;\n }\n return res;\n }\n };\n\n this.nextInt = function() {\n return parseInt( this.next( 1 ) );\n };\n\n this.nextDouble = function() {\n return parseFloat( this.next( 1 ) );\n };\n\n this.nextString = function() {\n return this.next( 1 );\n };\n\n this.nextLine = function() {\n return this.next( 0 );\n };\n}\n\nfunction FileOutputHandler() {\n this.resultantStringArray = new Array();\n\n this.addNewLine = function( newString ) {\n this.resultantStringArray.push( newString );\n };\n\n this.clearPercase = function() {\n this.resultantStringArray = new Array();\n };\n\n this.flushOutOutputToFile = function( outputFileName ) {\n var i , sz , res , currentDirectory , fsObj , outputFilePath;\n res = \"\";\n sz = this.resultantStringArray.length;\n for( i = 0 ; i < sz ; i++ ) {\n if( i != 0 ) {\n res += \"\\n\";\n }\n res += this.resultantStringArray[ i ];\n }\n fsObj = require( 'fs' );\n currentDirectory = __dirname;\n outputFilePath = currentDirectory + \"\\\\\" + outputFileName;\n fsObj.writeFileSync( outputFilePath , res );\n this.clearPercase();\n };\n}\n\nfunction CodeExecutioner() {\n this.irObj = new InputReader();\n this.psObj = new ProblemSolver();\n this.fohObj = new FileOutputHandler();\n\n this.runCases = function() {\n if( this.psObj.HAS_TEST_CASES == true ) {\n testCases = this.irObj.nextInt();\n for( i = 0 ; i < testCases ; i++ ) {\n this.psObj.clearPerCase();\n this.psObj.getInput( this.irObj );\n this.psObj.solveCase();\n }\n }\n else {\n while( true ) {\n this.psObj.clearPerCase();\n hasMoreTestCases = this.psObj.getInput( this.irObj );\n if( hasMoreTestCases == false ) {\n break;\n }\n this.psObj.solveCase();\n }\n }\n if( this.psObj.DO_OUTPUT_TO_FILE == true ) {\n this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );\n }\n };\n\n this.detectEnvironmentType = function() {\n var environmentType = null ;\n try {\n if( importPackage != null ) {\n environmentType = 'rhino' ;\n }\n }\n catch( ex1 ) {\n try {\n //for nodejs local server check\n if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {\n environmentType = 'local-node-js' ;\n }\n }\n catch( ex2 ) {\n try {\n if( readline == null || typeof( readline ) != 'function' ) {\n environmentType = 'server-node-js' ;\n }\n else {\n try {\n if( Map != null ) {\n environmentType = 'spider-monkey' ;\n }\n else {\n environmentType = 'javascript-v8' ;\n }\n }\n catch( ex3 ) {\n environmentType = 'javascript-v8' ;\n }\n }\n }\n catch( ex3 ) {\n environmentType = 'server-node-js' ;\n }\n }\n }\n return environmentType ;\n };\n\n this.configureStreamsAndReadInput = function() {\n var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , environmentType ;\n isNodeJsJudgeServer = false ;\n environmentType = this.detectEnvironmentType() ;\n if( environmentType == 'local-node-js' ) {\n try {\n if( print == null || typeof( print ) != 'function' ) {\n print = console.log;\n }\n }\n catch( ex ) {\n print = console.log;\n }\n if( this.psObj.DO_OUTPUT_TO_FILE == true ) {\n localContext = this.fohObj;\n print = function() {\n localContext.addNewLine.apply( localContext , arguments );\n }\n }\n this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );\n this.runCases() ;\n }\n else if( environmentType == 'server-node-js' ) {\n try {\n if( print == null || typeof( print ) != 'function' ) {\n print = console.log;\n }\n }\n catch( ex ) {\n print = console.log;\n }\n this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;\n }\n else if( environmentType == 'javascript-v8' ) {\n this.irObj.readAllLines();\n this.runCases() ;\n }\n else if( environmentType == 'rhino' ) {\n this.irObj.readAllLinesFromRhino();\n this.runCases() ;\n }\n else if( environmentType == 'spider-monkey' ) {\n this.irObj.readAllLines();\n this.runCases() ;\n }\n };\n \n this.configureStreamsAndReadInput();\n}\n\nnew CodeExecutioner();\n", "lang_cluster": "Javascript", "tags": ["brute force", "bitmasks"], "code_uid": "85ae2107041ad8694dc458d5e91606a8", "src_uid": "0d43104a0de924cdcf8e4aced5aa825d", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n let [n, k] = d.split(' ').map(Number);\n\n for (let i = 0; i < k; i++) {\n if (n % 10 === 0) {\n n /= 10;\n }\n else {\n n -= 1;\n }\n }\n\n console.log(n);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3c6f65f2d7d2a9acef7c2f54048e762e", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input.push(line);\n});\n\nRL.on('close', () => {\n let n = parseInt(input[0]);\n let count_F = 0, count_S = 0;\n let start = (input[1][0] === 'S') ? 1 : 0;\n\n [...input[1]].forEach( (s) => {\n if(s === 'F' && start === 1){\n count_F++; start = 0;\n }\n else if(s === 'S' && start === 0){\n count_S++; start = 1;\n }\n });\n \n if(count_F > count_S)\n console.log('YES');\n else\n console.log(\"NO\");\n});\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "468227e05b5cd33b6304812e8a1db4e9", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "console.log(\"25\");", "lang_cluster": "Javascript", "tags": ["number theory"], "code_uid": "4172df29e96cd2152dbd0cfa1082a3f4", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n const [n, l, r] = d.split(' ').map(Number);\n const minArr = new Array(n).fill(1);\n const maxArr = new Array(n).fill(1);\n\n let count = 2;\n let idx = 0;\n for (let i = 1; i < l; i++) {\n minArr[idx] = count;\n idx++;\n count *= 2;\n }\n\n count = 2;\n idx = 0;\n for (let i = 1; i < r; i++) {\n idx = i;\n maxArr[i] = count;\n count *= 2;\n }\n\n count /= 2;\n for (let i = idx; i < maxArr.length; i++) {\n maxArr[i] = count;\n }\n\n const minSum = minArr.reduce((a, b) => a + b, 0);\n const maxSum = maxArr.reduce((a, b) => a + b, 0);\n\n console.log(minSum, maxSum);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "3fe8a43f65264611c55ffea5b384bf10", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const fs = require(\"fs\");\n\nconst input = fs.readFileSync(0, \"utf8\").trim().split(\"\\n\");\n\nconst testCases = [];\n\nfunction parseInput() {\n let index = 0;\n\n // T = parseInt(input[0]);\n\n // for (let i = 0; i < T; i++) {\n // index++;\n const [n, m] = input[index].split(\" \").map((item) => BigInt(item));\n const testCase = {\n n,\n m,\n };\n testCases.push(testCase);\n // }\n}\n\nfunction solution(testCase) {\n const { n, m } = testCase;\n\n const modulo = 998244353n;\n\n let result = 0n;\n let toRemove = m;\n const primes = [];\n let primeProd = 1n;\n\n let exp = m;\n for (let l = 2n; l <= n; l++) {\n exp = (exp * m) % modulo;\n result = (result + exp) % modulo;\n }\n\n for (let l = 2n; l <= n; l++) {\n if (!primes.find((p) => l % p == 0)) {\n primes.push(l);\n primeProd *= l;\n }\n if (toRemove) {\n toRemove *= m / primeProd;\n }\n if (toRemove == 0) break;\n result = (result - toRemove) % modulo;\n }\n\n console.log(((result + modulo) % modulo).toString());\n}\n\nparseInput();\n\ntestCases.forEach(solution);\n", "lang_cluster": "Javascript", "tags": ["math", "dp", "combinatorics", "number theory"], "code_uid": "510e1ea4b6d28f3a63fea9804f3e9ca4", "src_uid": "0fdd91ed33431848614075ebe9d2ee68", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n const arr = d.split(' ').map(Number);\n const idx1 = arr.indexOf(1);\n const idx2 = arr.indexOf(arr.length);\n const min = Math.min(idx1, idx2);\n const max = Math.max(idx1, idx2);\n const ans = Math.max(max - 0, arr.length - min - 1);\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation"], "code_uid": "497457aafd39dcd2c4da2ea01acfafea", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var s = next();\n var count = 0;\n for(var i = 0; i < s.length; i++){\n if(s[i] == \"7\" || s[i] == \"4\"){\n count++;\n }\n }\n if(count == 7 || count == 4){\n myout(\"YES\");\n }else{\n myout(\"NO\");\n }\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3f30e6e2cfa0296055d3c37699407625", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nrl.question(\"\", function (str) {\n var res = (str.replace(/[^A-Z]/g, \"\").length);\n var reslow = (str.replace(/[^a-z]/g, \"\").length);\n if (reslow >= res) {\n var up = str.replace(str, str.toLowerCase());\n console.log(up);\n } else {\n var low = str.replace(str, str.toUpperCase());\n console.log(low);\n }\n rl.close();\n }\n);", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "6ca2fbb5b314c3e1cd3878cf016bc903", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error(\"\\n\");\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr(\"time : \" + (end) + \"ms\");\n myerr(\"memory : \" + Math.round(process.memoryUsage().heapTotal / 1024) + \"KB\");\n});\nfunction makeClone(obj){return JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw \"ArrayIndexOutOfBoundsException ‚There is no more input\";}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error(\"debug:\" + require(\"util\").inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(\" \");case 4:return i.split(\" \").map(Number);case 6:return i.split(\"\");case 7:return i.split(\"\").map(Number);case 8:return i.join(\" \");case 9:return i.join(\"\\n\");case 0:return i.join(\"\");default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var N = nextInt();\n if(N % 2 == 0){\n myout(\"Mahmoud\");\n }else{\n myout(\"Ehab\");\n }\n}\n", "lang_cluster": "Javascript", "tags": ["math", "games"], "code_uid": "3f391c86ddd751eeec16bfef3deb6fc0", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nprocess.stdin.on('data', (input) => {\n let result = '';\n\n for (const c of input.trim())\n if (!c.match(/(a|o|y|e|u|i)/i)) result += `.${c.toLowerCase()}`;\n\n process.stdout.write(result);\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "3ffc84c44275d45a3f2d203944ea61d5", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume()\nprocess.stdin.setEncoding('utf8')\n\nlet currentLine = 0\nlet inputString = ''\n\nprocess.stdin.on('data', chunk => {\n inputString += chunk\n})\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(line => {\n return line.trim()\n })\n main()\n})\n\nfunction readLine() {\n return inputString[currentLine++]\n}\n\nfunction main() {\n const str = readLine().trim();\n const n = parseInt(str)\n let m = parseInt(str[str.length - 1]);\n // console.log(n, m)\n if (m % 2 === 0) {\n console.log(n / 2)\n } else if (m % 2 !== 0) {\n console.log(-(n + 1) / 2)\n }\n}\n\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "03a41d7f3d986dbdde98303e475b885f", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n↑入力 ↓出力');\n Main();\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var N = nextInt();\n var list = nextIntArray();\n var count = [0, 0, 0];\n for(var i = 0; i < N; i++){\n count[i % 3] += list[i];\n }\n if(count[0] > count[1] && count[0] > count[2]){\n myout(\"chest\");\n }else if(count[0] < count[1] && count[1] > count[2]){\n myout(\"biceps\");\n }else{\n myout(\"back\");\n }\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e41fa0db4f519e469d5b9b4458c565dc", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\n\nrl.on('line', (str) => {\n let L = 0;\n let R = str.length - 1;\n let ans = '';\n\n while (L <= R) {\n if (L !== R) {\n if (str.length % 2 === 0) {\n ans += str[R];\n ans += str[L];\n }\n else {\n ans += str[L];\n ans += str[R];\n }\n }\n else {\n ans += str[L];\n }\n\n L++;\n R--;\n }\n\n console.log([...ans].reverse().join(''));\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "41d733e66a5315b2fc910652cecdd796", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let data = '';\nprocess.stdin.on('data', c => data += c);\n\nfunction* nextLine() {\n\tlet lines = data.trim().split(/\\n/g);\n\tfor(let l of lines){\n\t\tyield l.trim();\n\t}\n}\n\nlet nl = nextLine();\n\nnl.num = function() {\n\t\treturn Number(this.next().value);\n\t};\nnl.nums = function() {\n\t\treturn this.next().value.split(/\\s/g).map(Number);\n\t};\nnl.line = function() {\n\t\treturn this.next().value;\n\t}\n\t\nconst sol = () => {\n\tlet [x, y] = nl.nums();\n\tans = ['1/1', '5/6','2/3','1/2','1/3','1/6'];\n\tconsole.log(ans[Math.max(x,y)-1]);\n\n};\n\nprocess.stdin.on('end', sol);\n", "lang_cluster": "Javascript", "tags": ["math", "probabilities"], "code_uid": "48fea2f5f03dd31eedea7a5cee3f37a2", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst INPUT = 'test.in';\nconst LOCAL = process.env.ENABLE_LOCAL_ENV === 'true';\nconst log = (...args) => {\n LOCAL && console.log(...args)\n};\nlet rl;\nlet lineNr = 0;\n\n/**\n * MAIN\n */\n(async () => {\n const promises = await setup(INPUT);\n await Promise.all(promises);\n})();\n\n\nfunction setup() {\n const promises = []\n rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false,\n });\n\n rl.on('line', (line) => {\n promises.push(work(line, lineNr));\n lineNr++;\n });\n\n rl.on('error', (err) => {\n log('Error:', err);\n });\n\n return new Promise(res => {\n rl.on('close', () => {\n res(promises)\n log('Done!');\n });\n });\n}\n\nasync function work(line, lineNr) {\n const solutionForLine = await solve(line.trim());\n const responseLine = `${solutionForLine}\\n`;\n process.stdout.write(responseLine);\n}\n\n/**\n * \n * Solution goes below\n * \n */\nfunction solve(line) {\n const [n, m, a] = line.split(' ').map(n => parseInt(n));\n return Math.ceil(n / a) * Math.ceil(m / a);\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "22cc32eaad87fcaf207c1c2ca052ceaa", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet count = 0;\nlet n, c;\nlet p, t;\n\nrl.on('line', (d) => {\n if (count === 0) {\n [n, c] = d.split(' ').map(Number);\n count++;\n return;\n }\n\n if (count === 1) {\n count++;\n p = d.split(' ').map(Number);\n return;\n }\n\n t = d.split(' ').map(Number);\n\n let ans = 'Tie';\n let score1 = 0;\n let score2 = 0;\n let spentTime = 0;\n\n for (let i = 0; i < n; i++) {\n spentTime += t[i];\n score1 += Math.max(0, p[i] - c * spentTime);\n }\n\n spentTime = 0;\n for (let i = n - 1; i >= 0; i--) {\n spentTime += t[i];\n score2 += Math.max(0, p[i] - c * spentTime);\n }\n\n if (score1 > score2) {\n ans = 'Limak';\n }\n\n if (score2 > score1) {\n ans = 'Radewoosh';\n }\n\n console.log(ans);\n\n count++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "be1e42fa1e98a5a38d8fd397101c1ea8", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n\n main();\n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction print(s) {\n process.stdout.write(`${s}`);\n}\n// Make a Snippet for the code above this and then write your logic in main();\n\nfunction main() {\n // input\n const s = readline();\n const t = readline();\n\n let pos = 0;\n for (let i = 0; i < t.length; i++) {\n if (t.charAt(i) === s.charAt(pos)) {\n pos++;\n }\n }\n // output\n print(pos + 1);\n}\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "c480eb4e8ad539644a326b84e1db84b2", "src_uid": "f5a907d6d35390b1fb11c8ce247d0252", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n// utils\nconst MOD = 1e9 + 7;\nconst mod = (n) => ((n % MOD) + MOD) % MOD;\nconst add = (a, b) => mod(mod(a) + mod(b));\nconst sub = (a, b) => mod(mod(a) - mod(b));\nfunction mul() {\n for (var a = arguments, r = a[0], i = a.length; --i; )\n r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;\n return r;\n}\nfunction inv(b) {\n for (var a = MOD, u = 0, v = 1, t; b; v = t)\n (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);\n u %= MOD;\n return u < 0 ? u + MOD : u;\n}\nfunction pow(base, n) {\n if (n === 0) return 1;\n let p = pow(base, Math.floor(n / 2));\n let res = mul(mod(p), mod(p));\n if (n % 2 === 1) res = mul(mod(res), base);\n return res;\n}\nfunction highestOneBit(i) {\n i |= i >> 1;\n i |= i >> 2;\n i |= i >> 4;\n i |= i >> 8;\n i |= i >> 16;\n return i - (i >>> 1);\n}\nfunction permutation(arr, len, store = \"\", permutations = []) {\n if (store.length === len) {\n permutations.push(store);\n return;\n }\n for (let i = 0; i < arr.length; i++) {\n const newArr = [...arr];\n const newChar = newArr.splice(i, 1);\n permutation(newArr, len, store.concat(newChar), permutations);\n }\n return permutations;\n}\n\nfunction main() {\n let t = +readLine();\n while (t--) {\n const num = readLine();\n const count = { 1: 1, 2: 3, 3: 6, 4: 10 };\n const len = count[num.length];\n const n = Math.abs(+num[0] - 1) * 10;\n\n console.log(len + n);\n }\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "4389ac3d6d9f340d8aac116fde4122eb", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet a, b, ans = '';\n\nrl.on('line', (d) => {\n if (c === 0) {\n a = d;\n c++;\n return;\n }\n\n b = d;\n\n for (let i = 0; i < a.length; i++) {\n ans += a[i] ^ b[i];\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "7a001e34688d0a79f2d9487ce20f137d", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const [n, m] = d.split(' ').map(Number);\n let ans = 0;\n ans += n;\n let add = Math.floor(n / m);\n ans += add;\n let secondAdd = Math.floor(ans / m);\n\n while (add !== secondAdd) {\n ans += secondAdd - add;\n\n add = secondAdd;\n secondAdd = Math.floor(ans / m);\n }\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "5600d2da65737e1970f4ddd464b2fc1c", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction readAsInt(){\n return parseInt(readline());\n}\n\nfunction readAsIntList(){\n return readline().split(' ').filter(i => i).map(i => parseInt(i));\n}\n\n\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n let x = readAsInt();\n console.log((x >= 5 ? (x - (x % 5)) / 5 : 0) + (x % 5 > 0 ? 1 : 0));\n}\n \n\n\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "5b7d9e49406491700223d89bf7b47be0", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var input = ''\nprocess.stdin.on('data', c => input += c)\nprocess.stdin.on('end', () => {\n console.log(Math.floor(input.split(' ').reduce((a, v) => a * v, 1) / 2))\n})", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "49fa35e25e6943d233908ad0b8cdad7f", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Sample code to perform I/O:\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\nvar stdin_input = \"\";\n\nprocess.stdin.on(\"data\", function (input) {\n stdin_input += input; // Reading input from STDIN\n});\n\nprocess.stdin.on(\"end\", function () {\n main(stdin_input);\n});\n\nfunction main(input) {\n let output = nameLookUp(input);\n process.stdout.write(output); // Writing output to STDOUT\n}\n\n// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n\n// Write your code here\nfunction nameLookUp(str) {\n let frnLocation = str.trim();\n let moves = [1, 2, 3, 4, 5];\n let steps = [];\n for (let i = moves.length - 1; i >= 0; i--) {\n if (frnLocation % moves[i] === 0) {\n steps.push(Math.floor(frnLocation / moves[i]));\n break;\n } else {\n steps.push(Math.floor(frnLocation / moves[i]) + 1);\n break;\n }\n }\n return steps.toString();\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "d7eb14a046b7eb2cc77023255265abd4", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Lang: Node.js\n'use strict';\nlet x = '', y = 0;\nlet print = x => console.log(x);\n \nprocess.stdin.on('data', inputStdin => x += inputStdin);\nprocess.stdin.on('end', () => { x = x.split('\\n'); main(); });\nlet readline = () => x[y++];\n \n \n// ************************ Code Start ***************************\n \nfunction main() {\n\n var ar = readline().split(\" \");\n var n = ar[0], m = ar[1];\n\n if (9 * n < m || (m == 0 && n > 1)) print(-1 + \" \" + -1);\n else {\n var mx = \"\", mm = m, nn = n;\n while (nn) {\n mx += Math.min(9, mm);\n mm -= Math.min(9, mm);\n nn--;\n }\n var mn = \"\", nn = n, mm = m;\n while (nn) {\n var res = Math.max(mm - (nn - 1) * 9, 0);\n if (!res && nn == n && mm > 0) res = 1;\n mn += res;\n mm -= res;\n nn--;\n }\n print(mn + \" \" + mx);\n }\n}", "lang_cluster": "Javascript", "tags": ["greedy", "dp", "implementation"], "code_uid": "2b4c2df5042a83df1cd65591a0915039", "src_uid": "75d062cece5a2402920d6706c655cad7", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nfunction getACount(str) {\n return str.split('').reduce( (result, char) => {\n if (char === 'a') return result+1;\n else return result;\n }, 0);\n}\nrl.on('line', (str) => {\n const a_count = getACount(str);\n const other_count = str.length - a_count;\n let result;\n if (a_count > other_count) {\n result = str.length;\n } else {\n const char_to_delete = other_count - a_count + 1;\n result = str.length - char_to_delete;\n }\n console.log(result);\n rl.close();\n \n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "35c84293f3af9ef9dffd6b92b99bae56", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({input: process.stdin});\n\nlet a, b, c;\nrl.on('line', (line) => {\n [a, b, c] = line.split(' ').map(i => parseInt(i));\n}).on('close', () => {\n process.stdout.write(\"\" + Math.ceil(a / c) * Math.ceil(b / c));\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "e6f720bdb66254e8d7e77c83f625e55f", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', function (line) {\n console.log(dividable(parseInt(line)) ? 'YES' : 'NO');\n rl.close()\n})\n\n\nfunction dividable(w) {\n return (w != 2 && (w % 2) === 0);\n // let part = 0;\n // while (part <= w) {\n // if (((w - part) % 2) === 0) return true;\n // part += 2;\n // }\n // return false;\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "36f9c75bd5c9285a7b36de16c5694029", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline')\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n})\n\nlet input = []\n\nrl.on('line', line => {\n input = line.split(' ').map(x => parseInt(x))\n const output = solution(...input)\n console.log(output)\n})\n\nrl.on('close', () => {\n // console.log(input)\n})\n\nfunction solution(num, times) {\n for (let i=0; i {\n if (stringLength) {\n console.log(findMostCommonGram(input, stringLength));\n rl.close();\n } else {\n stringLength = input;\n }\n});\n\n// Problem\nfunction findMostCommonGram(string, stringLength) {\n let mostCommonGram = \"\";\n let mostCommonGramOccurrences = 0;\n const gramOccurrences = {};\n\n for (let i = 0; i < stringLength - 1; i++) {\n const twogram = string[i] + string[i + 1];\n const occurrences = gramOccurrences[twogram] ? gramOccurrences[twogram] : 0;\n const currentOcurrences = occurrences + 1;\n if (currentOcurrences > mostCommonGramOccurrences) {\n mostCommonGram = twogram;\n mostCommonGramOccurrences = currentOcurrences;\n }\n\n gramOccurrences[twogram] = currentOcurrences;\n }\n\n return mostCommonGram;\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "a2fe689035221f81bc9f67567868b073", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Queue at the School\n\nconst {EOL} = require('os');\n\nlet inp = '';\n\nprocess.stdin.on('data', c => inp += c);\n\nprocess.stdin.on('end', () => {\n let lines = inp.split(EOL);\n\n let t = +lines[0].split(' ')[1];\n let init = lines[1].split('');\n \n let iter = str => {\n \tfor(let i = 0; i < str.length - 1; i++) {\n \t\tif(str[i] == 'B') {\n \t\t\tif(str[i + 1] == 'G') {\n \t\t\t\tstr[i] = 'G';\n \t\t\t\tstr[i + 1] = 'B';\n \t\t\t\ti++;\n \t\t\t}\n \t\t}\n \t}\n \treturn str;\n }\n\n for(let i = 0; i < t; i++) {\n \tinit = iter(init);\n }\n\n process.stdout.write(init.join(''));\n\n return;\n});", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "ba80622bc2410e1af10f6af2edcb786f", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.question('', (input) => {\n const [n, m, a] = input.split(' ')\n console.log(Math.ceil(n/a) * Math.ceil(m/a));\n rl.close();\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "4a923d637e1bfaf5bc2b8d8270d8dff9", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf8');\n\nlet inputString = \"\";\nlet currentLine = 0;\n\nprocess.stdin.on('data', (data) => {\n inputString += data;\n});\n\nprocess.stdin.on('end', () => {\n inputString = inputString.trim().split(\" \");\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction getChange(string) {\n string = string.toLowerCase();\n resStr = \"\";\n for(let i=0; i {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nconst readLine=()=> inputString[currentLine++];\n/* ================================================ \n Main Solution Starts Here \n===================================================*/\n\nconst main=()=>{\n\tlet firstString=readLine().toLowerCase()\n\tlet secondString=readLine().toLowerCase()\n\n\tif(firstStringsecondString)\n\t\tconsole.log(1)\n\telse console.log(0)\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "5de04aadb542e60507350d979dd41833", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let data = '';\nprocess.stdin.on('data', c => data += c);\nconst sol = () => {\n let n = Number(data);\n let ans = 0; //[0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 15, 4];\n if (n - 10 <= 0 || n - 10 > 11) {\n ans = 0;\n } else if (n - 10 === 10){\n ans = 15\n } else {\n ans = 4;\n }\n console.log(ans);\n}\n \nprocess.stdin.on('end', sol);", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "dc605780253ac0bf5621524455aaa80e", "src_uid": "5802f52caff6015f21b80872274ab16c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//Don't have to see. start------------------------------------------\nvar read = require('readline').createInterface({\n input: process.stdin, output: process.stdout\n});\nvar obj; var inLine = [];\nread.on('line', function(input){inLine.push(input);});\nread.on('close', function(){\n obj = init(inLine);\n console.error('\\n');\n var start = Date.now();\n Main();\n var end = Date.now() - start;\n myerr('time : ' + end + 'ms');\n myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');\n});\nfunction makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}\nfunction nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}\nfunction nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}\nfunction next(){return obj.next();} function hasNext(){return obj.hasNext();}\nfunction init(input){ \n return {\n list : input, index : 0, max : input.length,\n hasNext : function(){return (this.index < this.max);},\n next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}\n };\n}\nfunction myout(s){console.log(s);}\nfunction myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}\n//param \"no\" is\n//unknown or outlier : return i. 1: parseInt.\n//2: split space. 4: split space and parseInt.\n//6: split 1 character. 7: split 1 character and parseInt.\n//8: join space. 9: join nextline. 0: join no character.\nfunction myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}\n\n//Don't have to see. end------------------------------------------\nfunction Main(){\n var N = nextInt();\n var list = nextIntArray();\n list.sort(function(a,b){\n \treturn a - b;\n });\n var map = {};\n for(var i = 0; i < N; i++){\n if(list[i] != -1){\n var div = list[i];\n map[list[i]] = [];\n for(var j = i; j < N; j++){\n if(list[j] % div == 0){\n list[j] = -1;\n }\n }\n }\n }\n myout(Object.keys(map).length);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "greedy", "implementation"], "code_uid": "e448a907ca1f10e4204e364e539bff47", "src_uid": "63d9b7416aa96129c57d20ec6145e0cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nprocess.stdin.resume()\nprocess.stdin.setEncoding('utf-8')\n\nvar arr = ''\nprocess.stdin.on('data', (i) => {\n arr += i\n})\n\n\nprocess.stdin.on('end', () => {\n arr = arr.split('\\n').map(a => a.replace(/(\\r\\n|\\n|\\r)/gm, ''))\n\n let [a, b, c, d, e, f] = arr.map(a => parseInt(a))\n let cost = 0\n\n if(e > f) {\n if(a < d) {\n cost += e * a\n d -= a\n a = 0\n }\n else {\n cost += e * d\n a -= d\n d = 0\n }\n\n cost += Math.min(b, c, d) * f\n }\n else {\n\n if(b <= c && b <= d) {\n cost += f * b\n c -= b\n d -= b\n b = 0\n }\n\n else if(c <= b && c <= d) {\n cost += f * c\n b -= c\n d -= c\n c = 0\n }\n\n else {\n cost += f * d\n c -= d\n b -= d\n d = 0\n }\n\n cost += Math.min(a, d) * e\n }\n\n console.log(cost)\n})", "lang_cluster": "Javascript", "tags": ["math", "greedy", "brute force"], "code_uid": "126bdfb6fb851e4027fe04aa24a3203e", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\nvar rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar templateString = \"\"\n\nvar c = 0;\nrl.on('line', function (line) {\n c += 1;\n if (c == 1) {\n templateString = line;\n rl.close();\n var _p = parse(templateString, 2)\n console.log(result(parseInt(_p[0]), parseInt(_p[1])));\n }\n});\n\nfunction parse(template, iLoop) {\n var out=[]\n var regex = /\\d+/gm;\n var str = template;\n var m;\n var c = 0;\n while ((m = regex.exec(str)) !== null) {\n if (m.index === regex.lastIndex) {\n regex.lastIndex++;\n }\n if (c==iLoop) {break}\n out[c] = m[0];\n c+=1;\n }\n return out;\n}\n\nfunction result(n,k) {\n var min = n>k ? k : n;\n min = n>=k ? min - 1 : min;\n var start = k - n;\n start = start <= 0 ? 1 : start >= n ? n : start;\n return Math.floor((min - start + 1) / 2);\n}\n\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "69e4f7b8108f61ad5567f584f50753e5", "src_uid": "98624ab2fcd2a50a75788a29e04999ad", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\nfunction readAsInt(){\n return parseInt(readline());\n}\n\nfunction readAsIntList(){\n return readline().split(' ').filter(i => i).map(i => parseInt(i));\n}\n\n\n// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n let l = readAsInt();\n let word = readline();\n let match = word.matchAll(/[R]{2,}|[G]{2,}|[B]{2,}/g);\n console.log([...match].map(g => g[0].length - 1).reduce((acc, n) => acc + n, 0));\n}\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "4500a3dc71eca97dbc87112c6dfead23", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// https://codeforces.com/problemset/problem/339/A\n\nfunction main(stdin) {\n process.stdout.write(stdin[0].split('+').sort().join('+') + '')\n}\n\n// Handle standard input\nprocess.stdin.resume()\nprocess.stdin.setEncoding('utf-8')\n\nlet inputString = ''\n\nprocess.stdin.on('data', (inputStdin) => inputString += inputStdin)\nprocess.stdin.on('end', () =>\n main(inputString.trim().split('\\n').map(s => s.trim())))\n", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "bbc7c92409c898d4bc61d84c3946f931", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n\tinput: process.stdin,\n\toutput: process.stdout\n});\nvar str;\nfunction main() {\n\trl.question('', (answer) => {\n\t\tif (answer.length) {\n\t\t\t//console.log(answer);\n\t\t\tstr = answer;\n\t\t\t//main();\n\t\t//} else {\n\t\t\trl.close();\n\t\t\tsolve();\n\t\t}\n\t});\n}\nfunction solve() {\n\t//console.log('tchau');\n\tvar cont = 1;\n\tvar f = true;\n\tfor(var i=1; i input.push(line));\n\nreadLine.on('close', () => {\n let [a, b] = input[0].split(' ').map(x => parseInt(x));\n \n let c = parseInt((Math.max(a, b) - Math.min(a, b)) / 2);\n console.log(`${Math.min(a, b)} ${c}`)\n}); \n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "b4c346b4ebfad25108a0264bd00128a7", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"ascii\");\n_input = \"\";\nprocess.stdin.on(\"data\", function (input) {\n _input += input;\n});\n\nprocess.stdin.on(\"end\", function () {\n processData(_input);\n});\n\nfunction processData(input1) {\n let input = input1.trim()\n let vowels = \"aeiouy\"\n let result = \"\"\n for(let i=0;i {\n let ans = 0, temp = input.split(' ').map(item => parseInt(item));\n let N = temp[0], M = temp[1];\n\n if (N % 2 == 0 || M % 2 == 0)\n ans = (N % 2 != 0) ? M / 2 * N : N / 2 * M;\n\n else\n ans = parseInt(N / 2) * M + parseInt(M / 2);\n\n console.log(ans);\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "704ee26f1cd3771814f8c1d78ea19a48", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nconst readLine=()=> inputString[currentLine++];\n/* ================================================ \n Main Solution Starts Here \n===================================================*/\n\nconst main=()=>{\n\tlet x=readLine()\n\tlet uc=0,lc=0\n\tfor(let char of x)\n\t\tif(char==char.toUpperCase())\n\t\t\tuc++\n\t\telse lc++\n\n\tif(lc==uc || lc > uc)\n\t\tconsole.log(x.toLowerCase())\n\telse console.log(x.toUpperCase())\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "fbb71226d8a9a5aee4d2b62d59f9de39", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nlet card, hand;\n\nrl.on('line', (line) => {\n !card ? card = new Set(line) : hand = new Set(line.replace(/\\s/g, ''));\n if (card && hand) {\n for (const char of hand) {\n if (card.has(char)) {\n rl.close();\n return console.log('YES');\n }\n }\n rl.close();\n return console.log('NO');\n }\n});", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "b4d1ae0acd1fa1e6f6ce5f33c0e15221", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function bautifulMartix(matrix) {\n // determine the location of the current 1 point\n let coordinates = [];\n for (let row = 0; row < matrix.length; row++) {\n for (let col = 0; col < matrix[row].length; col++) {\n if (matrix[row][col] == \"1\") {\n coordinates.push(row);\n coordinates.push(col);\n }\n }\n }\n console.log(Math.abs(coordinates[0] - 2) + Math.abs(coordinates[1] - 2));\n}\n\nconst readline = require(\"readline\");\n// Create readline Interface\nlet inputs = [];\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nrl.on(\"line\", (lineInput) => {\n inputs.push(lineInput);\n});\nrl.on(\"close\", () => {\n // call the function\n let matrix = [];\n inputs.forEach(function (el) {\n matrix.push(el.split(\" \"));\n });\n bautifulMartix(matrix);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "99310636204c6502b1b1dd52c37dab8a", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet currentLine = 0;\nlet inputString = \"\";\n\nprocess.stdin.on(\"data\", (raw_data) => {\n inputString += raw_data;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((line) => {\n return line.trim();\n });\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n/******** Main function*************/\n\nfunction main() {\n var s = readLine().split(\"+\").map(Number);\n\n s.sort((a, b) => {\n return a - b;\n });\n\n const result = s.join(\"+\");\n\n console.log(result);\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "601f9cb486070333e562c6d580a9e931", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar GCD=function(a, b){\n if( b==0) return a;\n return GCD(b, a%b);\n}\n\n/**\n * \n * while(true){\n * string input= Console.ReadLine();\n * }\n */\nrl.on('line', (input) => {\n let temp = input.split(' ').map(item=>parseInt(item));\n let y=temp[0],w=temp[1];\n let maxRoll=(y>w)?y:w;\n let dotChance=6-maxRoll+1;\n let gcd=GCD(dotChance,6);\n console.log(\"%d/%d\",dotChance/gcd,6/gcd);\n rl.close();\n\n\n });", "lang_cluster": "Javascript", "tags": ["math", "probabilities"], "code_uid": "0e5ceb23d6574d6dc0a30f3f8b5d9b36", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "/* big.js v3.1.1 https://github.com/MikeMcl/big.js/LICENCE */\n (function(global){\"use strict\";var DP=20,RM=1,MAX_DP=1e6,MAX_POWER=1e6,E_NEG=-7,E_POS=21,P={},isValid=/^-?(\\d+(\\.\\d*)?|\\.\\d+)(e[+-]?\\d+)?$/i,Big;function bigFactory(){function Big(n){var x=this;if(!(x instanceof Big)){return n===void 0?bigFactory():new Big(n)}if(n instanceof Big){x.s=n.s;x.e=n.e;x.c=n.c.slice()}else{parse(x,n)}x.constructor=Big}Big.prototype=P;Big.DP=DP;Big.RM=RM;Big.E_NEG=E_NEG;Big.E_POS=E_POS;return Big}function format(x,dp,toE){var Big=x.constructor,i=dp-(x=new Big(x)).e,c=x.c;if(c.length>++dp){rnd(x,i,Big.RM)}if(!c[0]){++i}else if(toE){i=dp}else{c=x.c;i=x.e+i+1}for(;c.length1?c[0]+\".\"+c.join(\"\").slice(1):c[0])+(i<0?\"e\":\"e+\")+i:x.toString()}function parse(x,n){var e,i,nL;if(n===0&&1/n<0){n=\"-0\"}else if(!isValid.test(n+=\"\")){throwErr(NaN)}x.s=n.charAt(0)==\"-\"?(n=n.slice(1),-1):1;if((e=n.indexOf(\".\"))>-1){n=n.replace(\".\",\"\")}if((i=n.search(/e/i))>0){if(e<0){e=i}e+=+n.slice(i+1);n=n.substring(0,i)}else if(e<0){e=n.length}for(i=0;n.charAt(i)==\"0\";i++){}if(i==(nL=n.length)){x.c=[x.e=0]}else{for(;n.charAt(--nL)==\"0\";){}x.e=e-i-1;x.c=[];for(e=0;i<=nL;x.c[e++]=+n.charAt(i++)){}}return x}function rnd(x,dp,rm,more){var u,xc=x.c,i=x.e+dp+1;if(rm===1){more=xc[i]>=5}else if(rm===2){more=xc[i]>5||xc[i]==5&&(more||i<0||xc[i+1]!==u||xc[i-1]&1)}else if(rm===3){more=more||xc[i]!==u||i<0}else{more=false;if(rm!==0){throwErr(\"!Big.RM!\")}}if(i<1||!xc[0]){if(more){x.e=-dp;x.c=[1]}else{x.c=[x.e=0]}}else{xc.length=i--;if(more){for(;++xc[i]>9;){xc[i]=0;if(!i--){++x.e;xc.unshift(1)}}}for(i=xc.length;!xc[--i];xc.pop()){}}return x}function throwErr(message){var err=new Error(message);err.name=\"BigError\";throw err}P.abs=function(){var x=new this.constructor(this);x.s=1;return x};P.cmp=function(y){var xNeg,x=this,xc=x.c,yc=(y=new x.constructor(y)).c,i=x.s,j=y.s,k=x.e,l=y.e;if(!xc[0]||!yc[0]){return!xc[0]?!yc[0]?0:-j:i}if(i!=j){return i}xNeg=i<0;if(k!=l){return k>l^xNeg?1:-1}i=-1;j=(k=xc.length)<(l=yc.length)?k:l;for(;++iyc[i]^xNeg?1:-1}}return k==l?0:k>l^xNeg?1:-1};P.div=function(y){var x=this,Big=x.constructor,dvd=x.c,dvs=(y=new Big(y)).c,s=x.s==y.s?1:-1,dp=Big.DP;if(dp!==~~dp||dp<0||dp>MAX_DP){throwErr(\"!Big.DP!\")}if(!dvd[0]||!dvs[0]){if(dvd[0]==dvs[0]){throwErr(NaN)}if(!dvs[0]){throwErr(s/0)}return new Big(s*0)}var dvsL,dvsT,next,cmp,remI,u,dvsZ=dvs.slice(),dvdI=dvsL=dvs.length,dvdL=dvd.length,rem=dvd.slice(0,dvsL),remL=rem.length,q=y,qc=q.c=[],qi=0,digits=dp+(q.e=x.e-y.e)+1;q.s=s;s=digits<0?0:digits;dvsZ.unshift(0);for(;remL++remL?1:-1}else{for(remI=-1,cmp=0;++remIrem[remI]?1:-1;break}}}if(cmp<0){for(dvsT=remL==dvsL?dvs:dvsZ;remL;){if(rem[--remL]digits){rnd(q,dp,Big.RM,rem[0]!==u)}return q};P.eq=function(y){return!this.cmp(y)};P.gt=function(y){return this.cmp(y)>0};P.gte=function(y){return this.cmp(y)>-1};P.lt=function(y){return this.cmp(y)<0};P.lte=function(y){return this.cmp(y)<1};P.sub=P.minus=function(y){var i,j,t,xLTy,x=this,Big=x.constructor,a=x.s,b=(y=new Big(y)).s;if(a!=b){y.s=-b;return x.plus(y)}var xc=x.c.slice(),xe=x.e,yc=y.c,ye=y.e;if(!xc[0]||!yc[0]){return yc[0]?(y.s=-b,y):new Big(xc[0]?x:0)}if(a=xe-ye){if(xLTy=a<0){a=-a;t=xc}else{ye=xe;t=yc}t.reverse();for(b=a;b--;t.push(0)){}t.reverse()}else{j=((xLTy=xc.length0){for(;b--;xc[i++]=0){}}for(b=i;j>a;){if(xc[--j]0){ye=xe;t=yc}else{a=-a;t=xc}t.reverse();for(;a--;t.push(0)){}t.reverse()}if(xc.length-yc.length<0){t=yc;yc=xc;xc=t}a=yc.length;for(b=0;a;){b=(xc[--a]=xc[a]+yc[a]+b)/10|0;xc[a]%=10}if(b){xc.unshift(b);++ye}for(a=xc.length;xc[--a]===0;xc.pop()){}y.c=xc;y.e=ye;return y};P.pow=function(n){var x=this,one=new x.constructor(1),y=one,isNeg=n<0;if(n!==~~n||n<-MAX_POWER||n>MAX_POWER){throwErr(\"!pow!\")}n=isNeg?-n:n;for(;;){if(n&1){y=y.times(x)}n>>=1;if(!n){break}x=x.times(x)}return isNeg?one.div(y):y};P.round=function(dp,rm){var x=this,Big=x.constructor;if(dp==null){dp=0}else if(dp!==~~dp||dp<0||dp>MAX_DP){throwErr(\"!round!\")}rnd(x=new Big(x),dp,rm==null?Big.RM:rm);return x};P.sqrt=function(){var estimate,r,approx,x=this,Big=x.constructor,xc=x.c,i=x.s,e=x.e,half=new Big(\"0.5\");if(!xc[0]){return new Big(x)}if(i<0){throwErr(NaN)}i=Math.sqrt(x.toString());if(i===0||i===1/0){estimate=xc.join(\"\");if(!(estimate.length+e&1)){estimate+=\"0\"}r=new Big(Math.sqrt(estimate).toString());r.e=((e+1)/2|0)-(e<0||e&1)}else{r=new Big(i.toString())}i=r.e+(Big.DP+=4);do{approx=r;r=half.times(approx.plus(x.div(approx)))}while(approx.c.slice(0,i).join(\"\")!==r.c.slice(0,i).join(\"\"));rnd(r,Big.DP-=4,Big.RM);return r};P.mul=P.times=function(y){var c,x=this,Big=x.constructor,xc=x.c,yc=(y=new Big(y)).c,a=xc.length,b=yc.length,i=x.e,j=y.e;y.s=x.s==y.s?1:-1;if(!xc[0]||!yc[0]){return new Big(y.s*0)}y.e=i+j;if(ai;){b=c[j]+yc[i]*xc[j-i-1]+b;c[j--]=b%10;b=b/10|0}c[j]=(c[j]+b)%10}if(b){++y.e}if(!c[0]){c.shift()}for(i=c.length;!c[--i];c.pop()){}y.c=c;return y};P.toString=P.valueOf=P.toJSON=function(){var x=this,Big=x.constructor,e=x.e,str=x.c.join(\"\"),strL=str.length;if(e<=Big.E_NEG||e>=Big.E_POS){str=str.charAt(0)+(strL>1?\".\"+str.slice(1):\"\")+(e<0?\"e\":\"e+\")+e}else if(e<0){for(;++e;str=\"0\"+str){}str=\"0.\"+str}else if(e>0){if(++e>strL){for(e-=strL;e--;str+=\"0\"){}}else if(e1){str=str.charAt(0)+\".\"+str.slice(1)}return x.s<0&&x.c[0]?\"-\"+str:str};P.toExponential=function(dp){if(dp==null){dp=this.c.length-1}else if(dp!==~~dp||dp<0||dp>MAX_DP){throwErr(\"!toExp!\")}return format(this,dp,1)};P.toFixed=function(dp){var str,x=this,Big=x.constructor,neg=Big.E_NEG,pos=Big.E_POS;Big.E_NEG=-(Big.E_POS=1/0);if(dp==null){str=x.toString()}else if(dp===~~dp&&dp>=0&&dp<=MAX_DP){str=format(x,x.e+dp);if(x.s<0&&x.c[0]&&str.indexOf(\"-\")<0){str=\"-\"+str}}Big.E_NEG=neg;Big.E_POS=pos;if(!str){throwErr(\"!toFix!\")}return str};P.toPrecision=function(sd){if(sd==null){return this.toString()}else if(sd!==~~sd||sd<1||sd>MAX_DP){throwErr(\"!toPre!\")}return format(this,sd-1,2)};Big=bigFactory();if(typeof define===\"function\"&&define.amd){define(function(){return Big})}else if(typeof module!==\"undefined\"&&module.exports){module.exports=Big}else{global.Big=Big}})(this);\n\nvar tmp = readline().split(' ');\nvar n = new Big(tmp[0]);\nvar m = new Big(tmp[1]);\nif(n.lte(m)) {\n print(n);\n} else {\n Big.RM = 3;\n print(n.minus(m).minus(1).times(8).plus(9).sqrt().times(0.5).minus(1.5).round().plus(1).plus(m).toString());\n}", "lang_cluster": "Javascript", "tags": ["math", "binary search"], "code_uid": "f2150b30aa3f63d542012b3a1f3d0eac", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readLine = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\nconst input = [];\nreadLine.on('line', line => input.push(line));\nconst queue = () => {\n let [n,t] = input[0].split(' ').map(x => +x);\n let s = Array.from(input[1]);\n for (let i = 0; i < t; i++) {\n for (let j = 1; j < n; j++) {\n if (s[j - 1] === 'B' && s[j] === 'G') {\n [s[j - 1], s[j]] = [s[j], s[j - 1]];\n j++;\n }\n }\n }\n console.log(s.join(''));\n};\n\nreadLine.on('close', queue);", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "73f709a65478ceda01bc9551fcfe5f96", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "readline = require('readline')\nlet stdinInput = '';\n\n// //file\n// var fs = require('fs');\n// const inputfile = '_in.txt';\n// const outputfile = '_out.txt';\n// fs.writeFileSync(outputfile, '');\n// var myInterface = readline.createInterface({\n// input: fs.createReadStream(inputfile),\n// });\n// myInterface.on('line', function (line) {\n// stdinInput += line+'\\n';\n// }).on('close', () => {\n// main(); \n// process.exit(0);\n// })\n /*\n * Api Scanner\n */\n class Scanner {\n constructor() {\n this.index = -1;\n this.lines = stdinInput.trim().split('\\n'); // eslint-disable-line\n }\n \n nextLine() {\n this.index += 1;\n return this.lines[this.index].trim();\n }\n nextArray(fn) {\n const array = this.nextLine().split(' ');\n return fn === String ? array : array.map(fn);\n }\n \n hasNext() {\n return this.index < this.lines.length;\n }\n }\n \n process.stdin.resume();\n process.stdin.setEncoding('utf-8');\n process.stdin.on('data', (input) => { stdinInput += input; });\n process.stdin.on('end', () => { main(); });\n\nvar n;\nfunction main() {\n const is = new Scanner();\n \n // const s = is.nextArray(Number);\n // const t = is.nextArray(Number);\n // // const k = is.nextArray();\n\n n = parseInt(is.nextLine());\n // console.log(n);\n\n \n if(kt()==1)\n console.log(\"YES\");\n\t\telse\n console.log(\"NO\");\n }\n \n function kt(){\n for(var i=2; i {\ni++\n if(i==1) {\n let msg = input.split(\" \")\n partPlace = msg[1]\n } else {\n rl.close()\n scores = input.split(\" \")\n let partPlaceScore = scores[partPlace - 1]\n \n let i = 0\n scores.forEach(function(score) {\n let blep = parseInt(score)\n if (blep >= partPlaceScore && blep > 0) {\n i++\n }\n })\n console.log(i)\n \n } \n \n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "7c84fe05fb66773b73c9bb7f0783461f", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.setEncoding('utf8');\nlet input = [];\nprocess.stdin.on('readable', () => {\n const chunk = process.stdin.read();\n if (chunk !== null) {\n let re = /\\n\\s*| /;\n input = chunk.split(re).slice(0, -1);\n let myinput = input.map(value => parseInt(value));\n console.log(snowball.apply(null, myinput));\n process.exit(0);\n }\n});\n\nfunction snowball(weight, height, u1, d1, u2, d2) {\n let w = weight, h = height;\n for (; h >= 0; h--) {\n w += h;\n if (h == d1) w -= u1;\n if (h == d2) w -= u2;\n if (w < 0) w = 0;\n }\n return w;\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "4e51eaf60cad0b06bef2090abbd63778", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "function ProblemSolver() {\n this.HAS_TEST_CASES = false;\n this.INPUT_FILE_NAME = \"test.in\";\n this.OUTPUT_FILE_NAME = \"out.txt\";\n this.DO_OUTPUT_TO_FILE = false;\n this.CLEAR_ARRAY_PER_CASE = false;\n\n this.solveCase = function() {\n var res , i , j , fl , cn , temp ;\n res = 0 ;\n for( i = 0 ; i < this.w ; i++ ) {\n \tres += ( ( i + 1 ) * this.k ) ;\n }\n if( res <= this.n ) {\n \tres = 0 ;\n }\n else {\n \tres = res - this.n ;\n }\n print( res );\n };\n\n this.init = function() {\n this.lim1 = 100010;\n this.lim2 = 110;\n this.cc = 1;\n this.ind = 1;\n this.n = 0;\n this.cn = 0;\n this.declareAndFillArrays();\n };\n\n this.getInput = function( irObj ) {\n var hasMoreInput , i;\n hasMoreInput = true;\n try {\n this.k = irObj.nextInt();\n this.n = irObj.nextInt();\n this.w = irObj.nextInt();\n }\n catch( ex ) {\n hasMoreInput = false;\n }\n return hasMoreInput;\n };\n\n this.clearArraysPerCase = function() {\n var i;\n this.arr = new Array();\n this.adj_list = new Array();\n for( i = 0 ; i < this.lim1 ; i++ ) {\n this.arr.push( 0 );\n this.adj_list.push( new Array() );\n }\n };\n\n this.clearPerCase = function() {\n this.cn = 0;\n this.cc++;\n if( this.CLEAR_ARRAY_PER_CASE == true ) {\n this.clearArraysPerCase() ;\n }\n };\n\n this.declareAndFillArrays = function() {\n var i , j;\n this.srr = new Array();\n this.vis = new Array();\n this.arr = new Array();\n this.brr = new Array();\n this.memo = new Array();\n this.done = new Array();\n this.adj_list = new Array();\n for( i = 0 ; i < this.lim1 ; i++ ) {\n this.srr.push( \"\" );\n this.vis.push( 0 );\n this.arr.push( 0 );\n this.brr.push( 0 );\n this.adj_list.push( new Array() );\n }\n for( i = 0 ; i < this.lim2 ; i++ ) {\n this.memo.push( new Array() );\n this.done.push( new Array() );\n for( j = 0 ; j < this.lim2 ; j++ ) {\n this.memo[ i ].push( -1 );\n this.done[ i ].push( 0 );\n }\n }\n };\n\n this.init();\n}\n\nfunction InputReader() {\n var self = this ;\n this.allLines = new Array();\n this.currrentLineNumber = 0;\n this.currrentCharacterIndex = 0;\n this.callBackFunction = null ;\n this.parentContext = null ;\n\n this.readAllLines = function() {\n var singleLine;\n while( true ) {\n try {\n singleLine = readline();\n if( singleLine == null ) {\n break;\n }\n }\n catch( ex ) {\n break;\n }\n this.allLines.push( singleLine );\n }\n };\n \n this.readAllLinesFromRhino = function() {\n var brObj , line ;\n importPackage( java.io ) ;\n importPackage( java.lang ) ;\n brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;\n this.allLines = [] ;\n while( true ) {\n line = brObj.readLine() ;\n if( line == null ) {\n break;\n }\n this.allLines.push( line ) ;\n }\n };\n \n this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {\n self.chunkData += chunk ;\n };\n\n this.readEndFromNodeJsJudgeServer = function() {\n self.parseRawData( self.chunkData ) ;\n self.parentContext.runCases() ;\n };\n \n this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {\n this.parentContext = parentContext ;\n process.stdin.resume() ;\n process.stdin.setEncoding( 'utf8' ) ;\n this.chunkData = '' ;\n process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;\n process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;\n };\n\n this.parseRawData = function( data ) {\n var len , i , currentString;\n len = data.length;\n currentString = \"\";\n this.allLines = [] ;\n for( i = 0 ; i < len ; i++ ) {\n if( data[ i ] == '\\r' ) {\n }\n else if( data[ i ] == '\\n' ) {\n this.allLines.push( currentString );\n currentString = \"\";\n }\n else {\n currentString += data[ i ];\n }\n }\n if( currentString != \"\" ) {\n this.allLines.push( currentString );\n }\n };\n\n this.readAllLinesFromFile = function( inputFileName ) {\n var currentDirectory , fsObj , inputFilePath , rawData;\n fsObj = require( 'fs' );\n currentDirectory = __dirname;\n inputFilePath = currentDirectory + \"\\\\\" + inputFileName;\n rawData = fsObj.readFileSync( inputFilePath , \"utf8\" );\n this.parseRawData( rawData );\n };\n\n this.next = function( flag ) {\n var len , i , startIdx , res , endIdx;\n if( flag == 0 ) {\n if( this.currrentCharacterIndex != 0 ) {\n this.currrentLineNumber++;\n this.currrentCharacterIndex = 0;\n }\n res = \"\";\n len = this.allLines[ this.currrentLineNumber ].length;\n if( typeof( len ) == 'function' ) {\n len = this.allLines[ this.currrentLineNumber ].length() ;\n }\n for( i = this.currrentCharacterIndex ; i < len ; i++ ) {\n res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;\n }\n this.currrentLineNumber++;\n this.currrentCharacterIndex = 0;\n return res;\n }\n while( true ) {\n if( this.currrentLineNumber >= this.allLines.length ) {\n throw new Error( \"No more tokens available!\" );\n }\n startIdx = -1;\n len = this.allLines[ this.currrentLineNumber ].length;\n if( typeof( len ) == 'function' ) {\n len = this.allLines[ this.currrentLineNumber ].length() ;\n }\n for( i = this.currrentCharacterIndex ; i < len ; i++ ) {\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {\n startIdx = i;\n break;\n }\n }\n if( startIdx == -1 ) {\n this.currrentLineNumber++;\n this.currrentCharacterIndex = 0;\n continue;\n }\n res = \"\";\n endIdx = len - 1 ;\n for( i = startIdx ; i < len ; i++ ) {\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {\n endIdx = i;\n break;\n }\n if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {\n res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;\n }\n else {\n res += '' + this.allLines[ this.currrentLineNumber ].charAt( i );\n }\n }\n this.currrentCharacterIndex = endIdx;\n if( endIdx == len - 1 ) {\n this.currrentLineNumber++;\n this.currrentCharacterIndex = 0;\n }\n return res;\n }\n };\n\n this.nextInt = function() {\n return parseInt( this.next( 1 ) );\n };\n\n this.nextDouble = function() {\n return parseFloat( this.next( 1 ) );\n };\n\n this.nextString = function() {\n return this.next( 1 );\n };\n\n this.nextLine = function() {\n return this.next( 0 );\n };\n}\n\nfunction FileOutputHandler() {\n this.resultantStringArray = new Array();\n\n this.addNewLine = function( newString ) {\n this.resultantStringArray.push( newString );\n };\n\n this.clearPercase = function() {\n this.resultantStringArray = new Array();\n };\n\n this.flushOutOutputToFile = function( outputFileName ) {\n var i , sz , res , currentDirectory , fsObj , outputFilePath;\n res = \"\";\n sz = this.resultantStringArray.length;\n for( i = 0 ; i < sz ; i++ ) {\n if( i != 0 ) {\n res += \"\\n\";\n }\n res += this.resultantStringArray[ i ];\n }\n fsObj = require( 'fs' );\n currentDirectory = __dirname;\n outputFilePath = currentDirectory + \"\\\\\" + outputFileName;\n fsObj.writeFileSync( outputFilePath , res );\n this.clearPercase();\n };\n}\n\nfunction CodeExecutioner() {\n this.irObj = new InputReader();\n this.psObj = new ProblemSolver();\n this.fohObj = new FileOutputHandler();\n\n this.runCases = function() {\n if( this.psObj.HAS_TEST_CASES == true ) {\n testCases = this.irObj.nextInt();\n for( i = 0 ; i < testCases ; i++ ) {\n this.psObj.clearPerCase();\n this.psObj.getInput( this.irObj );\n this.psObj.solveCase();\n }\n }\n else {\n while( true ) {\n this.psObj.clearPerCase();\n hasMoreTestCases = this.psObj.getInput( this.irObj );\n if( hasMoreTestCases == false ) {\n break;\n }\n this.psObj.solveCase();\n }\n }\n if( this.psObj.DO_OUTPUT_TO_FILE == true ) {\n this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );\n }\n };\n\n this.detectEnvironmentType = function() {\n var environmentType = null ;\n try {\n if( importPackage != null ) {\n environmentType = 'rhino' ;\n }\n }\n catch( ex1 ) {\n try {\n //for nodejs local server check\n if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {\n environmentType = 'local-node-js' ;\n }\n }\n catch( ex2 ) {\n try {\n if( readline == null || typeof( readline ) != 'function' ) {\n environmentType = 'server-node-js' ;\n }\n else {\n try {\n if( Map != null ) {\n environmentType = 'spider-monkey' ;\n }\n else {\n environmentType = 'javascript-v8' ;\n }\n }\n catch( ex3 ) {\n environmentType = 'javascript-v8' ;\n }\n }\n }\n catch( ex3 ) {\n environmentType = 'server-node-js' ;\n }\n }\n }\n return environmentType ;\n };\n\n this.configureStreamsAndReadInput = function() {\n var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , environmentType ;\n isNodeJsJudgeServer = false ;\n environmentType = this.detectEnvironmentType() ;\n if( environmentType == 'local-node-js' ) {\n try {\n if( print == null || typeof( print ) != 'function' ) {\n print = console.log;\n }\n }\n catch( ex ) {\n print = console.log;\n }\n if( this.psObj.DO_OUTPUT_TO_FILE == true ) {\n localContext = this.fohObj;\n print = function() {\n localContext.addNewLine.apply( localContext , arguments );\n }\n }\n this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );\n this.runCases() ;\n }\n else if( environmentType == 'server-node-js' ) {\n try {\n if( print == null || typeof( print ) != 'function' ) {\n print = console.log;\n }\n }\n catch( ex ) {\n print = console.log;\n }\n this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;\n }\n else if( environmentType == 'javascript-v8' ) {\n this.irObj.readAllLines();\n this.runCases() ;\n }\n else if( environmentType == 'rhino' ) {\n this.irObj.readAllLinesFromRhino();\n this.runCases() ;\n }\n else if( environmentType == 'spider-monkey' ) {\n this.irObj.readAllLines();\n this.runCases() ;\n }\n };\n \n this.configureStreamsAndReadInput();\n}\n\nnew CodeExecutioner();\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "61aa9a0177b6f67b1d6795a89b223d7b", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = '';\nlet currentLine = 0;\nprocess.stdin.on('data', data => {\n\tinputString += data;\n});\nprocess.stdin.on('end', function () {\n\tinputString = inputString\n\t\t.trim()\n\t\t.split('\\n')\n\t\t.map(str => str.trim());\n\tmain();\n});\n\nfunction readLine() {\n\treturn inputString[currentLine++];\n}\n\nconst store = {};\n\nfunction main() {\n\tlet [n, m] = readLine()\n\t\t.split(' ')\n\t\t.map(x => x >> 0);\n\n\tif (m > n) {\n\t\tconsole.log(-1);\n\t\treturn;\n\t}\n\n\tlet steps = (n & 1) === 0 ? n >> 1 : (n >> 1) + 1;\n\n\tif (steps % m === 0) {\n\t\tconsole.log(steps);\n\t\treturn;\n\t}\n\n\tlet found = false;\n\twhile (steps <= n) {\n\t\tsteps++;\n\t\tif (steps % m === 0) {\n\t\t\tfound = true;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tfound ? console.log(steps) : console.log(-1);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "b90899b5a64dcc0b736f36b9472435c5", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nlet c = 0;\nlet arr1, arr2;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n if (c === 1) {\n c++;\n arr1 = d.split(' ').map(Number);\n return;\n }\n\n arr2 = d.split(' ').map(Number);\n let ans = 0;\n\n for (let i = 0; i < arr1.length; i++) {\n ans += arr1[i];\n }\n\n for (let i = 0; i < arr2.length; i++) {\n ans -= arr2[i];\n }\n\n if (ans >= 0) {\n console.log('YES');\n }\n else {\n console.log('NO');\n }\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "713b1a57bbd10b61ebcea0ca02f7c161", "src_uid": "e0ddac5c6d3671070860dda10d50c28a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.on('line', (input) => {\n let len=input.length;\n let met=false;\n let ans=\"\";\n for(let i=0;i {\n inputs.push(lineInput);\n});\nrl.on(\"close\", () => {\n let firstWord = inputs[0];\n let secondWord = inputs[1];\n lexicographically(firstWord, secondWord);\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "bc031f1421f2281a7a34e9b23ac70e17", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readline() {\n return inputString[currentLine++];\n}\n\n// thats all what you have to write to get input from stdin, using readLine.\n\n\n// Main code runs in main();\n\n\nfunction main(){\n let onerow = 1;\n let onecol = 1\n\n for(var row=1; row<=5;row++)\n {\n let line = readline();\n for (let col = 0; col < line.split(\" \").length; col++) {\n const element = line.split(\" \")[col];\n if(element === '1')\n {\n onerow = row;\n onecol = col + 1;\n }\n }\n }\n var res= Math.abs(3 - onerow) + Math.abs(3 - onecol);\n process.stdout.write(res.toString());\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "ad0fcc59505f53e12d6500a53f836c46", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet currentLine = 0;\nlet inputString = \"\";\n\nprocess.stdin.on(\"data\", (raw_data) => {\n inputString += raw_data;\n});\n\nprocess.stdin.on(\"end\", (_) => {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((line) => {\n return line.trim();\n });\n main();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n/******** Main function*************/\n\nfunction main() {\n var arr = readLine().split(\" \").map(Number);\n\n var uniqArr = [...new Set(arr)];\n console.log(4 - uniqArr.length);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "02a8c122e03f640d5fa8bc1e450da642", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n \nlet input = [];\n \nconst RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n});\n\nRL.on('line', (line) => {\n input = line.split(' ').map(x => parseInt(x));\n let n = input[0]; let k = input[1];\n\n for(let i = 0; i < k; i++){\n if (n % 10 == 0)\n n = n/10;\n else\n n--;\n }\n console.log(n);\n});\n\nRL.on('close', () => {\n //console.log(input);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "88844b4e9b12c01c7f91be06e58d0f6e", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\nrl.on('line', (d) => {\n const [k, n, s, p] = d.split(' ').map(Number);\n const airplanes = Math.ceil(n / s) * k;\n const ans = Math.ceil(airplanes / p);\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "ba711ab2caec17ae86bc71a7de60a55a", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function read(cb) {\n let buffer = ''\n process.stdin.on('end', () => cb(buffer))\n process.stdin.on('data', data => buffer += data.toString())\n}\n\nread(input => {\n const [a, b] = input.split(/\\W/).map(Number)\n if (a === b) {\n console.log(1)\n } else {\n console.log(Math.ceil(Math.log(b/a) / (Math.log(3) - Math.log(2))))\n }\n})\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "91fc9207269cb46a30327def831d5c17", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let inputString = \"\";\nlet currentLine = 0;\nprocess.stdin.on(\"data\", (data) => {\n inputString += data;\n});\nprocess.stdin.on(\"end\", function () {\n inputString = inputString\n .trim()\n .split(\"\\n\")\n .map((str) => str.trim());\n main();\n});\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n const a = parseInt(readLine());\n const b = parseInt(readLine());\n const c = parseInt(readLine());\n const maxN = Math.max(Math.max(a+b+c, a + (b * c), (a * b) + c), Math.max(a * b * c, a * ( b + c), (a + b) * c));\n console.log(maxN);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "42cbc7cafa7865db44de713a41348172", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet l = 0;\nlet hand = []\nrl.on('line', (input) => {\n if (l === 0) { \n hand = input.split(\"\")\n }\n else {\n rl.close();\n let arr = input.split(\" \").map(x => x.split(\"\"))\n let can =false\n for(let i=0;i {\r\n inputString += inputStdin;\r\n});\r\nprocess.stdin.on(\"end\", () => {\r\n inputString = inputString.split(\"\\n\");\r\n main();\r\n});\r\nfunction readline() {\r\n return inputString[currentLine++];\r\n}\r\n \r\n// ************************ Code Start ***************************\r\n \r\nfunction main() {\r\n \r\n var t=+readline();\r\n while(t--){\r\n var input= readline();\r\n var arr= input.split(\" \").map(x=>+x);\r\n var a=arr[0];\r\n var b=arr[1];\r\n var res=1;\r\n for(var i=0; i