code
stringlengths 24
983k
| language
stringclasses 3
values | AST_depth
int64 -1
40
| alphanumeric_fraction
float64 0
1
| max_line_length
int64 0
500k
| avg_line_length
float64 0
249k
| num_lines
int64 0
33.7k
| source
stringclasses 1
value |
---|---|---|---|---|---|---|---|
function main(input) {
var num = input.split("\n");
num.slice(0, num.length - 1).forEach(function(value) {
var a = value.split(" ");
var num = (parseInt(a[0]) + parseInt(a[1]));
console.log(String(num).length);
});
}
main(require("fs").readFileSync("/dev/stdin", "utf8")); | javascript | 15 | 0.599315 | 56 | 25.636364 | 11 | codenet |
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
var aaa = chunk.toString();
var line = aaa.split("\n")
line.pop();
for(var i in line){
var l = line[i].split(" ")
var num1 = new Number (l[0]);
var num2 = new Number(l[1]);
var num = num1+num2
//num.toString();
console.log(String(num).length);
}
}); | javascript | 14 | 0.548694 | 43 | 25.375 | 16 | codenet |
var input = [];
var data = [];
process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on('data', function(chunk){
input = chunk.toString("utf8").split("\n");
});
process.stdin.on('end', function(){
for (var i = 0; i < input.length; i++) {
data[i] = input[i].split(" ");
var a = parseInt(data[i].shift());
var b = parseInt(data[i].shift());
if(!isNaN(a + b)) {
console.log(String(a + b).length)
}
}
}); | javascript | 17 | 0.53527 | 46 | 27.411765 | 17 | codenet |
function Main(input){
input = input.split("\n");
var n = input.length;
for(var i = 0;i < n - 1;i++){
input[i] = input[i].split(" ");
var a = parseInt(input[i][0],10);var b = parseInt(input[i][1],10);
var ans = 0;
a += b;
while(a > 0){
ans++;a = Math.floor(a / 10);
}
console.log(ans);
}
}
Main(require("fs").readFileSync("/dev/stdin","utf8")); | javascript | 12 | 0.465278 | 74 | 26.0625 | 16 | codenet |
var sample_input = require('fs').readFileSync('/dev/stdin', 'utf8');
var sets = (sample_input.trim()).split("\n");
sets.forEach(function(pair){
var sum = pair.split(" ").map(Number).reduce(function(a,b){return a + b;},0);
console.log(sum.toString().length);
}); | javascript | 15 | 0.656604 | 79 | 43.333333 | 6 | codenet |
//config = {stdin: 'tmp', newline: '\r\n'}; // win
config = {stdin: '/dev/stdin', newline: '\n'}; // linux
line = require('fs').readFileSync(config.stdin, 'ascii')
.trim()
.split(config.newline)
.map(function (line) { return line.split(' '); })
.map(function (ary) { return parseInt(ary[0]) + parseInt(ary[1]); })
.map(String)
.map(function (str) { return str.length; })
;
console.log(line.join('\n')); | javascript | 20 | 0.613139 | 69 | 30.692308 | 13 | codenet |
(function(stdin) {
stdin.trim().split('\n').forEach(function(line) {
var values = line.trim().split(' ').map(Number);
var sum = values[0] + values[1];
console.log(sum.toString().length);
});
})(require('fs').readFileSync('/dev/stdin', 'utf8')); | javascript | 19 | 0.607692 | 53 | 36.285714 | 7 | codenet |
(function(undefined){
'use strict';
(function init() {
this.output = function() {
console.log.apply( console, arguments );
};
this.stdin = process.openStdin();
stdin.setEncoding('utf8');
}).call( this );
(function solver(){
var input_list = [];
(function reciever() {
stdin.on('data', function(chunk){
var regexp = /\d+/g;
var result = chunk.match(regexp);
input_list = input_list.concat(result);
setTimeout( solve, 0 );
});
})();
function solve() {
var a = parseInt( input_list.splice(0, 1)[0] );
var b = parseInt( input_list.splice(0, 1)[0] );
var sum = a + b;
output( sum.toString().length );
if ( input_list.length )
setTimeout( solve, 0 );
}
})();
}).call(global); | javascript | 26 | 0.591033 | 50 | 24.413793 | 29 | codenet |
function Main(input) {
lines=input.split("\n");
for(i in lines){
if(lines[i]=="")break;
n=lines[i].split(" ").map(function(x){return x-0;});
sum=n[0]+n[1];
console.log(sum.toString().length);
}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8")); | javascript | 13 | 0.599251 | 55 | 25.8 | 10 | codenet |
process.stdin.on("data",function(c){
(c+"").trim().split("\n").some(function(n){
n=n.split(" ");
console.log((+n[0]+(+n[1])+"").length);
});
}).resume(); | javascript | 23 | 0.528302 | 44 | 25.666667 | 6 | codenet |
var Digit;
(function (Digit) {
var Counter = (function () {
function Counter(a, b) {
this.number = a + b;
}
Counter.prototype.count = function () {
var digits = 1;
var remain = this.number;
while (true) {
remain = Math.floor(remain / 10);
if (remain <= 0) {
break;
}
digits++;
}
return digits;
};
return Counter;
})();
Digit.Counter = Counter;
})(Digit || (Digit = {}));
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
chunk.trim().split('\n').forEach(function (lines) {
var ab = lines.trim().split(' ');
var digit = new Digit.Counter(+ab[0], +ab[1]);
console.log(digit.count());
});
}); | javascript | 23 | 0.465986 | 55 | 27.483871 | 31 | codenet |
process.stdin.on("data",function(c){
(c+"").trim().split("\n").some(function(a){
console.log((a.split(" ").reduce(function(x,y){return (+x)+(+y)})+"").length);
});
}).resume(); | javascript | 27 | 0.559783 | 82 | 36 | 5 | codenet |
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
for (var i = 0; i < lines.length; i++) {
if (lines[i] == '') break;
var vals = lines[i].split(' ').map(function(i){return +i;});
var a = vals[0] + vals[1];
var str = a + '';
console.log(str.length);
} | javascript | 11 | 0.571906 | 61 | 29 | 10 | codenet |
"use strict";
new Promise(function(resolve, reject) {
let content = "";
process.stdin.on("data", chunk => { content += chunk; })
process.stdin.on("end", () => { resolve([content, process.stdout]); });
}).then(function([cin, cout]) {
const data = cin.split("\n").map(elt => elt.split(" ")).filter(elt => elt.length === 2);
data.map(elt => elt.map(e => parseInt(e))).forEach(elt => {
cout.write(`${elt.reduce((car, cdr) => car + cdr, 0).toString().length}\n`);
});
});
| javascript | 23 | 0.560878 | 92 | 37.538462 | 13 | codenet |
let input = ''
process.stdin.resume()
process.stdin.setEncoding('utf8')
process.stdin.on('data', function(chunk) {
input += chunk
})
process.stdin.on('end', function() {
input = input.trim().split('\n')
main()
})
function main() {
dataset_num = input[0]
if (dataset_num > 1000) {
return
}
for(i=1; i<input.length; i++) {
input_line = input[i].split(' ')
input_line.sort(compareNumbers)
// console.log(input_line)
if(0 > input_line[0] || input_line[0] > 1000 ) {
return
}
if(0 > input_line[1] || input_line[1] > 1000 ) {
return
}
if(0 > input_line[2] || input_line[2] > 1000 ) {
return
}
if (Math.pow(input_line[0],2) === Math.pow(input_line[1],2) + Math.pow(input_line[2],2)) {
console.log('YES')
} else {
console.log('NO')
}
// console.log(Math.pow(input_line[0],2))
}
}
function compareNumbers(a, b) {
return b - a;
}
| javascript | 12 | 0.558414 | 94 | 21.214286 | 42 | codenet |
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
Arr.shift();
Arr.forEach(function(v){
var arr=v.split(" ").map(Number);
arr.sort(function(a,b){return a-b;});
var a=arr[0];
var b=arr[1];
var c=arr[2];
var str="";
str=(c*c==a*a+b*b)?"YES":"NO";
console.log(str);
}); | javascript | 13 | 0.611465 | 61 | 23.230769 | 13 | codenet |
(function(input) {
var p = input.replace(/\n$/, '').split('\n');
var n = Number(p.shift());
for (var i = 0; i < p.length; i++) {
var args = p[i].split(' ').map(Number).sort(function(a, b) {
return b - a;
});
console.log(
Math.pow(args[0], 2) === Math.pow(args[1], 2) + Math.pow(args[2], 2)
? 'YES' : 'NO'
);
}
})(require('fs').readFileSync('/dev/stdin', 'utf8')); | javascript | 17 | 0.449664 | 80 | 33.461538 | 13 | codenet |
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
// ここから
function main(){
for(var line = 1, maxLines = input[0] - 0; line <= maxLines; line++){
var inputArray = new Int32Array(input[line].split(" "));
var i0 = inputArray[0];
var i1 = inputArray[1];
var i2 = inputArray[2];
console.log(isTri(i0,i1,i2) || isTri(i1, i2, i0) || isTri(i2, i0, i1) ? 'YES' : 'NO');
}
}
function isTri(a, b, c){
return a*a + b*b == c*c;
} | javascript | 13 | 0.605965 | 92 | 26.73913 | 23 | codenet |
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
// ここから
function main(){
for(var line = 1, maxLines = input[0] - 0; line <= maxLines; line++){
var inputArray = input[line].split(" ").sort(function(a,b){return a-b});
var longest = inputArray[2];
var middle = inputArray[1];
var shortest = inputArray[0];
console.log((longest*longest == middle*middle + shortest*shortest) ? 'YES' : 'NO');
}
} | javascript | 13 | 0.640984 | 89 | 31.157895 | 19 | codenet |
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
// ここから
function main(){
for(var line = 1, maxLines = input[0] - 0; line <= maxLines; line++){
var inputArray = new Int32Array(input[line].split(" ").sort(function(a,b){return a-b}));
var longest = inputArray[2];
var middle = inputArray[1];
var shortest = inputArray[0];
console.log((longest*longest == middle*middle + shortest*shortest) ? 'YES' : 'NO');
}
} | javascript | 15 | 0.643312 | 92 | 32.105263 | 19 | codenet |
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
// ここから
function main(){
for(var line = 1, maxLines = input[0] - 0; line <= maxLines; line++){
var inputArray = input[line].split(" ").sort(function(a,b){return a-b});
var longest = inputArray[2];
var middle = inputArray[1];
var shortest = inputArray[0];
console.log((longest*longest == middle*middle + shortest*shortest) ? 'YES' : 'NO');
}
} | javascript | 13 | 0.638889 | 89 | 31.263158 | 19 | codenet |
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
// ここから
function main(){
for(var line = 1, maxLines = input[0] - 0; line <= maxLines; line++){
var inputArray = input[line].split(" ").sort(function(a,b){return a-b});
var longest = inputArray[2];
var middle = inputArray[1];
var shortest = inputArray[0];
console.log((longest*longest - middle*middle - shortest*shortest) ? 'NO' : 'YES');
}
} | javascript | 13 | 0.638889 | 89 | 31.263158 | 19 | codenet |
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
// ここから
function main(){
for(var line = 1, maxLines = input[0] - 0; line <= maxLines; line++){
var inputArray = input[line].split(" ").sort(function(a,b){return a-b});
var longest = inputArray[2];
var middle = inputArray[1];
var shortest = inputArray[0];
console.log((longest*longest - middle*middle - shortest*shortest) ? 'NO' : 'YES');
}
} | javascript | 13 | 0.638889 | 89 | 31.263158 | 19 | codenet |
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
// ここから
function main(){
for(var line = 1, maxLines = input[0] - 0; line <= maxLines; line++){
var inputArray = input[line].split(" ").sort(function(a,b){return a-b});
var longest = inputArray[2];
var middle = inputArray[1];
var shortest = inputArray[0];
console.log((longest*longest == middle*middle + shortest*shortest) ? 'YES' : 'NO');
}
} | javascript | 13 | 0.638889 | 89 | 31.263158 | 19 | codenet |
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
// ここから
function main(){
for(var line = 1, maxLines = input[0] - 0; line <= maxLines; line++){
var inputArray = input[line].split(" ").sort(function(a,b){return a-b});
var longest = pow(inputArray[2]);
var middle = pow(inputArray[1]);
var shortest = pow(inputArray[0]);
var isRightTriangle = longest == middle + shortest;
console.log(isRightTriangle ? 'YES' : 'NO');
}
}
function pow(a){
return a*a;
} | javascript | 13 | 0.639053 | 76 | 28.434783 | 23 | codenet |
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
// ここから
function main(){
for(var line = 1, maxLines = input[0] - 0; line <= maxLines; line++){
var inputArray = input[line].split(" ").sort(function(a,b){return a-b});
var longest = pow(inputArray[2]);
var middle = pow(inputArray[1]);
var shortest = pow(inputArray[0]);
var isRightTriangle = middle + shortest - longest;
console.log(isRightTriangle ? 'NO' : 'YES');
}
}
function pow(a){
return a*a;
} | javascript | 13 | 0.64 | 76 | 28.391304 | 23 | codenet |
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
var lineNum = +lines.shift();
for (var i = 0; i < lineNum; i++) {
var line = lines[i];
var args = line.split(' ');
args = args.map(function(k) { return +k; })
args.sort(function(a, b) { return b - a; });
if (Math.pow(args[0], 2) == Math.pow(args[1], 2) + Math.pow(args[2], 2)) {
console.log('YES');
} else {
console.log('NO');
}
} | javascript | 11 | 0.532051 | 78 | 30.266667 | 15 | codenet |
function Main(input) {
var input = input.split("\n");
var N = Int(input[0]);
for(var i=1;i<=N;i++){
var side = input[i].split(" ");
for(var j =0;j<3;j++){
side[j]=Int(side[j]);
}
side.sort(descendingOrder);
if(side[0]*side[0]==side[1]*side[1]+side[2]*side[2]){
console.log("YES");
}else{
console.log("NO");
}
}
}
//??°????????????????????¢??°??¨(??????)
function ascendingOrder(val1,val2){
return val1 - val2;
}
//??°????????????????????¢??°??¨(??????)
function descendingOrder(val1,val2){
return val2 - val1;
}
//??°??????
function Int(str){
return parseInt(str, 10);
}
//????????????
function Str(num){
return num.toString(10);
}
//???????????°??¨
function debug(){
var input = document.getElementById("input").value;
Main(input);
}
//?????????????????\??????????????????
Main(require("fs").readFileSync("/dev/stdin", "utf8")); | javascript | 12 | 0.478261 | 58 | 20.928571 | 42 | codenet |
function Main(input) {
var input = input.split("\n");
var N = Int(input[0]);
for(var i=1;i<=N;i++){
var side = input[i].split(" ");
for(var j =0;j<3;j++){
side[j]=Int(side[j]);
}
side.sort(descendingOrder);
if(side[0]*side[0]==side[1]*side[1]+side[2]*side[2]){
output("YES");
}else{
output("NO");
}
}
}
//??°??????????????¢??°??¨(??????)
function ascendingOrder(val1,val2){
return val1 - val2;
}
//??°??????????????¢??°??¨(??????)
function descendingOrder(val1,val2){
return val2 - val1;
}
//??°??????
function Int(str){
return parseInt(str, 10);
}
//????????????
function Str(num){
return num.toString(10);
}
function output(str){
if(_Isdebug){
document.getElementById("input").value+=(str+"\n");
}
console.log(str);
}
//???????????°??¨
var _Isdebug = false;
function debug(){
_Isdebug =true;
var input = document.getElementById("input").value;
Main(input);
}
//?????????????????\??????????????????
Main(require("fs").readFileSync("/dev/stdin", "utf8")); | javascript | 12 | 0.48944 | 61 | 20.372549 | 51 | codenet |
x=require('fs').readFileSync('/dev/stdin','utf8').split(/\s/);for(i=1;i<x[0]*3+1;){a=x[i]*x[i++],b=x[i]*x[i++],c=x[i]*x[i++];if(a+b==c||b+c==a||c+a==b){console.log("YES");}else{console.log("NO");}} | javascript | 10 | 0.532995 | 197 | 197 | 1 | codenet |
var input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
input += chunk;
});
process.stdin.on('end', function() {
main(input)
});
function main(input){
var args = input.trim().split('\n');
args = args.slice(1, parseInt(args[0]) + 1 );
args.forEach(function(data){
data = data.split(' ').map(function(x){
x = parseInt(x);
return x * x;
}).sort(function(a,b){
return a - b;
});
var isRight = data[0] + data[1] === data[2];
var res = isRight ? "YES" : "NO";
console.log(res);
})
} | javascript | 20 | 0.523148 | 52 | 23.961538 | 26 | codenet |
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Get lines from standard input.
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split("\n");
var number_of_datasets = lines.shift();
for (var dataset = 0; dataset < number_of_datasets; dataset++)
{
var value = "NO";
var values = lines[dataset].split(" ");
var a = parseInt(values[0]);
var b = parseInt(values[1]);
var c = parseInt(values[2]);
if ((a*a) + (b*b) === (c*c))
{
value = "YES";
}
if ((a*a) + (c*c) === (b*b))
{
value = "YES";
}
if ((c*c) + (b*b) === (a*a))
{
value = "YES";
}
console.log(value);
} | javascript | 9 | 0.590461 | 62 | 17.454545 | 33 | codenet |
// tested on node version 0.10.36
var fs = require("fs");
function is_right_abc(a, b, c) {
return a*a + b*b === c*c;
}
function is_right(a, b, c) {
return is_right_abc(a, b, c) || is_right_abc(b, c, a) || is_right_abc(c, a, b);
}
var input = fs.readFileSync('/dev/stdin').toString();
var lines = input.split("\n");
var count = parseInt(lines.shift());
for(var i = 0; i < count; i++) {
var parts = lines[i].split(" ");
var a = parseInt(parts.shift());
var b = parseInt(parts.shift());
var c = parseInt(parts.shift());
if(!isNaN(a + b + c)) {
console.log(is_right(a, b, c) ? "YES" : "NO");
}
} | javascript | 11 | 0.556962 | 83 | 29.142857 | 21 | codenet |
function main(input) {
var lines = input.split("\n");
var problemCount = parseInt(lines.shift());
lines = lines.slice(0, problemCount);
for (var i = 0; i < lines.length; i++) {
var sides = lines[i].split(" ").slice(0,3)
.map(function(value) {
return parseInt(value);
})
.sort(function (a, b) {
return a - b;
});
if(!isNaN(sides[0] && !isNaN(sides[1]) && !isNaN(sides[2]))) {
console.log((Math.pow(sides[2],2) === Math.pow(sides[1],2) + Math.pow(sides[0],2)) ?
'YES' :
'NO');
}
}
}
main(require('fs').readFileSync('/dev/stdin','utf8')); | javascript | 17 | 0.577933 | 87 | 27.6 | 20 | codenet |
function generateTrianglesFromInput(input) {
var max = 1000;
var lines = getInputAsLines(input, "\n");
var vertices = lines.map(processLineToVertices);
for(var i = 0; i < vertices.length; i++) {
var line = vertices[i];
if(i === 0) {
if(line[0] > max) {
break;
}
}
var tri = new Triangle({
constraints: {
min: 1,
max: 1000
},
vertices: {
a: line[0],
b: line[1],
c: line[2]
}
});
if(tri.isValid()) {
var isRightAngleTriangle = tri.isRightAngleTriangle();
var logValue = (isRightAngleTriangle) ? 'YES' : 'NO';
console.log(logValue);
}
}
}
function getInputAsLines(input, delimeter) {
return input.split(delimeter);
}
function processLineToVertices(line) {
var vertices = line.split(' ');
return vertices;
}
//Triangle
function Triangle(options) {
this.constraints = {};
this.vertices = {};
//Set up triangle constraints.
this.constraints.min = options.constraints.min || 1;
this.constraints.max = options.constraints.max || 1000;
//Set up triangle vertices
this.vertices.a = (this.vertexIsWithinConstraints(options.vertices.a)) ? options.vertices.a : null;
this.vertices.b = (this.vertexIsWithinConstraints(options.vertices.b)) ? options.vertices.b : null;
this.vertices.c = (this.vertexIsWithinConstraints(options.vertices.c)) ? options.vertices.c : null;
}
Triangle.prototype.vertexIsWithinConstraints = function(vertex) {
return (vertex >= this.constraints.min && vertex <= this.constraints.max);
}
Triangle.prototype.isValid = function() {
return (this.vertices.a && this.vertices.b && this.vertices.c);
}
Triangle.prototype.isRightAngleTriangle = function() {
var value = false;
if(this.isValid) {
var vertexArray = [];
vertexArray.push(this.vertices.a);
vertexArray.push(this.vertices.b);
vertexArray.push(this.vertices.c);
vertexArray.sort(function(a, b) {return a-b});
var squares = vertexArray.map(function (vertex) { return Math.pow(vertex, 2)});
value = (squares[2] === (squares[0] + squares[1]));
}
return value;
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim();
generateTrianglesFromInput(input); | javascript | 16 | 0.651845 | 101 | 24.862069 | 87 | codenet |
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk){
var array = (chunk.trim()).split("\n")
var hen = 3
for (var i = 1; i < array.length; i++) {
var x = array[i].split(" ");
x.sort(function(d, e){
return e - d
})
if (Math.pow(x[0] , 2) == Math.pow(x[1] , 2) + Math.pow(x[2] , 2)) {
console.log("YES");
} else
console.log("NO");
}
}) | javascript | 15 | 0.541966 | 70 | 16.416667 | 24 | codenet |
var input = [];
var dataCount;
var data;
process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on('data', function(chunk){
input = chunk.toString("utf8").split("\n");
});
process.stdin.on('end', function(){
dataCount = parseInt(input.shift());
for (var i = 0; i < dataCount; i++) {
data = input[i].split(" ").map(Number).sort(function(a,b){
if (a < b) return -1;
if (a > b) return 1;
return 0;
});
if (Math.pow(data[0],2) + Math.pow(data[1],2) == Math.pow(data[2],2)) {
console.log("YES")
}else{
console.log("NO")
}
}
}); | javascript | 17 | 0.517557 | 79 | 27.521739 | 23 | codenet |
function Main(input){
input = input.split("\n");
var n = parseInt(input[0],10);
for(var i = 0;i < n;i++){
input[i + 1] = input[i + 1].split(' ');
var a = parseInt(input[i + 1][0],10);
var b = parseInt(input[i + 1][1],10);
var c = parseInt(input[i + 1][2],10);
if(a > b){
var ex = a;
a = b;
b = ex;
}
if(b > c){
var ex = b;
b = c;
c = ex;
}
if(a * a + b * b === c * c)
console.log("YES");
else
console.log("NO");
}
}
Main(require("fs").readFileSync("/dev/stdin","utf8")); | javascript | 12 | 0.381024 | 54 | 23.62963 | 27 | codenet |
var sample_input = require('fs').readFileSync('/dev/stdin', 'utf8');
var triangles = (sample_input.trim()).split("\n");
triangles.shift();
triangles.forEach(function(triangle){
var sides = triangle.split(" ").map(Number);
sides.sort( function(a,b) { return a-b; } );
var is_right="";
is_right=(sides[2]*sides[2]==sides[0]*sides[0]+sides[1]*sides[1]) ? "YES" : "NO";
console.log(is_right);
}); | javascript | 14 | 0.641791 | 83 | 39.3 | 10 | codenet |
//config = {stdin: 'tmp', newline: '\r\n'}; // win
config = {stdin: '/dev/stdin', newline: '\n'}; // linux
line = require('fs').readFileSync(config.stdin, 'ascii')
.trim()
.split(config.newline)
;
line.shift();
line = line.map(function (line) {
var ary = line.split(' ').map(Number);
ary.sort(function (a, b) { return b - a; });
if (sqr(ary[0]) === sqr(ary[1]) + sqr(ary[2])) return 'YES';
else return 'NO';
});
console.log(line.join('\n'));
function sqr(x) { return x * x; } | javascript | 14 | 0.587629 | 61 | 26 | 18 | codenet |
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
var array = (chunk.trim()).split("\n")
var hen = 3
for (var i = 1; i < array.length; i ++) {
var x = array[i].split(" ");
x.sort(function(d, e) {
return e - d
})
if (Math.pow(x[0], 2) == Math.pow(x[1] , 2) + Math.pow(x[2], 2)) {
console.log("YES");
} else
console.log("NO");
}
}) | javascript | 15 | 0.526807 | 70 | 21.631579 | 19 | codenet |
(function Main() {
var input = require("fs").readFileSync("/dev/stdin", "utf8");
input = input.split("\n");
var n=parseInt(input[0],10);
for(var i = 1; i <= n; i++){
var tmp=input[i].split(" ");
var a = parseInt(tmp[0], 10);
var b = parseInt(tmp[1], 10);
var c = parseInt(tmp[2], 10);
if(a*a+b*b==c*c || a*a+c*c==b*b || a*a==b*b+c*c) console.log("YES");
else console.log("NO");
}
})();
| javascript | 15 | 0.533981 | 72 | 28.428571 | 14 | codenet |
(function(undefined){
'use strict';
(function init() {
this.output = function() {
console.log.apply( console, arguments );
};
this.stdin = process.openStdin();
stdin.setEncoding('utf8');
this.input_list = [];
stdin.on('data', function(chunk){
var result = chunk.match(/\d+/g);
input_list = input_list.concat(result);
});
this.input_number = function() {
return parseInt( input_list.splice(0,1)[0] );
};
}).call( this );
(function solver(){
function sq(x) {
return x * x;
}
function check(v) {
return sq(v.a)+sq(v.b)===sq(v.c)
|| sq(v.b)+sq(v.c)===sq(v.a)
|| sq(v.c)+sq(v.a)===sq(v.b);
}
setTimeout( function solve() {
var n = input_number();
var vertexes = [];
while ( n -- )
vertexes.push({
a: input_number(),
b: input_number(),
c: input_number()
});
vertexes.forEach(function(vertex){
output( check(vertex) ? 'YES' : 'NO' );
});
}, 0 );
})();
}).call(global); | javascript | 28 | 0.558212 | 48 | 22.487805 | 41 | codenet |
function Main(input) {
lines=input.split("\n").slice(1);
for(var i in lines){
if(lines[i]=="")break;
len=lines[i].split(" ").map(function(x){return x-0;});
len.sort(function(a,b){return a-b;});
console.log(len[0]*len[0]+len[1]*len[1]==len[2]*len[2] ? "YES":"NO");
}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8")); | javascript | 13 | 0.59292 | 70 | 33 | 10 | codenet |
process.stdin.on("data",function(c){
(c+"").trim().split("\n").slice(1).some(function(n){
n=n.split(" ").map(function(a){return +a}).sort(function(a,b){return b-a});
console.log(n[0]*n[0]===n[1]*n[1]+n[2]*n[2]?"YES":"NO");
});
}).resume(); | javascript | 23 | 0.563265 | 77 | 40 | 6 | codenet |
var Triangle;
(function (Triangle) {
var RightAngle = (function () {
function RightAngle(a, b, c) {
this.a = a;
this.b = b;
this.c = c;
}
RightAngle.prototype.isRightAngle = function () {
var values = [this.a, this.b, this.c].sort(function (a, b) {
return b - a;
});
return Math.pow(values[0], 2.0) == (Math.pow(values[1], 2.0) + Math.pow(values[2], 2.0));
};
return RightAngle;
})();
Triangle.RightAngle = RightAngle;
})(Triangle || (Triangle = {}));
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
chunk.trim().split('\n').forEach(function (line) {
var items = line.trim().split(' ');
if (items.length == 3) {
var r = new Triangle.RightAngle(+items[0], +items[1], +items[2]);
if (r.isRightAngle()) {
console.log("YES");
} else {
console.log("NO");
}
}
});
}); | javascript | 24 | 0.485019 | 101 | 31.393939 | 33 | codenet |
process.stdin.on("data",function(c){
(c+"").trim().split("\n").slice(1).some(function(a){
var n = a.split(" ").map(function(x){return x*x}).sort(function(x,y){return x-y}); console.log(n[0]+n[1]===n[2]?'YES':'NO');
});
}).resume(); | javascript | 23 | 0.261036 | 248 | 103.4 | 5 | codenet |
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
var n = +lines.shift();
for (var i = 0; i < n; i++) {
var nums = lines[i].split(' ').sort(function(a,b){return a-b;});
var a = nums[0];
var b = nums[1];
var c = nums[2];
if (c * c == a * a + b * b)
console.log('YES');
else
console.log('NO');
} | javascript | 11 | 0.541547 | 65 | 20.875 | 16 | codenet |
let input = ''
process.stdin.resume()
process.stdin.setEncoding('utf8')
process.stdin.on('data', function(chunk) {
input += chunk
})
process.stdin.on('end', function() {
input = input.trim().split('\n')
main()
})
function main() {
for(i=0; i<input.length; i++) {
input_line = input[i].split(' ')
let sort_input_line = input_line.slice()
sort_input_line.sort(compareNumbers)
if (input_line[0] > 1000 || input_line[0] < -1000) {
return
}
let a = input_line[0]
let b = input_line[1]
let c = input_line[2]
let d = input_line[3]
let e = input_line[4]
let f = input_line[5]
let x = (b*f - e*c)/(d*b - a*e)
let y = (c-a*x)/b
console.log(x.toFixed(3), y.toFixed(3))
}
}
function compareNumbers(a, b) {
return b - a;
}
| javascript | 12 | 0.532239 | 60 | 22.054054 | 37 | codenet |
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
Arr.forEach(function(v){
var arr=v.split(" ").map(Number);
var A=arr[0]*arr[4]-arr[3]*arr[1];
var B=arr[2]*arr[4]-arr[5]*arr[1];
var C=arr[0]*arr[5]-arr[3]*arr[2];
var x=(B/A).toFixed(3);
var y=(C/A).toFixed(3);
console.log(x+" "+y);
}); | javascript | 13 | 0.602985 | 61 | 29.545455 | 11 | codenet |
(function(input) {
var p = input.replace(/\n$/, '').split('\n');
for (var i = 0; i < p.length; i++) {
var args = p[i].split(' ').map(Number);
var a = args[0];
var b = args[1];
var c = args[2];
var d = args[3];
var e = args[4];
var f = args[5];
var x = (c * e - b * f) / (a * e - b * d);
var y = (c * d - a * f) / (b * d - a * e);
x = x.toFixed(3);
y = y.toFixed(3);
console.log('%s %s', x, y);
}
})(require('fs').readFileSync('/dev/stdin', 'utf8')); | javascript | 15 | 0.396768 | 53 | 31.823529 | 17 | codenet |
require("fs").readFileSync("/dev/stdin","utf8").trim().split('\n').forEach(function(z){i=z.split(' ');console.log(x=((i[2]*i[4]-i[1]*i[5])/(i[0]*i[4]-i[1]*i[3])).toFixed(3),((i[2]-i[0]*x)/i[1]).toFixed(3))}) | javascript | 18 | 0.560386 | 207 | 207 | 1 | codenet |
require("fs").readFileSync("/dev/stdin","utf8").split('\n').map(function(z){i=z.split(' ');if(i[5])console.log(x=((i[2]*i[4]-i[1]*i[5])/(i[0]*i[4]-i[1]*i[3])).toFixed(3),((i[2]-i[0]*x)/i[1]).toFixed(3))}) | javascript | 19 | 0.54902 | 204 | 204 | 1 | codenet |
require("fs").readFileSync("/dev/stdin","utf8").trim().split('\n').map(function(z){i=z.split(' ');console.log(x=((i[2]*i[4]-i[1]*i[5])/(i[0]*i[4]-i[1]*i[3])).toFixed(3),((i[2]-i[0]*x)/i[1]).toFixed(3))}) | javascript | 18 | 0.551724 | 203 | 203 | 1 | codenet |
z=require('fs').readFileSync('/dev/stdin','utf8').trim().split(/\s/);
for(i=0;i<z.length;){
a=z[i++];
b=z[i++];
c=z[i++];
d=z[i++];
e=z[i++];
f=z[i++];
y=(c*d-a*f)/(b*d-a*e);
x=(c-b*y)/a;
console.log((Math.round(x*=1000)/1000).toFixed(3)+" "+(Math.round(y*=1000)/1000).toFixed(3));
} | javascript | 15 | 0.473354 | 97 | 25.666667 | 12 | codenet |
var input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
input += chunk;
});
process.stdin.on('end', function() {
main(input)
});
function main(input){
var args = input.trim().split('\n');
args.forEach(function(data){
data = data.split(' ').map(Number);
solve(data);
})
}
function solve(numbers){
var a = numbers[0], b = numbers[1], p = numbers[2];
var c = numbers[3], d = numbers[4], q = numbers[5];
var z = a * d - b * c;
var x = (d * p - b * q) / z;
var y = (a * q - c * p) / z;
console.log(x.toFixed(3) + ' ' + y.toFixed(3));
} | javascript | 15 | 0.539514 | 55 | 20.966667 | 30 | codenet |
// tested on node version 0.10.36
var fs = require("fs");
// Note: solution is based on information from the following page
// https://www.chilimath.com/algebra/advanced/cramers/2x2.html
/*
determinant of 2x2 matrix
[ a b ]
[ c d ]
*/
function det(a, b, c, d) {
return a * d - b * c;
}
/*
ax+by=c
dx+ey=f
[a b] = [c]
[d e] = [f]
x matrix:
[c b]
[f e]
y matrix:
[a c]
[d f]
*/
function solve_xy(a, b, c, d, e, f) {
var D = det(a, b, d, e)
var x = det(c, b, f, e) / D;
var y = det(a, c, d, f) / D;
return { x: x, y: y }
}
var input = fs.readFileSync('/dev/stdin').toString();
var lines = input.split("\n");
for(var i = 0; i < lines.length; i++) {
var parts = lines[i].split(" ");
var a = parseInt(parts.shift());
var b = parseInt(parts.shift());
var c = parseInt(parts.shift());
var d = parseInt(parts.shift());
var e = parseInt(parts.shift());
var f = parseInt(parts.shift());
if(!isNaN(a)) {
var solution = solve_xy(a, b, c, d, e, f);
console.log(solution.x.toFixed(3), solution.y.toFixed(3));
}
} | javascript | 11 | 0.530558 | 66 | 21.6 | 50 | codenet |
var input = [];
process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on('data', function(chunk){
input = chunk.toString("utf8").trim().split("\n");
});
process.stdin.on('end', function(){
for (var i = 0; i < input.length; i++) {
var data = input[i].split(" ").map(Number);
var a = data[0],
b = data[1],
c = data[2],
d = data[3],
e = data[4],
f = data[5];
var x = ((c * e - b * f) / (a * e - b * d)).toFixed(3);
var y = ((f * a - c * d) / (a * e - d * b)).toFixed(3);
console.log(x + " " + y);
}
}); | javascript | 17 | 0.464345 | 59 | 26.454545 | 22 | codenet |
var sample_input = require('fs').readFileSync('/dev/stdin', 'utf8');
var coefficient_sets = (sample_input.trim()).split("\n");
coefficient_sets.forEach(function(coefficient_set){
var coefficients = coefficient_set.split(" ").map(Number);
var a = coefficients[0];
var b = coefficients[1];
var c = coefficients[2];
var d = coefficients[3];
var e = coefficients[4];
var f = coefficients[5];
var x;
var y;
// (e*a x + -(d*b) )x = c*e - f*b
var x = ( c*e - f*b ) / (e*a - d*b);
var y = (c-a*x) / b;
console.log([x.toFixed(3),y.toFixed(3)].join(" "));
}); | javascript | 14 | 0.6 | 68 | 32.882353 | 17 | codenet |
var sample_input = require('fs').readFileSync('/dev/stdin', 'utf8');
var coefficient_sets = (sample_input.trim()).split("\n");
coefficient_sets.forEach(function(coefficient_set){
var coefficients = coefficient_set.split(" ").map(Number);
var a = coefficients[0];
var b = coefficients[1];
var c = coefficients[2];
var d = coefficients[3];
var e = coefficients[4];
var f = coefficients[5];
var x;
var y;
var x = (c*e - f*b )/(e*a - d*b);
var y = (c-a*x)/b;
console.log([x.toFixed(3),y.toFixed(3)].join(" "));
}); | javascript | 14 | 0.627341 | 68 | 32.4375 | 16 | codenet |
//config = {stdin: 'tmp', newline: '\r\n'}; // win
config = {stdin: '/dev/stdin', newline: '\n'}; // linux
require('fs').readFileSync(config.stdin, 'ascii')
.trim()
.split(config.newline)
.forEach(function (line) {
var ary = line.split(' ').map(Number);
var a = ary[0], b = ary[1], c = ary[2],
d = ary[3], e = ary[4], f = ary[5];
var det = a * e - b * d;
var Ainv_c = (e * c - b * f) / det;
var Ainv_f = (-d * c + a * f) / det;
console.log('%s %s', format(Ainv_c), format(Ainv_f));
});
function format(num) {
var s = num.toFixed(4);
var point = s.indexOf('.');
if (point === -1) return s + '.000';
return (s + '000').slice(0, point + 4);
} | javascript | 13 | 0.534639 | 55 | 29.227273 | 22 | codenet |
(function set_utils(undefined){
this.print_float = function print_float(val, base, pad, prec) {
var p10=Math.pow(10,prec);
var ival=""+Math.round(val*p10);
if ( ival === '0' )
return '0.000';
var ilen=ival.length-prec;
if(ilen===0)
return "0."+ival.substr(ilen,prec);
return ival.substr(0,ilen)+"."+ival.substr(ilen,prec);
};
}).call(global);
(function(undefined){
'use strict';
(function init() {
this.output = function() {
console.log.apply( console, arguments );
};
this.stdin = process.openStdin();
stdin.setEncoding('utf8');
this.input_list = [];
stdin.on('data', function(chunk){
var result = chunk.match(/[-]?\d+/g);
input_list = input_list.concat(result);
});
stdin.on('end', function(){
fire();
});
this.input_number = function() {
return parseInt( input_list.splice(0,1)[0] );
};
this.has_next = function() {
return ! input_list.length;
};
}).call( this );
(function solver(){
function sq(x) {
return x * x;
}
function check(v) {
}
this.fire = function() {
setTimeout( function solve() {
var a = input_number();
var b = input_number();
var c = input_number();
var d = input_number();
var e = input_number();
var f = input_number();
var delta = 1.0 / ( a*e - b*d );
var x = ( e * c - b * f ) * delta;
var y = ( a * f - d * c ) * delta;
output( print_float(x,10,3,3) + ' ' + print_float(y,10,3,3) );
if ( ! has_next() )
setTimeout( solve, 0, this );
}, 0, this );
};
}).call(this);
}).call(global); | javascript | 29 | 0.567742 | 67 | 23.619048 | 63 | codenet |
(function set_utils(undefined){
this.print_float = function print_float(val, base, pad, prec) {
var p10=Math.pow(10,prec);
var ival=""+Math.round(val*p10);
if ( ival === '0' )
return '0.'+Array(prec+1).join('0');
var ilen=ival.length-prec;
if(ilen===0)
return "0."+ival.substr(ilen,prec);
return ival.substr(0,ilen)+"."+ival.substr(ilen,prec);
};
}).call(global);
(function(undefined){
'use strict';
(function init() {
this.output = function() {
console.log.apply( console, arguments );
};
this.stdin = process.openStdin();
stdin.setEncoding('utf8');
this.input_list = [];
stdin.on('data', function(chunk){
var result = chunk.match(/[-]?\d+/g);
input_list = input_list.concat(result);
});
stdin.on('end', function(){
fire();
});
this.input_number = function() {
return parseInt( input_list.splice(0,1)[0] );
};
this.has_next = function() {
return ! input_list.length;
};
}).call( this );
(function solver(){
function sq(x) {
return x * x;
}
function check(v) {
}
this.fire = function() {
setTimeout( function solve() {
var a = input_number();
var b = input_number();
var c = input_number();
var d = input_number();
var e = input_number();
var f = input_number();
var delta = 1.0 / ( a*e - b*d );
var x = ( e * c - b * f ) * delta;
var y = ( a * f - d * c ) * delta;
output( print_float(x,10,3,3) + ' ' + print_float(y,10,3,3) );
if ( ! has_next() )
setTimeout( solve, 0, this );
}, 0, this );
};
}).call(this);
}).call(global); | javascript | 29 | 0.567791 | 67 | 23.952381 | 63 | codenet |
process.stdin.on("data",function(c){
(c+"").trim().split("\n").some(function(n,x){
n=n.split(" ");
var a=+n[0],b=+n[1],c=+n[2],d=+n[3],e=+n[4],f=+n[5],x;
console.log((x=((c*e-b*f)/(a*e-b*d))).toFixed(3),((c-a*x)/b).toFixed(3));
});
}).resume(); | javascript | 25 | 0.5 | 75 | 35.142857 | 7 | codenet |
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
var line;
while (line = lines.shift()) {
var vals = line.split(' ').map(function(n){return +n;});
var a = vals[0];
var b = vals[1];
var c = vals[2];
var d = vals[3];
var e = vals[4];
var f = vals[5];
var D = a * e - b * d;
var x = (e * c - b * f) / D;
var y = (a * f - d * c) / D;
console.log(x.toFixed(3) + ' ' + y.toFixed(3));
} | javascript | 11 | 0.524027 | 61 | 22.052632 | 19 | codenet |
require("fs").readFileSync("/dev/stdin","utf8").trim().split('\n').map(function(z){i=z.split(' ');console.log(x=((i[2]*i[4]-i[1]*i[5])/(i[0]*i[4]-i[1]*i[3])).toFixed(3),((i[2]-i[0]*x)/i[1]).toFixed(3))})
| javascript | 18 | 0.54902 | 203 | 203 | 1 | codenet |
let input = ''
process.stdin.resume()
process.stdin.setEncoding('utf8')
process.stdin.on('data', function(chunk) {
input += chunk
})
process.stdin.on('end', function() {
input = input.trim().split('\n')
main()
})
function main() {
for(i=0; i<input.length; i++) {
input_line = input[i].split(' ')
input_line.sort(compareNumbers)
let a = input_line[0]
let b = input_line[1]
let r = input_line[0] % input_line[1]
let x = a * b
while(r!=0){
a = b
b = r
r = a % b
}
console.log(b, x/b)
}
}
function compareNumbers(a, b) {
return b - a;
}
| javascript | 12 | 0.515291 | 45 | 19.4375 | 32 | codenet |
function GCD(a,b){
var m=Math.max(a,b);
var n=Math.min(a,b);
while(n!=0){
var N=n;
n=m%n;
m=N;
}
return m;
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
Arr.forEach(function(v){
var arr=v.split(" ").map(Number);
var gcd=GCD(arr[0],arr[1]);
var lcm=arr[0]*arr[1]/gcd;
console.log(gcd+" "+lcm);
}); | javascript | 13 | 0.540201 | 61 | 20 | 19 | codenet |
(function(input) {
var p = input.replace(/\n$/, '').split('\n');
for (var i = 0; i < p.length; i++) {
var args = p[i].split(' ').map(Number);
var a = args[0];
var b = args[1];
var gcd = greatestCommonDivisor(a, b);
var lcm = leastCommonMultiple(a, b);
console.log('%s %s', gcd, lcm);
}
})(require('fs').readFileSync('/dev/stdin', 'utf8'));
function greatestCommonDivisor(a, b) {
if (b > a) {
var tmp = a;
a = b;
b = tmp;
}
if (b == 0) {
return a;
}
return greatestCommonDivisor(a % b, b);
}
function leastCommonMultiple(a, b) {
return a * b / greatestCommonDivisor(a, b);
} | javascript | 15 | 0.506512 | 53 | 24.62963 | 27 | codenet |
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).trim().split('\n');
main();
// ここから
function main(){
for(var i = 0, len = input.length; i < len; i++){
var j = input[i].split(" ");
var a = j[0] - 0;
var b = j[1] - 0;
var g = gcd(a, b);
var lcm = a * b / g;
console.log(g + " " + lcm);
}
}
function gcd(a, b){
var x = max(a, b);
var y = min(a, b);
var mod
while(mod = x % y){
x = y;
y = mod;
}
return y;
}
function max(a, b) {
var t = a - b;
return a - (t & (t >> 31));
}
function min(a, b){
var t = a - b;
return b + (t & (t >> 31));
} | javascript | 11 | 0.509753 | 65 | 18.25 | 40 | codenet |
require("fs").readFileSync("/dev/stdin","utf8").trim().split('\n').some(function(i){j=i.split(' ');a=j[0],b=j[1],c=a*b;while(m=a%b)a=b,b=m;console.log(b,c/b)}) | javascript | 13 | 0.610063 | 159 | 159 | 1 | codenet |
require("fs").readFileSync("/dev/stdin","utf8").split('\n').map(function(i){j=i.split(' ');a=j[0],b=j[1],c=a*b;while(m=a%b)a=b,b=m;if(b)console.log(b,c/b)}) | javascript | 11 | 0.608974 | 156 | 156 | 1 | codenet |
for(i=require("fs").readFileSync("/dev/stdin","utf8").split(/\s/),j=0;a=i[j++],b=i[j++],c=a*b;){while(m=a%b)a=b,b=m;console.log(b,c/b)} | javascript | 12 | 0.585185 | 135 | 135 | 1 | codenet |
x=require('fs').readFileSync('/dev/stdin','utf8').split(/\s/);
i=0;
for(;i<x.length-2;){
if(x[i++]<x[i++]){
tmp = x[i-2];
x[i-2] = x[i-1];
x[i-1] = tmp;
}
l=x[i-2]*x[i-1];
r = x[i-2] % x[i-1];
while(r!==0){
x[i-2] = x[i-1];
x[i-1] = r;
r = x[i-2] % x[i-1];
}
console.log(x[i-1], l/x[i-1]);
} | javascript | 10 | 0.41433 | 62 | 17.941176 | 17 | codenet |
var input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
input += chunk;
});
process.stdin.on('end', function() {
main(input)
});
function main(input){
var args = input.trim().split('\n');
args.forEach(function(data){
data = data.split(' ').map(Number);
solve(data[0], data[1]);
})
}
function solve(a, b){
if(a < b){
var tmp = b;
b = a;
a = tmp;
}
var gcd = calcGcd(a, b);
var lcm = a * b / gcd;
console.log(gcd + ' ' + lcm);
}
function calcGcd(a, b){
if(b <= 0){
return a;
}
return calcGcd(b, a % b);
} | javascript | 15 | 0.516467 | 43 | 17.583333 | 36 | codenet |
function calcultateGCD(a,b,res) {
if(a==b)
return a*res;
else if ((a&1)==0 && (b&1)==0)
return calcultateGCD(a>>1, b>>1, res<<1);
else if ((a&1)==0)
return calcultateGCD(a>>1, b, res);
else if ((b&1)==0)
return calcultateGCD(a, b>>1, res);
else if (a>b)
return calcultateGCD(a-b, b, res);
else
return calcultateGCD(a, b-a, res);
}
function calcultateLCM(a,b,gcd) {
return a*b/gcd;
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
if(lines.length > 50) {
console.log("Invalid dataset size. Dataset size is "+lines.length+" but must be <= 50");
} else {
for (var i = 0; i < lines.length; i++) {
var line = lines[i].trim();
if (line == '') break;
var vals = line.split(' ').map(function(i){return +i;});
if(vals.length != 2 || isNaN(vals[0]) || isNaN(vals[1]) || vals[0] < 0 || vals[0] > 2000000000 || vals[1] < 0 || vals[1] > 2000000000) {
console.log("Invalid dataset: "+line+ ". Use 0 <= a, b <= 2,000,000,000");
} else {
var gcd = calcultateGCD(vals[0],vals[1],1);
var lcm = calcultateLCM(vals[0],vals[1],gcd);
if(lcm > 2000000000)
console.log("Invalid dataset: "+line+ ". LCM is "+lcm+" but must be <= 2,000,000,000");
else
console.log(gcd+" "+lcm);
}
}
} | javascript | 18 | 0.558296 | 141 | 31.658537 | 41 | codenet |
function calcultateGCD(a,b,res) {
if(a==b)
return a*res;
else if ((a&1)==0 && (b&1)==0)
return calcultateGCD(a>>1, b>>1, res<<1);
else if ((a&1)==0)
return calcultateGCD(a>>1, b, res);
else if ((b&1)==0)
return calcultateGCD(a, b>>1, res);
else if (a>b)
return calcultateGCD(a-b, b, res);
else
return calcultateGCD(a, b-a, res);
}
function calcultateLCM(a,b,gcd) {
return a*b/gcd;
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
if(lines.length > 50) {
console.log("Invalid dataset size. Dataset size is "+lines.length+" but must be <= 50");
} else {
for (var i = 0; i < lines.length; i++) {
var line = lines[i].trim();
if (line == '') break;
var vals = line.split(' ').map(function(i){return +i;});
if(vals.length != 2 || isNaN(vals[0]) || isNaN(vals[1]) || vals[0] < 0 || vals[0] > 2000000000 || vals[1] < 0 || vals[1] > 2000000000) {
console.log("Invalid dataset: "+line+ ". Use 0 <= a, b <= 2,000,000,000");
} else {
var gcd = calcultateGCD(vals[0],vals[1],1);
var lcm = calcultateLCM(vals[0],vals[1],gcd);
if(lcm > 2000000000)
console.log("Invalid dataset: "+line+ ". LCM is "+lcm+" but must be <= 2,000,000,000");
else
console.log(gcd+" "+lcm);
}
}
} | javascript | 18 | 0.558296 | 141 | 31.658537 | 41 | codenet |
// tested on node version 0.10.36
var fs = require("fs");
function gcd(a, b) {
// make sure a > b
var t = a;
if(b > a) {
a = b;
b = t;
}
while(b != 0) {
t = b;
b = a % b;
a = t;
}
return a;
}
var input = fs.readFileSync('/dev/stdin').toString();
var lines = input.split("\n");
for(var i = 0; i < lines.length; i++) {
var parts = lines[i].split(" ");
var a = parseInt(parts.shift());
var b = parseInt(parts.shift());
if(!isNaN(a + b)) {
var g = gcd(a, b);
var lcm = (a * b) / g;
console.log(g, lcm);
}
} | javascript | 10 | 0.450407 | 53 | 20.241379 | 29 | codenet |
// ??\???????????\??????
var input = require("fs").readFileSync("/dev/stdin","utf8");
var array = (input.trim()).split("\n");
for (var i = 0; i < array.length; i++) {
var splited = array[i].split(" ");
//??§?????????????????????
splited.sort(function(d, e){
return e - d
})
test(splited)
}
// ?????\??????????????????????????????
function test(data) {
var a = data[0]
var b = data[1]
// c_multi=????°???¬?????° gcd=?????§??¬?´???°
// ?????§??¬?´???°????±???????
var x = a;
var y = b;
var z;
while ((z = x % y) != 0) {
x = y
y = z
}
var gcd = y
// ????°???¬?????°????±???????
var lcm = a * b / gcd
// ??¨?¨?
console.log(gcd + " " + lcm)
} | javascript | 10 | 0.364964 | 60 | 19.787879 | 33 | codenet |
var input = [];
process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on('data', function(chunk){
input = chunk.toString("utf8").trim().split("\n");
});
process.stdin.on('end', function(){
for (var i = 0; i < input.length; i++) {
var data = input[i].split(" ").map(Number);
var a = data[0],
b = data[1];
var GCD,
LCM;
while(b != 1){
if(a === b) break;
sortedData = [a,b].sort(function(a,b){
if (a < b) {
return 1
}else if(a > b){
return -1
}
return 0
});
b = sortedData[0] - sortedData[1];
a = sortedData[1]
}
GCD = b;
LCM = data[0] * data[1] / GCD;
console.log(GCD + " " + LCM)
}
}); | javascript | 22 | 0.451005 | 53 | 23.151515 | 33 | codenet |
const rl = require('readline').createInterface({
input: process.stdin, output: process.stdout
});
rl.on('line', function (line) {
var ary = line.split(' ');
var a = Number(ary[0]), b = Number(ary[1]);
console.log('%d %d', gcd(a, b), lcm(a, b));
});
function gcd(a, b) {
while (a !== b) {
if (a < b) {
var tmp = a;
a = b;
b = tmp;
}
if (a % b === 0) return b;
a -= b;
}
return a;
}
function lcm(a, b) {
var g = gcd(a, b);
return g * (a / g) * (b / g);
} | javascript | 11 | 0.511435 | 48 | 16.851852 | 27 | codenet |
(function set_utils(undefined){
this.print_float = function print_float(val, base, pad, prec) {
var p10=Math.pow(10,prec);
var ival=""+Math.round(val*p10);
if ( ival === '0' )
return '0.'+Array(prec+1).join('0');
var ilen=ival.length-prec;
if(ilen===0)
return "0."+ival.substr(ilen,prec);
return ival.substr(0,ilen)+"."+ival.substr(ilen,prec);
};
this.gcd = function gcd( a, b ) {
return !b ? a : gcd( b, a % b );
};
this.lcm = function lcm( a, b ) {
return a / gcd( a, b ) * b;
};
}).call(global);
(function(undefined){
'use strict';
(function init() {
this.output = function() {
console.log.apply( console, arguments );
};
this.stdin = process.openStdin();
stdin.setEncoding('utf8');
this.input_list = [];
stdin.on('data', function(chunk){
var result = chunk.match(/[-]?\d+/g);
input_list = input_list.concat(result);
});
stdin.on('end', function(){
fire();
});
this.input_number = function() {
return parseInt( input_list.splice(0,1)[0] );
};
this.has_next = function() {
return ! input_list.length;
};
}).call( this );
(function solver(){
function sq(x) {
return x * x;
}
function check(v) {
}
this.fire = function() {
setTimeout( solve, 0, this );
};
function solve() {
var args = [input_number(), input_number()];
output( gcd.apply( this, args ), lcm.apply( this, args ) );
if ( ! has_next() )
setTimeout( solve, 0, this );
}
}).call(this);
}).call(global); | javascript | 23 | 0.584855 | 64 | 22.870968 | 62 | codenet |
(function utils(undefined){
this.print_float = function print_float(val, base, pad, prec) {
var p10=Math.pow(10,prec);
var ival=""+Math.round(val*p10);
if ( ival === '0' )
return '0.'+Array(prec+1).join('0');
var ilen=ival.length-prec;
if(ilen===0)
return "0."+ival.substr(ilen,prec);
return ival.substr(0,ilen)+"."+ival.substr(ilen,prec);
};
}).call(global);
(function math(undefined) {
this.gcd = function gcd( a, b ) {
return !b ? a : gcd( b, a % b );
};
this.lcm = function lcm( a, b ) {
return a / gcd( a, b ) * b;
};
this.sq = function sq(x) {
return x * x;
};
}).call(global);
(function(undefined){
'use strict';
(function init() {
this.output = function() {
console.log.apply( console, arguments );
};
this.stdin = process.openStdin();
stdin.setEncoding('utf8');
this.input_list = [];
stdin.on('data', function(chunk){
var result = chunk.match(/[-]?\d+/g);
input_list = input_list.concat(result);
});
stdin.on('end', function(){
fire();
});
this.input_number = function() {
return parseInt( input_list.splice(0,1)[0] );
};
this.has_next = function() {
return ! input_list.length;
};
}).call( this );
(function solver(){
this.fire = function() {
setTimeout( solve, 0, this );
};
function solve() {
var args = [input_number(), input_number()];
output( gcd.apply( this, args ), lcm.apply( this, args ) );
if ( ! has_next() )
setTimeout( solve, 0, this );
}
}).call(this);
}).call(global); | javascript | 23 | 0.588822 | 64 | 22.873016 | 63 | codenet |
process.stdin.on("data",function(c){
(c+"").trim().split("\n").some(function(n,m,h){
n=n.split(" "),m=+n[1],n=+n[0];
var g=function(m,n,t){
m<n&&(t=n,n=m,m=t);
while(n=m%(m=n));
return m;
};
console.log(h=g(n,m),n*m/h);
});
}).resume(); | javascript | 23 | 0.501961 | 48 | 22.272727 | 11 | codenet |
function gcd(a, b) {
if (b > a) return gcd(b, a);
if (b == 0) return a;
return gcd(b, a % b);
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
var line;
while (line = lines.shift()) {
var nums = line.split(' ').map(function(n){return +n;});
var a = nums[0];
var b = nums[1];
var d = gcd(a, b);
var m = a * b / d;
console.log(d + ' ' + m);
} | javascript | 11 | 0.549118 | 61 | 21.111111 | 18 | codenet |
let input = ''
process.stdin.resume()
process.stdin.setEncoding('utf8')
process.stdin.on('data', function(chunk) {
input += chunk
})
process.stdin.on('end', function() {
input = input.trim().split('\n')
main()
})
function main() {
return console.log(input[0].split("").reverse().join(""))
}
| javascript | 13 | 0.641196 | 59 | 19.066667 | 15 | codenet |
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
console.log((input.trim()).split("").reverse().join("")); | javascript | 13 | 0.638655 | 61 | 59 | 2 | codenet |
(function(input) {
var str = input.replace(/\n$/, '');
console.log(str.split('').reverse().join(''));
})(require('fs').readFileSync('/dev/stdin', 'utf8')); | javascript | 16 | 0.576687 | 53 | 40 | 4 | codenet |
var str="";
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(input) {
str = input.split("\n")[0].split("").reverse().join("");
});
process.stdin.on('end', function() {
console.log(str);
}); | javascript | 18 | 0.631799 | 58 | 23 | 10 | codenet |
for(i=require("fs").readFileSync("/dev/stdin","utf8").trim(),j=i.length,k='';j--;)k+=i[j];console.log(k) | javascript | 12 | 0.625 | 104 | 104 | 1 | codenet |
console.log(require("fs").readFileSync("/dev/stdin","utf8").trim().split('').reverse().join('')) | javascript | 17 | 0.65625 | 96 | 96 | 1 | codenet |
function Main(input) {
var input = input.split("\n");
var str = input[0].split("");
var ans="";
for(;str.length!=0;){
ans+=str.pop();
}
console.log(ans);
}
//??°??????????????¢??°??¨(??????)
function ascendingOrder(val1,val2){
return val1 - val2;
}
//??°??????????????¢??°??¨(??????)
function descendingOrder(val1,val2){
return val2 - val1;
}
//??°??????
function Int(str){
return parseInt(str, 10);
}
//????????????
function Str(num){
return num.toString(10);
}
//???????????°??¨
function debug(){
var input = document.getElementById("input").value;
Main(input);
}
//?????????????????\??????????????????
Main(require("fs").readFileSync("/dev/stdin", "utf8")); | javascript | 9 | 0.490141 | 55 | 19.314286 | 35 | codenet |
function main(){
print(scan('string').split('').reverse().join(''))
}
function rep(a, b, c){
if(c == null){
c = b;
b = a;
a = 0;
}
for(var i = a; i < b; ++i){
c(i);
}
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
var input = '';
var input_index = 0;
function scan(type){
if(type === 'string'){
return input[input_index++];
}
else{
return +input[input_index++];
}
}
function print(val){
console.log(val);
}
process.stdin.on('data', function(chunk){
input += chunk;
});
process.stdin.on('end', function(){
input = input.split(/\s+/);
main();
}); | javascript | 15 | 0.569748 | 51 | 13.536585 | 41 | codenet |
console.log(x=require('fs').readFileSync('/dev/stdin','utf8').replace(/\n/g,"").split("").reverse().join("")); | javascript | 18 | 0.627273 | 110 | 110 | 1 | codenet |
var input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
input += chunk;
});
process.stdin.on('end', function() {
main(input)
});
function main(input){
console.log(input.trim().split('').reverse().join(''));
} | javascript | 14 | 0.636042 | 59 | 20.846154 | 13 | codenet |
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Get lines from standard input.
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split("\n");
var line = lines[0];
console.log(line.split("").reverse().join("")); | javascript | 11 | 0.678431 | 61 | 31 | 8 | codenet |
// tested on node version 0.10.36
var fs = require("fs");
function reverse(s) {
return s.split('').reverse().join('');
}
var input = fs.readFileSync('/dev/stdin').toString().trim();
console.log(reverse(input)); | javascript | 11 | 0.658879 | 60 | 22.888889 | 9 | codenet |
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
console.log(input.trim().split('').reverse().join('')); | javascript | 12 | 0.649573 | 61 | 58 | 2 | codenet |
var input = require('fs').readFileSync('/dev/stdin', 'utf8').replace(/\n/g,'');
function reverseSequence(str) {
var output = '';
var arr = str.split('');
while (arr.length) {
output += arr.pop();
}
return output;
}
console.log(reverseSequence(input)); | javascript | 10 | 0.642308 | 79 | 20.75 | 12 | codenet |
var input = require("fs").readFileSync("/dev/stdin","utf8");
var rSt = input.trim().split("").reverse().join("");
console.log(rSt); | javascript | 11 | 0.648855 | 60 | 43 | 3 | codenet |