kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: Parameterized SQL statement
C++: #include <QtSql>
#include <iostream>




int main(int argc, char *argv[]) {
    if (argc != 4) {
        std::cerr << "Usage: " << argv[0] << " data-source user password\n";
        return 1;
    }
    QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    db.setDatabaseName(argv[1]);
    if (!db.open(argv[2], argv[3])) {
        auto error = db.lastError();
        std::cerr << "Cannot connect to data source: " << error.text().toStdString() << '\n';
    } else {
        std::cout << "Connected to data source.\n";
        QSqlQuery query(db);
        query.prepare("UPDATE players SET name = ?, score = ?, active = ? WHERE jerseyNum = ?");
        query.bindValue(0, "Smith, Steve");
        query.bindValue(1, 42);
        query.bindValue(2, true);
        query.bindValue(3, 99);
        if (!query.exec()) {
            auto error = db.lastError();
            std::cerr << "Cannot update database: " << error.text().toStdString() << '\n';
        } else {
            std::cout << "Update succeeded.\n";
        }
    }
    return 0;
}

Go: package main

import (
    "database/sql"
    "fmt"

    _ "github.com/mattn/go-sqlite3"
)

func main() {
    db, _ := sql.Open("sqlite3", "rc.db")
    defer db.Close()
    db.Exec(`create table players (name, score, active, jerseyNum)`)
    db.Exec(`insert into players values ("",0,0,"99")`)
    db.Exec(`insert into players values ("",0,0,"100")`)

    
    db.Exec(`update players set name=?, score=?, active=? where jerseyNum=?`,
        "Smith, Steve", 42, true, "99")

    rows, _ := db.Query("select * from players")
    var (
        name      string
        score     int
        active    bool
        jerseyNum string
    )
    for rows.Next() {
        rows.Scan(&name, &score, &active, &jerseyNum)
        fmt.Printf("%3s %12s %3d %t\n", jerseyNum, name, score, active)
    }
    rows.Close()
}
Task: Parameterized SQL statement
C#: using System.Data.Sql;
using System.Data.SqlClient;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            using var tConn = new SqlConnection("ConnectionString");

            using var tCommand = tConn.CreateCommand();
            tCommand.CommandText = "UPDATE players SET name = @name, score = @score, active = @active WHERE jerseyNum = @jerseyNum";

            tCommand.Parameters.Add(new SqlParameter("@name", System.Data.SqlDbType.VarChar).Value = "Smith, Steve");
            tCommand.Parameters.Add(new SqlParameter("@score", System.Data.SqlDbType.Int).Value = "42");
            tCommand.Parameters.Add(new SqlParameter("@active", System.Data.SqlDbType.Bit).Value = true);
            tCommand.Parameters.Add(new SqlParameter("@jerseyNum", System.Data.SqlDbType.Int).Value = "99");

            tCommand.ExecuteNonQuery();
        }
    }
}

Python: import sqlite3

db = sqlite3.connect(':memory:')


db.execute('create temp table players (name, score, active, jerseyNum)')
db.execute('insert into players values ("name",0,"false",99)')
db.execute('insert into players values ("name",0,"false",100)')




db.execute('update players set name=?, score=?, active=? where jerseyNum=?', ('Smith, Steve', 42, True, 99))


db.execute('update players set name=:name, score=:score, active=:active where jerseyNum=:num',
    {'num': 100,
     'name': 'John Doe',
     'active': False,
     'score': -1}
)


for row in db.execute('select * from players'):
   print(row)
Task: Parameterized SQL statement
C++: #include <QtSql>
#include <iostream>




int main(int argc, char *argv[]) {
    if (argc != 4) {
        std::cerr << "Usage: " << argv[0] << " data-source user password\n";
        return 1;
    }
    QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    db.setDatabaseName(argv[1]);
    if (!db.open(argv[2], argv[3])) {
        auto error = db.lastError();
        std::cerr << "Cannot connect to data source: " << error.text().toStdString() << '\n';
    } else {
        std::cout << "Connected to data source.\n";
        QSqlQuery query(db);
        query.prepare("UPDATE players SET name = ?, score = ?, active = ? WHERE jerseyNum = ?");
        query.bindValue(0, "Smith, Steve");
        query.bindValue(1, 42);
        query.bindValue(2, true);
        query.bindValue(3, 99);
        if (!query.exec()) {
            auto error = db.lastError();
            std::cerr << "Cannot update database: " << error.text().toStdString() << '\n';
        } else {
            std::cout << "Update succeeded.\n";
        }
    }
    return 0;
}

Java: import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
 
public class DBDemo{
   private String protocol; 
   private String dbName;   
   private String username;
   private String password;

   PreparedStatement query;
 
   public int setUpAndExecPS(){
      try {
         Connection conn = DriverManager.getConnection(protocol + dbName, username, password);

         query = conn.prepareStatement(
            "UPDATE players SET name = ?, score = ?, active = ? WHERE jerseyNum = ?");
 
         query.setString(1, "Smith, Steve");
         query.setInt(2, 42);
         query.setBoolean(3, true);
         query.setInt(4, 99);
         
         return query.executeUpdate();
         
         

      } catch (Exception e) {
         e.printStackTrace();
      }

      return 0;
   }
}
Task: Parameterized SQL statement
Java: import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
 
public class DBDemo{
   private String protocol; 
   private String dbName;   
   private String username;
   private String password;

   PreparedStatement query;
 
   public int setUpAndExecPS(){
      try {
         Connection conn = DriverManager.getConnection(protocol + dbName, username, password);

         query = conn.prepareStatement(
            "UPDATE players SET name = ?, score = ?, active = ? WHERE jerseyNum = ?");
 
         query.setString(1, "Smith, Steve");
         query.setInt(2, 42);
         query.setBoolean(3, true);
         query.setInt(4, 99);
         
         return query.executeUpdate();
         
         

      } catch (Exception e) {
         e.printStackTrace();
      }

      return 0;
   }
}

Python: import sqlite3

db = sqlite3.connect(':memory:')


db.execute('create temp table players (name, score, active, jerseyNum)')
db.execute('insert into players values ("name",0,"false",99)')
db.execute('insert into players values ("name",0,"false",100)')




db.execute('update players set name=?, score=?, active=? where jerseyNum=?', ('Smith, Steve', 42, True, 99))


db.execute('update players set name=:name, score=:score, active=:active where jerseyNum=:num',
    {'num': 100,
     'name': 'John Doe',
     'active': False,
     'score': -1}
)


for row in db.execute('select * from players'):
   print(row)
Task: Parameterized SQL statement
C#: using System.Data.Sql;
using System.Data.SqlClient;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            using var tConn = new SqlConnection("ConnectionString");

            using var tCommand = tConn.CreateCommand();
            tCommand.CommandText = "UPDATE players SET name = @name, score = @score, active = @active WHERE jerseyNum = @jerseyNum";

            tCommand.Parameters.Add(new SqlParameter("@name", System.Data.SqlDbType.VarChar).Value = "Smith, Steve");
            tCommand.Parameters.Add(new SqlParameter("@score", System.Data.SqlDbType.Int).Value = "42");
            tCommand.Parameters.Add(new SqlParameter("@active", System.Data.SqlDbType.Bit).Value = true);
            tCommand.Parameters.Add(new SqlParameter("@jerseyNum", System.Data.SqlDbType.Int).Value = "99");

            tCommand.ExecuteNonQuery();
        }
    }
}

PHP: $updatePlayers = "UPDATE `players` SET `name` = ?, `score` = ?, `active` = ?\n".
		"WHERE `jerseyNum` = ?";
$dbh = new PDO( "mysql:dbname=db;host=localhost", "username", "password" );

$updateStatement = $dbh->prepare( $updatePlayers );

$updateStatement->bindValue( 1, "Smith, Steve", PDO::PARAM_STR );
$updateStatement->bindValue( 2, 42, PDO::PARAM_INT );
$updateStatement->bindValue( 3, 1, PDO::PARAM_INT );
$updateStatement->bindValue( 4, 99, PDO::PARAM_INT );

$updateStatement->execute();

$updateStatement = $dbh->prepare( $updatePlayers );
$updateStatement->execute( array( "Smith, Steve", 42, 1, 99 ) );
Task: Parameterized SQL statement
C++: #include <QtSql>
#include <iostream>




int main(int argc, char *argv[]) {
    if (argc != 4) {
        std::cerr << "Usage: " << argv[0] << " data-source user password\n";
        return 1;
    }
    QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    db.setDatabaseName(argv[1]);
    if (!db.open(argv[2], argv[3])) {
        auto error = db.lastError();
        std::cerr << "Cannot connect to data source: " << error.text().toStdString() << '\n';
    } else {
        std::cout << "Connected to data source.\n";
        QSqlQuery query(db);
        query.prepare("UPDATE players SET name = ?, score = ?, active = ? WHERE jerseyNum = ?");
        query.bindValue(0, "Smith, Steve");
        query.bindValue(1, 42);
        query.bindValue(2, true);
        query.bindValue(3, 99);
        if (!query.exec()) {
            auto error = db.lastError();
            std::cerr << "Cannot update database: " << error.text().toStdString() << '\n';
        } else {
            std::cout << "Update succeeded.\n";
        }
    }
    return 0;
}

PHP: $updatePlayers = "UPDATE `players` SET `name` = ?, `score` = ?, `active` = ?\n".
		"WHERE `jerseyNum` = ?";
$dbh = new PDO( "mysql:dbname=db;host=localhost", "username", "password" );

$updateStatement = $dbh->prepare( $updatePlayers );

$updateStatement->bindValue( 1, "Smith, Steve", PDO::PARAM_STR );
$updateStatement->bindValue( 2, 42, PDO::PARAM_INT );
$updateStatement->bindValue( 3, 1, PDO::PARAM_INT );
$updateStatement->bindValue( 4, 99, PDO::PARAM_INT );

$updateStatement->execute();

$updateStatement = $dbh->prepare( $updatePlayers );
$updateStatement->execute( array( "Smith, Steve", 42, 1, 99 ) );
Task: Parameterized SQL statement
Go: package main

import (
    "database/sql"
    "fmt"

    _ "github.com/mattn/go-sqlite3"
)

func main() {
    db, _ := sql.Open("sqlite3", "rc.db")
    defer db.Close()
    db.Exec(`create table players (name, score, active, jerseyNum)`)
    db.Exec(`insert into players values ("",0,0,"99")`)
    db.Exec(`insert into players values ("",0,0,"100")`)

    
    db.Exec(`update players set name=?, score=?, active=? where jerseyNum=?`,
        "Smith, Steve", 42, true, "99")

    rows, _ := db.Query("select * from players")
    var (
        name      string
        score     int
        active    bool
        jerseyNum string
    )
    for rows.Next() {
        rows.Scan(&name, &score, &active, &jerseyNum)
        fmt.Printf("%3s %12s %3d %t\n", jerseyNum, name, score, active)
    }
    rows.Close()
}

PHP: $updatePlayers = "UPDATE `players` SET `name` = ?, `score` = ?, `active` = ?\n".
		"WHERE `jerseyNum` = ?";
$dbh = new PDO( "mysql:dbname=db;host=localhost", "username", "password" );

$updateStatement = $dbh->prepare( $updatePlayers );

$updateStatement->bindValue( 1, "Smith, Steve", PDO::PARAM_STR );
$updateStatement->bindValue( 2, 42, PDO::PARAM_INT );
$updateStatement->bindValue( 3, 1, PDO::PARAM_INT );
$updateStatement->bindValue( 4, 99, PDO::PARAM_INT );

$updateStatement->execute();

$updateStatement = $dbh->prepare( $updatePlayers );
$updateStatement->execute( array( "Smith, Steve", 42, 1, 99 ) );
Task: Parameterized SQL statement
Java: import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
 
public class DBDemo{
   private String protocol; 
   private String dbName;   
   private String username;
   private String password;

   PreparedStatement query;
 
   public int setUpAndExecPS(){
      try {
         Connection conn = DriverManager.getConnection(protocol + dbName, username, password);

         query = conn.prepareStatement(
            "UPDATE players SET name = ?, score = ?, active = ? WHERE jerseyNum = ?");
 
         query.setString(1, "Smith, Steve");
         query.setInt(2, 42);
         query.setBoolean(3, true);
         query.setInt(4, 99);
         
         return query.executeUpdate();
         
         

      } catch (Exception e) {
         e.printStackTrace();
      }

      return 0;
   }
}

PHP: $updatePlayers = "UPDATE `players` SET `name` = ?, `score` = ?, `active` = ?\n".
		"WHERE `jerseyNum` = ?";
$dbh = new PDO( "mysql:dbname=db;host=localhost", "username", "password" );

$updateStatement = $dbh->prepare( $updatePlayers );

$updateStatement->bindValue( 1, "Smith, Steve", PDO::PARAM_STR );
$updateStatement->bindValue( 2, 42, PDO::PARAM_INT );
$updateStatement->bindValue( 3, 1, PDO::PARAM_INT );
$updateStatement->bindValue( 4, 99, PDO::PARAM_INT );

$updateStatement->execute();

$updateStatement = $dbh->prepare( $updatePlayers );
$updateStatement->execute( array( "Smith, Steve", 42, 1, 99 ) );
Task: Parameterized SQL statement
Python: import sqlite3

db = sqlite3.connect(':memory:')


db.execute('create temp table players (name, score, active, jerseyNum)')
db.execute('insert into players values ("name",0,"false",99)')
db.execute('insert into players values ("name",0,"false",100)')




db.execute('update players set name=?, score=?, active=? where jerseyNum=?', ('Smith, Steve', 42, True, 99))


db.execute('update players set name=:name, score=:score, active=:active where jerseyNum=:num',
    {'num': 100,
     'name': 'John Doe',
     'active': False,
     'score': -1}
)


for row in db.execute('select * from players'):
   print(row)

PHP: $updatePlayers = "UPDATE `players` SET `name` = ?, `score` = ?, `active` = ?\n".
		"WHERE `jerseyNum` = ?";
$dbh = new PDO( "mysql:dbname=db;host=localhost", "username", "password" );

$updateStatement = $dbh->prepare( $updatePlayers );

$updateStatement->bindValue( 1, "Smith, Steve", PDO::PARAM_STR );
$updateStatement->bindValue( 2, 42, PDO::PARAM_INT );
$updateStatement->bindValue( 3, 1, PDO::PARAM_INT );
$updateStatement->bindValue( 4, 99, PDO::PARAM_INT );

$updateStatement->execute();

$updateStatement = $dbh->prepare( $updatePlayers );
$updateStatement->execute( array( "Smith, Steve", 42, 1, 99 ) );
Task: Triplet of three numbers
C: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define LIMIT 6000

char *primes(unsigned int limit) {
    char *p = malloc(limit + 1);
    int i, j, sqr = sqrt(limit);
    
    p[0] = p[1] = 0;
    memset(p+2, 1, limit-1);
    for (i=2; i<=sqr; i++)
        if (p[i])
            for (j=i*2; j<=limit; j+=i)
                p[j] = 0;
            
    return p;
}

int triplet(const char *p, unsigned int n) {
    return n >= 2 && p[n-1] && p[n+3] && p[n+5];
}

int main() {
    char *p = primes(LIMIT+5);
    int i;
    
    for (i=2; i<LIMIT; i++)
        if (triplet(p, i))
            printf("%4d: %4d, %4d, %4d\n", i, i-1, i+3, i+5);
    
    free(p);
    return 0;
}

C#: #include <iostream>
#include <vector>

constexpr unsigned int LIMIT = 6000;

std::vector<bool> primes(unsigned int limit) {
    std::vector<bool> p(limit + 1, true);
    unsigned int root = std::sqrt(limit);

    p[0] = false;
    p[1] = false;

    for (size_t i = 2; i <= root; i++) {
        if (p[i]) {
            for (size_t j = 2 * i; j <= limit; j += i) {
                p[j] = false;
            }
        }
    }

    return p;
}

bool triplet(const std::vector<bool> &p, unsigned int n) {
    return n >= 2 && p[n - 1] && p[n + 3] && p[n + 5];
}

int main() {
    std::vector<bool> p = primes(LIMIT);

    for (size_t i = 2; i < LIMIT; i++) {
        if (triplet(p, i)) {
            printf("%4d: %4d, %4d, %4d\n", i, i - 1, i + 3, i + 5);
        }
    }

    return 0;
}
Task: Triplet of three numbers
C: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define LIMIT 6000

char *primes(unsigned int limit) {
    char *p = malloc(limit + 1);
    int i, j, sqr = sqrt(limit);
    
    p[0] = p[1] = 0;
    memset(p+2, 1, limit-1);
    for (i=2; i<=sqr; i++)
        if (p[i])
            for (j=i*2; j<=limit; j+=i)
                p[j] = 0;
            
    return p;
}

int triplet(const char *p, unsigned int n) {
    return n >= 2 && p[n-1] && p[n+3] && p[n+5];
}

int main() {
    char *p = primes(LIMIT+5);
    int i;
    
    for (i=2; i<LIMIT; i++)
        if (triplet(p, i))
            printf("%4d: %4d, %4d, %4d\n", i, i-1, i+3, i+5);
    
    free(p);
    return 0;
}

C#: using System; using System.Collections.Generic; using System.Linq;
using T3 = System.Tuple<int, int, int>; using static System.Console;
class Program { static void Main() {
   WriteLine(" \"N\":  Prime Triplet    Adjacent (to previous)\n" +
             " ---- ----------------- -----------------------");
   foreach(var lmt in new double[]{6e3, 1e5, 1e6, 1e7, 1e8}) {
    var pr = PG.Primes((int)lmt); int l = 0, c = 0; bool a;
    foreach (var t in pr) { c += (a = l == t.Item1) ? 1 : 0;
      if (lmt < 1e5) WriteLine("{0,4}: {1,-18} {2}",
        t.Item1 + 1, t, a ? " *" : ""); l = t.Item3; }
    Console.WriteLine ("Up to {0:n0} there are {1:n0} prime triples, " +
      "of which {2:n0} were found to be adjacent.", lmt, pr.Count(), c); } } }

class PG { static bool[] f; static bool isPrT(int x, int y, int z) {
  if (x < 7) return false; return !f[x] && !f[y] && !f[z]; }
  public static IEnumerable<T3> Primes(int l) { f = new bool[l += 6];
  int j, lj, llj, lllj; j = lj = llj = lllj = 3;
  for (int d = 8, s = 9; s < l; lllj = llj, llj = lj, lj = j, j += 2, s += d += 8)
    if (!f[j]) { if (isPrT(lllj, lj, j)) yield return new T3(lllj, lj, j);
      for (int k = s, i = j << 1; k < l; k += i) f[k] = true; }
  for (; j < l; lllj = llj, llj = lj, lj = j, j += 2)
   if (isPrT(lllj, lj, j)) yield return new T3(lllj, lj, j); } }
Task: Triplet of three numbers
C: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define LIMIT 6000

char *primes(unsigned int limit) {
    char *p = malloc(limit + 1);
    int i, j, sqr = sqrt(limit);
    
    p[0] = p[1] = 0;
    memset(p+2, 1, limit-1);
    for (i=2; i<=sqr; i++)
        if (p[i])
            for (j=i*2; j<=limit; j+=i)
                p[j] = 0;
            
    return p;
}

int triplet(const char *p, unsigned int n) {
    return n >= 2 && p[n-1] && p[n+3] && p[n+5];
}

int main() {
    char *p = primes(LIMIT+5);
    int i;
    
    for (i=2; i<LIMIT; i++)
        if (triplet(p, i))
            printf("%4d: %4d, %4d, %4d\n", i, i-1, i+3, i+5);
    
    free(p);
    return 0;
}

C++: #include <iostream>
#include <vector>

constexpr unsigned int LIMIT = 6000;

std::vector<bool> primes(unsigned int limit) {
    std::vector<bool> p(limit + 1, true);
    unsigned int root = std::sqrt(limit);

    p[0] = false;
    p[1] = false;

    for (size_t i = 2; i <= root; i++) {
        if (p[i]) {
            for (size_t j = 2 * i; j <= limit; j += i) {
                p[j] = false;
            }
        }
    }

    return p;
}

bool triplet(const std::vector<bool> &p, unsigned int n) {
    return n >= 2 && p[n - 1] && p[n + 3] && p[n + 5];
}

int main() {
    std::vector<bool> p = primes(LIMIT);

    for (size_t i = 2; i < LIMIT; i++) {
        if (triplet(p, i)) {
            printf("%4d: %4d, %4d, %4d\n", i, i - 1, i + 3, i + 5);
        }
    }

    return 0;
}
Task: Triplet of three numbers
C: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define LIMIT 6000

char *primes(unsigned int limit) {
    char *p = malloc(limit + 1);
    int i, j, sqr = sqrt(limit);
    
    p[0] = p[1] = 0;
    memset(p+2, 1, limit-1);
    for (i=2; i<=sqr; i++)
        if (p[i])
            for (j=i*2; j<=limit; j+=i)
                p[j] = 0;
            
    return p;
}

int triplet(const char *p, unsigned int n) {
    return n >= 2 && p[n-1] && p[n+3] && p[n+5];
}

int main() {
    char *p = primes(LIMIT+5);
    int i;
    
    for (i=2; i<LIMIT; i++)
        if (triplet(p, i))
            printf("%4d: %4d, %4d, %4d\n", i, i-1, i+3, i+5);
    
    free(p);
    return 0;
}

Python: 

N = 6000
p = [None] * 6000  

for i in range(2, round(pow(N,0.5))):
    if not p[i]:
        for j in range(i*2, N, i):
            p[j] = 1


for i in range(3, N):
    if (p[i-1] or p[i+3] or p[i+5]):
        continue
    else:
        print(i, ': ', i-1,  ' ', i+3,  ' ', i+5)
Task: Triplet of three numbers
C#: using System; using System.Collections.Generic; using System.Linq;
using T3 = System.Tuple<int, int, int>; using static System.Console;
class Program { static void Main() {
   WriteLine(" \"N\":  Prime Triplet    Adjacent (to previous)\n" +
             " ---- ----------------- -----------------------");
   foreach(var lmt in new double[]{6e3, 1e5, 1e6, 1e7, 1e8}) {
    var pr = PG.Primes((int)lmt); int l = 0, c = 0; bool a;
    foreach (var t in pr) { c += (a = l == t.Item1) ? 1 : 0;
      if (lmt < 1e5) WriteLine("{0,4}: {1,-18} {2}",
        t.Item1 + 1, t, a ? " *" : ""); l = t.Item3; }
    Console.WriteLine ("Up to {0:n0} there are {1:n0} prime triples, " +
      "of which {2:n0} were found to be adjacent.", lmt, pr.Count(), c); } } }

class PG { static bool[] f; static bool isPrT(int x, int y, int z) {
  if (x < 7) return false; return !f[x] && !f[y] && !f[z]; }
  public static IEnumerable<T3> Primes(int l) { f = new bool[l += 6];
  int j, lj, llj, lllj; j = lj = llj = lllj = 3;
  for (int d = 8, s = 9; s < l; lllj = llj, llj = lj, lj = j, j += 2, s += d += 8)
    if (!f[j]) { if (isPrT(lllj, lj, j)) yield return new T3(lllj, lj, j);
      for (int k = s, i = j << 1; k < l; k += i) f[k] = true; }
  for (; j < l; lllj = llj, llj = lj, lj = j, j += 2)
   if (isPrT(lllj, lj, j)) yield return new T3(lllj, lj, j); } }

C++: #include <iostream>
#include <vector>

constexpr unsigned int LIMIT = 6000;

std::vector<bool> primes(unsigned int limit) {
    std::vector<bool> p(limit + 1, true);
    unsigned int root = std::sqrt(limit);

    p[0] = false;
    p[1] = false;

    for (size_t i = 2; i <= root; i++) {
        if (p[i]) {
            for (size_t j = 2 * i; j <= limit; j += i) {
                p[j] = false;
            }
        }
    }

    return p;
}

bool triplet(const std::vector<bool> &p, unsigned int n) {
    return n >= 2 && p[n - 1] && p[n + 3] && p[n + 5];
}

int main() {
    std::vector<bool> p = primes(LIMIT);

    for (size_t i = 2; i < LIMIT; i++) {
        if (triplet(p, i)) {
            printf("%4d: %4d, %4d, %4d\n", i, i - 1, i + 3, i + 5);
        }
    }

    return 0;
}
Task: Triplet of three numbers
C++: #include <iostream>
#include <vector>

constexpr unsigned int LIMIT = 6000;

std::vector<bool> primes(unsigned int limit) {
    std::vector<bool> p(limit + 1, true);
    unsigned int root = std::sqrt(limit);

    p[0] = false;
    p[1] = false;

    for (size_t i = 2; i <= root; i++) {
        if (p[i]) {
            for (size_t j = 2 * i; j <= limit; j += i) {
                p[j] = false;
            }
        }
    }

    return p;
}

bool triplet(const std::vector<bool> &p, unsigned int n) {
    return n >= 2 && p[n - 1] && p[n + 3] && p[n + 5];
}

int main() {
    std::vector<bool> p = primes(LIMIT);

    for (size_t i = 2; i < LIMIT; i++) {
        if (triplet(p, i)) {
            printf("%4d: %4d, %4d, %4d\n", i, i - 1, i + 3, i + 5);
        }
    }

    return 0;
}

Go: package main

import (
    "fmt"
    "rcu"
)

func main() {
    c := rcu.PrimeSieve(6003, false)
    var numbers []int
    fmt.Println("Numbers n < 6000 where: n - 1, n + 3, n + 5 are all primes:")
    for n := 4; n < 6000; n += 2 {
        if !c[n-1] && !c[n+3] && !c[n+5] {
            numbers = append(numbers, n)
        }
    }
    for _, n := range numbers {
        fmt.Printf("%6s  => ", rcu.Commatize(n))
        for _, p := range []int{n - 1, n + 3, n + 5} {
            fmt.Printf("%6s ", rcu.Commatize(p))
        }
        fmt.Println()
    }
    fmt.Printf("\n%d such numbers found.\n", len(numbers))
}