{"lang": "JavaScript", "source_code": "var t = parseInt(readline());\r\n\r\n function solve() {\r\n var n = parseInt(readline())\r\n var ans = 0;\r\n\r\n ans += Math.floor(Math.sqrt(n))\r\n var qubic = Math.floor(Math.cbrt(n))\r\n ans += qubic\r\n ans -= Math.floor(Math.sqrt(qubic))\r\n return ans\r\n }\r\n\r\n while (t--) {\r\n print(solve())\r\n }", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "2e0b33dfcc88c448552da5fb3b840be4", "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});\nlet c = 0;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n let ans = new Set(d.toLowerCase()).size;\n\n if (ans === 26) {\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": ["strings", "implementation"], "code_uid": "ce95b7785c24bd073f9fd1f0d0e381d8", "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\nrl.on('line', (line) => {\n console.log(solution(line));\n});\n\n\n// Count the number of uppercase and lower case letters\n// If numUpper > numLower turn everything into upper\n// Else turn everything into lower\nfunction solution(input) {\n const word = input.split('');\n let numUpper = 0, numLower = 0;\n for (let i = 0; i < word.length; i++) {\n if (word[i] === word[i].toUpperCase()) {\n numUpper++;\n } else {\n numLower++;\n }\n }\n\n if (numUpper > numLower) {\n return input.toUpperCase();\n } else {\n return input.toLowerCase();\n }\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "8d9a45516960e241c902a82888c8ed98", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "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(' ').map(x => parseInt(x));\n const max = Math.max(...a);\n let nr = 6 - max + 1;\n let dr = 6;\n\n let r = 6;\n while(r > 0) {\n if (nr % r === 0 && dr % r === 0) {\n nr = nr / r;\n dr = dr / r;\n break;\n }\n r--;\n }\n\n // output\n print(`${nr}/${dr}`);\n}\n\n", "lang_cluster": "Javascript", "tags": ["math", "probabilities"], "code_uid": "b5fe717d5d2cf0102399b6ae475f8b2a", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data',c=>{a=c.toString();console.log(c>2&&c%2==0?\"YES\":\"NO\")})", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "dbcd4b9ea0aeeb4ce50850c5a639de23", "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 [n, k] = d.split(' ').map(BigInt);\n const ans = n / k;\n\n if (ans % 2n === 0n) {\n console.log('NO');\n }\n else {\n console.log('YES');\n }\n\n});\n", "lang_cluster": "Javascript", "tags": ["math", "games"], "code_uid": "fd4550c4e9fbfcbcd4811b1be8e0b1b2", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "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\tconst b = parseInt(line);\n\tlet counter = 0;\n\tconst sqrt = Math.sqrt(b)\n\tfor (let i = 2; i < sqrt; i++) {\n\t\tif (b % i === 0) { counter += 2; }\n\t}\n\tif (sqrt % 1 === 0) { counter++; }\n\tconsole.log(b === 1 ? 1 : counter + 2);\n\trl.close();\n});\n", "lang_cluster": "Javascript", "tags": ["math", "number theory"], "code_uid": "d03aa2efaaec588d5f7c5814638d765b", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const Fs = require('fs')\n\nconst content = Fs.readFileSync(0).toString()\n\nconst parse = (a) => {\n a = a.match(/(\\d*) (\\d*)/)\n return [a[1], a[2]]\n}\n\nconst decrease = (num, k) => {\n if (k === 0) {\n return num\n }\n if (num % 10 === 0) {\n return decrease(num / 10, k - 1)\n }\n return decrease(num - 1, k - 1)\n}\n\nconsole.log(decrease(...parse(content)))\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3626638db1c31aa1466d56ce140b34d6", "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\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 for(let i = 0; i < 5; i++) {\n let x = readAsIntList().findIndex(n => n);\n if(x>-1) {\n let result = (x > 2 ? ((x+1) % 3) : 2 - x) + (i > 2 ? ((i+1) % 3) : 2 - i);\n console.log(result);\n return;\n }\n }\n}\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "765b169224fe37ecd92db5f129dcf6c0", "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\nlet input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n const count = parseInt(input[0], 10)\n let hash = []\n for (let a = 1; a <= count; a ++) {\n let index = hash.length === 0 ? 1 : hash.length - 1\n if (hash[index] === undefined) {\n hash.push([a])\n } else {\n hash[index].push(a)\n }\n }\n for (let a = 1; a < count - 1; a++) {\n for (let b = 0; b < count; b++) {\n const _prevLeftNum = b > 0 ? hash[a][b - 1] : 0\n const _prevTopNum = hash[a - 1][b]\n const all = _prevLeftNum + _prevTopNum\n if (hash[a] === undefined) {\n hash.push([all])\n } else {\n hash[a].push(all)\n }\n }\n }\n const lastResult = hash[hash.length - 1]\n console.log(hash[hash.length - 1][lastResult.length - 1])\n})", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "575e7b6250ea3c0ef8435b989dd36ecf", "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\nvar finalWord=\"\";\nvar vowels=[\"A\",\"O\",\"Y\",\"E\",\"U\",\"I\"];\nreadline.question(\"\",ans=>{\n for (let i = 0; i < ans.length; i++) {\n !vowels.includes(ans[i].toUpperCase())?finalWord+=\".\"+ans[i].toLocaleLowerCase():void 0;\n }\n console.log(finalWord);\n readline.close();\n})\n\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "f092b2eba44a9e5b8e012ad45f6cd317", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\nconst readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nreadline.question('', str => {\n solution(str);\n readline.close();\n});\n\nfunction solution(str) {\n let i, j, count = 0;\n for(i = 0; i < str.length; i++) {\n for(j = i - 1; j >= 0; j--) {\n if (str[i] === str[j]) {\n break;\n }\n }\n if (j === -1) count++;\n }\n if (count % 2) {\n console.log(\"IGNORE HIM!\");\n return;\n }\n console.log(\"CHAT WITH HER!\");\n return;\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "f3236faae66ffa5101f5eacd5422ba95", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "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 checkT(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 return \"I\";\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 (checkT(a, b, c) == \"T\" || checkT(b, c, d) == \"T\" || checkT(a, c, d) == \"T\" || checkT(a, b, d) == \"T\")\n console.log(\"TRIANGLE\");\n else if (checkT(a, b, c) == \"S\" || checkT(b, c, d) == \"S\" || checkT(a, c, d) == \"S\" || checkT(a, b, d) == \"S\")\n console.log(\"SEGMENT\");\n else\n console.log(\"IMPOSSIBLE\");\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["brute force", "geometry"], "code_uid": "1d342a15f6a4026db54ff6ee9c259f2d", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "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});\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 [k, n, w] = nums;\n let realSum = 0, i = 1;\n \n while (w > 0) {\n realSum += k*i;\n i += 1; w -= 1;\n }\n\n if (n >= realSum) console.log(0)\n else console.log(realSum - n);\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "de81115b3bd445463bd6e86f865781d4", "src_uid": "e87d9798107734a885fd8263e1431347", "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 terminal: false\n});\n\nlet input=[];\n\nrl.on('line', line => {input.push(line.trim());\n}).on('close', main);\n\nfunction main() {\n let [n, k] = input[0].split(' ');\n const stdin = input[1].split(' ');\n\n const scores = stdin.map((stdin) => {\n return Number(stdin);\n });\n let count = 0;\n const thK = Number(k);\n scores.forEach(elm => {\n if (elm > 0 && elm >= scores[thK - 1]) {\n count++;\n }\n });\n console.log(count);\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "5740f009b2093415b6c06a1a7a0f716c", "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\n\n//init\nlet tempi = 0;\nlet tempj = 0;\nlet columnCounter = 0;\nlet rowCounter = 0;\n\nlet inputCounterRow = 0;\n\n\nrl.on('line', input => {\n inputCounterRow++;\n let array = input.split(\" \").map(Number);\n for(let j = 0; j < 5; j++){\n if(array[j] === 1){\n tempi = inputCounterRow - 1;\n tempj = j;\n\n //j loop row counter\n while( tempj != 2){\n if(tempj > 2)\n tempj--;\n else\n tempj++;\n \n rowCounter++;\n }\n //j loop column counter.\n while(tempi != 2){\n if(tempi > 2)\n tempi--;\n else\n tempi++;\n\n columnCounter++;\n }\n }\n }\n\n if(inputCounterRow === 5){\n console.log(rowCounter + columnCounter);\n rl.close();\n }\n \n \n });", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "7dad2f0052bf5d703279baf5a399c078", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "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 = 2;\n for(let i in thr) {\n if(thr[i] < lines[4]) {\n flg = 0;\n break;\n }\n if(thr[i] == lines[4]) {\n flg = 1;\n }\n }\n if(flg == 2) {\n process.stdout.write('0');\n return;\n }\n // if(flg == 1) {\n // process.stdout.write('1');\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": "f44b9d65d213f3ed8c4da56810339937", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "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.replace(/\\s*$/, '').split(\"\\n\").map(str => str.replace(/\\s*$/, ''));\n \n \n main();\n \n})\n\n\n\n\nfunction main(){\n n = inp[0].split(\" \")[0]\n k = inp[0].split(\" \")[1]\n \n let allscores = inp[1].split(\" \").map(item=>{return parseInt(item)})\n \n let gecen = allscores.filter((item)=>{return item >= allscores[k-1]}).filter(item=>{return item>0})\n console.log(gecen.length)\n \n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "c83c3dbbe58165162659f615e3e79525", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "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\nvar T, n, k;\n\nrl.on(\"line\", (line) => {\n\tvar n = parseInt(line);\n\tconsole.log( (n > 2 && n % 2 == 0) ? \"YES\" : \"NO\" );\n\trl.close();\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "b2baa276669c6a387266a19959304f18", "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 (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 \u201aThere 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 l = one[2];\n var c = one[3];\n var d = one[4];\n var p = one[5];\n var nl = one[6];\n var np = one[7];\n var allB = k * l;\n var allS = c * d;\n myout(Math.min.apply(null, [Math.floor(allB / nl / n), Math.floor(p / np / n), Math.floor(allS / n)]));\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "1885d0a331a7c00436b54fbb9fd3ec37", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "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, t] = readLine().split(' ').map(num => Number(num));\n const str = readLine().split('');\n for (let i = 0; i < t; i++) {\n let j = 0;\n while (j < n - 1) {\n if (str[j] === 'B' && str[j + 1] === 'G') {\n str[j] = 'G';\n str[j + 1] = 'B';\n j++;\n }\n j++;\n }\n }\n console.log(str.join(''));\n}\n", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "c2839fa4f1512bd5b74a68b4038a6701", "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\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, k, l, c, d, p, nl, np] = readLine()\n\t\t.split(' ')\n\t\t.map(x => x >> 0);\n\n\tlet bottle = Math.floor((k * l) / nl);\n\tlet limes = c * d;\n\tlet salt = Math.floor(p / np);\n\n\tlet res = Math.floor(Math.min(bottle, limes, salt) / n);\n\tconsole.log(res);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "c34365ace189a7e3abbaeb7d952043e9", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "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": "47085a3f58d375e5ea1ea295579afb4b", "src_uid": "04c067326ec897091c3dbcf4d134df96", "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 arrStr = input[0].split('');\n const b = input[1].split('').join('').split('');\n \n for (let i = 0; i < arrStr.length; i++){\n for (let n = 0; n < b.length; n++){\n if( arrStr[i] == b[n]){\n console.log('yes');\n return;\n }\n \n }\n \n \n }\n \n console.log('no');\n\n \n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "b724a38a748edab08b09cb9bf12d4bde", "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\nrl.on('line', (data) => {\n let [n, k, l, c, d, p, nl, np] = data.split(' ').map(Number);\n\n let x = Math.floor(k * l / nl);\n let y = c * d;\n let z = Math.floor(p / np);\n let ans = Math.floor(Math.min(x, y, z) / n);\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "4336eb0df6a5eb26440bed05708810a6", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const solve = (n) => {\n let res = 1;\n for (let i = 1; i <= n; i++) {\n res *= i;\n }\n res /= n;\n res /= (n >> 1);\n return res;\n};\n\nconst main = () => {\n const readline = require('readline');\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n });\n rl.on('line', (line) => {\n console.log(solve(Number(line)));\n });\n};\n\nmain()", "lang_cluster": "Javascript", "tags": ["math", "combinatorics"], "code_uid": "9fa1fec6b0b93f8cc0df185d74ed9603", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "difficulty": 1300.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\nrl.on('line', function(line){\n console.log(theatreSquare(line))\n})\n\n// watermelon\n// function watermelon(line) {\n// line = parseInt(line)\n// return line % 2 ? 'NO' : (line === 2 ? 'NO' : 'YES')\n// }\n\n// theatreSquare\nfunction theatreSquare(line) {\n var arr = line.split(' ')\n return Math.ceil(arr[0] / arr[2]) * Math.ceil(arr[1] / arr[2])\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "8aa2d0d156b9b80d2d3b83d9b173328a", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n const n = Number(stdin[0]);\n var arr = stdin[1].split(' ').map(Number);\n var obj = {};\n var times = [];\n for (let i = 0; i < n; i++) {\n if (obj[arr[i]]) {\n obj[arr[i]]++;\n } else {\n obj[arr[i]] = 1;\n }\n }\n for (var key in obj) {\n times.push(obj[key]);\n }\n console.log(Math.max(...times));\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": "ec33e6b29ba69f34d8482faf595e99cf", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function solution(arr){ \n for (var i = 1; i < arr.length; i++){\n if (arr[0][0] == arr[i][0] || arr[0][1] == arr[i][1]){\n return \"YES\"\n }\n }\n return \"NO\"\n}\nprocess.stdin.addListener(\"data\", (data)=>{\n var arr = data.toString().trim().split(/\\s+/)\n \n console.log(solution(arr))\n})", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "25cbab210f1459b27118544e0fb8ec79", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "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 word;\nlet currentChar = \"a\".charCodeAt(0)\nlet rotations = 0;\n\nrl.on(\"line\", (input) => {\n if (!word) {\n word = input.split(\" \").toString();\n }\n if (word) {\n for (let index = 0; index < word.length; index++) {\n let temp = Math.abs((word.charCodeAt(index) - currentChar))\n if (temp > 13) {\n rotations += (25 - (temp - 1))\n currentChar = word.charCodeAt(index)\n }\n if (temp <= 13) {\n currentChar = word.charCodeAt(index)\n rotations += temp\n }\n }\n console.log(rotations)\n rl.close();\n\n\n }\n})", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "58f2e15690ef6ae9a9fbec30ae146390", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const lines = [];\nconst rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });\nrl.on('line', line => lines.push(line));\nrl.on('close', main);\nlet rli = 0;\nfunction readline() {\n return lines[rli++];\n}\n\nconst ra = ()=>readline().split(' ').map(a=>+a);\n\n/*---------------------------------------------------*/\n\nfunction div(val, by){\n return (val - val % by) / by;\n}\n\nconst getDigits = (x) => {\n let digits = new Array(10).fill(false);\n let len = 0;\n while (x) {\n len++;\n digits[x % 10n] = true;\n x /= 10n;\n }\n return [digits, len];\n}\n\nconst getLen = (x) => {\n let str = x.toString(10);\n return str.length;\n}\n\nconst calc = (t)=>{\n /* read */\n let [n, x] = readline().split(' ');\n n = +n;\n x = BigInt(x);\n\n let arr = new Array(10).fill(x);\n\n let q = [BigInt(x)];\n let visited = new Set([x]);\n\n for (let steps = 1; steps <= 1000000; steps++) {\n let maxlen = 0;\n let newq = [];\n for (const num of q) {\n let [digits, len] = getDigits(num);\n if (len === n) return steps - 1;\n if (len > maxlen) maxlen = len;\n if (len < maxlen - 1) continue;\n for (let i = 9; i > 1; i--) {\n if (!digits[i]) continue;\n let newNum = num * BigInt(i);\n if (visited.has(newNum)) continue;\n if (getLen(newNum) > n) continue;\n newq.push(newNum);\n visited.add(newNum);\n }\n }\n\n if (newq.length === 0) return -1;\n // if (q.length === 1 && newq.length === 1 && q[0] === newq[0]) return -1;\n newq.sort((x, y) => {\n if (y > x) return 1;\n if (x > y) return -1;\n return 0;\n });\n q = newq;\n }\n \n\n return -1;\n};\n\nfunction main() {\n // let T = +readline();\n let out = [];\n // for (let t = 1; t <= T; t++){\n out.push(calc());\n // process.stdout.write(`${calc(n, a)}\\n`);\n // }\n // process.stdout.write(`${calc()}\\n`);\n process.stdout.write(out.join('\\n')+'\\n');\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "dfs and similar", "shortest paths", "dp", "data structures"], "code_uid": "d42a0c4bfdfac8edad612918957f3abd", "src_uid": "cedcc3cee864bf8684148df93804d029", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const {EOL} = require('os')\n \nlet input = ''\nprocess.stdin.on('data', s => input += s)\nprocess.stdin.on('end', () => {\n let [number, times] = input.split(\" \").map(element => parseInt(element));\n for(let i = 0; i < times; i++) {\n number = number % 10 == 0 ? number / 10 : number - 1;\n }\n console.log(number);\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "5aa43946495106b73fd47dfe86c90f3f", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main(input) {\n //Enter your code here\n let [target, counter] = input.split(' ');\n for(let i = 0; i {\n let temp=input.match(/B/g);\n // console.log(\"temp= \"+temp);\n if(/*temp.length == 8*/ input==\"BBBBBBBB\")\n ans++;\n else if(!met){\n if(temp!=null) \n ans+=temp.length;\n met=true;\n }\n \n }).on('close',function(){\n console.log(ans);\n });", "lang_cluster": "Javascript", "tags": ["brute force", "constructive algorithms"], "code_uid": "cced2b7dcb8bdcc86e67e28e98ea2c2c", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let i = ''\n\nfunction main(w) {\n // let dem = 0;\n // for(let i = 2; i <= w ; i++){\n // if(w % i == 0){\n // dem++;\n // }\n // };\n //\n // if(dem >= 2){\n // console.log(\"YES\");\n // }else {\n // console.log(\"NO\");\n // }\n if(w % 2 == 0 && w > 2){\n console.log(\"YES\");\n }else {\n console.log(\"NO\");\n }\n}\n// main(6);\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 w = line1Array[0]\n\n main(w);\n})\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "b4631c68ca8b8eedf206432ee5c38778", "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 \u201aThere 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().split(\"+\").map(Number);\n s.sort(function(a,b){\n \treturn a - b;\n });\n myout(s.join(\"+\"));\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "ead8d3c2a897ab11a879fb4bd4416119", "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});\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n const name = input[0];\n const set = new Set();\n for (let i = 0; i < name.length; i += 1) set.add(name[i]);\n\n console.log(\n set.size % 2 === 0 ? \n \"CHAT WITH HER!\" : \"IGNORE HIM!\"\n )\n});", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "11530f9801284609a0fdf3c505790f54", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n var m=Number(stdin[0]);\n var n=1;\n for(var i=1;i<=m;i++){\n n+=4*(i-1);\n }\n console.log(n);\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", "dp", "implementation"], "code_uid": "65597bf7c449a87590f99015bfd183c5", "src_uid": "758d342c1badde6d0b4db81285be780c", "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;\n const banknotes = [1, 5, 10, 20, 100];\n\n let min = 0;\n\n for (let i = banknotes.length - 1; i >= 0; --i) {\n min += Math.floor( n/ banknotes[i]);\n\n n -= Math.floor(n / banknotes[i]) * banknotes[i];\n }\n console.log( +min);\n \n\n \n});\n", "lang_cluster": "Javascript", "tags": ["greedy", "dp"], "code_uid": "033ca79605539c9ba6083df48060160a", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "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 = 1\n var n = lines[j]\n for(k = 1; k < n; k++){\n s += s + 1\n }\n console.log(s )\n }\n});\n ", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f4790c0e5cab37504290714437815b84", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict'\nconst readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin\n});\nvar MN= [], sum = 0, tt =0;\nrl.question('', (nb) => {\n MN = nb.split(' ');\n tt = MN[0]*MN[1];\n console.log(parseInt(tt/2));\n rl.close();\n});\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "470258857d086b62b43bb15672eb6801", "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 = \"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 , d ;\n res = 0 ;\n a = 9 ;\n b = 10 ;\n c = 1 ;\n d = 9 ;\n for( i = 1 ; i <= 11 ; i++ ) {\n if( this.n >= a ) {\n res += d * c ;\n }\n else {\n res += c * ( this.n - Math.floor( a / 10 ) ) ;\n break ;\n }\n a = ( a * 10 ) + 9 ;\n b = ( b * 10 ) ;\n c++ ;\n d = ( d * 10 ) ;\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 \tthis.n = 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": ["math", "implementation"], "code_uid": "9b6913b28747d058a61d0ef8eba0091e", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.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, m, a] = splitAndConvert(inputs[0]);\n const result = solve(n, m, a);\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, m, a) {\n return Math.ceil(n / a) * Math.ceil(m / a);\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "654fcf2b318057f8a84ccb2db3eedf1a", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// node template.js < A-small.in > A-small.out\n\nfunction main() {\n var tests = 1;\n tests = nextInt();\n\n for (let t = 1; t <= tests; t++) {\n let N = nextInt();\n\n let result = -1;\n for(let i = 2; i*i <= N; i++) {\n if (N % i === 0) {\n result = i;\n break;\n }\n }\n if (result !== -1) {\n let b = (result-1)*(N/result);\n let a = N-b;\n print(a + \" \" + b);\n } else {\n print(1 + \" \" + (N-1));\n }\n\n }\n}\n\n// ------- Template ------------------\nfunction newTensor(dimensions, value) {\n let res = [];\n let dim = dimensions[0], subdim = dimensions.slice(1);\n if (subdim.length == 0) {\n for(let i = 0; i < dim; i++) {\n res.push(value);\n }\n } else {\n for(let i = 0; i < dim; i++) {\n res.push(newTensor(subdim, value));\n }\n }\n return res;\n}\n\nif (!String.prototype.startsWith) {\n Object.defineProperty(String.prototype, 'startsWith', {\n value: function(search, rawPos) {\n var pos = rawPos > 0 ? rawPos|0 : 0;\n return this.substring(pos, pos + search.length) === search;\n }\n });\n}\nif (!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\nvar curTokens = [], curToken = 0;\n\nfunction next() {\n while (curToken >= curTokens.length) {\n curTokens = readline().split(/[\\s]+/);\n curToken = 0;\n }\n return curTokens[curToken++];\n}\n\nfunction nextInt() {\n return parseInt(next());\n}\n\n// code for nodejs\nvar inputBuffer = '', curLine = 0;\n\nfunction readline() {\n return inputBuffer[curLine++];\n}\n\nfunction print(data) {\n process.stdout.write(data + '\\n');\n}\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf8');\n\nprocess.stdin.on('data', function (chunk) {\n inputBuffer += chunk;\n});\n\nprocess.stdin.on('end', function () {\n inputBuffer = inputBuffer.split(/[\\s]+/);\n main();\n});", "lang_cluster": "Javascript", "tags": ["math", "greedy", "number theory"], "code_uid": "f1adf89ca1484881188cebcc96cdbc73", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "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 nt = readLine().split(' ');\n let n = parseInt(nt[0]);\n let t = parseInt(nt[1]);\n let queue = readLine().split('');\n for (var i = 0; i < t; i++) {\n for (var j = 0; j < queue.length; j++) {\n if (queue[j] == 'G' && queue[j - 1] == 'B') {\n queue[j] = 'B';\n queue[j - 1] = 'G';\n j++;\n }\n }\n }\n console.log(queue.join(''));\n\n}", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "7cafea4deff3ceee560f230719c09471", "src_uid": "964ed316c6e6715120039b0219cc653a", "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 [k,n,w]=readLine().split(\" \").map(n=>+n)\n\tlet price=0\n\tfor(let i=1;i<=w;i++)\n\t\tprice+=(i*k)\n\n\tprice<=n ? console.log(0) : console.log(price-n)\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "7263e88bc6929da5c6cacdd93fbf2856", "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\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 hoes = readLine()\n\t\t.split(' ')\n\t\t.map(x => x >> 0);\n\n\tlet counter = {};\n\tlet spend = 0;\n\tfor (let i = 0; i < 4; ++i) counter[hoes[i]] = (counter[hoes[i]] || 0) + 1;\n\n\tObject.entries(counter).forEach(([k, v]) => {\n\t\tspend += v - 1;\n\t});\n\tconsole.log(spend);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "6c790d39eb31a40236f141d0f3e5e95b", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict'\nconst readline = require('readline');\nconst rl = readline.createInterface({\n input: process.stdin\n});\nvar sec, fst, win = 0,\n arr = [],\n arr2 = [],\n i, n, k;\nrl.question('', (fst) => {\n rl.on('line', (sec) => {\n arr2 = fst.split(' ');\n n = Number(arr2[0]);\n k = Number(arr2[1]);\n arr = sec.split(' ');\n for (i = 0; i < k; i++) {\n if (arr[i] > 0) {\n win++;\n }\n }\n while ((arr[k - 1] === arr[k]) && (k < n) && (arr[k - 1] != 0)) {\n if (arr[k] > 0) {\n k++;\n win++;\n }\n }\n console.log(win);\n rl.close();\n });\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "8edfbaf927feca2bf6923c6b849acbf0", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "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 const first = data[0].toLowerCase();\n const second = data[1].toLowerCase();\n if (first === second) console.log(0);\n else if (first < second) console.log(-1);\n else console.log(1);\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "1423808d39b4a268032991ccee275a42", "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}\n\nfunction main() {\n let word = readLine();\n if (word.includes('H') || word.includes('Q') || word.includes('9')) {\n console.log('YES');\n } else {\n console.log('NO');\n }\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "318b5d507c39323986bf417baed15256", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "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 let [k, r] = input[0].split(' ').map(x => parseInt(x));\n let lastNum = k % 10;\n\n if (lastNum === r || lastNum === 0) {\n console.log(1);\n } else {\n let i = 1; let f = k;\n while (lastNum !== r && lastNum !== 0) {\n i += 1;\n f += k; lastNum = f % 10; \n }\n console.log(i);\n }\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "a5b3bc8a740a3415da868be0af8ef6bd", "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});\n\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": "246f44e3a98febddb6057ec4de4078ab", "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, a, b, c] = input[0].split(' ').map(x => parseInt(x));\n \n let max = 0;\n for (let i = 0; i <= 4000; i += 1) {\n for (let j = 0; j <= 4000; j += 1) {\n let ax = i*a, by = j*b;\n let z = (n - ax - by);\n\n if (z > 0 && z % c === 0) {\n z /= c;\n if (i + j + z > max) max = i + j + z;\n }\n if (ax + by === n) {\n if (i + j > max) max = i + j;\n }\n }\n }\n\n console.log(max);\n \n}); ", "lang_cluster": "Javascript", "tags": ["brute force", "dp"], "code_uid": "898456b66484b032bde1c64cbea903dc", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.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 readline() { 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 s = readline();\n let cur = s[0];\n let cnt = 1;\n let f = 0;\n for (let i = 1; i < s.length; ++i) {\n if (s[i] === cur) { cnt += 1; }\n else {\n cnt = 1;\n cur = s[i];\n }\n if (cnt >= 7) f = 1;\n }\n println(f ? \"YES\" : \"NO\");\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "cb573be0129679ec807af2872014a359", "src_uid": "ed9a763362abc6ed40356731f1036b38", "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 s = readLine();\n\n function isLowerCase(str) {\n return str == str.toLowerCase() && str != str.toUpperCase();\n }\n\n var lCount = 0,\n uCount = 0;\n\n for (var i = 0; i < s.length; i++) {\n if (isLowerCase(s[i])) {\n lCount++;\n } else {\n uCount++;\n }\n }\n\n var str = \"\";\n\n if (lCount > uCount || lCount == uCount) str = s.toLowerCase();\n\n if (lCount < uCount) str = s.toUpperCase();\n\n console.log(str);\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "ddc7f62b07ec5046f96b4c14c0cd410a", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "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 k = parseInt(readLine());\n let l = parseInt(readLine());\n let m = parseInt(readLine());\n let n = parseInt(readLine());\n let d = parseInt(readLine());\n\n let result = d;\n\n if (k === 1 || l === 1 || m === 1 || n === 1) {\n console.log(result);\n return;\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 result--;\n }\n }\n console.log(result);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "fea148d64902e903385651e88726757b", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var rl=require('readline');\nvar dd=rl.createInterface(process.stdin,process.stdout);\n\nvar s=[];\n\ndd.question('',function(x){\n \n s=x.split(' ').map(Number);\n dd.close();\n})\n\ndd.on('close',function () {\n console.log(Math.ceil(s[0]/s[2])*Math.ceil(s[1]/s[2]));\n process.exit();\n})\n\n\n\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "0c406b77dc97bec28268ac16bee2009f", "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\nasync function getNumbers() {\n\tlet str = '' \n\treturn new Promise((res,rej)=>{\n\t\trl\n\t\t.question(str,ans=>res(ans))\n\t})\n}\n\n\n\nfunction subtraction(n,k){\n\t\n\tif(k == 0)return n\n\n\tlet resedue = n%10\n\n\tif( resedue > 0 ){\n\t\t--n\n\t\t--k\n\t\treturn subtraction(n,k)\n\t}\n\telse{\n\t\t--k\n\t\treturn subtraction(n/10,k)\n\t}\n\n}\nasync function main() {\n\tlet nums = await getNumbers()\n\tnums = nums.trim().split(' ')\n\trl.close()\n\n\t\n\tconsole.log(subtraction(...nums))\n\t\n}\n\nmain()", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "00d7a22ff7eee0a2df3fdb9753d9c504", "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 str = readline();\n let upperCase = 0;\n let lowerCase = 0;\n for (let i = 0; i < str.length; i++) {\n if (str[i] === str[i].toUpperCase()) {\n upperCase++;\n }\n else {\n lowerCase++;\n }\n }\n\n if (upperCase > lowerCase)\n console.log(str.toUpperCase())\n else\n console.log(str.toLowerCase())\n\n\n return;\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "5785a52a48364a7f8fbceb36e0b4ed7a", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "#!/usr/bin/env nodejs\n\n// 4A - Watermelon\n\nfunction main(stdin) {\n const n = parseInt(stdin);\n console.log(n % 2 === 0 && n >= 4 ? \"YES\" : \"NO\");\n}\n\n\nmain(require(\"fs\").readFileSync(0, \"utf-8\"));\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "3c667c73dec708b3cc8a8dc344627724", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\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 solution(inputString[0], inputString[1]);\n});\n\nfunction solution(len, A) {\n var freqArr = {};\n var alphaBet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\".toLowerCase();\n var A = A.toLowerCase();\n for (let i = 0; i < A.length; i++) {\n if (!freqArr[A[i]])\n freqArr[A[i]] = 1;\n else {\n freqArr[A[i]]++;\n }\n }\n for (let i = 0; i < alphaBet.length; i++) {\n if (!freqArr[alphaBet[i]]) {\n console.log(\"NO\");\n return;\n }\n\n }\n console.log(\"YES\");\n return;\n}\n\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "3e99f13c7a4e939766990893d5311f91", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "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 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 answer = [];\n for(let i = 0; i < str.length; i += 1) {\n if (!bad.has(str[i])) {\n answer.push('.'); answer.push(str[i]);\n }\n }\n\n console.log(answer.join(''));\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "892ada86adb226e286b4c6b4d525774a", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main(input) {\n const lines = input.split(EOL);\n const line1 = lines[0].split(' ');\n let n = line1[0] * 1;\n let k = line1[1] * 1;\n \n while (k--) {\n if (n < 2) break;\n n % 10 === 0 ? n /= 10 : --n;\n }\n\n console.log(n);\n}\n\nconst { EOL } = require('os')\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"ascii\");\n_input = \"\";\nprocess.stdin.on(\"data\", (input) => _input += input);\nprocess.stdin.on(\"end\", () => main(_input));", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f3c0adf1824445d27953181d9dcdb2fb", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// https://codeforces.com/problemset/problem/50/A\n\nfunction main(stdin) {\n const [m, n] = stdin[0].split(' ').map(Number)\n process.stdout.write(Math.floor(m * n / 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": ["math", "greedy"], "code_uid": "fad174e417db9acdbda5a8c220399139", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const 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 lastDigitAsString = numberAsString[numberLength - 1];\n return parseInt(lastDigitAsString);\n}\n\nfunction removeLastDigit(number) {\n const { numberAsString, numberLength } = getNumberStringValues(number);\n return parseInt(numberAsString.slice(0, numberLength - 1));\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": "1379a1afa5c23523f2f6c0655af824c2", "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;\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 < arr.length; i++) {\n if (hand[0] === arr[i][0] || hand[1] === arr[i][1]) {\n can = true\n break\n }\n }\n if (can)\n console.log('YES')\n else\n console.log('NO')\n return 0;\n }\n l++\n})", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "287e1aa3453ad51ffb2c5184aa281efc", "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});\nlet counter = 0;\nlet S, T;\n\nrl.on('line', (d) => {\n if (counter === 0) {\n S = d;\n }\n else {\n T = d;\n\n let ans = 'YES';\n let j = 0;\n for (let i = T.length - 1; i >=0; i--) {\n if (T[i] !== S[j]) {\n ans = 'NO';\n break;\n }\n j++;\n }\n\n console.log(ans);\n }\n\n counter++;\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "902df35f6ba013e8ba5fde43ddc109b9", "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', (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 let prev = -1;\n\n for (let i = 0; i < arr.length; i++) {\n if (prev !== arr[i] && arr[i] !== 0) {\n ans++;\n prev = arr[i];\n }\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation"], "code_uid": "f728375c4c22ee03e44d16c364b022bc", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "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 console.log(25);\n});\n", "lang_cluster": "Javascript", "tags": ["number theory"], "code_uid": "e583322f289db9741340aaaf370700ac", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "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, k] = readLine()\n\t\t.split(' ')\n\t\t.map(x => x >> 0);\n\tlet arr = readLine()\n\t\t.split(' ')\n\t\t.map(x => x >> 0);\n\n\tif (arr[0] === 0) {\n\t\tconsole.log(0);\n\t\treturn;\n\t}\n\n\tlet score = 0;\n\n\tfor (let i = 0; i < n; i++) {\n\t\tif (arr[i] <= 0) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (i <= k - 1) {\n\t\t\tscore++;\n\t\t} else {\n\t\t\tif (arr[i] === arr[k - 1]) {\n\t\t\t\tscore++;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tconsole.log(score);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "b6d82814afbcc595bb017ea20a558540", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "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 console.log(4 - [...new Set(txt[i].split(/[ ]/))].length);\n\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "650f32278add7f5fb3486902ec4e3381", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "require('readline').createInterface({\n input: process.stdin,\n}).on('line', (line) => {\n const split = line.split(' ')\n let num = parseInt(split[0])\n const count = parseInt(split[1])\n for (let i = 0; i < count; i++) {\n if (num % 10 === 0) {\n num /= 10\n } else {\n num -= 1\n }\n }\n process.stdout.write(num + '\\n')\n})\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "5623685e58929b65d6b5eb9e98f4c7a6", "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 let str1 = readLine();\n let str2 = readLine();\n let [count1, count2] = [0, 0];\n const len = Math.max(str1.length, str2.length);\n str1 = str1.toLowerCase();\n str2 = str2.toLowerCase();\n\n if (str1 === str2) {\n console.log(0);\n return;\n }\n\n for (let i = 0; i < len; i++) {\n if (str1[i] !== str2[i]) {\n count1 = str1[i].charCodeAt(0);\n count2 = str2[i].charCodeAt(0);\n break;\n }\n }\n\n if (count1 < count2) console.log(-1);\n else console.log(1);\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "e4107572ac474ad5d2169292eaef8433", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const black = 'B';\nconst white = 'W';\n\nfunction is_row_all_black(row) {\n for (const sqr of row) {\n if (sqr === black) {\n // do nothing ...\n } else {\n return false;\n }\n }\n return true;\n}\n\nfunction is_column_all_black(rows, i) {\n for (const row of rows) {\n const sqr = row[i];\n if (sqr === black) {\n // do nothing ...\n } else {\n return false;\n }\n }\n return true;\n}\n\nfunction solve(rows) {\n let result = 0;\n for (const row of rows) {\n result = result + (is_row_all_black(row) ? 1 : 0);\n }\n if (result === rows.length) {\n // do nothing ...\n } else {\n for (let i = 0; i < rows.length; i = i + 1) {\n result = result + (is_column_all_black(rows, i) ? 1 : 0);\n }\n }\n return result;\n};\n\nfunction main(lines) {\n const rows = [];\n for (const line of lines) {\n const t = line.trim();\n if (t.length > 0) {\n rows.push(t);\n }\n }\n const result = solve(rows);\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", "constructive algorithms"], "code_uid": "35d8d4e8de40b3bbce5f84c2c296e474", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "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 let a = readLine();\n if (a.toUpperCase() === a) {\n console.log(a.toLowerCase());\n } else if (a[0].toLowerCase() + a.substring(1).toUpperCase() === a) {\n console.log(a[0].toUpperCase() + a.substring(1).toLowerCase());\n } else {\n console.log(a);\n }\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "244d422578d87b8a3c447d2d6a64b45e", "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 let [y, w] = d.split(' ').map(Number);\n let start = Math.max(y, w);\n let count = 0;\n\n for (let i = start; i <= 6; i++) {\n count++;\n }\n\n if (count === 1) {\n console.log('1/6');\n }\n else if (count === 6) {\n console.log('1/1');\n }\n else {\n if (count % 2 === 0) {\n console.log(`${count / 2}/3`);\n }\n else if (count % 3 === 0) {\n console.log(`${count / 3}/2`);\n }\n else {\n console.log(`${count}/6`);\n }\n }\n});\n", "lang_cluster": "Javascript", "tags": ["math", "probabilities"], "code_uid": "de636edad9a4e3bb308dd878d2e9a350", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function businessTrip(k, months) {\n // sort the array\n months = months.split(\" \");\n months = months.sort(function(a, b) {\n return b - a;\n });\n // itarate\n let count = 0;\n let sum = 0;\n for (let i = 0; i < months.length; i++) {\n if (k == 0) {\n return console.log(count);\n }\n if (k <= parseInt(months[i]) + parseInt(sum)) {\n count++;\n return console.log(count);\n } else {\n sum = parseInt(sum) + parseInt(months[i]);\n count++;\n }\n }\n\n return console.log(\"-1\");\n}\n\n// businessTrip(\"14\", \"0 0 0 0 0 0 0 1 1 2 3 0\");\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 businessTrip(arr[0], arr[1]);\n});\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "c84200b3b3e0aded6c05a49a30317530", "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\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 box = [];\n\tlet r = 3;\n\n\twhile (r--)\n\t\tbox.push(\n\t\t\treadLine()\n\t\t\t\t.split(' ')\n\t\t\t\t.map(x => x >> 0)\n\t\t);\n\n\tlet board = [Array(3).fill(1), Array(3).fill(1), Array(3).fill(1)];\n\n\tfor (let i = 0; i < 3; ++i) {\n\t\tfor (let j = 0; j < 3; ++j) {\n\t\t\t// If odd\n\t\t\tif ((box[i][j] & 1) === 1) {\n\t\t\t\tboard[i][j] = board[i][j] === 0 ? 1 : 0;\n\t\t\t\tif (i + 1 < 3) board[i + 1][j] = board[i + 1][j] === 0 ? 1 : 0;\n\t\t\t\tif (i - 1 >= 0) board[i - 1][j] = board[i - 1][j] === 0 ? 1 : 0;\n\t\t\t\tif (j + 1 < 3) board[i][j + 1] = board[i][j + 1] === 0 ? 1 : 0;\n\t\t\t\tif (j - 1 >= 0) board[i][j - 1] = board[i][j - 1] === 0 ? 1 : 0;\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (let i = 0; i < 3; ++i) {\n\t\tconsole.log(board[i].join(''));\n\t}\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "a4494b501b3858ac6eecca4ab1b7c261", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const fs = require('fs');\nconst text = fs.readFileSync(0, 'utf8');\nconst n = parseInt(text, 10);\nif (n & 1) {\n console.log(0);\n} else {\n console.log(Math.pow(2, n/2));\n}\n", "lang_cluster": "Javascript", "tags": ["math", "dp"], "code_uid": "c81ebf6c0136d9b7f946bda7499c6dd1", "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 = '';\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 s = readLine().toLowerCase();\n let arr = s.split('').reduce((a, item) => {\n if (a.indexOf(item) == -1) {\n a.push(item);\n }\n return a;\n }, []);\n if (arr.length == 26) console.log(\"YES\");\n else console.log(\"NO\");\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "1b5e37f0cca19f997988686ee7417408", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "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', stdin => inputString += stdin);\r\n\r\nprocess.stdin.on('end', _ => {\r\n inputString = inputString.trim().split('\\n').map(s => s.trim());\r\n main(); \r\n});\r\n\r\nfunction readline() {\r\n return inputString[currentLine++];\r\n}\r\n\r\nfunction output(x) {\r\n if (typeof x !== 'string') {\r\n x = x.toString();\r\n }\r\n //process.stdout.write(x); // without auto '\\n' (newline)\r\n console.log(x); // with auto '\\n' (newline)\r\n}\r\n\r\nfunction main() {\r\n let N = readline();\r\n\r\n for (let test = 0; test < N; test++) {\r\n let n = parseInt(readline(), 10);\r\n output( 2 ** n - 1 );\r\n }\r\n}\r\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3552148136fe65e29fe7eea3baa13a57", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.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 firstWord = inputs[0].toLowerCase();\n let secondWord = inputs[1].toLowerCase();\n\n if (firstWord < secondWord)\n console.log(-1)\n else if (firstWord > secondWord)\n console.log(1)\n else\n console.log(0)\n\n})\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "49924b67ecf3495febcfac36e3de7c0e", "src_uid": "ffeae332696a901813677bd1033cf01e", "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, m, a] = splitAndConvert(inputLines[0], 3);\n const result = solve(n, m, a);\n console.log(result);\n});\n\nfunction splitAndConvert(stringOfNumbers, numOfValid) {\n\treturn stringOfNumbers.split(' ').slice(0, numOfValid).map(function(num) {\n\t\treturn parseInt(num);\n\t});\n}\n\nfunction solve(n, m, a) {\n return Math.ceil(n/a) * Math.ceil(m/a);\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "046cf6f0a9fc82839c795bf39939138c", "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 mat = [];\n \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": "1d15fd1f8decb28a6f3a65b39948e45f", "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.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 t = readLine();\n if (s == t.split('').reverse().join('')) {\n console.log('YES')\n } else console.log('NO')\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "07fa04499a0aafb4a436db3fbba400e0", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//'use strict';\nprocess.stdin.resume();\nprocess.stdin.setEncoding(\"utf-8\");\n\nlet currentLine = 0;\nlet i = '';\nprocess.stdin.on('data', c => {\n i += c;\n});\nprocess.stdin.on('end', () => {\n const { EOL } = require('os');\n i = i.trim()\n .split(' ' || EOL)\n .map(string => {\n return string.trim();\n });\n main();\n});\n\nfunction readLine() {\n return i[currentLine++];\n}\nfunction main() {\n var x = readLine();\n var res = Math.floor(x / 5);\n if (x % 5 == 0) {\n console.log(res);\n }\n else console.log(res + 1);\n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "2bb0f3e475b06c3513290b6ebcc48080", "src_uid": "4b3d65b1b593829e92c852be213922b6", "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, k, l, c, d, p, nl, np] = input[0].split(' ').map(x => parseInt(x));\n let botl = parseInt((k * l) / nl);\n let lim = c*d; let s = parseInt(p / np);\n\n console.log( parseInt(Math.min(botl, lim, s) / n) );\n});", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "432b53d1e5126c6c52a67950f1855858", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "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 = readLine() >> 0;\n\tconst s = readLine().split('');\n\n\tlet current = s[0];\n\tlet deleteCount = 0;\n\n\tfor (let i = 1; i < n; i++) {\n\t\tif (s[i] === current) {\n\t\t\tdeleteCount++;\n\t\t} else {\n\t\t\tcurrent = s[i];\n\t\t}\n\t}\n\n\tconsole.log(deleteCount);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "b533d719e95cfc065a7f50c1947e08d5", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const { EOL } = require('os');\n\nfunction 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\nlet data = '';\nprocess.stdin.on('data', c => data += c);\nprocess.stdin.on('end', () => {\n const res = findGreeting(data.split(EOL)[0]);\n console.log(res);\n});\n", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "5037b772020d7b532fda617d3092e0a6", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.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 F = N>0?true:false;\n for(var i = 1;i<=Math.abs(N);i++){\n if(F){\n P += 1;\n P = P<=L?P:1;\n }else{\n P -= 1;\n P = P>0?P:L;\n }\n }\n console.log(P);\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": "7a56f82048dee763fb17b2c3c1a048c9", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "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});\nrl.question(\"\", loop =>{\n getUserInput(loop);\n})\n\n\nfunction totalPressedDigit(number){\n let digit = number[0];\n let length = number.length;\n console.log( (digit-1) * 10 + length*(length+1)/2);\n}\n\nfunction getUserInput(n) {\n rl.question('', (number) => {\n totalPressedDigit(number)\n if (n > 1) {\n getUserInput(n-1);\n } else {\n rl.close();\n }\n }); \n}\n\nrl.on(\"close\", function() {\n process.exit(0);\n});", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "8b548ff8cd25c4371cee1fac378769ea", "src_uid": "289a55128be89bb86a002d218d31b57f", "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 this.brr = [] ;\n for( i = 1 ; i < this.n ; i++ ) {\n this.brr.push( this.arr[ i ] ) ;\n }\n this.brr = this.brr.sort( function( left , right ) {\n return right - left ;\n } ) ;\n a = this.arr[ 0 ] ;\n while( true ) {\n if( this.brr[ 0 ] < res + a ) {\n break ;\n }\n this.brr[ 0 ]-- ;\n res++ ;\n this.brr = this.brr.sort( function( left , right ) {\n return right - left ;\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 \tthis.n = 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 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": ["greedy", "implementation"], "code_uid": "ff810e4de01e80e99cf07fb31b28e859", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58", "difficulty": 1200.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 [data, results] = i.split(EOL).map((x) => {return x.split(\" \").map((y) => { return parseInt(y)})})\n \n if (!(Math.max(...results) < results[data[1] - 1])){\n console.log(results.filter(i => (i > 0) && !(i < results[data[1] - 1])).length);\n } else {console.log(0)}\n \n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "10c260f7b0b4505f5899e6202ecf1013", "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\n\nrl.question('', (tableCard) => {\n rl.question('', (handCards) => {\n isAllowed(tableCard, handCards) ? console.log('YES') : console.log('NO');\n rl.close()\n });\n});\n\nrl.on(\"close\", () => {\n process.exit(0);\n});\n\n\nfunction isAllowed(tableCard, handCards) {\n\n const handCardsArray = handCards.split(' ');\n\n for (let index = 0; index < handCardsArray.length; index++) {\n\n if (handCardsArray[index].charAt(0) == tableCard.charAt(0)) {\n return true;\n }\n else if (handCardsArray[index].charAt(1) == tableCard.charAt(1)) {\n return true;\n }\n };\n return false;\n};\n\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "d09aad9a59f085716eda304b29074d99", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function businessTrip(k, months) {\n // sort the array\n months = months.split(\" \");\n months = months.sort(function(a, b) {\n return b - a;\n });\n // itarate\n for (let i = 0; i < months.length; i++) {\n let sumOfFirsNLement = months\n .slice(0, i + 1)\n .reduce((startPoint, current) => {\n return parseInt(startPoint) + parseInt(current);\n });\n if (k == 0) return console.log(0);\n if (parseInt(sumOfFirsNLement) >= parseInt(k)) return console.log(i + 1);\n }\n return console.log(\"-1\");\n}\n\n// let sum = [1, 2, 3];\n\n// console.log(sum);\n\n// businessTrip(\"5\", \"0 0 0 0 0 0 0 1 1 2 3 0\");\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 businessTrip(arr[0], arr[1]);\n});\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "a5da7d2948cd7e9d6786331b0172109e", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// NYAN NYAN\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2584\u2591\u2591\u2591\u2591\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2584\u2584\u2591\u2591\u2584\u2591\u2591\u2591\u2588\u2591\u2584\u2584\u2584\u2591\u2591\u2591\n// \u2591\u2584\u2584\u2584\u2584\u2584\u2591\u2591\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2580\u2588\u2591\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2580\u2580\u2591\u2588\u2588\u2591\u2591\n// \u2591\u2588\u2588\u2584\u2580\u2588\u2588\u2584\u2588\u2591\u2591\u2591\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2580\u2580\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\n// \u2591\u2591\u2580\u2588\u2588\u2584\u2580\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2588\u2588\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2588\u2588\u2591\n// \u2591\u2591\u2591\u2591\u2580\u2588\u2588\u2588\u2588\u2591\u2580\u2591\u2591\u2591\u2591\u2584\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2584\u2588\u2591\u2591\u2591\u2591\u2584\u2591\u2584\u2588\u2591\u2591\u2588\u2588\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2588\u2591\u2591\u2591\u2591\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2584\u2591\u2591\u2591\u2584\u2591\u2591\u2584\u2591\u2591\u2591\u2588\u2588\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2591\u2591\u2584\u2580\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2580\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2580\u2591\u2591\u2588\u2588\u2588\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2588\u2588\u2588\u2591\u2591\u2580\u2588\u2588\u2580\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\n// \ubc31\uc900\uc758 \ub178\ub4dc \ubc84\uc804\uc774 \ub108\ubb34 \ub0ae\uc544 babel \uc0ac\uc6a9. \n// \ud480\uc774\ub294 solve() \ud568\uc218\uc5d0 \uc788\uc74c.\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) { //\ubd84\ud560 \uc815\ubcf5\uc744 \uc774\uc6a9\ud558\uc5ec x^y \uad6c\ud558\uae30\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// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591 MAIN SOLVE FUNCTION \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\nfunction numericSortList(list){\n list.sort((a,b)=>a-b);\n}\n\nfunction solve(){\n const [n, k] = readInts();\n\n var ans = [0,0,0];\n\n var r = n * 2;\n var g = n * 5;\n var b = b * 8;\n\n var rn = k * ans[0]; // k * ans[0] > n * 2\n var gn = k * ans[1];\n var bn = k * ans[2];\n\n ans[0] = Math.ceil(n * 2 / k);\n ans[1] = Math.ceil(n * 5 / k);\n ans[2] = Math.ceil(n * 8 / k);\n it(ans);\n print(ans.reduce((a,b)=>a+b));\n}\n\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\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"], "code_uid": "2ef6d237bf602ae1e085d9e9fd1617a9", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main(stdin) {\n const horseshoes = stdin.split(\" \").map(v => parseInt(v));\n console.log(horseshoes.sort().reduce((ac, val, i, arr) => arr[i - 1] === val ? ac + 1 : ac, 0));\n}\n\nmain(\n require(\"fs\")\n .readFileSync(0, \"utf-8\")\n .trim()\n);\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "d626146316cfa73258c86422031daf35", "src_uid": "38c4864937e57b35d3cce272f655e20f", "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 \u201aThere 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 for(var i = 0; i < s.length - 2; i++){\n \tif(s[i] == \"Q\"){\n \t\tfor(var j = i + 1; j < s.length - 1; j++){\n \t\t\tif(s[j] == \"A\"){\n \t\t\t\tfor(var k = j + 1; k < s.length; k++){\n \t\t\t\t\tif(s[k] == \"Q\"){\n \t\t\t\t\t\toutput++;\n \t\t\t\t\t}\n \t\t\t\t}\n \t\t\t}\n \t\t}\n \t}\n }\n myout(output);\n}", "lang_cluster": "Javascript", "tags": ["brute force", "dp"], "code_uid": "0616a4efcb4a575986098151b60ecd25", "src_uid": "8aef4947322438664bd8610632fe0947", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function solve(n, k){\n for(var i=0; i {\n main(w);\n rl.close();\n});\n\nfunction main(watermelon) {\n watermelon = parseInt(watermelon);\n let numbersPar = fragWatermelon(watermelon);\n let totalNumbers = numbersPar.length;\n if (numbersPar.length >= 1 && (numbersPar[0] + numbersPar[totalNumbers-1]) === watermelon){\n console.log('YES')\n } else {\n console.log('NO')\n }\n}\n\nfunction fragWatermelon(watermelon) {\n let numbersPar = [];\n for(let i = 1; i < watermelon; i++){\n if ((i%2) === 0){\n numbersPar.push(i)\n }\n }\n return numbersPar;\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "acb04e32924e8b79b186821cdd757681", "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 let n = input[0].split(' ').map(function (a) { return parseInt(a); });\n let result = solution(n[0], n[1]);\n console.log(result);\n});\n\n// End of interface\n\n\nconst solution = function(a, b){\n\tlet i = 0;\n\twhile (a <= b) {\n\t\ta = a * 3; \n\t\tb = b * 2; \n\t\ti++;\n\t}\n\treturn i;\n};", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "fd2b653fa2972b202adf30015cca3a67", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function solve() {\n let input = readline().split(' ').map(Number),\n n = input[0],\n k = input[1];\n for (;k--;) {\n if (n % 10) {\n n--;\n } else {\n n /= 10;\n }\n }\n print(n);\n}\n\nif (typeof readline !== 'function') {\n let input = [],\n i = 0;\n function print() {\n console.log.apply(null, arguments);\n }\n function readline() {\n return input[i++];\n };\n\n const RL = require('readline').createInterface({\n input : process.stdin,\n output : process.stdout\n });\n \n RL.on('line', (line) => {\n input.push(line);\n });\n \n RL.on('close', solve);\n} else {\n solve();\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f0879583eec8745c397ba728c469ed8e", "src_uid": "064162604284ce252b88050b4174ba55", "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(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": "64fcd6d1697b2fd1415dfc146fefc223", "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 const n = +d;\n\n if (n === 2) {\n console.log(2);\n }\n else {\n console.log(1);\n }\n});\n", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms"], "code_uid": "9d4a4188041d8600148f7a03fecba133", "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d", "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 mat = [];\nlet result;\n\nintInput.on('line', (line) => {\n\tmat.push(line.split(\" \"))\n});\nintInput.on('close', () => {\n\tlet iOne, jOne;\n\touter: for (let i = 0; i < mat.length; i++) {\n\t\tlet row = mat[i];\n\t\tinner: for (let j = 0; j < row.length; j++) {\n\t\t\tif (Number(row[j]) == 1) {\n\t\t\t\tiOne = i;\n\t\t\t\tjOne = j;\n\t\t\t\tbreak inner;\n\t\t\t\tbreak outer\n\t\t\t}\n\t\t}\n\t}\n\tresult = Math.abs(iOne - 2);\n\tresult += Math.abs(jOne - 2)\n\tconsole.log(result);\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "8a9ec464c2e019202a0f68eef8fd33a1", "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 [n] = input[0].split(' ').map(x => parseInt(x));\n\n if (n % 2 === 0) console.log('Mahmoud');\n else console.log('Ehab');\n}); ", "lang_cluster": "Javascript", "tags": ["math", "games"], "code_uid": "4b6c580465889e5831bcc51f83a5f725", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "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 .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 testCases = readline();\n // let isPalindrome = true;\n\n for (let i = 0; i < testCases; i++) {\n let n = Number(readline());\n console.log(2 ** n - 1);\n // console.log(Number(n) - 1);\n }\n // return isPalindrome ? k : 2 * k;\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "eff9274f24561af09867d468989265bb", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.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// 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 (chars.indexOf(char1) > chars.indexOf(char2))\n return console.log(1);\n else if (chars.indexOf(char1) < chars.indexOf(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": "8769c5f2680273a0b434479679c9882e", "src_uid": "ffeae332696a901813677bd1033cf01e", "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 output(x) {\r\n if (typeof x !== 'string') {\r\n x = x.toString();\r\n }\r\n //process.stdout.write(x); // without auto '\\n' (newline)\r\n console.log(x); // with auto '\\n' (newline)\r\n}\r\n\r\nfunction main() {\r\n let N = readline();\r\n\r\n for (let test = 0; test < N; test++) {\r\n let f = readline().split(' ').map(Number);\r\n let s = readline().split(' ').map(Number);\r\n\r\n let result = 2;\r\n if (f[0] === 0 && f[1] === 0 && s[0] === 0 && s[1] === 0) {\r\n result = 0;\r\n } else if (f[0] + f[1] + s[0] + s[1] === 4) {\r\n result = 2;\r\n } else {\r\n result = 1;\r\n }\r\n\r\n output(result);\r\n }\r\n}\r\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "80bf0e055db432850d8d2a01a1a0f111", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "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\nconst lines = [];\nasync function work(line, lineNr) {\n lines.push(line);\n if (lines.length === 8) {\n const solutionForLine = await solve(lines);\n const responseLine = `${solutionForLine}\\n`;\n process.stdout.write(responseLine);\n }\n}\n\n/**\n * \n * Solution goes below\n * \n */\nfunction solve(input) {\n const arr = input.map(row => row.trim().split(''));\n let counter = 0;\n const row = arr.find(r => r.some(i => i === 'W'));\n // console.log(row);\n if (row) row.forEach(i => i === 'B' && counter++);\n // console.log(counter);\n counter += arr.filter(row => row.every(i => i === 'B')).length;\n // console.log(arr);\n // console.log(arr.filter(row => row.every(i => i === 'B')))\n return counter;\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "constructive algorithms"], "code_uid": "b550d567ac25b7b80f6b9282fa0e2532", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "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});\nlet word;\nlet currentChar = \"a\".charCodeAt(0)\nlet rotations = 0;\n\nrl.on(\"line\", (input) => {\n if (!word) {\n word = input.split(\" \").toString();\n // console.log(word.charCodeAt(0), currentChar)\n }\n if (word) {\n for (let index = 0; index < word.length; index++) {\n // if (word.charCodeAt(index) == currentChar) {\n // rotations += 0\n // continue;\n // }\n let temp = Math.abs((word.charCodeAt(index) - currentChar))\n // console.log(\"Temp=>\", temp, \"CurrentChar =>\", currentChar, \"\\n\")\n if (temp > 13) {\n rotations += (25 - (temp - 1))\n currentChar = word.charCodeAt(index)\n }\n if (temp <= 13) {\n currentChar = word.charCodeAt(index)\n rotations += temp\n }\n\n }\n console.log(rotations)\n rl.close();\n\n\n }\n})", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "4135dfda43d74b94efbf189b79d824e8", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "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 = Number(input[0]);\n const left = [], right = [];\n for (let i = 1; i <= n; i++) {\n let [l, r] = input[i].split(' ');\n left.push(l); right.push(r);\n }\n let c = 0;\n for (let i = 0; i < left.length; i++) {\n for (let j = 0; j < right.length; j++) {\n if (j === i) continue;\n if (left[i] === right[j]) c++;\n }\n }\n console.log(c);\n});", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "85e16288bf9ca9f9912727a3f379ba3f", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline');\n\nconst rl = readline.createInterface({input: process.stdin, output:process.stdout});\n\nlet x = 0\nlet y = 0\n\nrl.question('',data=>{\n let data_found = data.split(\" \");\n x = parseInt(data_found[0]);\n y = parseInt(data_found[1]);\n\n let count = 1;\n\n for(var i = 0;true;i++)\n {\n x = x * 3;\n y = y * 2;\n\n if(x > y)\n {\n console.log(count);\n return;\n }\n else\n {\n count++;\n }\n }\n \n})\n\n\n\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "069ff1a10677e7ac29d0e4706413e9ea", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\nconst readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar isPrime = function (n) {\n if (n === 2)\n return true;\n if (n % 2 === 0) return false;\n let limit = parseInt(Math.sqrt(n));\n for (let i = 3; i <= limit; i += 2) {\n if (n % i === 0)\n return false;\n }\n return true;\n}\n\n\nvar hasExactlyTwoPrimeDivs = function (n) {\n let counter = 0, limit = parseInt(n / 2);\n for (let i = 2; i <= limit; i++)\n counter += (n % i == 0 && isPrime(i));\n\n return counter == 2;\n}\n\n\n\nrl.on('line', function (input) {\n let n = parseInt(input), ans = 0;\n for (let i = 6; i <= n; i++)\n ans += hasExactlyTwoPrimeDivs(i);\n console.log(ans);\n rl.close();\n\n});", "lang_cluster": "Javascript", "tags": ["number theory"], "code_uid": "30b79bb0a3931c21d155a030c49c2ece", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "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 nums = readLine().split(' ').map(Number);\n let [studentNums, seconds] = nums;\n let studentOrder = readLine().split('');\n for (let i = 0; i < seconds; i++) {\n for (let j = 0; j < studentNums - 1; j++) {\n if (studentOrder[j] === 'B' && studentOrder[j + 1] === 'G') {\n studentOrder[j] = 'G';\n studentOrder[j + 1] = 'B';\n j++;\n }\n }\n }\n console.log(studentOrder.join(''));\n}\n", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "8282be7f660248d7fda17d2612b5b80a", "src_uid": "964ed316c6e6715120039b0219cc653a", "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, m] = rns();\r\n let pre = 1,\r\n M = mod(m),\r\n res = 0,\r\n ans = M,\r\n ans1 = M;\r\n const p = getPrimes(n + 10);\r\n for (let i = 2; i <= n; i++) {\r\n if (pre <= m && p[i]) pre = pre * i;\r\n if (pre > m) {\r\n ans = 0;\r\n } else {\r\n ans = mul(ans, Math.floor(m / pre));\r\n }\r\n ans1 = mul(ans1, M);\r\n res = mod(res + ans1 - ans);\r\n }\r\n return res;\r\n}\r\nfunction getPrimes(n) {\r\n const nums = new Array(n + 1).fill(1);\r\n nums[0] = nums[1] = 0;\r\n const primes = [];\r\n for (let i = 2; i <= n; i++) {\r\n if (nums[i]) primes.push(i);\r\n for (let j = 0; primes[j] <= n / i; j++) {\r\n nums[primes[j] * i] = 0;\r\n if (i % primes[j] === 0) break;\r\n }\r\n }\r\n return nums;\r\n}\r\nconst MOD = 998244353;\r\nfunction mod(num) {\r\n if (num >= MOD) return num % MOD;else if (num < 0) return (num % MOD + MOD) % MOD;\r\n return num;\r\n}\r\nfunction mul(...args) {\r\n if (args.length === 0) throw new Error('\u53c2\u6570\u4e0d\u80fd\u4e3a\u7a7a');\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 = () => read().split(/\\s+/).map(Number);\r\n const re = () => read().split(/\\s+/).map(s => Number(s) - 1);\r\n const rbs = () => read().split(/\\s+/).map(BigInt);\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 = 0;\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) ; else {\r\n res[i] = s;\r\n }\r\n }\r\n if (t >= limit) {\r\n return res.join('\\n');\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(/\\r?\\n/);\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", "dp", "combinatorics", "number theory"], "code_uid": "2f314d0cbd1aa5a967af96169a2d14e9", "src_uid": "0fdd91ed33431848614075ebe9d2ee68", "difficulty": 1900.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 [k, n, w] = readLine().split(\" \").map(Number);\n\n var totalPrice = 0;\n\n for (var i = 1; i <= w; i++) {\n totalPrice += k * i;\n }\n var borrow = totalPrice - n;\n if (borrow > 0) {\n console.log(borrow);\n } else {\n console.log(0);\n }\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "11f035fbe4863a52ddbd0da79e348f09", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n const n = +stdin[0];\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": "16835f957f8a26e39000d5c28effd2db", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "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', n => {\n const a = Array.from(n).filter(letter => letter === 'a').length;\n console.log((a > (n.length / 2)) ? n.length : (a + (a - 1)));\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "257d1b512cff12600ee4ec59d3ed36f5", "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', (d) => {\n const arr = d.split(' ').map(Number);\n let point = Infinity;\n\n for (let i = 0; i <= 2; i++) {\n if (point + i > arr[i]) {\n point = arr[i] - i;\n }\n }\n\n console.log(point * 3 + 3);\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "b98874cf1a38d8928340b4fdad1e0661", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Nothing special here, just self-made reading api\nclass Reader{constructor(a,b){this.stream=a,this.stream.setEncoding(\"utf8\"),this.bufSize=b||1024,this.buf=\"\",this.streamEnded=!1}onReadable(a){return()=>{for(let b;-1===(b=this.buf.indexOf(\"\\n\"));){if(0===this.stream.readableLength)return this.stream.read(),void this.stream.once(\"readable\",this.onReadable(a));this.buf+=this.stream.read(Math.min(this.bufSize,this.stream.readableLength))}this.stream.removeAllListeners(\"end\"),this.readline().then(a)}}onEnd(a){return()=>{this.streamEnded=!0,this.readline().then(a)}}readline(){return new Promise(a=>{const b=this.buf.indexOf(\"\\n\");if(-1===b&&!this.streamEnded)this.stream.once(\"readable\",this.onReadable(a)),this.stream.once(\"end\",this.onEnd(a));else{let c;this.streamEnded?(c=this.buf,this.buf=\"\"):(c=this.buf.substring(0,b),this.buf=this.buf.substring(b+1)),a(c)}})}}(async()=>{const a=new Reader(process.stdin);await solution(a.readline.bind(a),console.log.bind(this))})();\n\nasync function solution(rl, wl) {\n let [n, k] = (await rl()).split(' ').map(Number);\n\n for(let i = 0; i < k; i++) {\n n = n % 10 === 0 ? n / 10 : n - 1;\n }\n\n wl(n);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "4866bc09bb730dc35a4f99befb7cdb76", "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 = [];\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 const square = splitAndParseInt(input[0])\n console.log(Math.floor((square[0]*square[1])/2))\n});", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "bb64d9958606566723af3c542a5a9cf3", "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\nreadLine.on('close', () => {\n const x = parseInt(input[0]);\n\n console.log( Math.ceil(x/5) );\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "3b9c7043b0c2545cae82e238014746ad", "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});\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 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": "ab5980a0df7d6f1d1dee99c1d119e8ae", "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 exp = readLine().split('+').sort().join('+');\n\tconsole.log(exp);\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "2d8faaeae13e6813421cc7276a3ac36c", "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\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\u2191\u5165\u529b \u2193\u51fa\u529b');\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 \u201aThere 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 L = one[0];\n\tvar R = one[1];\n\tvar C = one[2];\n\tif(Math.abs(L - R) >= C){\n\t\tmyout((Math.min(Math.max(L, R), Math.min(L, R) + C)) * 2);\n\t}else{\n\t\tvar diff = Math.abs(L - R);\n\t\tif(L > R){\n\t\t\tR += diff;\n\t\t}else{\n\t\t\tL += diff;\n\t\t}\n\t\tC -= diff;\n\t\tmyout((Math.floor(C / 2) + L) * 2);\n\t}\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "8eaf0f0c76b1d17a211a4f810d93d188", "src_uid": "e8148140e61baffd0878376ac5f3857c", "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 l = 0;\nvar r = 0;\nrl.on(\"line\", function(line){\n l++;\n if(line.indexOf(\"1\") != -1){ \n r = Math.abs(l-3) + Math.abs(line.split(\" \").indexOf('1') - 2);\n }\n if (l == 5) {\n console.log(r);\n process.exit(0);\n }\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3af55ecf5dad353118df4e44a1ee8b3d", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "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('', (usrIn) => {\n [ lim, bob] = usrIn.split(' ');\n lim = parseInt(lim);\n bob = parseInt(bob);\n let count = 0\n while(true) {\n if(lim <= bob) {\n lim *= 3;\n bob *=2;\n count++;\n } else {\n break;\n }\n }\n console.log(count);\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "ee02d59ff75f9be71f7f697eb92193c1", "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\nreadline.on('line', input => {\n let n = input;\n const seq = ['Sheldon', 'Leonard', 'Penny', 'Rajesh', 'Howard'];\n\n while (n > 5) {\n n = Math.floor(n / 2) - 2;\n }\n\n console.log(seq[n - 1]);\n});", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "7d89551b9f636d77eeca9ee5bc2351f1", "src_uid": "023b169765e81d896cdc1184e5a82b22", "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\nlet end = 0;\nrl.on('line', (input) => {\n x = input.split(' ').map((item) => {return parseInt(item)});\n while (x[1] > 0){\n let lastDigit = x[0]%10;\n if (lastDigit != 0)x[0]--;\n if (lastDigit == 0)x[0]= parseInt(x[0] / 10);\n x[1]--;\n }\n console.log(x[0]);\n rl.close();\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "d1998a767d3105431ae0ea30b5661252", "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 arr = arr.split('\\n')\n const n = parseInt(arr[0])\n const a = arr[1]\n const map = {}\n for(let i = 1; i < n; i ++) {\n var key = a[i - 1] + a[i]\n if(!map[key]) map[key] = 1\n else map[key] = map[key] + 1\n }\n\n var max = 0\n var maxK = ''\n for(let i in map) {\n if(map[i] > max) {\n max = map[i]\n maxK = i\n }\n }\n console.log(maxK)\n\n})", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "63e6f609dba192625a4acf12931b415e", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "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=>{return data.length>0})\n\n\ntxt.forEach(element => {\n football(element)\n});\n\nfunction football(str){\n let tab=str.split(\"+\").filter(data=>{return data.length>0}).map(data=>{return data*1}).sort((a,b)=>{return a-b}).join(\"+\")\n console.log(tab);\n}", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "3133919722a6792bd140eead5ceb3cf7", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "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 findTheTotalPlacedDominoes(readline());\n}\n\nfunction findTheTotalPlacedDominoes(matrix) {\n \n const matrixArr = matrix.split(' ');\n \n const canvasX = matrixArr[0];\n const canvasY = matrixArr[1];\n \n const result = Math.floor(canvasX * canvasY / 2);\n \n process.stdout.write(result.toString());\n\n}\n\n\n\n\n\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "8a09fc1ccd3644b414893d825d4752ab", "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});\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": "3ccfe8acd96df1f6c325f04ea2b523e4", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "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 n = parseInt(readLine());\n if (n % 2 === 0) {\n console.log(n / 2)\n } else if (n % 2 !== 0) {\n console.log((-(n + 1) )/ 2)\n }\n}\n\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "810d525d690c596ab7a814e9553a2b3e", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function pagesPrinter (string) {\n let [n, p, k] = string.split(' ');\n n = parseInt(n)\n p = parseInt(p)\n k = parseInt(k)\n let result = [];\n if ((p - k) > 1) result.push('<<');\n\n for (let i = (p - k); i < p; i++) {\n if (i >= 1) result.push(i);\n }\n\n result.push('(' + p + ')');\n\n for (let i = (p + 1); i <= (p + k); i++) {\n if (i <= n) result.push(i);\n }\n\n if ((p + k) < n) result.push('>>');\n\n return result.join(' ');\n}\n\nvar 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(pagesPrinter(line));\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "8355b97f6408e42b8c557ac2c3e90b91", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null, "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 \nfunction solution(input){\n if(input === \"2\"){\n return \"NO\"\n }\n return input % 2 === 0 ? \"YES\" : \"NO\"\n}\n \nrl.on('line', function(line){\n console.log(solution(line))\n})", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "37f6e7ec40f38447ad5322ae7d3abb5c", "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\nrl.on('line', line => {\n const [a, b] = line.split(' ').map(v => parseInt(v, 10))\n solve(a, b)\n})\n\nfunction solve(a, b) {\n if (a == b) { console.log(0); return; }\n\n const m = {}\n if (b > a) {\n const t = a; a = b; b = t;\n }\n const ma = { [a]: 0 }\n const mb = { [b]: 0 }\n\n const qa = [[a, 0]]\n const qb = [[b, 0]]\n\n let min = Infinity;\n while (true) {\n if (qa.length) {\n const [aa, sa] = qa.shift()\n\n for (const d of [2,3,5]) {\n if (aa%d == 0) {\n const r = aa/d\n if (mb[r] != undefined) { min = Math.min(mb[r]+sa+1, min); } \n if (!ma[r]) { qa.push([r, sa+1]) }\n ma[r] = ma[r] || (sa+1); \n }\n }\n }\n\n if (qb.length) {\n\n const [bb, sb] = qb.shift()\n for (const d of [2,3,5]) {\n if (bb%d == 0) {\n const r = bb/d\n if (ma[r] != undefined) { min = Math.min(ma[r]+sb+1, min); }\n if (!mb[r]) { qb.push([r, sb+1]) }\n mb[r] = mb[r] || (sb+1);\n }\n }\n }\n\n if (isFinite(min)) { console.log(min); return; }\n\n if (!qa.length && !qb.length) { console.log(-1); return; }\n\n }\n}\n\n", "lang_cluster": "Javascript", "tags": ["math", "number theory"], "code_uid": "26b3c8f6596cce58b2fddb47ef2c5863", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49", "difficulty": 1300.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 output(x) {\r\n if (typeof x !== 'string') {\r\n x = x.toString();\r\n }\r\n //process.stdout.write(x); // without auto '\\n' (newline)\r\n console.log(x); // with auto '\\n' (newline)\r\n}\r\n\r\nfunction main() {\r\n let N = readline();\r\n\r\n for (let test = 0; test < N; test++) {\r\n let x = Number(readline());\r\n let arr = readline().split(' ').map(Number);\r\n\r\n let result = 'YES';\r\n\r\n let first = arr[x - 1];\r\n let second = first ? arr[first - 1] : 0;\r\n\r\n if (first === 0) {\r\n result = 'NO';\r\n } else if (second === 0) {\r\n result = 'NO';\r\n }\r\n\r\n output(result);\r\n }\r\n}\r\n", "lang_cluster": "Javascript", "tags": ["brute force", "greedy", "implementation", "math"], "code_uid": "b28eaee69c1ce648187a89fef0e6b749", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "/**\n * Problem - http://codeforces.com/contest/989/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 process.stdout.write(doAppearInSomeCell(input))\n process.exit()\n}\n\nfunction doAppearInSomeCell(input) {\n if (input.length < 3) {\n return 'No'\n }\n\n let set = ['ABC', 'ACB', 'BAC', 'BCA', 'CAB', 'CBA']\n\n for (let i = 0 ; i < input.length ; i++) {\n let k = input.substring(i, i + 3)\n if (k.length === 3 && set.indexOf(k) !== -1) {\n return 'Yes'\n }\n }\n\n return 'No'\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "6c8400e57c449c07ef1429e3faa80564", "src_uid": "ba6ff507384570152118e2ab322dd11f", "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// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n const number = readline();\n (number !=2 && number % 2 == 0) ? process.stdout.write(\"YES\") : process.stdout.write(\"NO\"); \n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "8ff0025f33a3d5a33c8d6066e81e268b", "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});\nconst arr = [];\n\nrl.on('line', (data) => {\n arr.push(+data);\n});\n\nrl.on('close', () => {\n const [a, b, c, d, e, f] = arr;\n\n let suite2 = Math.min(b, c, d);\n let suite1 = Math.min(a, d - suite2);\n if (f > e) {\n suite2 = Math.min(b, c, d);\n suite1 = Math.min(a, d - suite2);\n }\n else {\n suite1 = Math.min(a, d);\n suite2 = Math.min(b, c, d - suite1);\n }\n\n const price1 = suite1 * e < 0 ? 0 : suite1 * e;\n const price2 = suite2 * f < 0 ? 0 : suite2 * f;\n const ans = price1 + price2;\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["math", "greedy", "brute force"], "code_uid": "6f6a5cf2b6108684350d7d7551f90a53", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "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];\n const obj = {};\n\n for (let i = 0; i < arr.length; i++) {\n if (obj[arr[i]]) {\n obj[arr[i]]++;\n }\n else {\n obj[arr[i]] = 1;\n }\n }\n\n const countArr = Object.values(obj);\n\n if (countArr.some((x) => x > k)) {\n console.log('NO');\n }\n else {\n console.log('YES');\n }\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "9a28134ca3c739740e67649ae316393d", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "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});\nfor (let i = 0; i < txt.length; i++) {\n let info = txt[i].split(\" \");\n doit(info[0] * 1, info[1] * 1);\n\n}\n\nfunction doit(n1, n2) {\n for (let i = 1; i < Infinity; i++) {\n n1 *= 3;\n n2 *= 2;\n if (n1 > n2) {\n console.log(i);\n break;\n }\n\n }\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "5ccacdf547cf987309de9d412cfee84f", "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\nlet l = 0;\nlet w = []\nlet h = []\n\nrl.on('line', (input) => {\n if (l === 0) {\n let inp = input.split(\" \").map(x => parseInt(x))\n w.push(inp[0])\n h.push(inp[1])\n } else if (l === 1) {\n let inp = input.split(\" \").map(x => parseInt(x))\n w.push(inp[0])\n h.push(inp[1])\n } else {\n rl.close();\n let inp = input.split(\" \").map(x => parseInt(x))\n let wg = w[0]\n let hg = h[0]\n w.push(inp[0])\n h.push(inp[1])\n if (h[1] < h[2]) {\n let aux = h[1]\n h[1] = h[2]\n h[2] = aux\n aux = w[1]\n w[1] = w[2]\n w[2] = aux\n }\n for (let i = h[0]; i >= h[1]; i--) {\n wg += i\n hg--\n }\n\n wg -= w[1]\n if (wg < 0)\n wg = 0\n if (hg <= 0) {\n console.log(wg)\n return\n }\n for (let i = h[1] - 1; i >= h[2]; i--) {\n wg += i\n hg--\n }\n wg -= w[2]\n if (wg < 0)\n wg = 0\n for (let i = hg; i >= 0; i--) {\n wg += i;\n }\n console.log(wg)\n }\n l++\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3ebcf1ad39ef6ed11bc5bd44d209e99f", "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;\n\nrl.on('line', (d) => {\n const [n, m] = d.split(' ').map(Number);\n\n if (m === 0 || m === 1) {\n console.log(1);\n }\n else if (n === m) {\n console.log(0);\n }\n else if (n / 2 > m) {\n console.log(m);\n }\n else {\n console.log(n - m);\n }\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "e10ee55c9f1a4e3a1e4ba974d6731087", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "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 word = new Set(input[1].toLowerCase());\n if (word.size === 26) console.log('YES');\n else console.log('NO');\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "ac7a0a6c5b782563e5ea3969d5dcbc6d", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "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 a = parseInt(lines[0].split(\" \")[0])\n let ta = parseInt(lines[0].split(\" \")[1])\n \n let b = parseInt(lines[1].split(\" \")[0])\n let tb = parseInt(lines[1].split(\" \")[1])\n\n let startingHour = parseInt(lines[2].split(\":\")[0])\n let startingMinute = parseInt(lines[2].split(\":\")[1])\n let startingTime = (startingHour * 60) + startingMinute\n\n let startOfShift = 5 * 60\n let endOfShift = 23 * 60 + 59\n\n let count = 0\n\n for (i = startOfShift; i <= endOfShift; i = i+b) {\n if ( i < startingTime + ta && i + tb > startingTime ) {\n count ++\n }\n }\n\n console.log(count)\n })", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "66816c0d8eaa82a439662842a17032c7", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7", "difficulty": 1600.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 = str.split(' ');\n\n for (let i = 0; i < arr.length; i++) {\n let curr = 0;\n\n for (let j = 0; j < arr[i].length; j++) {\n if (arr[i].charCodeAt(j) >= 65 && arr[i].charCodeAt(j) <= 90) {\n curr++;\n }\n }\n\n ans = Math.max(ans, curr);\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "96924e105e53ac170cf3358a6a0a5662", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "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 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(max - min);\n});\n", "lang_cluster": "Javascript", "tags": ["math", "sortings", "implementation"], "code_uid": "d33dedcee00d3af35babe6bac400fec4", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "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\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": "aa50cbebea9c8bc5f131d1f9e2bb2114", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "var xString = readline(),\n\tdigits = xString.split(\"\"),\n\txLength = xString.length,\n\tmaxSum = getDigitsSum(xString),\n\tmaxNumber = xString,\n\tnewNumber, newDigits, newSum, nineDigits;\n\n\nfor(var i = 0; i < xLength; i++) {\n\tnineDigits = (new Array(xLength - i)).join(\"9\").split(\"\");\n\tnewDigits = digits.slice(0, i + 1).concat(nineDigits);\n\n\tif(--newDigits[i] < 0 && i) continue;\n\tnewDigits[i] = (!i && newDigits[i] <= 0) ? \"\" : \"\" + newDigits[i];\n\n\tnewNumber = newDigits.join(\"\");\n\tnewSum = getDigitsSum(newDigits);\n\n\tif(newSum > maxSum || (newSum == maxSum && +newNumber > +maxNumber)) {\n\t\tmaxNumber = newNumber;\n\t\tmaxSum = newSum;\n\t}\n}\n\nfunction getDigitsSum(digits) {\n\tif(!Array.isArray(digits)) digits = (\"\" + digits).split(\"\");\n\treturn digits.reduce(function (sum, n) {\n\t\treturn sum + 1*n;\n\t}, 0);\n}\n\nprint(maxNumber);", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "ef1ecbf7e2dc4f9a51ebfe59b5e28df0", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n var arr = stdin[0].split('');\n var str = Array.from(new Set(arr)).length % 2 === 0 ? 'CHAT WITH HER!' : 'IGNORE HIM!';\n console.log(str);\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", "strings", "implementation"], "code_uid": "a87737092d46dccde528be9cd087ec63", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "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 [Limak , Bob] = readline().split(\" \");\n let years =1;\n while (true){\n \n Limak*=3;\n Bob*=2;\n if (Limak > Bob)\n break;\n\n years++\n }\n console.log(years);\n return ; \n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3abf03d06428e848cc26056252b35b24", "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 s = readline();\n let result = 0;\n let last = 'a'.charCodeAt();\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n const delta = Math.abs(last - c);\n if (delta > 13) {\n result += 26 - delta;\n } else {\n result += delta;\n }\n last = c;\n }\n // output\n print(result);\n}\n\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "3fc16a3ac8046fa59fb72e0616096bb1", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\n\nasync function readInput() {\n const readLineInterface = readline.createInterface({\n input: process.stdin\n });\n return new Promise(resolve => {\n readLineInterface.on(\"line\", line => {\n const [n, m, a] = line.split(\" \");\n resolve({\n n: parseInt(n, 10),\n m: parseInt(m, 10),\n a: parseInt(a, 10)\n });\n });\n });\n}\n\nfunction calculateOutput(n, m, a) {\n const stonesOnNSide = Math.ceil(n / a);\n const stonesOnMSide = Math.ceil(m / a);\n return stonesOnNSide * stonesOnMSide;\n}\n\nasync function main() {\n const { n, m, a } = await readInput();\n const output = calculateOutput(n, m, a);\n console.log(output);\n}\n\nmain();\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "d828d8463669c2df48897e0940e7ace3", "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});\n\nprocess.stdin.on('end', () => {\n const { EOL } = require('os');\n const lines = i.split(EOL);\n const tiles = lines[0].split(' ');\n console.log(minTiles(tiles));\n});\n\nfunction minTiles(arr) {\n const set = new Set([...arr]);\n if (set.size === 1) return 0;\n if (set.size === 2) return 1;\n\n let min = 2;\n set.forEach(tile => {\n if (set.has(`${Number(tile.split('')[0]) + 1}${tile.split('')[1]}`)) {\n if (set.has(`${Number(tile.split('')[0]) + 2}${tile.split('')[1]}`)) {\n min = 0;\n } else {\n min = Math.min(min, 1);\n }\n } else if (set.has(`${Number(tile.split('')[0]) + 2}${tile.split('')[1]}`)) {\n min = Math.min(min, 1);\n }\n });\n\n return min;\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "7211225bf307b9fbd8ced900858f4a73", "src_uid": "7e42cebc670e76ace967e01021f752d3", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function solution(arr){ \n var ret = 0;\n while (arr[0] <= arr[1]) {\n arr[0] *= 3\n arr[1] *= 2\n ret++;\n }\n return ret\n}\nprocess.stdin.addListener(\"data\", (data)=>{\n var arr = data.toString().trim().split(/[\\s,]+/).map(Number)\n console.log(solution(arr))\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "c2b8fdad42bf8712df8cfd434e92c126", "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 \u201aThere 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 t = next().toLowerCase();\n if(s == t){\n myout(0);\n }else if(s < t){\n myout(-1);\n }else{\n myout(1);\n }\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "c2fdd12143a751338fc43fdd060e5133", "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 a = readLine();\n let b = readLine();\n let c = '';\n for (let i = 0; i < a.length; i++) {\n c = a[i] + c;\n }\n if (b === c) {\n console.log('YES');\n } else {\n console.log('NO');\n }\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "fbbe3af4b8e0b78046dc02dcdc8dd1b8", "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;\nlet n, m;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n n = BigInt(d);\n return;\n }\n\n m = BigInt(d);\n const ans = (m % 2n ** n).toString();\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "604764e98c8371d13294400b133a42b4", "src_uid": "c649052b549126e600691931b512022f", "difficulty": 900.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=+(readLine());\n let enc=readLine().trim();\n let ans=enc;\n for(let i=2;i<=n;++i)\n {\n if(n%i==0)\n {\n ans=ans.substr(0,i).split(\"\").reverse().join(\"\")+ans.substr(i);\n }\n }\n console.log(ans);\n \n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "14b53101641eec84fe6f4a164c75646f", "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3", "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\u2191\u5165\u529b \u2193\u51fa\u529b');\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 \u201aThere 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 set = new Set();\n\tfor(var i = 0; i < N; i++){\n\t\tif(list[i] != 0){\n\t\t\tset.add(list[i]);\n\t\t}\n\t}\n\tmyout(set.size);\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation"], "code_uid": "e6a60f6dd4afe6026fb6d0caf52fc26d", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "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(s => s.trim())\n main()\n})\n\nfunction readline() {\n return inputString[currentLine++]\n}\n\nfunction main() {\n const size = +readline()\n process.stdout.write(size > 2 && size % 2 === 0 ? 'YES' : 'NO')\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "b32c3a4339c5d9333578dcd5657e20a2", "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 \u201aThere 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 set = new Set(nextIntArray());\n myout(4 - set.size);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "b8e262359314e3c3db081cacc66fe64d", "src_uid": "38c4864937e57b35d3cce272f655e20f", "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 const testCases = Number(readline());\r\n for (let i = 0; i < testCases; i++) {\r\n const n = Number(readline());\r\n console.log(countSquaresAndCubes(n));\r\n }\r\n}\r\n\r\nfunction countSquaresAndCubes(num) {\r\n let cnt = 0;\r\n let i = 2;\r\n let squares = 1, cubes = 1;\r\n let arr = [];\r\n while (squares <= num) {\r\n squares = i*i;\r\n if (squares <= num) {\r\n arr.push(squares);\r\n cnt++;\r\n }\r\n i++;\r\n }\r\n let j = 2;\r\n while (cubes <= num) {\r\n cubes = j*j*j;\r\n if (cubes <= num && !arr.includes(cubes)) cnt++;\r\n j++;\r\n }\r\n return cnt + 1;\r\n}", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "8bfe8b6ee4527729f7c35353f465e0a7", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "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\nmain();\n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\nfunction solve(n) {\n return n%2===0 && n>=4 ? `YES`: `NO`;\n}\n\nfunction main() {\n\n const nk = readLine().split(' ');\n\n const n = parseInt(nk[0], 10);\n\n let result = solve(n);\n console.log(result);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "d8ade8273d014616179e35fba2752394", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let stdin = process.openStdin();\n\nstdin.addListener('data', (data) => {\n let input = data.toString().split(' ');\n console.log(Math.ceil(input[0] / input[2]) * Math.ceil(input[1] / input[2]));\n process.exit(0);\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "cbd070d17fce64548fe073a793f73595", "src_uid": "ef971874d8c4da37581336284b688517", "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\tinputString += inputStdin;\n});\n\nprocess.stdin.on('end', (_) => {\n\tinputString = inputString.trim().split('\\n').map((string) => {\n\t\treturn string.trim();\n\t});\n\n\tmain();\n});\n\nfunction readline() {\n\treturn inputString[currentLine++];\n}\n\nfunction main() {\n\tlet n = +readline();\n\tlet a = [];\n\twhile (n--) {\n\t\tlet m = +readline();\n\t\ta.push(m);\n\t}\n\tlet flag = calc(a, 0);\n\tif (flag == 0) console.log('NO');\n\telse console.log('YES');\n}\n\ncalc = (a, sum) => {\n\tif (a.length == 0) {\n\t\tif (sum % 360 == 0) return 1;\n\t\telse return 0;\n\t} else {\n\t\treturn calc(a.slice(1), sum + a[0]) + calc(a.slice(1), sum - a[0]);\n\t}\n};\n", "lang_cluster": "Javascript", "tags": ["brute force", "dp", "bitmasks"], "code_uid": "5413b0ed7b670a287c0495b879f7ba9e", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10", "difficulty": 1200.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, k, x] = nl.nums();\n\tlet a = nl.nums();\n\t\n\tlet result = a.slice(0, n - k).reduce((x, y) => x + y, 0) + k * x;\n\tconsole.log(result);\n\n};\n\nprocess.stdin.on('end', sol);\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "a134544b2eab6497a1bc3d0cafbcbd70", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "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', () => {\n inputString = inputString.trim().split('\\n').map(str => {\n return str.trim();\n });\n main();\n});\nconst readLine = () => inputString[currentLine++];\n\nconst main = () => {\n const line = readLine();\n let [n, k] = line.trim().split(' ').map(Number);\n for (let i = 0; i < k; i++) {\n if ((n % 10) === 0) {\n n = parseInt(n / 10);\n } else {\n n = n - 1;\n }\n }\n console.log(n);\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "1dfc0ffec8ab96ad84ca36a2ec33526d", "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 length;\nlet t;\n\nfunction transform(data) {\n for (let i = 0; i < length - 1; i++) {\n if (data[i] === 'B' && data[i + 1] === 'G') {\n const temp = data[i];\n data[i] = data[i + 1];\n data[i + 1] = temp;\n i++;\n }\n }\n return data;\n}\n\nfunction solve(data) {\n for (let i = 0; i < t; i++) {\n data = transform(data);\n }\n return data;\n\n}\n\nrl.on('line', (line) => {\n if (!length) {\n [length, t] = line.split(' ').map(Number);\n return\n }\n console.log(solve(line.split('')).join(''));\n});\n", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "76506fbadf2967861984574969f4fbd4", "src_uid": "964ed316c6e6715120039b0219cc653a", "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\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nconst dragons = () => {\n let [k,l,m,n,d] = input.map(x => +x);\n let count = 0;\n for (let i = 1; i <= d; i++) {\n if ( (i % n === 0) || (i % m === 0) ||\n (i % l === 0) || (i % k === 0) ) {\n count++;\n }\n }\n console.log(count);\n};\n\n\n\nreadLine.on('close', dragons);", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "786ee1594a57fef64c279f3085a430c2", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const fs = require('fs');\nconst stdinBuffer = fs.readFileSync(0);\nconst inpuString = stdinBuffer.toString();\nlet [number,times] = inpuString.split(' ').map(x => { return parseInt(x, 10);});\n\nfunction tanyaSub(number) {\n return number % 10 === 0 ? number / 10 : number -1;\n}\n\nwhile (times > 0) {\n number = tanyaSub(number);\n times--;\n}\n\nprocess.stdout.write(`${number}`)", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "60494481e776b7b62e5661972b98e606", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "input = []\nprocess.stdin.setEncoding('ascii');\nprocess.stdin.on('data', z => {\n inp = z.split('\\n')\n for(let i in inp) {\n if(inp[i].slice(-1) == '\\r') {\n inp[i] = inp[i].slice(0, -1)\n }\n input.push(inp[i])\n }\n})\n\nprocess.stdin.on('end', z => {\n // console.log(input)\n a = input[1].split(' ')\n b = input[2].split(' ')\n // console.log(a, b)\n for(let i in a) {\n if(b.includes(a[i])) {\n process.stdout.write(a[i] + ' ')\n }\n }\n process.stdout.write('\\n')\n})\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "028cbab785b122bc74a6e62eb294761c", "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72", "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 [total, front, back] = readLine()\n .split(\" \")\n .map((n) => parseInt(n));\n const diff = total - front;\n\n if (diff > back) console.log(back + 1);\n else console.log(diff);\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "7a7a6040af7a56cebc90a37617d9c73e", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000.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\nlet input = [];\n\nrl.on('line', function(line) {\n\tinput.push(line);\n\tif (input.length === 3) {\n\t\texpression(input);\n\t\trl.close();\n\t}\n});\n\nlet expression = (input) => {\n\t//1+2+3 _ 1*2*3 _ (1+2)*3 _ 1*(2+3) _ 1*2+3 _ 1+2*3\n\tinput = input.map((el) => {\n\t\treturn el * 1;\n\t});\n\n\tlet val = [\n\t\tinput[0] + input[1] + input[2],\n\t\tinput[0] * input[1] * input[2],\n\t\t(input[0] + input[1]) * input[2],\n\t\tinput[0] * (input[1] + input[2]),\n\t\tinput[0] * input[1] + input[2],\n\t\tinput[0] + input[1] * input[2]\n\t];\n\n\tvar max = val.reduce(function(a, b) {\n\t\treturn Math.max(a, b);\n\t});\n\n\tconsole.log(max);\n};\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "3c1ab6cedc3f797ba3a72f0765770c0c", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "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 findTheTotalPlacedDominoes(readline());\n}\n\nfunction findTheTotalPlacedDominoes(matrix) {\n const dominoX = 2;\n const dominoY = 1;\n \n const matrixArr = matrix.split(' ');\n \n const canvasX = matrixArr[0];\n const canvasY = matrixArr[1];\n \n const possibleDivision4XAxis = canvasX / dominoX;\n const possibleDivision4YAxis = canvasY / dominoY;\n \n const result = Math.floor(possibleDivision4XAxis * possibleDivision4YAxis);\n \n process.stdout.write(result.toString());\n\n}\n\n\n\n\n\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "20899dcf182bef38ec5fae7cf5271ec7", "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 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().split(\"\");\n var getLen = removed(str);\n if (getLen.length % 2 === 0) {\n console.log(\"CHAT WITH HER!\");\n } else {\n console.log(\"IGNORE HIM!\");\n }\n}\nfunction removed(str) {\n return [...new Set(str)].join(\"\");\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "a34275ef033801d56b96cb24647bd0f6", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// https://codeforces.com/problemset/problem/158/A\n\nfunction main(stdin) {\n const [n, k] = stdin.shift().split(' ').map(Number)\n const as = stdin.shift().split(' ')\n process.stdout.write(as.filter(a => a > 0 && +a >= as[k-1]).length + '')\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": "ce6976f589d4f5e406b5659cbca0644c", "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 const [a, b, c] = input.map(v => parseInt(v));\n let abc = a * b * c, apbpc = a + b + c, apbc = (a + b) * c, abpc = a * (b + c);\n if (abc > apbpc && abc > apbc && abc > abpc) console.log(abc);\n else if (apbpc > abc && apbpc > apbc && apbpc > abpc) console.log(apbpc);\n else if (apbc > abc && apbc > apbpc && apbc > abpc) console.log(apbc);\n else console.log(abpc);\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "e2143ec52a8c7cea001162b592df0c61", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.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){\n if(arr==2) return \"NO\"\n \n if ((arr/2)%2==0){\n return \"YES\"\n \n }\n else if(arr%2!=0){\n return \"NO\"\n } \n else{\n return \"YES\"\n \n }\n \n \n}\n\n\nmodule.exports=(minfill)\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "f4085f621e0e36c66325d06a84f385d8", "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\tlet table = input[0].split('')\n\tconst your = input[1].split(' ')\n\t\n\tlet check = false\n\t\n\tyour.forEach((el, index) => {\n\t\tel.split('').forEach(item => {\n\t\t\tif (table.indexOf(item) !== -1) {\n\t\t\t\tcheck = true\n\t\t\t}\n\t\t})\n\t})\n\t\n\tif (check)\n\t\tconsole.log('YES')\n\telse \n\t\tconsole.log('NO')\n})", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "e57d2f3476735f00a974ff53b28c215c", "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.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 s2 = readline().toLowerCase();\nlet output = 0;\n\n for (let i =0,c=s1.length ; i < c ; i++ ){\n if (s1[i].charCodeAt(0) > s2[i].charCodeAt(0)) {\n output = 1; break;\n }\n else if (s1[i].charCodeAt(0) < s2[i].charCodeAt(0)){\n output = -1 ; break;\n }\n }\n\nconsole.log(output)\n\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "d382ce107eb2a2f1d84ce4811d7ec868", "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\nrl.on(\"line\", (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\nrl.on(\"close\", () => {});\n", "lang_cluster": "Javascript", "tags": ["implementation", "number theory"], "code_uid": "3ac4ad7b1641269c31a2461a0a642dd1", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.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 ax = arr.shift().split(' ')\n const v = parseInt(ax[0])\n const e = parseInt(ax[1])\n\n if(e == 0) {\n console.log(0)\n return\n }\n if(v <= 6) {\n console.log(e)\n }\n\n else {\n let m = new Map()\n \n for(let i = 1; i <= v; i ++) {\n m.set(i, [])\n }\n \n for(let i = 0; i < e; i ++) {\n const edge = arr.shift().split(' ')\n const a = parseInt(edge[0])\n const b = parseInt(edge[1])\n m.get(a).push(b)\n m.get(b).push(a)\n }\n\n var f = false\n var noOfVertices = 20\n for(let j = 1; j <= 7; j ++) {\n var a7 = m.get(j)\n for(let i = 1; i <= 7; i ++) {\n if(i == j) continue\n var other = m.get(i)\n var x = a7.filter(el => other.indexOf(el) != -1)\n if(x.length == 0) {\n f = true\n break\n }\n else if(x.length < noOfVertices) {\n noOfVertices = x.length\n }\n }\n }\n if(f) {\n console.log(e)\n }\n\n else {\n console.log(e - noOfVertices)\n }\n }\n}) ", "lang_cluster": "Javascript", "tags": ["brute force", "graphs"], "code_uid": "12ef2da25ccd0f255054ae58aa658cee", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "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.parseInt(a)),s;\n var min = Math.min(arr[1], arr[2]);\n s=(arr[0] <= min) ? '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": "a1819de4cd1f79453c6453d2bf2af7d9", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\nprocess.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.trim().split('\\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().split(\" \").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": "8cb5f7350da56d85a800a77482660c9f", "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 var out;\n if (line % 2 === 0 && line > 2 ) {\n out = \"Yes\"\n }\n else {\n out = \"NO\";\n }\n console.log(out);\n})", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "2295ece9ab21279157ff888025663e82", "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 let temp = input.split(' ').map(item => parseInt(item));\n let n = temp[0], m = temp[1], a = temp[2];\n // let x = (n % a ) ? (n/a).toFixed(0) + 1 : n/a;\n // let y = (m % a) ? (m/a).toFixed(0) + 1 : m/a;\n let x = Math.ceil(n/a);\n let y = Math.ceil(m/a);\n //console.log(\"n = \" + n + \" m = \" + m + \" a = \" + a + \" x = \" + x + \" y = \" + y );\n console.log(x*y);\n rl.close();\n });\n\n ", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "3085fd5e63dbed8798741ff9d9d719d6", "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 \n main(); \n});\n\nconst readLine=()=> inputString[currentLine++];\n/* ================================================ \n Main Solution Starts Here \n===================================================*/\n\nconst main=()=>{\n\tlet [k,r] = readLine().split(\" \").map(n=>+n)\n\tlet canBuy = true\n\tlet i = 0\n\tlet h = 1\n\n\twhile(canBuy){\n\t\ti++\n\t\th = i*k\n\t\tif(h%10==0 || h%10==r)\n\t\t\tcanBuy=false\n\t}\n\n\n\n\tconsole.log(i)\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "ba125436598cc945a0b19f21d94e27c7", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.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, lastDigit-1);\n }\n }\n console.log(n)\n}\n\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "a1cc70fe47861f029935e983b73f7ee7", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\nlet input = [];\nconst readline = require('readline')\n\nconst rl = 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\n let count = input[0];\n for(let i = input[1]; i--;) {\n if(count % 10) {\n count--;\n }\n else {\n count /= 10;\n }\n }\n console.log(count);\n});\n\nrl.on('close', () => {\n //console.log(input);\n });\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "07156cdc153ab7f79a37d92ce7048e7d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function funkyNumbers(n) { \n\n var funkyNumber = 'NO';\n\n var maxTriangle = maxTrianglePossible(n);\n\n for(let i = maxTriangle; i > 0; i--) {\n var firstTriangle = triangleNumbers(i);\n var rem = n - firstTriangle\n\n if(rem === 0) continue;\n\n var secFactor = maxTrianglePossible(rem);\n var secTriangle = triangleNumbers(secFactor);\n\n var triangles = firstTriangle + secTriangle;\n\n if(triangles == n) {\n funkyNumber = 'YES';\n break;\n } \n \n }\n \n return funkyNumber; \n} \n\nfunction maxTrianglePossible(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\n\n var k = Math.floor( Math.sqrt(n*2) );\n\n return k;\n\n}\n\nfunction triangleNumbers(x) {\n \n var f = ( x * (x + 1) ) / 2;\n\n return f;\n}\n\n//stdin \u2192 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": "86353972c6f9605a10afe48297caea9d", "src_uid": "245ec0831cd817714a4e5c531bffd099", "difficulty": 1300.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 readline() { 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 s = readline();\n let f = 0;\n if (s.includes(\"H\")) f = 1;\n if (s.includes(\"Q\")) f = 1;\n if (s.includes(\"9\")) f = 1;\n println(f ? \"YES\" : \"NO\");\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "bb50118575b9ebc67c909db26a8da9c4", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const { read } = require('fs');\n\nconst readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nreadline.question('', w => {\n if(parseInt(w) %2==0 && parseInt(w)>=4){\n console.log('YES');\n }\n else{\n console.log('NO');\n }\n readline.close();\n})", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "0e0d4daf3373b1366e4ab9f6194552f6", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume();\nprocess.stdin.setEncoding('utf8');\n\n// * STANDARD INPUT IS STORED IN A STRING\nvar arr = '';\n\nprocess.stdin.on('data', function (chunk) {\n arr += chunk;\n});\n\nprocess.stdin.on('end', function () {\n // * CONVERTING THAT INPUT INTO AN ARRAY\n arr = arr.split('\\n');\n // * EXTRACTING THE NUMBER OF TESTCASES\n var a = arr[0];\n var b = arr[1];\n\n a = a.toLowerCase();\n b = b.toLowerCase();\n\n if (a === b) {\n console.log(0);\n } else if (a > b) {\n console.log(1);\n } else if (a < b) {\n console.log(-1);\n }\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "ef30039c3fdf0180e44cc74cc401f175", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// let weight = process.argv[2];\n// let weight = input();\n\n// if (weight >= 2 && weight % 2 == 0)\n\n// {\n// console.log('YES')\n// }\n// else\n// {\n// console.log('NO')\n// }\n\n/************* KEEP BELOW CODE AS IT IS *********************/\n/**\n * This code has been taken from: https://codeforces.com/blog/entry/69610\n * I am not the owner of the readLine function below, understanding them require knowledge of basic NodeJS I/O and streams\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\n/****** BELOW HERE START WRITING YOUR CODE IN main() FUNCTION ***************************************/\n/**\n * Use \"readLine()\" function for input, which will return a string consisting the entire line, so accordingly split the string \n * when required.\n *\n * I am using console.log() to output\n */\nfunction main() {\n let weight = readLine();\n // let weight = process.argv[2];\n // console.log(weight)\n if (weight > 2 && weight % 2 == 0)\n {\n console.log('YES')\n }\n else\n {\n console.log('NO')\n }\n\n // t = parseInt(t);\n // console.log(\"mai yahan aaya\")\n // while(t--) {\n // let line = readLine();\n // line = line.split(\" \");\n // let n = parseInt(line[0]);\n // let m = parseInt(line[1]);\n // if(n === 1) {\n // console.log(\"0\");\n // } else if (n === 2) {\n // console.log(m);\n // } else {\n // console.log(2*m);\n // }\n // }\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "2b648ade75de2d39eed4c97f35902dd9", "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// Make a Snippet for the code above this and then write your logic in main();\n\n\nfunction main() {\n // const x = readline();\n\n\n var x = readline(); // first line of input usually gives the no. of test cases,i.e, the no. of lines ahead.\n var inp; // declaring the variable outside the loop\n for (var i = 0; i < x; i++) {\n inp = readline();\n console.log(foo(inp))\n }\n\n // for (let i = 1; i <= x; i++) {\n // var line2 = readline();\n // console.log(foo(line2))\n // }\n // foo(x);\n // foo(line2);\n}\n\nfunction test_same_digit(num) {\n const first = num % 10;\n while (num) {\n if (num % 10 !== first) return false;\n num = Math.floor(num / 10);\n }\n return true\n}\n\n\n\nfunction foo(n) {\n\n\n let result = new Set();\n let b = false;\n for (let i = 1; i <= n; i++) {\n let res = i;\n let index = 1;\n let d = i;\n\n if (b) {\n\n break\n }\n while (res < 10000) {\n if (res == n) {\n result.add(`${res}`)\n b = true;\n break\n }\n if (test_same_digit(Number(res)) && !result.has(res)) {\n result.add(`${res}`)\n\n }\n res = `${d}`.repeat(index);\n index++\n }\n }\n\n let d = Array.from(result);\n\n let sum = 0;\n for (let i = 0; i < d.length; i++) {\n let f = d[i].split(\"\").length || 0;\n sum += Number(f)\n }\n return sum\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "deeff1348bdb3450698b59fa034445d5", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let input = '';\nlet inputResolve;\nlet inputPromise = new Promise(resolve => inputResolve = resolve);\nprocess.stdin.on('data', c => input += c);\nprocess.stdin.on('end', () => inputResolve());\n\nfunction For(a, b, fn) {\n let res;\n if (a < b) {\n for (let i = a; i <= b; i++) {\n if ((res = fn(i)) !== undefined) return res;\n }\n } else {\n for (let i = a; i >= b; i--) {\n if ((res = fn(i)) !== undefined) return res;\n }\n }\n}\n\nfunction Arr(a, b, fn, prev) {\n let p = prev || 0;\n if (a < b) return Array(b - a + 1).fill(0).map((v, i) => fn ? (p = fn(a + i, p)) : a + i);\n return Array(a - b + 1).fill(0).map((v, i) => fn ? (p = fn(a - i, p)) : a - i);\n}\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), 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}\nArray.prototype.min = function (fn) {\n let min = Math.min(...this.map((v, i) => fn ? fn(v, i) : v));\n let i = this.findIndex((v, i) => fn ? fn(v, i) == min : v == min);\n return [this[i], i, min];\n}\nArray.prototype.max = function (fn) {\n let max = Math.max(...this.map((v, i) => fn ? fn(v, i) : v));\n let i = this.findIndex((v, i) => fn ? fn(v, i) == max : v == max);\n return [this[i], i, max];\n}\n\nfunction gcd(a, b) {\n if (!b) return a;\n return gcd(b, a % b);\n}\nfunction mod(a, n, m) {\n if (n == 0n) return 1n;\n if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);\n return a * mod(a, n - 1n, m) % m;\n}\nfunction extendedEuclid(a, b) {\n if (!b) return [1, 0];\n else {\n let [x, y] = extendedEuclid(b, a % b);\n return [y, x - (a / b | 0) * y];\n }\n}\n// [m] = extendedEuclid(a, 998244353);\n\n(async () => {\n await inputPromise;\n let inp = input.split(/\\s+/); r = 0;\n let [n, k, s, t] = inp;\n n = +n;\n k = +k;\n if (t[0] == t[1]) {\n let x = Math.min([...s].filter(c => c == t[0]).length + k, n);\n console.log(x * (x - 1) / 2);\n return;\n }\n let f = Arr(0, n + 1, i => Arr(0, n + 1, i => Arr(0, n + 1, i => -1e5)));\n f[0][0][0] = 0;\n For(0, n, i => {\n For(0, k, j => {\n For(0, i, cnt0 => {\n if (f[i][j][cnt0] < 0) return;\n let e0 = s[i] == t[0];\n let e1 = s[i] == t[1];\n f[i + 1][j][cnt0 + e0] = Math.max(f[i + 1][j][cnt0 + e0], f[i][j][cnt0] + e1 * cnt0);\n f[i + 1][j + 1][cnt0 + 1] = Math.max(f[i + 1][j + 1][cnt0 + 1], f[i][j][cnt0]);\n f[i + 1][j + 1][cnt0] = Math.max(f[i + 1][j][cnt0], f[i][j][cnt0] + cnt0);\n })\n })\n })\n // console.log(f);\n console.log(Arr(0, k, i => Arr(0, n, j => f[n][i][j]).max()[0]).max()[0]);\n})();", "lang_cluster": "Javascript", "tags": ["strings", "dp"], "code_uid": "100c816511ef0df576076a6d7dde3f5d", "src_uid": "9c700390ac13942cbde7c3428965b18a", "difficulty": 2100.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\");\n let content_one = content[0].split(\" \");\n let total_cities = parseInt(content_one[0]);\n let a = parseInt(content_one[1]);\n let array = content[1].split(\" \");\n console.log(totalCriminalCatch(total_cities, a, array));\n});\n\n\n\n\nfunction totalCriminalCatch(totalCities, a, ti) {\n\n ti = ti.map(Number);\n let count = 0;\n\n for (var i = 0; i < 100; i++) {\n\n let a1 = (a - 1 - i >= 0 && ti[a - 1 - i] > 0) || a - 1 - i < 0;\n let a2 = (a - 1 + i < totalCities && ti[a - 1 + i] > 0) || a - 1 + i >= totalCities\n\n if (a1 && a2) {\n if (i == 0) {\n count += 1;\n } else {\n\n if ((a - 1 - i >= 0 && ti[a - 1 - i] > 0)) {\n count++;\n }\n\n if ((a - 1 + i < totalCities && ti[a - 1 + i] > 0)) {\n count++;\n }\n }\n }\n }\n\n return count;\n}\n", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation"], "code_uid": "d4c507048fbdf336d71659f17310a3e9", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5", "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 isCapitalize = s => s.toUpperCase() === s;\nconst isLower = s => s.toLowerCase() === s;\n\nreadLine.on('close', () => {\n const word = input[0];\n let s = 0, b = 0;\n\n for (let i = 0; i < word.length; i += 1) {\n if (isCapitalize(word[i])) b += 1;\n else s += 1;\n }\n\n if ( s >= b ) console.log(word.toLowerCase());\n else console.log(word.toUpperCase());\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "a812b081feb6f2676333b44c42b16c73", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "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().toLowerCase().split(\"\");\n if (str.length <= 100) {\n var strWithoutVowels = [];\n var vowels = [\"a\", \"e\", \"i\", \"o\", \"u\", \"y\"];\n for (var i = 0; i < str.length; i++) {\n if (vowels.indexOf(str[i]) < 0) {\n strWithoutVowels.push(\".\" + str[i]);\n }\n }\n console.log(strWithoutVowels.join(\"\"));\n }\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "ae7602b3b8716ff4608aee881fbac7df", "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\n// readline.on(\"line\", (line) => {\n// readline.close();\n// });\n\n// multi line input\nreadline.on(\"line\", (line) => {\n const input = +line.split(\" \")[0];\n readline.close();\n const half = input / 2;\n if (input % 2 === 0) {\n if (half > 1) {\n console.log(\"YES\");\n return;\n }\n }\n console.log(\"NO\");\n return;\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "9d4fe26a36bc94b813e4cfd6a51af1a8", "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\u2191\u5165\u529b \u2193\u51fa\u529b');\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 \u201aThere 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 sum = 0;\n\tfor(var i = 0; i < N; i++){\n\t\tsum += Math.abs(list[i]);\n\t}\n\tmyout(sum);\n}\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "ae4b3c1305ae4c210dd7f5367ec6073c", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "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\u2191\u5165\u529b \u2193\u51fa\u529b');\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 \u201aThere 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 alist = nextIntArray();\n\tvar blist = nextIntArray();\n\tvar asum = 0;\n\tvar bsum = 0;\n\tfor(var i = 0; i < N; i++){\n\t\tasum += alist[i];\n\t\tbsum += blist[i];\n\t}\n\tif(asum >= bsum){\n\t\tmyout(\"Yes\");\n\t}else{\n\t\tmyout(\"No\");\n\t}\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "919b5455b5e3f09aee8c06a3bc47b082", "src_uid": "e0ddac5c6d3671070860dda10d50c28a", "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 var ans=Math.ceil(n/a)*Math.ceil(m/a);\n console.log(ans);\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "3400debab64196234640d3f6570aa1f5", "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 teams;\nlet teamsCounter = 0;\nlet arrayOfteams = [];\nlet counter = 0\n\nrl.on(\"line\", (input) => {\n if (!teams) {\n teams = parseInt(input.split(\" \"))\n } else {\n arrayOfteams.push(input.split(\" \").map(Number))\n if (arrayOfteams.length == teams) {\n arrayOfteams.forEach(team => {\n arrayOfteams.forEach(element => {\n if (team[0] === element[1]) {\n counter++\n }\n })\n });\n console.log(counter)\n }\n\n\n }\n\n})", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "f325b3b0902c553c0478698e390111d3", "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 x = readLine()\n .split(' ')\n .map(v => parseInt(v))\n .sort((a, b) => {\n return a - b;\n });\n let x1 = x[0];\n let x2 = x[1];\n let x3 = x[2];\n console.log(Math.abs(x2 - x1) + Math.abs(x3 - x2))\n}", "lang_cluster": "Javascript", "tags": ["math", "sortings", "implementation"], "code_uid": "7c7d5a119a7065b36d0a2ef86530c967", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "/**\n * Created by bhavyaagg on 09/06/18.\n */\n\nconst readline = require('readline');\n\nr1 = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nr1.on('line', (data) => {\n let x = data.split(\" \")[0];\n let y = data.split(\" \")[1];\n\n if (x == y) {\n console.log(\"=\");\n } else {\n if (x == 1) {\n console.log(\"<\")\n }\n else if (y == 1) {\n console.log(\">\")\n }\n else {\n let a = y * Math.log(x) - x * Math.log(y);\n\n if (a == 0) {\n console.log(\"=\")\n }\n else if (a < 0) {\n console.log(\"<\")\n } else {\n console.log(\">\")\n }\n }\n }\n // else if (x < y) {\n //\n // console.log(\">\")\n // } else {\n // console.log(\"<\")\n // }\n\n r1.close();\n})\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "59218e1a419cd8920f1a08ebd70a86c7", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "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 c = 0;\n\nrl.on('line', (d) => {\n const [n, k] = d.split(' ').map(Number);\n let red = n * 2;\n let green = n * 5;\n let blue = n * 8;\n let ans = Math.ceil(red / k) + Math.ceil(green / k) + Math.ceil(blue / k);\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "e3089754200669cd7c18c22febcbcd04", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const fs = require(\"fs\");\r\nconst input = fs.readFileSync(0, 'utf8').trim().split('\\n');\r\nlet currentline = 0;\r\nfunction readline(){\r\n return input[currentline++];\r\n}\r\n\r\nfunction alph() {\r\n var f = 'abcdefghijklmnopqrstuvwxyz';\r\n return f;\r\n}\r\nfunction Alph() {\r\n var f = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\r\n return f;\r\n}\r\nfunction max(x,y) {\r\n return x >=y ? x : y;\r\n}\r\nfunction min(x,y) {\r\n return x <=y ? x : y;\r\n}\r\nfunction abs(x) {\r\n return x < 0 ? x*(-1) : x;\r\n}\r\n\r\nvar T = readline();\r\n// var inf = 1000000000000;\r\nfor(var qe=1;qe<=T;qe++) {\r\n // var n = readline();\r\n var [a,b] = readline().split(' ').map((x) => parseInt(x));\r\n var [c,d] = readline().split(' ').map((x) => parseInt(x));\r\n if(c==1&&d==1&&a==1&&b==1) console.log(2)\r\n else if(a==1||b==1||c==1||d==1) console.log(1)\r\n else console.log(0)\r\n}\r\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "41e821c133f0e3587cfaaf4884ea802a", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let data = ''\nprocess.stdin.on('data', line => data += line)\nprocess.stdin.on('end', () => {\n const {EOL} = require('os');\n const lines = data.split(EOL);\n let [n, k] = lines[0].split(' ').map(x => +x);\n \n while (k) {\n if (n % 10) {\n n--;\n } else {\n n /= 10;\n }\n \n k--;\n }\n \n console.log(n);\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3c88c2ff6c60079ab267f3695a459e43", "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\u2191\u5165\u529b \u2193\u51fa\u529b');\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 \u201aThere 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 n1 = one[0];\n var n2 = one[1];\n var k1 = one[2];\n var k2 = one[3];\n myout((n1 > n2) ? \"First\" : \"Second\");\n}\n", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms"], "code_uid": "92e0125fc8b4e2ccbc1eab4e2151ef9a", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "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 stones = () => {\n let length = +input[0];\n let s = input[1];\n let count = 0;\n for (let i = 1; i < length; i++) {\n if (s[i] === s[i -1]) {\n count++;\n }\n }\n console.log(count);\n};\n\nreadLine.on('close', stones);\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "a7217d9c3725931d2f1c93ac226db469", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const { on } = require('process');\nconst readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nvar check = function (s) {\n let sLen = s.length;\n if (sLen == 0 || sLen > 16)\n return false;\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] == '_'))\n return false;\n }\n return true;\n}\n\nvar checkHost = function (hostName) {\n let hostLen = hostName.length;\n if (hostLen == 0 || hostLen > 32)\n return false;\n let cont = hostName.split(\".\");\n for (let i = 0; i < cont.length; i++) {\n if (!check(cont[i]))\n return false;\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 let userName = input.substring(0, atIndex);\n isUser = check(userName);\n let slashIndex = input.indexOf(\"/\");\n let hostName = (slashIndex != -1) ? input.substring(atIndex + 1, slashIndex) : input.substring(atIndex + 1);\n isHost = checkHost(hostName);\n isResource = (slashIndex == -1) ? true : check(input.substring(slashIndex + 1));\n }\n console.log((isUser && isHost && isResource) ? \"YES\" : \"NO\");\n rl.close();\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "e41b0fbf390bfd57c90b2cf86c2dbb86", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.setEncoding('utf8')\nprocess.stdin.on('data', chunk => {\n const [n, m, a] = chunk.split(' ').map(s => parseInt(s))\n const ans = Math.ceil(n / a) * Math.ceil(m / a)\n // console.log(ans)\n process.stdout.write(String(ans))\n})", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "f25a926828027966758127432aea3a4e", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.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 [d1, d2, d3] = input[0].split(' ').map(x => parseInt(x));\n\n console.log(\n Math.min(\n d1+d3+d2,\n d1+d1+d2+d2,\n d1+d3+d3+d1,\n d2+d3+d3+d2,\n )\n )\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "1a6aede9912f35405456f181bd2cb540", "src_uid": "26cd7954a21866dbb2824d725473673e", "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\n//\"use strict\";\nfunction main(input) {\n var line = input.split(\"\\n\");\n var str1 = line[0];\n var str2 = line[1];\n str1 = str1.toLowerCase();\n str2 = str2.toLowerCase();\n var ans = str1.localeCompare(str2);\n console.log(ans);\n}\n//main(require('fs').readFileSync('/dev/stdin', 'utf8'));\n//main(require('fs').readFileSync('input.txt', 'utf8'));", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "1da98e7c658c35345e78e6c1b3486b63", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "/* eslint-disable no-param-reassign */\nconst 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\nconst handleI = (i, k) => {\n if (i === 1) {\n return String(k);\n }\n\n // \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0446\u0438\u0444\u0440 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043e\u0442\u0440\u0435\u0437\u043a\u0435. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0432 \u043e\u0442 \u0440\u0435\u0437\u043a\u0435 [100, 199] - 300 \u0446\u0438\u0444\u0440.\n const rangeCount = i * (10 ** (i - 1));\n // \u0427\u0438\u0441\u043b\u043e 522 \u043b\u0435\u0436\u0438\u0442 \u0432 \u043e\u0442\u0440\u0435\u0437\u043a\u0435 [200, 299]\n const rangeIdx = Math.ceil((k + 1) / rangeCount);\n // \u0414\u0430\u043d\u043d\u043e\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432\u043e\u0435 \u0447\u0438\u0441\u043b\u043e.\n const rangeNum = (10 ** (i - 1)) * rangeIdx;\n const num = rangeNum + Math.floor(((k % rangeCount) - 1) / i);\n return String(num)[(k - 1) % i];\n};\n\nconst optimalWayGetNumber = (k) => {\n // \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0447\u0438\u0441\u043b\u043e 711\n let i = 1;\n while (k > 0) {\n k -= 9 * i * (10 ** (i - 1));\n i += 1;\n }\n\n i -= 1;\n // \u041f\u043e\u0441\u043b\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u044d\u0442\u0430\u043f\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u043e\u043c\u0435\u0440 \u0446\u0438\u0444\u0440\u044b \u0432 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c \u043e\u0442\u0440\u0435\u0437\u043a\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430.\n // \u0414\u043b\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 - \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e 522.\n k += 9 * i * (10 ** (i - 1));\n return handleI(i, k);\n};\n\nreadline.on('line', (line) => {\n const k = Number(line);\n\n console.log(optimalWayGetNumber(k));\n});\n\nmodule.exports = {\n getNumber,\n optimalWayGetNumber,\n};\n", "lang_cluster": "Javascript", "tags": ["divide and conquer", "implementation", "binary search"], "code_uid": "c9ddf3237aaf53331e97bb24320a89e7", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1800.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 [n, k] = lines[0].split(' ');\n console.log(getCandiesEaten(parseInt(n, 10), parseInt(k, 10)));\n});\n\nfunction getCandiesEaten(n, k) {\n if (n === 1) return 0;\n n--;\n let candies = 1;\n let sum = 2;\n let consumed = 0;\n while (n > 0) {\n while (candies <= k) {\n candies += sum;\n sum++;\n n--;\n }\n // Reduce candies to less than k\n const candiesToSubtract = candies - k;\n n -= candiesToSubtract;\n consumed += candiesToSubtract;\n candies -= candiesToSubtract;\n }\n return consumed;\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "binary search"], "code_uid": "3c793135afffbfd78992282386bf7423", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "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 \u201aThere 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 t = one[1];\n var list = nextCharArray();\n for(var i = 0; i < t; i++){\n for(var j = 0; j < N - 1; j++){\n if(list[j] == \"B\" && list[j + 1] == \"G\"){\n list[j] = \"G\";\n list[j + 1] = \"B\";\n j++;\n }\n }\n }\n myout(myconv(list, 0));\n}\n", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "d2a3c51d878caa3aeb15c38f97521d25", "src_uid": "964ed316c6e6715120039b0219cc653a", "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 [k, r] = readline().split(' ').map(x => parseInt(x));\n let x = 1;\n while (k * x % 10 !== 0 && k * x % 10 !== r) {\n x++;\n }\n // output\n print(x);\n}\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "24193e3542570a5f25d2335da69c79c7", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "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 [n, k] = nl.nums();\n\tlet a = nl.nums();\n\tlet r = Array(n);\n\tr.fill(0);\n\tfor(let i of a){\n\t\tfor(let j = i-1; j < n && r[j] === 0; j++){\n\t\t\tr[j] = i;\n\t\t}\n\t}\n\tconsole.log(r.join(' '));\n\n};\n\nprocess.stdin.on('end', sol);\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "9c645fab4322f3f0b397c98736a924f3", "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\n\nfunction substract(number, times) {\n\n let result = number;\n while (times > 0) {\n const lastDigit = getLastDigit(result);\n if (lastDigit == 0) {\n result = removeLastDigit(result);\n } else {\n result -= 1;\n }\n\n times--;\n }\n\n return result;\n}\n\nfunction getLastDigit(number) {\n const numberAsString = number.toString()\n const numberLength = numberAsString.length;\n const lastDigitAsString = numberAsString[numberLength - 1];\n return parseInt(lastDigitAsString);\n}\n\nfunction removeLastDigit(number) {\n const numberAsString = number.toString();\n const length = numberAsString.length;\n return parseInt(numberAsString.slice(0, length - 1));\n}\n\n// console.log(substract(512, 4));\n// console.log(substract(1000000000, 9));\n\n\n// function start() {\n// const line = readline();\n// const input = line.split(\" \");\n// const number = parseInt(input[0]);\n// const repetitions = parseInt(input[1]);\n// console.log(substract(number, repetitions));\n// }\n\n\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 repetitions = parseInt(input[1]);\n console.log(substract(number, repetitions));\n\n rl.close();\n});\n\n// start();", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "b2cfc586134446bff14a5fd28a28ed1d", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data',c=>{a=Number(c);console.log(c>2&&c%2==0?\"YES\":\"NO\")})", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "27199d1ec1721faf91a509187da91006", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.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\ncount.delete(count.size);\r\n}\r\n/*\r\n if((Math.floor(Math.sqrt(j)) == Math.ceil(Math.sqrt(j)))\r\n && (Math.floor(Math.cbrt(j)) == Math.ceil(Math.cbrt(j))))\r\n {\r\n count++;\r\n }\r\n else if (Math.floor(Math.sqrt(j)) == Math.ceil(Math.sqrt(j)))\r\n count++;\r\n else if (Math.floor(Math.cbrt(j)) == Math.ceil(Math.cbrt(j)))\r\n count++;\r\n */", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "086800805e50f644209df6ed9a199df3", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "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 count = 0;\n\nconst compare = (a, b, count) => {\n a > b ? console.log(count) : compare((a * 3), (b * 2), ++count);\n}\n\nrl.on('line', (line) => {\n let array = line.toString().trim().split(' ').map(Number);\n\n compare(array[0], array[1], count);\n\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "02b370da0d5ea67f3986c93fdad8b55f", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.setEncoding('ASCII');\nlet string = '';\nprocess.stdin.on('data', (data) => string += data);\n\nconst main = (input) => {\n const ns = input[0].split(' ').map(Number);\n const vol = input[1].split(' ').map(Number);\n\n let sum = 0, mx = 0;\n\n vol.forEach( (val) => {\n sum += val;\n mx = Math.max(mx, val);\n });\n\n if ((sum - mx) <= ns[1]) console.log(\"YES\");\n else console.log(\"NO\");\n};\n\nprocess.stdin.on('end', () => main( string.trim().split('\\n') ));\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f88a7d4e85929073f233c6d9b448370d", "src_uid": "496baae594b32c5ffda35b896ebde629", "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().split(' ').map(num => parseInt(num));\n for (let i = 0; i < t; i++) {\n let [n] = readline().split(' ').map(num => parseInt(num));\n let cnt = 1;\n for (let j = 2; j <= Math.sqrt(n); j++) {\n if (j * j <= n && !Number.isInteger(Math.cbrt(j))) cnt++;\n if (j * j * j <= n && (!Number.isInteger(Math.sqrt(j)) || Math.sqrt(j) * Math.sqrt(j) * Math.sqrt(j) > j)) cnt++;\n }\n console.log(cnt);\n }\n}", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "d6dba4c63455a507921ff7c24283f23d", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "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 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": "3f21594a10b4d00aad07df54071b8378", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.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 x = BigInt(lines[0][0])\n predict([\"1<=x<=10**15\"]);\n\n let S=0,e=0,o=0\n if (x%2n == 0) {\n e = (x*x+2n*x)/4n\n o = (x*x)/4n\n }\n else\n {\n e = ((x-1n)*(x-1n)+2n*(x-1n))/4n\n o = ((x+1n)*(x+1n))/4n\n }\n\n print(Number(e-o))\n\n}\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "830e6b5744db19bcff50aa45059dcefe", "src_uid": "689e7876048ee4eb7479e838c981f068", "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 if (weight <= 3) {\n console.log('NO');\n return;\n }\n\n var answer = weight % 2;\n console.log(answer ? 'NO' : 'YES');\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "30ff43a0c3c49b3441887a73e8970a4c", "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 const [n, m] = Array.from(input[0].split(' '), v => parseInt(v));\n const puzzles = Array.from(input[1].split(' '), v => parseInt(v));\n puzzles.sort((a, b) => a - b);\n \n let min = Number.MAX_SAFE_INTEGER;\n for(i = 0; i <= puzzles.length - n; i++) {\n let distance = puzzles[i + n - 1] - puzzles[i];\n if(distance < min) min = distance;\n }\n\n console.log(min);\n});", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "44c9d981789004a7114c41526107c420", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.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};\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "55d36781cb220260990aa1e7d94ee39f", "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\n\nrl.on('line', (input) => {\n rl.close();\n let line = input.split(' ');\n console.log(solve(parseInt(line[0]), parseInt(line[1])));\n});\n\n\nconst solve = (pOfShovel, rBurles) => {\n let noOfShovels = 1;\n while ((pOfShovel * noOfShovels % 10) !== 0 && ((pOfShovel * noOfShovels - rBurles) % 10 !== 0)) {\n noOfShovels++;\n }\n return noOfShovels;\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "ab6996a5f6102f695a35de8a92bdfbd7", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "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 [l, b] = Array.from(input[0].split(' '), x => parseInt(x));\n let i = 0;\n while (l <= b) {\n l *= 3;\n b *= 2;\n i++;\n }\n\n console.log(i);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e11947ca4544d7f2cb9ac76f92118c51", "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 arr = d.split(' ');\n const uniqueArr = new Set(arr);\n const ans = arr.length - uniqueArr.size;\n\n console.log(ans);\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "7dfe99255c81f2ce9766dfd1150652b5", "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 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(){\nlet n=readLine();\nlet twoGram=readLine();\nlet res=0;\nlet answer=\" \";\nfor(let i=0;i {\n /*\n method I.\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 */\n let ans = \"\", len = input.length, met = false;\n for (let i = 0; i < len - 1; i++) {\n if (input[i] == '/' && input[i + 1] != '/')\n ans += '/';\n else if (input[i] != '/') {\n ans += input[i];\n met = true;\n }\n }\n if (!met || input[len - 1] != '/')\n ans += input[len - 1];\n\n console.log(ans);\n \n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "00337107c89062c802e50a08d74af3ac", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "difficulty": 1700.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\tconst str = line.toLowerCase();\n\tconst remove = 'aoyeui';\n\tlet res = '';\n\tfor (let i = 0; i < str.length; i++) {\n\t\tif (remove.indexOf(str[i]) < 0) {\n\t\t\tres += '.' + str[i];\n\t\t}\n\t}\n\tconsole.log(res);\n\trl.close();\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "52b48ba7f4c3b97065d5e28a5a9f47b0", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "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 = 1e9 + 7;\r\n\r\nfunction main () {\r\n\tlet t = rn();\r\n\twhile (t--) {\r\n\t\tlet [n, k] = rna();\r\n\r\n\t\tlet ans = 1;\r\n\t\tfor (let i = 1; i <= k; i++)\r\n\t\t\tans = (ans * n) % MOD;\r\n\r\n\t\tconsole.log(ans);\r\n\t}\r\n}\r\n\r\n", "lang_cluster": "Javascript", "tags": ["math", "combinatorics", "bitmasks"], "code_uid": "bc5fc7512ba1fdc4b43a601390752341", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.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 ax = arr[0].split(' ')\n const a1 = parseInt(ax[0])\n const a2 = parseInt(ax[1])\n const a3 = parseInt(ax[2])\n const a4 = parseInt(ax[3])\n\n var f = false\n\n if(a1 + a2 == a3 + a4) f = true\n else if(a1 + a3 == a2 + a4) f = true\n else if(a1 + a4 == a3 + a2) f = true\n else if(a1 + a2 + a3 == a4) f = true\n else if(a1 + a2 + a4 == a3) f = true\n else if(a1 + a4 + a3 == a2) f = true\n else if(a2 + a4 + a3 == a1) f = true\n\n if(f) console.log('YES')\n else console.log('NO')\n}) ", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "56d79a7e153376c2a8f3805f1ca117df", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "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 tableCard;\n\nrl.on('line', (d) => {\n if (c === 0) {\n tableCard = d;\n c++;\n return;\n }\n\n const cards = d.split(' ');\n let ans = 'NO';\n\n for (let i = 0; i < cards.length; i++) {\n if (tableCard[0] === cards[i][0] || tableCard[1] === cards[i][1]) {\n ans = 'YES';\n break;\n }\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "8866111e35da9f38563279deed99661d", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "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 const arr = readLine()\n .split(\" \")\n .map((n) => parseInt(n));\n let found = false;\n const total = arr.reduce((s, n) => s + n, 0);\n\n for (let i = 0; i < 4; i++) {\n for (let j = i + 1; j < 5; j++) {\n for (let k = j + 1; k < 6; k++) {\n const sum = arr[i] + arr[j] + arr[k];\n const otherSum = total - sum;\n if (sum === otherSum) {\n found = true;\n break;\n }\n }\n }\n }\n\n if (found) console.log(\"YES\");\n else console.log(\"NO\");\n}\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "70b20aa401077fd44cf2ab8cf6c64c95", "src_uid": "2acf686862a34c337d1d2cbc0ac3fd11", "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 terminal: false\n});\n\nrl.on('line', line => {\n const str = line.toLowerCase().slice(' ');\n // console.log(str);\n const remove = 'aoyeui';\n let res = ' ';\n for (let i = 0; i < str.length; i++) {\n if (remove.indexOf(str[i]) < 0) {\n res += '.' + str[i];\n }\n }\n console.log(res);\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "a880959c835a39e692db3442ed83fb44", "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\n\nrl.on('line', (input) => {\n let line = input.split(' ');\n let limakW = parseInt(line[0]);\n let bobW = parseInt(line[1]);\n rl.close();\n console.log(solve(limakW, bobW));\n\n});\n\n\nconst solve = (limakW, bobW) => {\n let year = 0;\n while (limakW <= bobW) {\n limakW *= 3;\n bobW *= 2;\n year++;\n }\n return year;\n};", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "df69e4bf85a006d0b76445f63b8ae962", "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 input = [];\nreadLine.on('line', line => input.push(line));\nconst mathHelp = () => {\n let s= input.toString();\n let string = s.split('+');\n string.sort();\n console.log(string.join('+'));\n};\nreadLine.on('close', mathHelp);", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "e2a5c6b786705ea6cef1548f4cd8b3de", "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 console.log(Math.floor(+d / 2) + 1);\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "e4b36b867bd86773dd6eccfc9ea1af3d", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "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\n\tif ((n & 1) === 1) {\n\t\tconsole.log(0);\n\t} else {\n\t\tconsole.log(1 << (n / 2));\n\t}\n}\n", "lang_cluster": "Javascript", "tags": ["math", "dp"], "code_uid": "0843c776c45f07be70abb38ecb354df6", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "difficulty": 1000.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 str= readline();\n let unique = new Set(str);\n let result = unique.size %2 ===0? \"CHAT WITH HER!\":\"IGNORE HIM!\";\n console.log(result);\n return;\n}", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "797985e320606a16725832ab6a0d61d6", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "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', line1 => {\n var arr = line1.split(' ');\n var plateSide = parseInt(arr.splice(-1));\n var sides = arr.map(item => parseInt(item));\n // console.log(plateSide, sides);\n \n var [isCoversFirstSide, forFirstSide] = prepareResult(sides[0], plateSide);\n var [isCoversSecondSide, forSecondSide] = prepareResult(sides[1], plateSide);\n\n // console.log(isCoversFirstSide, forFirstSide, isCoversSecondSide, forSecondSide);\n\n var result = forFirstSide * forSecondSide;\n\n var needCorner = 0;\n\n if (!isCoversFirstSide) {\n result += forSecondSide;\n needCorner += 1;\n }\n\n if (!isCoversSecondSide) {\n result += forFirstSide;\n needCorner += 1;\n }\n\n if (needCorner === 2) result += 1;\n\n console.log(result);\n\n rl.close();\n});\n\nfunction prepareResult(sideSize, plateSize) {\n if (sideSize <= plateSize) return [true, 1];\n\n var platesForSideFloat = sideSize / plateSize;\n var plateForSideInt = parseInt(platesForSideFloat);\n var isCovers = platesForSideFloat === plateForSideInt;\n\n return [isCovers, plateForSideInt];\n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "cf1cdd36dbf35d3fa8725da0aff49bb3", "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 main() {\n\tlet n = readLine().split('');\n\tlet ld = 0;\n\tn.forEach(d => {\n\t\tif (+d === 4 || +d === 7) {\n\t\t\tld++;\n\t\t}\n\t});\n\n\tif (ld === 4 || ld === 7) console.log('YES');\n\telse console.log('NO');\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "51d0d152a72e1b3e985774f127023b34", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "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 , a , b , c ;\n res = 0 ;\n a = Math.max( this.n , this.m ) ;\n for( i = 0 ; i <= a ; i++ ) {\n \tfor( j = 0 ; j <= a ; j++ ) {\n \t\tb = i * i + j ;\n \t\tc = i + j * j ;\n \t\tif( b == this.n && c == this.m ) {\n \t\t\tres++ ;\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.n = irObj.nextInt();\n this.m = 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"], "code_uid": "7def56bfc69206cc65bf73870839b5e2", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "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 [k,n,w] = readAsIntList();\n let total = 0;\n for(let i = 1; i <= w; i++) {\n total += k * i;\n }\n console.log(Math.max(total - n, 0));\n}\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "11f12313021aec59367e4a5a298db1f0", "src_uid": "e87d9798107734a885fd8263e1431347", "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 \u201aThere 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] % 2 == 1 && one[1] % 2 == 1){\n myout((one[0] * one[1] - 1) / 2);\n }else{\n myout((one[0] * one[1]) / 2);\n }\n}\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "d888b86d9cade8552c68e138d582413f", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "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 a,b;\nfunction main() {\n [a,b] = lines[0].map(x => parseInt(x))\n predict([\"1<=a<=b<=10\"])\n let years = 0\n for (;;a=a*3,b=b*2,years++) {\n if (a <= b ){\n continue;\n }\n else break;\n }\n print(years)\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "00b4933372fdf2082eaa6023607b0e2a", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "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, m, a] = splbsi(input[0]);\n console.log(parseInt(Math.ceil(m / a) * Math.ceil(n / a)));\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "3a697ec04dd230a4c3759eb697d2d59e", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\nconst solve = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\nlet data = [];\nconst main = () => {\n solve.question('', (value) => {\n data = value.split(' ').map(Number);\n var res = data[0] * data[1];\n res /= 2;\n console.log(Math.floor(res));\n solve.close();\n })\n}\nmain()", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "c8e46808025181888eaa8afd3e59c882", "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}\n\nfunction main() {\n let numberString = readLine();\n let numberArray = numberString.split('');\n let luckyDigits = [];\n for (let i = 0; i < numberArray.length; i++) {\n if (numberArray[i] === '7' || numberArray[i] === '4') {\n luckyDigits.push(numberArray[i]);\n }\n }\n if (luckyDigits.length === 7 || luckyDigits.length === 4) {\n console.log('YES');\n } else {\n console.log('NO');\n }\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "55bae58347bb910dfd1e880592dbc60e", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main(stdin) {\n var _a = stdin.split(\" \").map(function (v) { return parseInt(v); }), n = _a[0], m = _a[1], a = _a[2];\n console.log(Math.ceil(n / a) * Math.ceil(m / a));\n}\nmain(require(\"fs\")\n .readFileSync(0, \"utf-8\")\n .trim());\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "c553a16b60328aff1a29873730a8b29d", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\nvar z = readline.createInterfrace\nvar r = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\nvar b = [];\nr.on('line', function (line) {\n b.push(line);\n if(b.length == 2){\n r.close();\n\n bain();\n }\n});\nfunction bain(){\n let a = \"\";\n for(let k = 0; k i && 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 })", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "58bceb76746c0de8c48a91338db841db", "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 k = parseInt(input[0]);\n const l = parseInt(input[1]);\n const m = parseInt(input[2]);\n const n = parseInt(input[3]);\n const d = parseInt(input[4]);\n\n let answ = 0;\n for (let i = 1; i <= d; i += 1) {\n if (i % k === 0 || i % l === 0 || i % m === 0 || i % n === 0) answ += 1;\n }\n\n console.log(answ);\n});", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "3945593c938588cf4e794e9af813e897", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "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\tvar tableCard = input[0].split(\"\");\n\tvar tableValue = tableCard[0];\n\tvar tableSuit = tableCard[1];\n\tvar handCards = input[1].split(\" \");\n\t\n\tfor (var i = 0; i < 5; i++) {\n\t\tif (handCards[i][0] == tableValue || handCards[i][1] == tableSuit) {\n\t\t\tconsole.log(\"YES\");\n\t\t\treturn;\n\t\t}\n\t}\n\tconsole.log(\"NO\");\n}", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "44337084490ffcfaab8d2b75b72d1543", "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\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": "9860604224458d77adc1eb9a3fde3e22", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "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 const testCases = data[0] * 1;\n let i = 1;\n while (i <= testCases) {\n let a = data[i].trim();\n // const n = data[i] * 1;\n // const k = a[1];\n // let s = data[i + 1].trim().split(' ').map(Number);\n // s.sort((a, b) => b - a);\n let press = 0;\n out:\n for (let j = 1; j < 10; j += 1) {\n let k = j + '';\n while (k.length <= 4) {\n press += k.length;\n if (k === a) {\n break out;\n } else k += j;\n }\n }\n console.log(press);\n i += 1;\n }\n}", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "1ad1b9b6ff7e7a8b291eee3abecd9632", "src_uid": "289a55128be89bb86a002d218d31b57f", "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\tif (count === 5) break;\n\t\t}\n\t}\n\tcount === 5 ? console.log('YES') : console.log('NO');\n};\n", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "7856e1f29ed24438ac032dcabc241ef7", "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})\nreadline.question(\"\",ans=>{\n ans=ans.split(\" \")\n \n var each_Banana_money=ans[0]\n var initial_Money=ans[1]\n var banana_Want=ans[2]\n \n var res=calculate(-initial_Money,banana_Want,each_Banana_money)\n console.log(res>-1?res:0)\n readline.close()\n})\n\n\nfunction calculate(total_Money,banana_Want,each_Banana_money){\n return banana_Want==0?total_Money:calculate(total_Money+(each_Banana_money*banana_Want),banana_Want-1,each_Banana_money)\n}", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "361e6b66127d2ed09a128ea71142c921", "src_uid": "e87d9798107734a885fd8263e1431347", "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 first=+readLine()\n\tlet second=+readLine()\n\tlet third = first+second\n\tlet newFirst='', newSecond='' , newThird2=''\n\tfor(let char of first.toString()) \n\t\tif(char!=='0')\n\t\t\tnewFirst+=char\n\tfor(let char of second.toString())\n\t\t\tif(char!=='0')\n\t\t\t\tnewSecond+=char\t\t\n\tfor(let char of third.toString())\n\t\tif(char!=='0')\n\t\t\tnewThird2+=char\n\tlet newThird=+newFirst + (+newSecond)\n\n\tif(+newThird2===newThird)\n\t\tconsole.log('YES')\n\telse console.log('NO')\n\t\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "d2729083de8443b6f65da34fe3a04839", "src_uid": "ac6971f4feea0662d82da8e0862031ad", "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\nfunction test(t) {\n if (t < 1 || t > 100) {\n console.log(\"input error\");\n process.exit();\n }\n}\n\nreadline.on(\"line\", (input) => {\nreadline.close()\n////////////////////////////////////////////////////////////////\ntest(input);\n\nfor (let i = 1; i < input; i++) {\n if (i % 2 == 0) {\n let m = input - i;\n if (m % 2 == 0) {\n console.log(\"YES\");\n process.exit();\n }\n }\n}\nconsole.log(\"NO\")\n \n})\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "63797bfd482f0fcb01067ec35c42cdc2", "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(\"\", (firstLine) => {\n const [n, k] = firstLine.split(\" \").map((numStr) => parseInt(numStr));\n\n rl.question(\"\", (scopeListString) => {\n let result = 0;\n const scopeList = scopeListString\n .split(\" \")\n .map((numStr) => parseInt(numStr));\n let scopesOfWinners = scopeList.slice(0, k);\n\n if (scopesOfWinners[0] > 0) {\n const scopesOfAdditionalParticipans = scopeList.slice(k);\n\n scopesOfAdditionalParticipans.forEach((scope) => {\n if (scope !== scopesOfWinners[scopesOfWinners.length - 1]) {\n return;\n }\n scopesOfWinners.push(scope);\n });\n\n result = scopesOfWinners.length;\n }\n\n scopesOfWinners = scopesOfWinners.filter((n) => n > 0);\n result = scopesOfWinners.length;\n\n console.log(result);\n rl.close();\n });\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e1ebf4225758578c5dd27a18ec35213e", "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 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 pages = readLine()\n\t\t.split(' ')\n\t\t.map(x => x >> 0);\n\tlet i = 0,\n\t\ts = 0,\n\t\td = 0;\n\twhile (true) {\n\t\ts += pages[i++];\n\t\tif (s >= n) {\n\t\t\td = i;\n\t\t\tbreak;\n\t\t}\n\t\tif (i % 7 === 0) i = 0;\n\t}\n\tconsole.log(d);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0e25c077687a54a7c73987ae1d8e8680", "src_uid": "007a779d966e2e9219789d6d9da7002c", "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=o.default.readFileSync(\"input.txt\").toString().trim().split(\"\\n\").map((t=>t.trim())),t(),o.default.writeFileSync(\"output.txt\",l),console.log(l),void(o.default.readFileSync(\"expected.txt\").toString().trim()==l.trim()&&console.log(\"\u2705 AC!\"));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(l)}))};function f(){return i[s++]}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", "implementation"], "code_uid": "289f6f1fd2a841bdf9ebb1a1f8fb82c7", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require(\"readline\");\r\nconst rl = readline.createInterface({\r\n input: process.stdin,\r\n output: process.stdout\r\n})\r\nlet input = [];\r\nrl.on('line', line => {\r\n input.push(line);\r\n})\r\nrl.on('close', line => {\r\n var t = Number(input[0]);\r\n var mod = 10 ** 9 + 7;\r\n for (var j = 1; j < input.length; j++) {\r\n var [n, k] = input[j].split(\" \").map((i) => {\r\n return Number(i);\r\n });\r\n var product = 1;\r\n for (var i = 1; i <= k; i++) {\r\n product = (product * n % mod);\r\n }\r\n console.log(product);\r\n }\r\n})", "lang_cluster": "Javascript", "tags": ["math", "combinatorics", "bitmasks"], "code_uid": "2e662bcc13712f0e885bb9ed1a5265db", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.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=>{return data.length>0})\n\n\ntxt.forEach(element => {\n football(element)\n});\n\nfunction football(str){\n if(str.match(\"0000000\")!=null ||str.match(\"1111111\")!=null){\n console.log(\"YES\");\n }else{\n console.log(\"NO\");\n }\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "681475c06cf95bf2f5a6c443a0dacefc", "src_uid": "ed9a763362abc6ed40356731f1036b38", "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 => input.push(line));\n\nfunction fact(n) {\n if (n-1 === 0) return 1;\n return n * fact(n-1);\n}\n\nRL.on('close', () => {\n const [a, b] = input[0].split(' ').map(x => parseInt(x));\n\n console.log(fact(Math.min(a, b)));\n});", "lang_cluster": "Javascript", "tags": ["math", "implementation", "number theory"], "code_uid": "96d598ef2a561b509345cb666d7ec693", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6", "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(n)\n// Space complexity: O(n)\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": "4ae615a63759c635a430fd3257882cf0", "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 const [n, k] = Array.from(input[0].split(' '), v => parseInt(v));\n let center = Math.round(n / 2);\n if (k <= center) console.log(k * 2 - 1);\n else console.log(2 * (k - center));\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "bc8f8e4c49e250433789cb1d536694dd", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "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 nums = readLine().split(' ').map(Number);\n let [n, m] = nums; // [2, 5]\n for (let i = n + 1; i <= m; i++) {\n // console.log(i);\n if (isPrime(i) && i !== m) {\n console.log('NO');\n return;\n }\n if (isPrime(i)) {\n if (i === m) {\n // console.log(isPrime(i));\n console.log('YES');\n return;\n }\n }\n }\n console.log('NO');\n}\n\nfunction isPrime(number) {\n if (number <= 1) {\n return false;\n }\n for (let i = 2; i < number; i++) {\n if (number % i === 0) {\n return false;\n }\n }\n return true;\n}\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "45bc8c8fdc58ba73c9e10f56e88dda3f", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var inputs = null;\n//let inputs = ['8'];\nfunction main(inputs) {\n var weight = parseInt(inputs[0]);\n if (weight == 2)\n return console.log('NO');\n for (var i = 2; i < 50; i += 2) {\n if (weight % 2 == 0)\n return console.log('YES');\n }\n console.log('NO');\n}\n// Do not change this\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);\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "50e4851887c736743ecf8bd1e45f43ce", "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 const denominations = [100, 20, 10, 5, 1];\n let sum = 0;\n num = Number(line);\n denominations.forEach(bill => {\n while(num >= bill) {\n sum += 1;\n num -= bill;\n }\n });\n console.log(sum);\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["greedy", "dp"], "code_uid": "2d7ec2727afbbe36c5493b802cb3c5d8", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "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": "edd05f5f38877f53a7e6387cdc74274c", "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863", "difficulty": 900.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\tthis.calc = function() {\n\t\tvar i , fl , idx , j , crr , cnt , k ;\n\t\twhile( true ) {\n\t\t\tfl = 0 ;\n\t\t\tfor( i = 0 ; i < this.cn ; i++ ) {\n\t\t\t\tcnt = 1 ;\n\t\t\t\tfor( j = i + 1 ; j < this.cn ; j++ ) {\n\t\t\t\t\tif( this.brr[ i ] != this.brr[ j ] ) {\n\t\t\t\t\t\tbreak ;\n\t\t\t\t\t}\n\t\t\t\t\tcnt++ ;\n\t\t\t\t\tk = j ;\n\t\t\t\t}\n\t\t\t\tif( cnt >= 3 ) {\n\t\t\t\t\tidx = 0 ;\n\t\t\t\t\tcrr = new Array() ;\n\t\t\t\t\tfor( j = 0 ; j < i ; j++ ) {\n\t\t\t\t\t\tcrr.push( this.brr[ j ] ) ;\n\t\t\t\t\t\tidx++ ;\n\t\t\t\t\t}\n\t\t\t\t\tfor( j = k + 1 ; j < this.cn ; j++ ) {\n\t\t\t\t\t\tcrr.push( this.brr[ j ] ) ;\n\t\t\t\t\t\tidx++ ;\n\t\t\t\t\t}\n\t\t\t\t\tthis.brr = crr ;\n\t\t\t\t\tthis.cn = idx ;\n\t\t\t\t\tfl = 1 ;\n\t\t\t\t\tbreak ;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif( fl == 0 ) {\n\t\t\t\tbreak ;\n\t\t\t}\n\t\t}\n\t\treturn this.n - this.cn ;\n\t} ;\n\t\n this.solveCase = function() {\n var res , i , j , fl , cn , temp ;\n res = 0 ;\n //at the start\n this.cn = 0 ;\n this.brr[ this.cn++ ] = this.x ;\n for( i = 0 ; i < this.n ; i++ ) {\n \tthis.brr[ this.cn++ ] = this.arr[ i ] ;\n }\n res = Math.max( res , this.calc() ) ;\n //at the end\n this.cn = 0 ;\n for( i = 0 ; i < this.n ; i++ ) {\n \tthis.brr[ this.cn++ ] = this.arr[ i ] ;\n }\n this.brr[ this.cn++ ] = this.x ;\n res = Math.max( res , this.calc() ) ;\n //anywhere in the middle\n for( j = 0 ; j < this.n - 1 ; j++ ) {\n \tthis.cn = 0 ;\n\t for( i = 0 ; i <= j ; i++ ) {\n\t \tthis.brr[ this.cn++ ] = this.arr[ i ] ;\n\t }\n\t this.brr[ this.cn++ ] = this.x ;\n\t for( i = j + 1 ; i < this.n ; i++ ) {\n\t \tthis.brr[ this.cn++ ] = this.arr[ i ] ;\n\t }\n \tres = Math.max( res , this.calc() ) ;\n \t//print( j , res , this.cn ) ;\n\t }\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.k = irObj.nextInt();\n this.x = irObj.nextInt();\n for( i = 0 ; i < this.n ; i++ ) {\n this.arr[ i ] = 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": ["two pointers", "brute force"], "code_uid": "fbe14449c0c2e210433d50695c1fdf77", "src_uid": "d73d9610e3800817a3109314b1e6f88c", "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('', (input) => {\n let weight = (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": "ae65e001bb7f064926569078b04768fe", "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\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 if (n > m) {\n console.log(n - m); return;\n }\n let data = {};\n data[n] = n;\n \n let find = 0;\n while (true) {\n const map = {};\n for (const i of Object.keys(data)) {\n let x = parseInt(i);\n if (x - 1 >= 1 ) {\n map[x - 1] = x-1;\n if (x - 1 === m) {\n console.log(find+1); return;\n }\n }\n if (x*2 <= m*1.5) {\n map[x * 2] =x*2;\n if (x*2 === m) {\n console.log(find+1); return;\n }\n }\n }\n data = map;\n \n find += 1;\n }\n});", "lang_cluster": "Javascript", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "99383e2a03bf4eeb0a7c807c09b99f8e", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400.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\tconst [n, t] = inputReader.readNumberArray();\n\t\n\tconst line = inputReader.readLine().split('');\n\tlet count = 0;\n\tlet i = 0;\n\t\n\t\n\twhile (1) {\n\t\tif (i >= line.length && count < t) {\n\t\t\ti = 0;\n\t\t\tcount++;\n\t\t}\n\t\tif (count === t) {\n\t\t\tbreak;\n\t\t}\n\t\tif (line[i] == \"B\" && line[i + 1] == \"G\") {\n\t\t\tlet temp = line[i];\n\t\t\tline[i] = line[i + 1];\n\t\t\tline[i + 1] = temp;\n\t\t\ti += 2;\n\t\t} else {\n\t\t\ti++;\n\t\t}\n\t\n\t}\n\tconsole.log(line.join(\"\"));\n\t\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 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\treadLine,\n\t\treadNumberArray,\n\t}\n}", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "0372cdfcf03f41a2b0e19aeceb88d7cf", "src_uid": "964ed316c6e6715120039b0219cc653a", "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 berdLang = inputs[0].trim();\n let birdLang = inputs[1].trim();\n\n let strFlag = 'NO';\n if (berdLang === birdLang.split('').reverse().join('')) {\n strFlag = 'YES';\n }\n\n return strFlag.toString();\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "25caaa0ec7fb6a9afb09909cd877f865", "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 = [];\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 const array = splitAndParseInt(input[0])\n const items = splitAndParseInt(input[1])\n const length = array[0];\n const max = array[1];\n let answer = 0;\n for(let i = 0; i <= length; i++){\n if(items[i] >= items[max - 1] && items[i] > 0){\n answer++;\n }\n }\n console.log(answer)\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "dc9f489b43c6fac3b0a929d9bf1b9c6c", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.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// 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": "a341d414db3579c7c649b4868d2de589", "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 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 \u201aThere 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 for(var i = n + 1; i < m; i++){\n if(isPrime(i)){\n myout(\"NO\");\n return;\n }\n }\n myout((isPrime(m) ? \"YES\" : \"NO\"));\n}\nfunction isPrime(val){\n if(val == null || val <= 1 || (val != 2 && val % 2 == 0)){\n return false;\n }else if(val == 2){\n return true;\n }\n var root = Math.floor(Math.sqrt(val));\n for(var i = 3; i <= root; i += 2){\n if(val % i == 0){\n return false;\n }\n }\n return true;\n}", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "4355b33de5ed21e33657e9060f6e77e9", "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 terminal: false\n});\n\nprocess.stdin.setEncoding('utf8');\nrl.once('line', line => {\n const n = line.toString().split(' ').map(Number);\n\n if (n % 2 === 0 && n > 2) console.log('YES');\n else console.log('NO');\n process.exit();\n});", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "0524ea92d100725c727d770662419c17", "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 const obj = {};\n\n for (let i = 0; i < str.length - 1; i++) {\n let pair = str[i] + str[i + 1];\n\n if (obj[pair]) {\n obj[pair]++;\n }\n else {\n obj[pair] = 1;\n }\n }\n\n let ans;\n let max = 0;\n\n Object.keys(obj).forEach(x => {\n if (obj[x] > max) {\n max = obj[x];\n ans = x;\n }\n });\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "688f0f476c3ff10af487ffc86867fddc", "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\tconst _input = parseInt(input[0], 10)\n\tlet _res = 0\n\tlet count = 1 // \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u0439\n\twhile (count <= Math.floor(_input / 2)) {\n\t\tconst it1 = _input - count // \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432\n\t\tconst it2 = it1 / count\n\t\tconst it3 = Math.floor(it1 / count)\n\t\tif (it2 === it3) {\n\t\t\t_res++\n\t\t}\n\t\tcount++\n\t}\n\tconsole.log(_res)\n})", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "ca0806cb4b8939bc3ccd4bb4d4863d07", "src_uid": "89f6c1659e5addbf909eddedb785d894", "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 scores = text.toString().trim().split(' ').map(a => parseInt(a, 10));\n const output = Math.trunc(scores[0] * scores[1] / 2);\n console.log(output);\n }\n}", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "d0bcdac48c4d14c6f0f9d44d2df41a96", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "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 number = Array.from(readLine());\n const n = 1*number.join(\"\");\n if(n % 4 === 0 || n%7 === 0 || n%47 === 0 || n%74 === 0 || n%44 === 0 || n%444 === 0 || n%447 === 0 || n%474 === 0 || n%477 === 0 || n%777 === 0 || n%774 === 0 || n%744 === 0) {\n console.log('YES');\n return;\n }\n\n let match = number.filter(n => {\n if(n === '4' || n === '7') {\n return true;\n } else {\n return false;\n }\n })\n\n if(number.length === match.length) { \n console.log('YES');\n } else {\n console.log(\"NO\");\n }\n}", "lang_cluster": "Javascript", "tags": ["brute force", "number theory"], "code_uid": "ecf4d68d319a1aa60b2d5744360d9166", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var readline = require('readline');\nvar rl = readline.createInterface(process.stdin, process.stdout);\nrl.question('', (arg)=>{\n\tlet sum = 0;\n\tif(arg>10){\n\t\tlet b = 0;\n\t\tlet a = arg;\n\t\twhile(a>10){\n\t\t\tb = b*10+9;\n\t\t\ta=a/10;\n\t\t}\n\t\ta = arg - b;\n\twhile(a!=0|| b!=0){\n\t\t\tsum = sum + a%10 + b%10;\n\t\t\ta= Math.floor(a/10);\n\t\t\tb=Math.floor(b/10);\n\t\t}\n\n\t\t}else{\n\t\t\tsum = arg;\n\t\t}\n\tconsole.log(sum);\n\trl.close();\n}); ", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "a7b48d8d60385b8593ceed5e5859d759", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "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 let str = readLine().toLowerCase();\n const vowels = { a: \"\", o: \"\", y: \"\", e: \"\", y: \"\", i: \"\", u: \"u\" };\n str = str\n .split(\"\")\n .filter((s) => {\n return vowels[s] == undefined;\n })\n .join(\".\");\n console.log(\".\" + str);\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "972cc590fe8aea79ad7d88bb187e2a06", "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 let [x, y] = d.split(' ').map(Number);\n let n1 = Math.min(x, y);\n let n2 = Math.floor((Math.max(x, y) - n1) / 2);\n\n console.log(`${n1} ${n2}`);\n});\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "092bd6aa81e575757d633501efc68020", "src_uid": "775766790e91e539c1cfaa5030e5b955", "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, t] = readLine()\n\t\t.split(' ')\n\t\t.map(x => x >> 0);\n\n\tlet queue = readLine().split('');\n\n\twhile (t--) {\n\t\tlet i = 0;\n\t\twhile (i < queue.length) {\n\t\t\tif (queue[i] === 'B' && queue[i + 1] === 'G') {\n\t\t\t\tqueue[i] = 'G';\n\t\t\t\tqueue[i + 1] = 'B';\n\t\t\t\ti += 2;\n\t\t\t} else {\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\t}\n\tconsole.log(queue.join(''));\n}\n", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "cfb1d2946cfe29bcaf2249c49728fe7d", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.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\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "1aa36ba0f62e366fdbb43ccebc52fe84", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "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 input = readline();\n const str = readline();\n let count =0;\n for (let i =0;i reg1.test(a) || reg2.test(a)) ? '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) {\n stdin.push(line);\n});\nrl.on('close', main);\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "8e4a9464c3fea043ecaace395946ab0a", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "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\nrl.on('line', (input) => {\n let n = parseInt(input);\n for (let i = 1; i * i <= n; i++){\n let eq = ((n - 1) - i - (i * i)) / (2 * i);\n if (eq === parseInt(eq) && eq > 0){\n console.log(i + \" \" + eq);\n process.exit(0);\n }\n }\n console.log(\"NO\");\n rl.close(); \n});", "lang_cluster": "Javascript", "tags": ["brute force", "math", "number theory"], "code_uid": "4984cf0c5c2ceee1911be71decb8f7d9", "src_uid": "3ff1c25a1026c90aeb14d148d7fb96ba", "difficulty": 1200.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].split(\"\").filter(data => {\n return data.length > 0\n }).map(data => {\n return data * 1\n }))\n}\n\nfunction doit(tab) {\n let t = tab.filter(data => {\n return data != 7 && data != 4;\n }).length;\n t = tab.length - t\n if (t == 4 || t == 7) {\n console.log(\"YES\");\n } else {\n console.log(\"NO\");\n }\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "87f929b5d59ca148a31aaf39991d456c", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "JavaScript", "source_code": "var root = function(dsu, v) {\n if (dsu[v] === v) {\n return v;\n } else {\n dsu[v] = root(dsu, dsu[v]);\n return dsu[v];\n }\n}\n\nvar main = function () {\n var n = parseInt(readline());\n var p = [], prev = [], next = [];\n readline().split(/\\s+/).forEach(function (t, i) {\n p.push(parseFloat(t));\n });\n\n for (var i = -1; i <= n; ++i) {\n prev[i] = next[i] = i;\n }\n\n var s = [];\n p.forEach(function(e, i) {\n s.push({pos: i, val: e});\n });\n\n s.sort(function(a, b) {\n return (a.val !== b.val) ? (a.val - b.val) : (a.pos - b.pos);\n });\n\n var ans = 0;\n var dec = 0;\n var left = n - 2;\n s.forEach(function (e, i) {\n if (left <= 0) {\n return;\n }\n \n var i = e.pos;\n next[i] = i + 1;\n prev[i] = i - 1;\n var lf = root(prev, i);\n var rg = root(next, i);\n \n var cur = e.val - dec;\n dec = e.val;\n ans += left * cur;\n left--;\n\n if (0 <= lf && lf <= rg && rg < n) {\n ans += Math.min(p[lf] - dec, p[rg] - dec);\n }\n\n return left > 0;\n });\n\n print(ans);\n};\n\nmain();\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "00cf8a8cf9265e436e7bb8b02b36a5fa", "src_uid": "e7e0f9069166fe992abe6f0e19caa6a1", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.on('data', input => {\n const arr = input.toString().split(' ');\n const m = arr[0];\n const n = arr[1];\n const a = arr[2];\n\n console.log(Math.ceil(m/a) * Math.ceil(n/a));\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "771c98793903d5208f92ffe78bb70e60", "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 const [n, m, a] = answer.split(' ').map(v => parseInt(v));\n console.log(Math.ceil(n / a) * Math.ceil(m / a));\n\n rl.close();\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "a1e47165d2a3e9233cdd6effa135b059", "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;\n\nrl.on('line', (data) => {\n let [a, b, c, d] = data.split(' ').map(Number);\n let p1Points = Math.max(3*a/10, a - (a / 250) * c);\n let p2Points = Math.max(3*b/10, b - (b / 250) * d);\n\n if (p1Points === p2Points) {\n console.log('Tie');\n }\n else if (p1Points > p2Points) {\n console.log('Misha');\n }\n else {\n console.log('Vasya');\n }\n\n count++;\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e740f1ef9353d1241d161e4672622d96", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "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 doit(txt[i]);\n}\n\nfunction doit(str) {\n while (true) {\n let r= str.match(\"WUB\");\n if(r===null){\n break;\n }else{\n let t=str.split(\"\");\n t.splice(r.index,2);\n t[r.index]=\" \";\n str=t.join(\"\");\n \n }\n }\n console.log(str.split(\" \").filter(data=>{return data.length>0}).join(\" \"));\n}", "lang_cluster": "Javascript", "tags": ["strings"], "code_uid": "8336d5132f564aab93ad98170e942059", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.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 inputArray = null\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 inputArray = inputString\r\n .trim()\r\n .split('\\n')\r\n .map((s) => s.trim())\r\n\r\n main()\r\n})\r\n\r\nfunction readline() {\r\n return inputArray[currentLine++]\r\n}\r\n\r\nfunction main() {\r\n const s = readline()\r\n for (let i = 2; i < s.length; i++) {\r\n if (\r\n (s.charCodeAt(i - 2) -\r\n 'A'.charCodeAt() +\r\n s.charCodeAt(i - 1) -\r\n 'A'.charCodeAt()) %\r\n 26 !==\r\n s.charCodeAt(i) - 'A'.charCodeAt()\r\n ) {\r\n console.log('NO')\r\n return\r\n }\r\n }\r\n console.log('YES')\r\n}\r\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "2227d67b3981f66d7d2f0f84a12e69df", "src_uid": "27e977b41f5b6970a032d13e53db2a6a", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";var readline=require(\"readline\"),extendStatics=function(r,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var n in t)t.hasOwnProperty(n)&&(r[n]=t[n])})(r,t)};\n/*! *****************************************************************************\nCopyright (c) Microsoft Corporation. All rights reserved.\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthis file except in compliance with the License. You may obtain a copy of the\nLicense at http://www.apache.org/licenses/LICENSE-2.0\n\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\nMERCHANTABLITY OR NON-INFRINGEMENT.\n\nSee the Apache Version 2.0 License for specific language governing permissions\nand limitations under the License.\n***************************************************************************** */function __extends(r,t){function n(){this.constructor=r}extendStatics(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function isFunction(r){return\"function\"==typeof r}var _enable_super_gross_mode_that_will_cause_bad_things=!1,config={Promise:void 0,set useDeprecatedSynchronousErrorHandling(r){r&&(new Error).stack;_enable_super_gross_mode_that_will_cause_bad_things=r},get useDeprecatedSynchronousErrorHandling(){return _enable_super_gross_mode_that_will_cause_bad_things}};function hostReportError(r){setTimeout((function(){throw r}),0)}var empty={closed:!0,next:function(r){},error:function(r){if(config.useDeprecatedSynchronousErrorHandling)throw r;hostReportError(r)},complete:function(){}},isArray=function(){return Array.isArray||function(r){return r&&\"number\"==typeof r.length}}();function isObject(r){return null!==r&&\"object\"==typeof r}var UnsubscriptionErrorImpl=function(){function r(r){return Error.call(this),this.message=r?r.length+\" errors occurred during unsubscription:\\n\"+r.map((function(r,t){return t+1+\") \"+r.toString()})).join(\"\\n \"):\"\",this.name=\"UnsubscriptionError\",this.errors=r,this}return r.prototype=Object.create(Error.prototype),r}(),UnsubscriptionError=UnsubscriptionErrorImpl,Subscription=function(){function r(r){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,r&&(this._unsubscribe=r)}return r.prototype.unsubscribe=function(){var t;if(!this.closed){var n=this._parentOrParents,e=this._unsubscribe,o=this._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,n instanceof r)n.remove(this);else if(null!==n)for(var i=0;ithis.total&&this.destination.next(r)},t}(Subscriber);readStdin().pipe(skip(1),take(1),map((function(r){return r.split(\" \").map((function(r){return+r}))}))).subscribe((function(r){for(var t=0,n=0,e=0,o=[],i=0;i0&&r[i-1]>0&&r[i-1]%2!=r[i]%2&&(e+=1);var p=Math.round(r.length/2),h=Math.floor(r.length/2),b=p-t,f=h-n,l=function(r,t){\"any\"===r?e+=1===t?0:1:\"even\"===r?f>=t?f-=t:e+=1:b>=t?b-=t:e+=1},d=function(r){var t=r.left,n=r.right,e=r.distance;return\"any\"===t||\"any\"===n?e+1e4:e};o.sort((function(r,t){return d(r)-d(t)})).forEach((function(r){var t=r.left,n=r.right,o=r.distance;\"even\"===t&&\"odd\"===n||\"odd\"===t&&\"even\"===n?e+=1:\"any\"===t?l(n,o):\"any\"===n?l(t,o):\"even\"===t?f>=o?f-=o:e+=2:\"odd\"===t&&(b>=o?b-=o:e+=2)})),console.log(e)}));\n", "lang_cluster": "Javascript", "tags": ["sortings", "dp", "greedy"], "code_uid": "a8c037b7ae87db12aa2f98cb8c9b6db8", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800.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 let str = input[0];\n let countQ = 0, countA = 0, answer = 0, rightQ = 0;;\n for (let i = 0; i < str.length; i += 1){\n if(str.charAt(i) === 'Q')\n countQ+=1;\n else if(str.charAt(i) === 'A')\n {\n for(let j = i; j < str.length; j += 1)\n if(str.charAt(j) === 'Q') rightQ += 1;\n answer += rightQ*countQ; \n rightQ = 0;\n }\n }\n global.console.log(answer);\n});\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "dp"], "code_uid": "e00f6d366955d39ef050a97705874a68", "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});\n\nlet pointToCompare;\nlet dot_prob;\n\nrl.on(\"line\", (input) => {\n if (!pointToCompare) {\n let temparr = input.split(\" \").map(Number)\n if (temparr[0] > temparr[1])\n pointToCompare = temparr[0]\n else pointToCompare = temparr[1]\n }\n if (pointToCompare) {\n dot_prob = (6 - pointToCompare + 1)\n\n let gcdd = gcd(dot_prob, 6)\n console.log(dot_prob / gcdd +\"/\"+ 6/gcdd)\n rl.close();\n }\n})\n\n\n\nvar gcd = function (a, b) {\n if (!b) return a;\n\n return gcd(b, a % b);\n};", "lang_cluster": "Javascript", "tags": ["math", "probabilities"], "code_uid": "250b8571d7470b8c90d03185f27a7936", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "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());\n \n console.log(Math.ceil(n / 5));\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "21c53ce987e5f2a573e4761f148965b8", "src_uid": "4b3d65b1b593829e92c852be213922b6", "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 first = readLine()\n\tlet second = readLine()\n\n\tsecond = [...second].reverse().join('')\n\tif(first===second)\n\t\tconsole.log('YES')\n\telse console.log('NO')\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "00391af0ed0f1493a8915149d84008c5", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "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\u2191\u5165\u529b \u2193\u51fa\u529b');\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 \u201aThere 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 sf = 0;\n\tvar fs = 0;\n\tfor(var i = 0; i < N - 1; i++){\n\t\tif(s[i] == \"F\" && s[i + 1] == \"S\"){\n\t\t\tfs++;\n\t\t}\n\t\tif(s[i] == \"S\" && s[i + 1] == \"F\"){\n\t\t\tsf++;\n\t\t}\n\t}\n\tif(sf > fs){\n\t\tmyout(\"YES\");\n\t}else{\n\t\tmyout(\"NO\");\n\t}\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "f05425a933967eed3617e524de33368b", "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 terminal: false\n});\n\nrl.on('line', (d) => {\n if (+d % 2 === 0) {\n console.log('Mahmoud');\n }\n else {\n console.log('Ehab');\n }\n});\n", "lang_cluster": "Javascript", "tags": ["math", "games"], "code_uid": "1f4b520cbea52ff6910373b4d2a2d6b9", "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});\nlet c = 0;\nlet n, m, r;\nlet buy, sell;\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n [n, m, r] = d.split(' ').map(Number);\n return;\n }\n\n if (c === 1) {\n c++;\n buy = Math.min(...d.split(' ').map(Number));\n return;\n }\n\n sell = Math.max(...d.split(' ').map(Number));\n\n if (buy >= sell) {\n console.log(r);\n }\n else {\n let count = 0;\n\n while (r - buy >= 0) {\n count++;\n r -= buy;\n }\n\n let ans = count * sell + r;\n\n console.log(ans);\n }\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["greedy", "implementation"], "code_uid": "0dc66616116c75117696f9edc9419cfe", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const readline = require('readline').createInterface({input: process.stdin})\nconst assert = require('assert')\n\nreadline.on(\"line\", line => {\n let counter = 1;\n let result = \"NO\";\n let input = line;\n for (let i = 0; i < input.length; i++) {\n if (input[i] === input[i + 1]) {\n counter++;\n } else if (input[i] !== input[i + 1]) {\n counter = 1;\n } \n \n if (counter === 7) {\n result = 'YES';\n break;\n } else {\n result = 'NO';\n }\n }\n console.log(result);\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "828ba6d247969a2bf8bc148f897f06b3", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.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 reg = /x{3,}/g;\n if (reg.test(str)) {\n var arr = str.match(reg);\n var count = 0;\n for (let i = 0; i < arr.length; i++) {\n count += arr[i].lastIndexOf('x') - 1;\n }\n console.log(count);\n } else {\n console.log(0);\n }\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": ["greedy", "strings"], "code_uid": "b274dc98bdb107c10732d0178738ea0c", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "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 console.log((Array.from(readLine().split(\"+\").join(\"\")).sort()).join(\"+\"));\n}", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "3480e19b0c511c36d0181805a36f029a", "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\nlet input = [];\nlet result = \"\";\n\nrl.on('line', function (line) {\n input = line.split(' ').map((el) => parseInt(el));\n if(input[0] === 2){\n \tresult = \"No\";\n }\n else if(input[0] % 2 === 0){\n \tresult = \"Yes\";\n }\n else{\n \tresult = \"No\";\n }\n rl.close();\n })\n .on('close', function () {\n console.log(result);\n process.exit();\n });\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "8cb0aaa8a0e1913c384f0a22367c0742", "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});\n\nvar input = [];\n\nrl.on('line', function (line) {\n input.push(line);\n // console.log(\"You've entered:\", line);\n});\n\nrl.on('close', function () {\n var [n, m, a] = input[0].split(' ').map(Number);\n // console.log(n, m, a);\n var result = Math.ceil(n/a) * Math.ceil(m/a);\n console.log(result);\n});", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "524e65d775b21a6f68a1bce2fd735a14", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.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});\n\nintInput.on('close', () => {\n\t//1, 5, 10, 20, 100\n\tlet result = 0;\n\tlet val = [100, 20, 10, 5, 1];\n\tfor (let i = 0; i < val.length; i++){\n\t\tlet c = num / val[i]; \n\t\tif (c >= 1) {\n\t\t\tresult += parseInt(c);\n\t\t\tnum = num % val[i]\n\t\t}\n\t\tcontinue\n\t}\n\tconsole.log(result);\n})", "lang_cluster": "Javascript", "tags": ["greedy", "dp"], "code_uid": "b85a73d39c79841a44a1ab2cbccb6938", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "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: 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": "d2215535a5ac983f39b27dfee23267df", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "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 \u201aThere 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 list = nextIntArray();\n var min = list[K - 1];\n var output = 0;\n for(var i = 0; i < N; i++){\n if(list[i] > 0 && list[i] >= min){\n output++;\n }\n }\n myout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "cd997fb41181dded29725f616da59ab3", "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\n\n\n\n\n\nrl.on('line', (input) => {\n var ans = \"\";\n var N = input.length;\n var meet = false;\n for (let i = 0; i < N - 1; i++) {\n if (input[i] == '/' && input[i + 1] != '/')\n ans += \"/\";\n\n else if (input[i] != \"/\") {\n ans += input[i];\n meet = true;\n }\n }\n if (input[N - 1] != '/' || !meet)\n ans += input[N - 1];\n\n console.log(ans);\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "a032c2bbd67c088cd43e3635c404eede", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "difficulty": 1700.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 n = +readLine();\n let result = \"\";\n let fact = 1n;\n for (let i = 2; i <= n - 1; i++) {\n fact *= BigInt(i);\n }\n const ans = fact / BigInt(Math.floor(n / 2));\n result += ans;\n console.log(result);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "combinatorics"], "code_uid": "744cb25c5b50b203b682b414354d3bf2", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "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\nlet count = 0;\nlet r, c;\n// let matrix = [];\n// const cake = [];\n\n// const 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\n// const 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\nlet row = [];\nlet col = [];\nconst cake = [];\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\n row = new Array(20).fill(1);\n col = new Array(20).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 i = 0; i < r; i++) {\n for (let j = 0; j < c; j++) {\n if (cake[i][j] === 'S') {\n row[i] = 0;\n col[j] = 0;\n }\n }\n }\n\n for (let i = 0; i < r; i++) {\n for (let j = 0; j < c; j++) {\n if (cake[i][j] === '.' && (row[i] === 1 || col[j] === 1)) {\n ans++;\n }\n }\n }\n\n console.log(ans);\n});\n\n// rl.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": "a438a2a219b7c097d79026d39e270972", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "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 rl.on('line', (line) => {\n let res = solve(Number(line)) ? 'YES' : 'NO';\n console.log(res);\n });\n};\n\nmain()", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "39e41cda2ca55be18e848e9992b55e04", "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\u2191\u5165\u529b \u2193\u51fa\u529b');\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 \u201aThere 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().split(\"W\");\n var output = [];\n for(var i = 0; i < s.length; i++){\n if(s[i] != \"\"){\n output.push(s[i].length);\n }\n }\n myout(output.length);\n myout(myconv(output, 8));\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "040ead5d05ece947ba1fc0ac77d4e1c1", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "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:n, 1:c} = {...input[0].split(' ')};\n n = parseInt(n); c = parseInt(c);\n let points = []; input[1].split(' ').forEach( i => points.push(parseInt(i)) );\n let times = []; input[2].split(' ').forEach( i => times.push(parseInt(i)) );\n let secondTimes = []; times.forEach(i => secondTimes.push(parseInt(i)));\n\n let firstPlayer = 0; let secondPlayer = 0;\n let j = n-1;\n\n for(let i = 0; i < n; i++) {\n firstPlayer += max(0, points[i] - c*times[i]);\n secondPlayer += max(0, points[j] - c*secondTimes[j]);\n \n if(i + 1 != n) {\n times[i+1] += times[i];\n }\n if(j - 1 >= 0) {\n secondTimes[j-1] += secondTimes[j];\n }\n j--;\n //console.log(`fp = ${firstPlayer}; sp = ${secondPlayer}`);\n }\n\n if(firstPlayer > secondPlayer) {\n console.log('Limak');\n } else if(secondPlayer > firstPlayer) {\n console.log('Radewoosh');\n } else \n console.log('Tie')\n});\n\nfunction max(a, b) {\n return (a > b) ? a : b;\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "56670baf31f60c3c4864d95c2ed6eba1", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use stric'\nconst readline = require('readline').createInterface({\n input: process.stdin,\n output: process.stdout\n})\nreadline.question(\"\", ans => {\n var problem = ans.split(\"+\");\n console.log(problem.sort(function(a, b){return a - b}).join(\"+\").trim());\n readline.close();\n})", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "35c55c23dbf8d316cff6b4a77965c93a", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\"use strict\";\nconst input = [];\nconst RL = require(\"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]\n .split(\"+\")\n .sort((a, b) => {\n if(a < b) {\n return -1;\n }\n if(a > b) {\n return 1;\n }\n return 0;\n })\n .join(\"+\");\n\n console.log(`${answer}`);\n});\n", "lang_cluster": "Javascript", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "f9e8374f7083f3807e50f4af9badf3b3", "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) \n divideEvenly(lines[0]);\n});\n \nfunction divideEvenly(w){\n if (w < 3 || w > 100) return console.log('NO');\n if (w % 2 === 0 ){ return console.log('YES')}\n else{ return console.log('NO');}\n}\n ", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "f4132e43e80d14820ecab3357aac9f84", "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 let num = parseInt(input[0]);\n\n if (num % 7 === 0 || num % 4 === 0 || num % 47 === 0 || num % 74 === 0 || num % 44 === 0 || num % 77 === 0\n || num % 477 === 0 || num % 774 == 0)\n console.log(`YES`);\n else\n console.log('NO');\n});", "lang_cluster": "Javascript", "tags": ["brute force", "number theory"], "code_uid": "b51b35752fa158ea3dfd23aed2a9e5b5", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.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', stdin => inputString += stdin);\r\n\r\nprocess.stdin.on('end', _ => {\r\n inputString = inputString.trim().split('\\n').map(s => s.trim());\r\n main(); \r\n});\r\n\r\nfunction readline() {\r\n return inputString[currentLine++];\r\n}\r\n\r\nfunction output(x) {\r\n if (typeof x !== 'string') {\r\n x = x.toString();\r\n }\r\n //process.stdout.write(x); // without auto '\\n' (newline)\r\n console.log(x); // with auto '\\n' (newline)\r\n}\r\n\r\nfunction main() {\r\n /*let N = readline();\r\n\r\n for (let test = 0; test < N; test++) {*/\r\n let [r, c] = readline().split(' ');\r\n r = BigInt(r);\r\n c = BigInt(c);\r\n if (c == BigInt(1)) {\r\n output(r - BigInt(1));\r\n } else {\r\n output((c - BigInt(1)) * r);\r\n }\r\n /*}*/\r\n}", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "c9cf811f08061fae628e5a7385ccd3f1", "src_uid": "a91aab4c0618d036c81022232814ef44", "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 x = readLine() >> 0;\n\tlet bec = x\n\t\t.toString(2)\n\t\t.split('')\n\t\t.reduce((a, c) => a + (c >> 0), 0);\n\tconsole.log(bec);\n}\n", "lang_cluster": "Javascript", "tags": ["bitmasks"], "code_uid": "9bd035d2d7af42eb297cec3e72ae75d9", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function solve(a, b) {\n let year = 0;\n while(a <= b) {\n year += 1;\n a *= 3;\n b *= 2;\n }\n return year;\n}\n\n\nlet line = '';\n\nprocess.stdin.on('data', data => line += data);\n\nprocess.stdin.on('end', () => {\n const [a, b] = line.split(' ').map(v => Number.parseInt(v));\n console.log(solve(a, b));\n});\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0853031f8c913765cdc80516f8c634cb", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "//HQ9+\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];\n \n for(let i in lines) {\n \tif('HQ9'.indexOf(lines[i]) != -1) {\n \t\tprocess.stdout.write(\"YES\");\n \t\treturn;\n \t}\n }\n\n process.stdout.write(\"NO\");\n return;\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "53260a874396b392ca7ee82b4cf4c7ea", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "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\nrl.on('line', (input) => {\n let line = input.split(' ');\n let y = parseInt(line[0]);\n let w = parseInt(line[1]);\n let max = y > w ? y : w;\n rl.close();\n let n = 6 - max + 1;\n let d = 6;\n let ans = solve(n, d);\n console.log(`${ans[0]}/${ans[1]}`)\n\n});\n\n\nconst getLCD = (x, y) => {\n let min = x < y ? x : y;\n for (let i = min; i > 0; i--) {\n if (x % i === 0 && y % i === 0) return i;\n }\n return 1;\n}\nconst solve = (n, d) => {\n let lcd = getLCD(n, d);\n return [n / lcd, d / lcd];\n}", "lang_cluster": "Javascript", "tags": ["math", "probabilities"], "code_uid": "8abb4df5ae1e21d2c2f9e6bbaee98d0b", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const rl = require(\"readline\").createInterface({\r\n input: process.stdin,\r\n output: process.stdout,\r\n});\r\n\r\nlet input = [];\r\nrl.on(\"line\", function (line) {\r\n input.push(line);\r\n}).on(\"close\", function () {\r\n solution(input);\r\n process.exit();\r\n});\r\n\r\nfunction solution(input) {\r\n let [N, X] = input[0].split(\" \");\r\n N = Number(N);\r\n X = BigInt(X);\r\n const dist = new Map();\r\n dist.set(X, 0);\r\n queue = [X];\r\n while (queue.length > 0) {\r\n const val = queue.shift();\r\n const str = String(val);\r\n let splited = new Set(str.split(\"\"));\r\n\r\n if (str.length === N) {\r\n console.log(dist.get(val));\r\n return;\r\n }\r\n\r\n splited.delete(\"0\");\r\n if (splited.has(1) && splited.size === 1) {\r\n break;\r\n }\r\n splited.delete(\"1\");\r\n\r\n for (const s of splited) {\r\n const nextVal = val * BigInt(s);\r\n if (!dist.has(nextVal)) {\r\n dist.set(nextVal, dist.get(val) + 1);\r\n queue.push(nextVal);\r\n }\r\n }\r\n }\r\n console.log(-1);\r\n}\r\n", "lang_cluster": "Javascript", "tags": ["brute force", "dfs and similar", "shortest paths", "dp", "data structures"], "code_uid": "40a5f9e20d83e5e8f7f166f32a8bb2ec", "src_uid": "cedcc3cee864bf8684148df93804d029", "difficulty": 1700.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": "b6df90cda7fbd0b8c3f285190d4535b7", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.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": "1b8482502e86b690f5450059fc5bf681", "src_uid": "289a55128be89bb86a002d218d31b57f", "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 = readLine()\n .split(' ')\n .map(v => parseInt(v))\n .sort((x, y) => {\n return y - x;\n });\n\n let a = n[0];\n let b = n[1];\n if (a == b) {\n console.log(a, 0);\n } else {\n console.log(b, Math.floor((a - b) / 2));\n }\n}", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "345f13996d35ac51163d7323a893505f", "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 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 \u201aThere 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 n = one[1];\n var w = one[2];\n var sum = 0;\n for(var i = 0; i < w; i++){\n sum += (i + 1) * k;\n }\n myout(Math.max(0, sum - n));\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "implementation"], "code_uid": "8d7ac25217619190bae34348fad7a539", "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 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 = 5;\n var arr = [];\n var ans = 0;\n while (T--) {\n var row = readLine().split(\" \").map(Number);\n arr.push(row);\n }\n for (let row = 0; row < 5; row++) {\n for (let col = 0; col < 5; col++) {\n if (arr[row][col] === 1) {\n ans = Math.abs(2 - row) + Math.abs(2 - col);\n }\n }\n }\n console.log(ans);\n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "15637ce946fc89eb80d5a29e2ffc5f8a", "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\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 buyAShovel(x[0],x[1]);\n}\n\nfunction buyAShovel(k, r) {\n let n = 1;\n k=+k;\n r=+r;\n\n while (!((n * k) % 10 === 0 || (n * k) % 10 === r)) {\n n++;\n }\n console.log(n);\n\n return n;\n}\n\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "329057781b49f8a1c69642780e49ea52", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "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 s = nl.line();\n\tlet flag = s.split('1').every(x => x.length < 3 && (x.length == 0 || x == '4' || x == '44'));\n\tflag = flag && s.charAt(0) !== '4';\n\tconsole.log(flag?'YES':'NO');\n\n};\n\nprocess.stdin.on('end', sol);\n", "lang_cluster": "Javascript", "tags": ["brute force", "greedy"], "code_uid": "9a0cd5ebadd9f4173c35b1df35528c92", "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 \n readline.question(\"\", (_input) => {\n const input = _input.split(' ').map(Number);\n digiGame(input[0], input[1], input[2]);\n });\n \n \n const 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 \n ", "lang_cluster": "Javascript", "tags": ["math", "constructive algorithms", "games"], "code_uid": "dda133a14e39e92c16f69aad82d16f65", "src_uid": "90b9ef939a13cf29715bc5bce26c9896", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "let fs = require('fs');\n\nlet txt = fs.readFileSync(0, \"utf-8\").split(\"\\n\").filter(data => data.length > 0);\nfor (let i = 0; i < txt.length; i++) {\n let info = txt[i].split(\" \").filter(data => data.length > 0).map(data => data * 1);\n doit(info[0], info[1]);\n}\n\nfunction doit(x, y) {\n let player = 1;\n let grid = new Array(y).fill(0);\n grid.forEach((data, index) => {\n grid[index] = new Array(x).fill(true);\n });\n while (true) {\n let test = true;\n for (let i1 = 0; i1 < y; i1++) {\n for (let i = 0; i < x; i++) {\n if (grid[i1][i] === true) {\n grid[i1][i] = false;\n test = false;\n player *= -1;\n for (let i3 = 0; i3 < x; i3++) {\n grid[i1][i3] = false;\n }\n for (let i4 = 0; i4 < y; i4++) {\n grid[i4][i] = false;\n }\n break;\n }\n }\n if (!test) break;\n\n }\n\n if (test) break;\n }\n if (player == 1) {\n console.log(\"Malvika\");\n } else {\n console.log(\"Akshat\");\n }\n\n\n\n\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "b68ecf8423393839394a8a12b02e0a61", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "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});\nrl.on('line', (inputString) => {\n let numberOfSquares = parseInt(inputString);\n rl.close();\n console.log(findTheNumberOfLinesForLady(numberOfSquares));\n process.exit(0);\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": "11dce5c764dc6fa82af050c86452dc9a", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "var stdin = process.openStdin();\n\nstdin.addListener(\"data\", function(d) {\n console.log(findn(d.toString().trim()));\n });\n \nfunction findn(str){\n const v = ['a','e','i','o','u'];\n let total = 0;\n for(i of str){\n const int = parseInt(i);\n if(v.includes(i) || (int && int % 2 === 1)){\n total++;\n }\n }\n \n return total;\n}", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "6903b504f4d7f14db3cd98137000896d", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// define __esModule on exports\n/******/ \t__webpack_require__.r = function(exports) {\n/******/ \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n/******/ \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n/******/ \t\t}\n/******/ \t\tObject.defineProperty(exports, '__esModule', { value: true });\n/******/ \t};\n/******/\n/******/ \t// create a fake namespace object\n/******/ \t// mode & 1: value is a module id, require it\n/******/ \t// mode & 2: merge all properties of value into the ns\n/******/ \t// mode & 4: return value when already ns object\n/******/ \t// mode & 8|1: behave like require\n/******/ \t__webpack_require__.t = function(value, mode) {\n/******/ \t\tif(mode & 1) value = __webpack_require__(value);\n/******/ \t\tif(mode & 8) return value;\n/******/ \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n/******/ \t\tvar ns = Object.create(null);\n/******/ \t\t__webpack_require__.r(ns);\n/******/ \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n/******/ \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n/******/ \t\treturn ns;\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = \"./sources/hackerrank/algorithms/practice/strings/highest-value-palindrome-copy/index.js\");\n/******/ })\n/************************************************************************/\n/******/ ({\n\n/***/ \"./helpers/input-manager.js\":\n/*!**********************************!*\\\n !*** ./helpers/input-manager.js ***!\n \\**********************************/\n/*! exports provided: InputManager */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"InputManager\", function() { return InputManager; });\nconst fs = __webpack_require__(/*! fs */ \"fs\");\n\nclass InputManager {\n static getInput() {\n return new Promise((resolve) => {\n let input = '';\n\n if (fs.existsSync('./input.txt')) {\n input = fs.readFileSync('./input.txt').toString();\n resolve(this.parseInputString(input));\n } else {\n process.stdin.resume();\n process.stdin.setEncoding('utf-8');\n process.stdin.on('data', inputStdin => {\n input += inputStdin;\n });\n\n process.stdin.on('end', () => {\n resolve(this.parseInputString(input));\n });\n }\n });\n }\n\n static parseInputString(input) {\n return input.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n }\n}\n\n/***/ }),\n\n/***/ \"./helpers/solution-manager.js\":\n/*!*************************************!*\\\n !*** ./helpers/solution-manager.js ***!\n \\*************************************/\n/*! exports provided: SolutionManager */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"SolutionManager\", function() { return SolutionManager; });\nclass SolutionManager {\n static printSolution(solutionFn) {\n let result = solutionFn();\n if (typeof result !== 'undefined') {\n if (Array.isArray(result)) {\n result.forEach(v => console.log(v));\n } else {\n console.log(result);\n }\n }\n }\n}\n\n/***/ }),\n\n/***/ \"./sources/hackerrank/algorithms/practice/strings/highest-value-palindrome-copy/index.js\":\n/*!***********************************************************************************************!*\\\n !*** ./sources/hackerrank/algorithms/practice/strings/highest-value-palindrome-copy/index.js ***!\n \\***********************************************************************************************/\n/*! no exports provided */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _helpers_solution_manager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../../../../helpers/solution-manager */ \"./helpers/solution-manager.js\");\n/* harmony import */ var _helpers_input_manager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../../../../helpers/input-manager */ \"./helpers/input-manager.js\");\n\n\n\n_helpers_input_manager__WEBPACK_IMPORTED_MODULE_1__[\"InputManager\"].getInput().then((input) => _helpers_solution_manager__WEBPACK_IMPORTED_MODULE_0__[\"SolutionManager\"].printSolution(() => {\n let [n, a, b] = input.shift().split(' ').map(v => Number(v));\n let suits = input.shift().split(' ').map(v => Number(v));\n let costs = [a, b];\n let totalCost = 0;\n let i = 0;\n\n for (i = 0; i < Math.floor(n / 2); i++) {\n let mirrorIndex = n - 1 - i;\n\n if (suits[i] !== suits[mirrorIndex]) {\n if (suits[mirrorIndex] !== 2 && suits[i] !== 2) {\n return -1;\n }\n\n let colorIndex = suits[mirrorIndex] === 2 ? mirrorIndex : i;\n totalCost += costs[mirrorIndex === colorIndex ? suits[i] : suits[mirrorIndex]];\n } else if (suits[mirrorIndex] === 2 && suits[i] === 2) {\n totalCost += Math.min(a, b) * 2;\n }\n }\n\n if (suits[i] === 2 && n % 2 !== 0) {\n totalCost += Math.min(a, b);\n }\n\n return totalCost;\n}));\n\n/***/ }),\n\n/***/ \"fs\":\n/*!*********************!*\\\n !*** external \"fs\" ***!\n \\*********************/\n/*! no static exports found */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"fs\");\n\n/***/ })\n\n/******/ });\n//# sourceMappingURL=index.built.js.map", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "b2162e56c81bbbb9b46d292ec7ddb80c", "src_uid": "af07223819aeb5bd6ded4340c472b2b6", "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 arr = [4, 7]\nfor (let i = 0; i < 6; i++) {\n arr.push(arr[i] * 10 + 4)\n arr.push(arr[i] * 10 + 7)\n}\nlet result, n\nrl.on('line', (input) => {\n n = input\n for (let i = 0; i < arr.length; i++) {\n if (+n % arr[i] == 0) {\n result = 'YES'\n break\n } else {\n result = 'NO'\n }\n }\n console.log(result)\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["brute force", "number theory"], "code_uid": "e92c4629b7e7256a44f5d24f5d9daab7", "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\nconst store = {};\n\nfunction main() {\n\tlet [n, a, b] = readLine()\n\t\t.split(' ')\n\t\t.map(x => x >> 0);\n\tlet m = n - a;\n\n\tif (m > b) {\n\t\tconsole.log(b + 1);\n\t} else {\n\t\tconsole.log(m);\n\t}\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "4c75d220fed71bd51c9dbcfe3027733a", "src_uid": "51a072916bff600922a77da0c4582180", "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 let str = readLine();\n str = str.toLowerCase();\n const vowels = [\"a\", \"o\", \"y\", \"e\", \"u\", \"i\"];\n\n const arr = str.split(\"\").filter((char) => !vowels.includes(char));\n console.log(`.${arr.join(\".\")}`);\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "2c1b54ba459c34b4f31158f907176a9f", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.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 line = readLine();\n let [n, k] = line.trim().split(' ').map(Number);\n for (let i = 0; i < k; i++) {\n if ((n % 10) === 0) {\n n = parseInt(n / 10);\n } else {\n n = n - 1;\n }\n }\n console.log(n);\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "55b308e92fc512ada3b98eb2eaa340f9", "src_uid": "064162604284ce252b88050b4174ba55", "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\n let citiesCount = parseInt(lines[0].split(\" \")[0])\n let limakCity = parseInt(lines[0].split(\" \")[1])\n\n let criminals = lines[1].split(\" \").map( value => {\n return parseInt(value)\n })\n\n let distanceCount = 0\n let caughtCriminalsCount = 0\n let passedCities = {}\n\n let limakCityIndex = limakCity - 1\n\n for(i = 0; i < citiesCount ; i++){\n\n distanceCount = Math.abs(i - limakCityIndex)\n\n let leftCityIndex = limakCityIndex - distanceCount\n let rightCityIndex = distanceCount + limakCityIndex\n\n if (passedCities[rightCityIndex] === true || passedCities[leftCityIndex] === true) {\n continue\n }\n\n if (distanceCount === 0) {\n caughtCriminalsCount = caughtCriminalsCount + criminals[i]\n passedCities[i] = true\n distanceCount++\n continue\n }\n\n let rightCriminalCount = 0\n let leftCriminalCount = 0\n\n if (leftCityIndex >= 0) {\n passedCities[leftCityIndex] = true\n leftCriminalCount = criminals[leftCityIndex]\n } else {\n leftCriminalCount = -1\n }\n\n if (rightCityIndex < citiesCount) {\n passedCities[rightCityIndex] = true\n rightCriminalCount = criminals[rightCityIndex]\n } else {\n rightCriminalCount = -1\n }\n\n if (rightCriminalCount + leftCriminalCount === 2) {\n caughtCriminalsCount = caughtCriminalsCount + 2\n } else if (rightCriminalCount === 1 && leftCriminalCount === -1) {\n caughtCriminalsCount = caughtCriminalsCount + 1\n } else if (leftCriminalCount === 1 && rightCriminalCount === -1){\n caughtCriminalsCount = caughtCriminalsCount + 1\n }\n\n distanceCount++\n }\n console.log(caughtCriminalsCount)\n})", "lang_cluster": "Javascript", "tags": ["constructive algorithms", "implementation"], "code_uid": "95ed666a0771e308909c77571493401a", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5", "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 numbers = [];\nlet seq = [];\n\nrl.on('line', (d) => {\n if (c === 0) {\n c++;\n return;\n }\n\n if (c === 1) {\n c++;\n numbers = d.split(' ').map(Number);\n return;\n }\n\n seq = d.split(' ').map(Number);\n const obj = {};\n\n for (let i = 0; i < seq.length; i++) {\n obj[seq[i]] = true;\n }\n\n const ans = [];\n\n for (let i = 0; i < numbers.length; i++) {\n if (obj[numbers[i]]) {\n ans.push(numbers[i]);\n }\n }\n\n console.log(ans.join(' '));\n\n c++;\n});\n\nrl.on('close', () => {\n\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0bf609d796c14bddce0da53b54b90c48", "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72", "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 sumInBase = function (N, base) {\n ans = 0;\n while (N != 0) {\n ans += N % base;\n N = parseInt(N / base);\n }\n return ans;\n}\n\nvar GCD = function (a, b) {\n if (b == 0)\n return a;\n return GCD(b, a % b);\n}\n\nrl.on('line', (input) => {\n var n = parseInt(input);\n var ans = 0;\n\n for (let i = 2; i < n; i++)\n ans += sumInBase(n, i);\n\n let temp = GCD(ans, n - 2);\n console.log(\"%d/%d\", ans / temp, (n - 2) / temp);\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "3076259ea3acfbd04ef84187b6190b81", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "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, 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 let ans = 0;\n let L = 0;\n let R = arr.length - 1;\n\n while (L <= R) {\n if (arr[L] <= k) {\n ans++;\n L++;\n }\n else if (arr[R] <= k) {\n ans++;\n R--;\n }\n else {\n break;\n }\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "608e955ac91709920bf2e0c6e147cee4", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "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 a1 = readLine();\n let a2 = readLine();\n let ans = '';\n for (var i = 0; i < a1.length; i++) {\n if (parseInt(a1[i]) + parseInt(a2[i]) == 1) {\n ans += 1;\n } else ans += 0;\n }\n console.log(ans);\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "0ce31304ef609ef02ca71ca854913410", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "/* Common Template Starts */\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\r\n .trim()\r\n .split(\"\\n\")\r\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/* Common Template Ends */\r\n\r\n\r\nfunction main() {\r\n //take input according to the format;\r\n const n = +(readline());\r\n for(let i =0; i{\r\n let sqN =Math.floor( Math.sqrt(num) );\r\n \r\n let set= new Set();\r\n for(let i =1; i <=sqN; ++i){\r\n set.add(i*i);\r\n if(i*i*i <=num)\r\n set.add(i*i*i);\r\n }\r\n console.log(set.size);\r\n}", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "c95af70e38b4bde091eca876a39c53d2", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const f = (n, s) => {\n const k = 2;\n\n const result = new Map();\n let best = null;\n let preBest = null;\n\n const compare = (sub) => {\n result[sub] = result[sub] ? result[sub] + 1 : 1;\n if (!best) {\n best = sub;\n } else if (result[sub] > result[best]) {\n preBest = best;\n best = sub;\n }\n };\n\n for (let i = 0; i < n - 1; i += 1) {\n if (result[best] > n / 2) { return best; }\n if (preBest) {\n const leftSteps = n - 1 - i;\n const bestLeadSteps = result[best] - result[preBest];\n if (leftSteps < bestLeadSteps) { return best; }\n }\n\n compare(s.slice(i, i + k));\n }\n\n return best;\n};\n\nlet i = '';\nprocess.stdin.on('data', c => i += c);\nprocess.stdin.on('end', () => {\n const {EOL} = require('os');\n const [ n, s ] = i.split(EOL);\n console.log(f(n, s));\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "22829a7328dda0963fb9d05db3764d61", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.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 stones = readLine()\n\tlet minStones=0\n\n\tfor(let i=0;i {\n input.push(line);\n});\n\nRL.on('close', () => {\n let hand = input[0];\n input[1].split(' ').forEach(i => {\n if(i[0] === hand[0] || i[1] == hand[1])\n {\n console.log('YES'); process.exit();\n }\n });\n console.log('NO');\n});\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "implementation"], "code_uid": "dc2ff99b53bd4cef155ae4600785cabb", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "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 target = +readLine();\n const arr = readLine()\n .split(\" \")\n .map((n) => parseInt(n));\n if (target === 0) {\n console.log(0);\n return;\n }\n arr.sort((a, b) => b - a);\n let [count, sum, found] = [0, 0, false];\n\n for (let i = 0; i < arr.length; i++) {\n sum += arr[i];\n count++;\n if (sum >= target) {\n found = true;\n break;\n }\n }\n\n if (found) console.log(count);\n else console.log(-1);\n}\n", "lang_cluster": "Javascript", "tags": ["sortings", "implementation", "greedy"], "code_uid": "34ed6733d77dd8dea199ab2c9dfbf09f", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "// Little Pigs and Wolves - https://codeforces.com/problemset/problem/116/B\n\nconst 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\n let m, n;\n let i = 1;\n\n for await (const line of rl) {\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\nconst 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 (\n arr[i - 1][j] == \"P\" ||\n arr[i + 1][j] == \"P\" ||\n arr[i][j - 1] == \"P\" ||\n arr[i][j + 1] == \"P\"\n ) {\n output++;\n }\n }\n }\n }\n console.log(output);\n};\n\nmain();\n", "lang_cluster": "Javascript", "tags": ["greedy", "implementation"], "code_uid": "fc5fe7f6ae26755ff64bcd6a525d1768", "src_uid": "969b24ed98d916184821b2b2f8fd3aac", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const fs = require(\"fs\");\n\nconst [sectionCountMax, nutCount, divisorCount, sectionCapacity] = fs.readFileSync(0).toString().trim().split(\" \").map(x => Number(x));\nconst divisorCountMax = sectionCountMax - 1;\nlet used = Math.floor(divisorCount / divisorCountMax);\nconst dividedCapacity = sectionCountMax * sectionCapacity;\nlet remaining = nutCount - used * dividedCapacity;\nif (remaining <= 0) process.stdout.write(Math.ceil(nutCount / dividedCapacity) + \"\\n\");\nelse {\n remaining -= (divisorCount - used++ * divisorCountMax + 1) * sectionCapacity;\n if (remaining > 0) used += Math.ceil(remaining / sectionCapacity);\n process.stdout.write(used + \"\\n\");\n} \nprocess.exit();\n", "lang_cluster": "Javascript", "tags": ["math", "greedy"], "code_uid": "2d0a7231af0d77ff9b96f8a7efa0499c", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const transformString = (newString, char) => newString += `.${char}`;\n\nprocess.stdin.once('data', (input) => {\n let withOutVowels = input.toString().trim().toLowerCase().replace(/[aeiouy]/gi, '');\n let newString = Array.from( withOutVowels ).reduce( transformString, '' ); \n console.log(newString);\n process.exit();\n});\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "02bab058feda03ff5975311316bdcc72", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.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 = lines.map(a => a.trim());\n \n let before;\n let count = 0;\n for (let i = 0; i < lines[0].length; i += 1) {\n if (lines[0].charAt(i) === before) {\n count += 1;\n if (count === 7) {\n console.log('YES');\n return;\n }\n } else {\n count = 1;\n }\n before = lines[0].charAt(i);\n }\n console.log('NO');\n});", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "c9a6ee908cffea8c640b1a198cc20075", "src_uid": "ed9a763362abc6ed40356731f1036b38", "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 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 let l = 0;\n let result = a.toUpperCase();\n for (let i = 0; i < a.length; i++) {\n const c = a.charAt(i);\n if (c === c.toLowerCase()) {\n l++\n }\n if (l >= Math.ceil((a.length) / 2)) {\n result = a.toLowerCase();\n break;\n }\n }\n // output\n print(result);\n}\n\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "3ebe3de8a1d379255e1380cc05010129", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "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 w = readline();\n let result =\"\";\n const vow = [\"a\", \"e\", \"i\", \"o\", \"u\", \"y\"];\n for(const letter of w){\n const lowerTerm = letter.toLowerCase();\n if(vow.indexOf(lowerTerm) == -1){\n result += `.${lowerTerm}`;\n }\n }\n console.log(result);\n}", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "2661c93afb55961dcf1859c2dbf83fb4", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "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}\nfunction main() {\n let s = readLine();\n if (s.includes('0000000') || s.includes('1111111')) {\n console.log('YES');\n } else {\n console.log('NO');\n }\n}\n", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "a527e301528be6341dda81fd8e49de08", "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\nrl.on('line', (d) => {\n const y = Number(d);\n let i = y;\n\n while (true) {\n i++;\n\n if (new Set(String(i)).size === 4) {\n console.log(i);\n break;\n }\n }\n});\n", "lang_cluster": "Javascript", "tags": ["brute force"], "code_uid": "a6da5a7fed455b78fc0d051dea8a196c", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "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 string = readLine();\n let stringArray = string.split('');\n let finalArray = [];\n for (let i = 0; i < stringArray.length; i++) {\n if (finalArray.indexOf(stringArray[i]) === -1) {\n finalArray.push(stringArray[i]);\n }\n }\n\n if (finalArray.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": "1465dacf1fdc72e1b0ed7fff67be087f", "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;\nlet n, d;\n\nrl.on('line', (data) => {\n if (c === 0) {\n c++;\n [n, d] = data.split(' ').map(Number);\n return;\n }\n\n const arr = data.split('').map(Number);\n let ans = 0;\n let best = 0;\n let inc = 1;\n\n for (let i = 1; i < arr.length; i++) {\n if (arr[i] === 1) {\n best = Math.max(best, i);\n }\n\n if (inc === d || i + 1 === arr.length) {\n if (best === 0) {\n ans = -1;\n break;\n }\n else {\n ans++;\n i = best;\n best = 0;\n inc = 0;\n }\n }\n\n inc++;\n }\n\n console.log(ans);\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["dfs and similar", "greedy", "dp", "implementation"], "code_uid": "47e2877e5dfde69714dcfc3b2836d512", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "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 terminal: false\n});\nlet input=[];\n\nrl.on('line', line => {\n input.push(line.trim());\n}).on('close', () => {\n let [n, k] = input[0].split(' ');\n const stdin = input[1].split(' ');\n\n const scores = stdin.map((stdin) => {\n return Number(stdin);\n });\n let count = 0;\n const thK = Number(k);\n scores.forEach(elm => {\n if (elm > 0 && elm >= scores[thK - 1]) {\n count++;\n }\n });\n console.log(count);\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "15f239276bd1d9ffc27fa3883249ee5f", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "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 str = readLine();\n const m = {};\n let c = 0;\n for (let i = 0; i < str.length; i++) {\n if (!m[str[i]]) {\n m[str[i]] = 1;\n c++;\n }\n }\n console.log(c % 2 === 0 ? 'CHAT WITH HER!' : 'IGNORE HIM!');\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "2574b5f20aa262fe9d786535d760867b", "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\u2191\u5165\u529b \u2193\u51fa\u529b');\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 \u201aThere 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 = 1;\n for(var i = 1; i < N; i++){\n output += i * 4;\n }\n myout(output);\n}\n", "lang_cluster": "Javascript", "tags": ["math", "dp", "implementation"], "code_uid": "accd8d59c9d496453fd1883eb67743c0", "src_uid": "758d342c1badde6d0b4db81285be780c", "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 w = []\nlet h = []\n\nrl.on('line', (input) => {\n if (l === 0) {\n let inp = input.split(\" \").map(x => parseInt(x))\n w.push(inp[0])\n h.push(inp[1])\n } else if (l === 1) {\n let inp = input.split(\" \").map(x => parseInt(x))\n w.push(inp[0])\n h.push(inp[1])\n } else {\n rl.close();\n let inp = input.split(\" \").map(x => parseInt(x))\n let wg = w[0]\n let hg = h[0]\n w.push(inp[0])\n h.push(inp[1])\n if (h[1] < h[2]) {\n let aux = h[1]\n h[1] = h[2]\n h[2] = aux\n aux = w[1]\n w[1] = w[2]\n w[2] = aux\n }\n for (let i = h[0]; i >= h[1]; i--) {\n wg += i\n hg--\n }\n\n wg -= w[1]\n if (wg < 0)\n wg = 0\n if (hg <= 0) {\n console.log(wg)\n return\n }\n for (let i = h[1] - 1; i >= h[2]; i--) {\n wg += i\n hg--\n }\n wg -= w[2]\n if (wg < 0)\n wg = 0\n for (let i = hg; i >= 0; i--) {\n wg += i;\n }\n console.log(wg)\n }\n l++\n});\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "81f6089ede88c452e9ab337b1076a3fb", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "process.stdin.resume()\r\nprocess.stdin.setEncoding('utf-8')\r\n\r\nprocess.stdin.on('data', (s) => {\r\n console.log(+s % 9 === 0 ? 9 : +s % 9)\r\n})\r\n", "lang_cluster": "Javascript", "tags": ["implementation", "number theory"], "code_uid": "2c6223f75d15461f28b91dfa423719c5", "src_uid": "477a67877367dc68b3bf5143120ff45d", "difficulty": 1600.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 i = line.length;\n for(var j = 0; j < line.length; j++){\n for(var c = j +1 ; c < line.length; c++) {\n if (line.charAt(j) == line.charAt(c)){\n i--;\n break;\n }\n }\n }\n \n if (i % 2 == 0 ){\n console.log(\"CHAT WITH HER!\");\n }else {\n console.log(\"IGNORE HIM!\");\n }\n process.exit(0);\n});", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "00f954505e27d91b92e2d26c780e241b", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "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 [a, b] = line.split(' ').map(n => parseInt(n, 10));\n return ~~(a * b / 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": ["math", "greedy"], "code_uid": "d3602fb08d059c2aecfb3898cf640fff", "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});\n\n\n\nrl.on('line', (line) => {\n console.log(solution(line));\n});\n\nfunction solution(input) {\n let luckyDigits = 0;\n for (let i = 0 ; i < input.length; i++) {\n if (input[i] === '4' || input[i] === '7') {\n luckyDigits++;\n }\n }\n\n if (luckyDigits === 4 || luckyDigits === 7) {\n return 'YES';\n }\n return 'NO';\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "18beba5c2669077a1892490f82f038e0", "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 if (+d % 2 === 0) {\n console.log(0);\n }\n else {\n console.log(1);\n }\n\n c++;\n});\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "d38de3663ff0732577df32a237c82d0f", "src_uid": "78e64fdbf59c5ce89d0f0a1d0591f795", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "\n\nconst lines = [];\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\n\n\nreadline.on('close', line => {\n\n /**\n * 1\n */\n\n let name = lines[0];\n\n recognizeHim(name);\n\n});\n\n\n\n\nfunction recognizeHim(name) {\n\n let exist = {};\n let distinct = 0;\n\n for (let ii = 0; ii < name.length; ii++) {\n if (!exist[name[ii]]) {\n exist[name[ii]] = 1;\n distinct++\n }\n }\n\n if (distinct % 2 == 0)\n return console.log(\"CHAT WITH HER!\")\n else\n return console.log(\"IGNORE HIM!\")\n}", "lang_cluster": "Javascript", "tags": ["brute force", "strings", "implementation"], "code_uid": "9b8340079b851ffb6b36bc89de8b61a0", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function main() {\n // write code here:\n var m=Number(stdin[0]);\n for(var i=m;;i++){\n //\u522b\u5fd8\u8bb0 parseInt(cur) \uff0c\u5426\u5219\u53ea\u4f1a\u50cf\u8fde\u63a5\u5b57\u7b26\u4e32\u4e00\u6837\n var n=i.toString().split('').reduce((acc,cur) => acc+parseInt(cur),0);\n if(n%4===0){\n //\u53ea\u9700\u8981\u6ee1\u8db3\u548c\u53d6\u4f594\u4e3a\u96f6\u5373\u53ef\n console.log(i);\n break;\n }\n }\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": "207641c9b16d0d8a6d81afc98ffcacb9", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.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\n data = data.replace(/\\s*$/, '')\r\n .split('\\n')\r\n .map(str => str.replace(/\\s*$/, ''));\r\n\r\n let testCases = parseInt(data.shift());\r\n\r\n var mod = BigInt(1e9 + 7);\r\n\r\n while(testCases--) {\r\n\r\n const [nn, kk ] = get_ints();\r\n \r\n const n = BigInt(nn);\r\n const k = BigInt(kk);\r\n\r\n let ans = BigInt(1);\r\n for(let i = 0; i < k; i++){\r\n ans = (ans * n) % mod;\r\n }\r\n console.log(parseInt(ans));\r\n }\r\n});\r\n\r\nfunction get_ints() { \r\n return data.shift().split(' ').map(Number);\r\n}\r\n \r\nfunction readLine() { \r\n return data[currentLine++];\r\n}\r\n ", "lang_cluster": "Javascript", "tags": ["math", "combinatorics", "bitmasks"], "code_uid": "b9d483b89a8411989a35181a7f6bb716", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "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(){if(0==this.length)return 0;let t=this[0];for(let e=1;e{if(a)return i=o.default.readFileSync(\"input.txt\").toString().trim().split(\"\\n\").map((t=>t.trim())),t(),o.default.writeFileSync(\"output.txt\",l),console.log(l),void(o.default.readFileSync(\"expected.txt\").toString().trim()==l.trim()&&console.log(\"\u2705 AC!\"));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(l)}))};function f(){return i[s++]}function p(){return f().split(\" \").map((t=>parseFloat(t)))}function h(){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", "matrices", "dp"], "code_uid": "4fd7ddb24a2629e0b7f27bffd3d11fe8", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "const processData = (lines) => {\n const k = lines[1].split(' ').map(x => +x)\n const l = lines[2].split(' ').map(x => +x)\n let diff = [0, 0]\n for (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 processData(lines)\n})\n", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "4b6e8d1b65181b0b9dab844134bf830f", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "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 const target = \"hello\";\n let count = 0;\n\n for (let i = 0, j = 0; i < str.length; i++) {\n const [char, targetChar] = [str[i], target[j]];\n if (char === targetChar) {\n count++;\n j++;\n }\n\n if (count === 5) {\n console.log(\"YES\");\n return;\n }\n }\n console.log(\"NO\");\n}\n", "lang_cluster": "Javascript", "tags": ["greedy", "strings"], "code_uid": "9421647862a86e909c2505475850adba", "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', () => {\nlet check = 'NO'\nlet SF = input[1].match(/(SF)/g)\nSF = SF ? SF.length : 0\nlet FS = input[1].match(/(FS)/g)\nFS = FS ? FS.length : 0\nif (SF > FS)\n check = 'YES'\nconsole.log(check)\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3e0c1ca8755a21f7ae09a76b711fdc73", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "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 x = readline();\n // process.stdout.write('hello')\n console.log(x % 2 == 0 && x > 3 ? 'YES' : 'NO');\n}\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "64392f6dd677d65be379553cf55110a9", "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 let t = +readLine();\n while (t--) {\n const num = +readLine();\n let found = false;\n if (num % 2 === 0) {\n console.log(`${num / 2} ${num / 2}`);\n continue;\n } else {\n for (let i = 2; i * i <= num; i++) {\n if (num % i === 0) {\n let [a, b] = [num / i, num - num / i];\n console.log(`${a} ${b}`);\n found = true;\n break;\n }\n }\n }\n !found && console.log(`${1} ${num - 1}`);\n }\n}\n", "lang_cluster": "Javascript", "tags": ["math", "greedy", "number theory"], "code_uid": "d107b76cfa9e4ea2aae5ebad504c450b", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "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\nconst input = [];\nreadLine.on('line', line => input.push(line));\n\nreadLine.on('close', () => {\n let [m, s] = input[0].split(' ').map(x => parseInt(x));\n if (s === 0 || m*9 < s) {\n if (m === 1 && s === 0)\n console.log(`0 0`);\n else\n console.log(`-1 -1`);\n } else {\n let bigAnswer = [];\n let smallAnswer = [1];\n let smallSumm = s - 1;\n \n if (s <= 9 && m === 1) {\n console.log(`${s} ${s}`); return;\n }\n\n if (s <= 9) {\n bigAnswer.push(s);\n bigAnswer = bigAnswer.concat(Array(m-1).fill(0));\n } else {\n while (s !== 0) {\n if (s - 9 < 0) {\n bigAnswer.push(s); break;\n }\n \n bigAnswer.push(9);\n s -= 9;\n }\n bigAnswer = bigAnswer.concat(Array(m - bigAnswer.length).fill(0));\n }\n\n let smallTmpNums = [];\n while (smallSumm !== 0) {\n if (smallSumm - 9 < 0) {\n smallTmpNums.push(smallSumm); break;\n }\n \n smallTmpNums.push(9);\n smallSumm -= 9;\n }\n\n if (smallTmpNums.length + 1 < m) {\n smallAnswer = smallAnswer.concat(Array( m - (smallTmpNums.length + 1) ).fill(0)).concat(smallTmpNums.reverse());\n } else {\n smallAnswer = smallAnswer.concat(smallTmpNums.reverse());\n }\n if (smallAnswer.length > bigAnswer.length) {\n smallAnswer = [...bigAnswer].reverse();\n }\n \n console.log(`${smallAnswer.join('')} ${bigAnswer.join('')}`)\n }\n}); ", "lang_cluster": "Javascript", "tags": ["greedy", "dp", "implementation"], "code_uid": "eb798ae788e822882f1f4a9342bdaf9a", "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\nrl.question('', (answer) => {\n const argumentArray = answer.split(' ');\n let bearWeight = parseInt(argumentArray[0]);\n let brotherWeight = parseInt(argumentArray[1]);\n let year = 0;\n\n while(brotherWeight >= bearWeight) {\n bearWeight *= 3;\n brotherWeight *= 2;\n year++;\n }\n\n console.log(year);\n\n rl.close();\n});", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "87d55b785c7dc97cfc401a1050dd571a", "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}\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 n = +readLine();\n let count = 0;\n\n for (let i = n; i >= 1; i--) {\n let [left, right] = [1, i - 1];\n const target = i * i;\n while (left < right) {\n const sum = left * left + right * right;\n if (sum === target) {\n count++;\n left++;\n right--;\n } else if (sum < target) left++;\n else right--;\n }\n }\n console.log(count);\n}\n", "lang_cluster": "Javascript", "tags": ["brute force", "math"], "code_uid": "f05718a18e70cb586953f4a4e4615bc4", "src_uid": "36a211f7814e77339eb81dc132e115e1", "difficulty": 1200.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 n = parseInt(readLine());\n var res = \"NO\";\n if(n%2 ==0){\n for(var i=1;i i += c);\nprocess.stdin.on('end', () => {\n const r = +i;\n const names = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"];\n let pos = 1, doubles = 1;\n while ('Doubling...') {\n for (let i = 0; i < names.length; i++) {\n if (r >= pos && r < pos + doubles) {\n console.log(names[i]);\n process.exit();\n }\n pos += doubles;\n }\n doubles <<= 1;\n }\n});", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "d12059e964175b142922baa5bbd937f3", "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\u2191\u5165\u529b \u2193\u51fa\u529b');\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 \u201aThere 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 a = nextInt();\n\tvar b = nextInt();\n\tvar diff = Math.abs(a - b);\n\tif(diff % 2 == 0){\n\t\tdiff /= 2;\n\t\tmyout(diff * (diff + 1));\n\t}else{\n\t\tvar tmp = diff - 1;\n\t\ttmp /= 2;\n\t\tmyout((tmp * (tmp + 1)) + (tmp + 1));\n\t}\n}\n", "lang_cluster": "Javascript", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "fe022179515b42942e7a761e1b08b776", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da", "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 \u201aThere 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 list = new Array(5);\n for(var i = 0; i < 5; i++){\n list[i] = nextStrArray();\n if(list[i].indexOf(\"1\") != -1){\n myout(Math.abs(list[i].indexOf(\"1\") + 1 - 3) + Math.abs(3 - (i + 1)));\n return;\n }\n }\n \n}\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "1f65c9cc3f8c1b53fb8ad248b5597385", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "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}\nfunction main() {\nvar num = readline().split(\" \").map(x => parseInt(x)); // num will be an array [1,2,3]\nvar x= num[0]; // to store values in different variables. \nvar y= num[1];\nvar z= num[2];\nconsole.log(Math.floor((x+z-1)/z)*Math.floor((y+z-1)/z));\n}\n", "lang_cluster": "Javascript", "tags": ["math"], "code_uid": "087e01a41e1d07c1f5784d3bb0d127f3", "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\n main()\n})\nfunction main() {\n let matrix = []\n for (let i = 0; i < 5; i++) {\n matrix[i] = readLine().split(' ').map(Number)\n }\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 (matrix[i][j] === 1) {\n res = 4\n } else {\n res = 0\n }\n } else if (matrix[i][j] === 1) {\n res = Math.abs(i - 2) + Math.abs(j - 2)\n }\n }\n }\n console.log(res)\n}", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "e7e928f107710a6ae8bcf81257a4f7ab", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "function processData(input) {\n //Enter your code here\n let res=input.split(\"\\n\"), [n,k]=res[0].split(\" \").map(Number),\n arr=res[1].split(\" \").filter((x)=>x!==\"\").map(Number);\n while(arr.length>0){\n if(arr[0]<=k){\n arr.shift()\n }else if(arr[arr.length-1]<=k){\n arr.pop()\n }else{\n break;\n }\n }\n console.log(n-arr.length)\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": ["brute force", "implementation"], "code_uid": "2ff80485e50f4430def3a110bb24c718", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "Node.js", "source_code": "'use strict';\n\u00a0\n//const fs = require('fs');\n\u00a0\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\u00a0\nlet inputString = '';\nlet currentLine = 0;\n\u00a0\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\u00a0\nprocess.stdin.on('end', _ => {\n inputString = inputString.replace(/\\s*$/, '')\n .split('\\n')\n .map(str => str.replace(/\\s*$/, ''));\n\u00a0\n main();\n});\n\u00a0\nfunction readLine() {\n return inputString[currentLine++];\n}\nfunction main() {\n var n = parseInt(readLine(), 10);\n var coins = [];\n coins.push(n);\n for (var i = n - 1; i > 0; i--) {\n if ((n % i) == 0) {\n coins.push(i);\n n = i;\n }\n }\n console.log(coins.join(\" \"));\n \n}", "lang_cluster": "Javascript", "tags": ["greedy"], "code_uid": "fb8d8fe1a6f7b44d066a0d7ef95004f8", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.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 n = 0\nlet s = \"\"\nlet count = 0\nfunction main(input){\n\tif(n === 0){\n\t\tn = parseInt(input)\n\t\treturn\n\t}\n\n\ts = input\n\n\tfor(var j = 0; j < s.length; j++){\n\t\t\n\t\t/*if(s.charAt(j) === s.charAt(j+1)){\n\t\t\tif(s.charAt(j) === s.charAt(j+2) && s.charAt(j) !== s.charAt(j+3)){\n\t\t\t\tcount++\n\t\t\t\tj = j + 3\n\t\t\t}\n\t\t}*/\n\t\tif(s.charAt(j) === s.charAt(j+1)){\n\t\t\tcount++\n\t\t}\n\t}\n\tconsole.log(count)\n}\n\n\n\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "18949373b575e0214bb97da07d8686db", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "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 k = +inputs[0];\n let r = +inputs[1];\n let shovelBought = 0;\n for (var i = 1; i <= 10; i++) {\n let shPrice = k * i;\n if (shPrice % 10 == 0 || shPrice % 10 == r) {\n break;\n }\n }\n return i.toString();\n\n}\n\n\n\n\n", "lang_cluster": "Javascript", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "789491efe509a97e39f89471cf818696", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "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 word;\nlet currentChar = \"a\".charCodeAt(0)\nlet rotations = 0;\n\nrl.on(\"line\", (input) => {\n if (!word) {\n word = input.split(\" \").toString();\n // console.log(word.charCodeAt(0), currentChar)\n }\n if (word) {\n for (let index = 0; index < word.length; index++) {\n if (word.charCodeAt(index) == currentChar) {\n rotations += 0\n continue;\n }\n let temp = Math.abs((word.charCodeAt(index) - currentChar))\n // console.log(\"Temp=>\", temp, \"CurrentChar =>\", currentChar, \"\\n\")\n if (temp > 13) {\n rotations += (25 - (temp - 1))\n currentChar = word.charCodeAt(index)\n }\n if (temp <= 13) {\n currentChar = word.charCodeAt(index)\n rotations += temp\n }\n\n }\n console.log(rotations)\n rl.close();\n\n\n }\n})", "lang_cluster": "Javascript", "tags": ["strings", "implementation"], "code_uid": "8405e4e4dace269311d78d854aa13cbc", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "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 = [];\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 const rowSteps = currentPositon[0] - bestPosition[0];\n const colSteps = currentPositon[1] - bestPosition[1];\n const minimumSteps = Math.abs(colSteps) + Math.abs(rowSteps);\n \n console.log(minimumSteps);\n\n})", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "ebd750a6691e5e0827306574b2b6ff4f", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "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 result = solution(n[0], n[1]);\n console.log(result);\n});\n\n// End of interface\n\nconst solution = function(a, b){\n for (i = 1; i < 10; i++){\n a = a * 3;\n b = b * 2;\n if (a > b){\n return i;\n }\n }\n};", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "8d9bd3f710a878bd01deba0133e4f9b6", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "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\t//your code this\n\tlet t = nl.nums();\n\tlet ans = [];\n\tfor(let i = 0; i < t; i++){\n\t\tlet n = nl.num();\n\t\tlet x = Math.trunc(Math.sqrt(n)) + Math.trunc(Math.cbrt(n));\n\t\tfor(let j = 1; j <= Math.cbrt(n); j++){\n\t\t\tlet c = j ** 3;\n\t\t\tif (Math.sqrt(c) % 1 === 0) x--;\n\t\t} \n\t\tans.push(x);\n\t}\n\tconsole.log(ans.join('\\n'));\n};\n \nprocess.stdin.on('end', sol);\n", "lang_cluster": "Javascript", "tags": ["math", "implementation"], "code_uid": "5eda51cbb4fd1218ae4345fcfd01f417", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "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\nfunction fact(num)\n{\n if(num === 0)\n return 1;\n return num * fact(num-1);\n}\n\nRL.on('close', () => {\n const n = parseInt(input[0], 10);\n const data = []; input[1].split(' ').forEach( i => data.push(parseInt(i, 10)) ); \n \n let b = 0; let g = 0; let t = 0;;\n for(let i = 0; i < n; i += 1){\n if(i % 3 === 0)\n b += data[i];\n else if(i % 3 === 1)\n g += data[i];\n else if(i % 3 === 2)\n t += data[i];\n }\n\n global.console.log( (b > t && b > g) ? 'chest' : (t > b && t > g) ? 'back' : 'biceps' );\n});\n\n", "lang_cluster": "Javascript", "tags": ["implementation"], "code_uid": "3af854d395d18e20e0da7429272ba8c7", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0, "exec_outcome": "PASSED"}