• + 0 comments

    in R could be

    stdin <- file('stdin')
    open(stdin)
    n <- as.integer(trimws(readLines(stdin, n = 1, warn = FALSE), which = "both"))
    dataX <- as.numeric(strsplit(trimws(readLines(stdin, n = 1, warn = FALSE), which = "right"), " ")[[1]])
    dataY <- as.numeric(strsplit(trimws(readLines(stdin, n = 1, warn = FALSE), which = "right"), " ")[[1]])
    correlation = cor(dataX, dataY, method = 'pearson')
    cat(round(correlation, 3))