kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: Pernicious numbers
C: #include <stdio.h>
 
typedef unsigned uint;
uint is_pern(uint n)
{
        uint c = 2693408940u; 
        while (n) c >>= 1, n &= (n - 1); 
        return c & 1;
}
 
int main(void)
{
        uint i, c;
        for (i = c = 0; c < 25; i++)
                if (is_pern(i))
                        printf("%u ", i), ++c;
        putchar('\n');
 
        for (i = 888888877u; i <= 888888888u; i++)
                if (is_pern(i))
                        printf("%u ", i);
        putchar('\n');
 
        return 0;
}

C++: #include <iostream>
using namespace std;

int main() {
    int cnt = 0, cnt2, cnt3, tmp, binary[8];
    for (int i = 3; cnt < 25; i++) {
        tmp = i;
        cnt2 = 0;
        cnt3 = 0;
        for (int j = 7; j > 0; j--) {
            binary[j] = tmp % 2;
            tmp /= 2;
        }
        binary[0] = tmp;
        for (int j = 0; j < 8; j++) {
            if (binary[j] == 1) {
                cnt2++;
            }
        }
        for (int j = 2; j <= (cnt2 / 2); j++) {
            if (cnt2 % j == 0) {
                cnt3++;
                break;
            }
        }
        if (cnt3 == 0 && cnt2 != 1) {
            cout << i << endl;
            cnt++;
        }
    }

    cout << endl;
    int binary2[31];

    for (int i = 888888877; i <= 888888888; i++) {
        tmp = i;
        cnt2 = 0;
        cnt3 = 0;
        for (int j = 30; j > 0; j--) {
            binary2[j] = tmp % 2;
            tmp /= 2;
        }
        binary2[0] = tmp;
        for (int j = 0; j < 31; j++) {
            if (binary2[j] == 1) {
                cnt2++;
            }
        }
        for (int j = 2; j <= (cnt2 / 2); j++) {
            if (cnt2 % j == 0) {
                cnt3++;
                break;
            }
        }
        if (cnt3 == 0 && cnt2 != 1) {
            cout << i << endl;
        }
    }
}
Task: Pernicious numbers
C: #include <stdio.h>
 
typedef unsigned uint;
uint is_pern(uint n)
{
        uint c = 2693408940u; 
        while (n) c >>= 1, n &= (n - 1); 
        return c & 1;
}
 
int main(void)
{
        uint i, c;
        for (i = c = 0; c < 25; i++)
                if (is_pern(i))
                        printf("%u ", i), ++c;
        putchar('\n');
 
        for (i = 888888877u; i <= 888888888u; i++)
                if (is_pern(i))
                        printf("%u ", i);
        putchar('\n');
 
        return 0;
}

Go: package main

import "fmt"

func pernicious(w uint32) bool {
    const (
        ff    = 1<<32 - 1
        mask1 = ff / 3
        mask3 = ff / 5
        maskf = ff / 17
        maskp = ff / 255
    )
    w -= w >> 1 & mask1
    w = w&mask3 + w>>2&mask3
    w = (w + w>>4) & maskf
    return 0xa08a28ac>>(w*maskp>>24)&1 != 0
}

func main() {
    for i, n := 0, uint32(1); i < 25; n++ {
        if pernicious(n) {
            fmt.Printf("%d ", n)
            i++
        }
    }
    fmt.Println()
    for n := uint32(888888877); n <= 888888888; n++ {
        if pernicious(n) {
            fmt.Printf("%d ", n)
        }
    }
    fmt.Println()
}
Task: Pernicious numbers
C: #include <stdio.h>
 
typedef unsigned uint;
uint is_pern(uint n)
{
        uint c = 2693408940u; 
        while (n) c >>= 1, n &= (n - 1); 
        return c & 1;
}
 
int main(void)
{
        uint i, c;
        for (i = c = 0; c < 25; i++)
                if (is_pern(i))
                        printf("%u ", i), ++c;
        putchar('\n');
 
        for (i = 888888877u; i <= 888888888u; i++)
                if (is_pern(i))
                        printf("%u ", i);
        putchar('\n');
 
        return 0;
}

Java: public class Pernicious{
    
    public static boolean isPrime(int x){
        if(x < 2) return false;
        for(int i = 2; i < x; i++){
            if(x % i == 0) return false;
        }
        return true;
    }

    public static int popCount(long x){
        return Long.bitCount(x);
    }

    public static void main(String[] args){
        for(long i = 1, n = 0; n < 25; i++){
            if(isPrime(popCount(i))){
                System.out.print(i + " ");
                n++;
            }
        }
        
        System.out.println();
        
        for(long i = 888888877; i <= 888888888; i++){
            if(isPrime(popCount(i))) System.out.print(i + " ");
        }
    }
}
Task: Pernicious numbers
C: #include <stdio.h>
 
typedef unsigned uint;
uint is_pern(uint n)
{
        uint c = 2693408940u; 
        while (n) c >>= 1, n &= (n - 1); 
        return c & 1;
}
 
int main(void)
{
        uint i, c;
        for (i = c = 0; c < 25; i++)
                if (is_pern(i))
                        printf("%u ", i), ++c;
        putchar('\n');
 
        for (i = 888888877u; i <= 888888888u; i++)
                if (is_pern(i))
                        printf("%u ", i);
        putchar('\n');
 
        return 0;
}

VB: Private Function population_count(ByVal number As Long) As Integer
    Dim result As Integer
    Dim digit As Integer
    Do While number > 0
        If number Mod 2 = 1 Then
            result = result + 1
        End If
        number = number \ 2
    Loop
    population_count = result
End Function

Function is_prime(n As Integer) As Boolean
    If n < 2 Then
        is_prime = False
        Exit Function
    End If
    For i = 2 To Sqr(n)
        If n Mod i = 0 Then
            is_prime = False
            Exit Function
        End If
    Next i
    is_prime = True
End Function
 
Function pernicious(n As Long)
    Dim tmp As Integer
    tmp = population_count(n)
    pernicious = is_prime(tmp)
End Function
 
Public Sub main()
    Dim count As Integer
    Dim n As Long: n = 1
    Do While count < 25
        If pernicious(n) Then
            Debug.Print n;
            count = count + 1
        End If
        n = n + 1
    Loop
    Debug.Print
    For n = 888888877 To 888888888
        If pernicious(n) Then
            Debug.Print n;
        End If
    Next n
End Sub
Task: Pernicious numbers
C#: using System;
using System.Linq;

namespace PerniciousNumbers
{
    class Program
    {
        public static int PopulationCount(long n)
        {
            int cnt = 0;
            do
            {
                if ((n & 1) != 0) 
                {
                    cnt++;
                }
            } while ((n >>= 1) > 0);

            return cnt;
        }

         public static bool isPrime(int x)
        {
            if (x <= 2 || (x & 1) == 0)
            {
                return x == 2;
            }

            var limit = Math.Sqrt(x);
            for (int i = 3; i <= limit; i += 2)
            {
                if (x % i == 0)
                {
                    return false;
                }
            }

            return true;
        }

        private static IEnumerable<int> Pernicious(int start, int count, int take)
        {
            return Enumerable.Range(start, count).Where(n => isPrime(PopulationCount(n))).Take(take);
        }

        static void Main(string[] args)
        {
            foreach (var n in Pernicious(0, int.MaxValue, 25))
            {
                Console.Write("{0} ", n);
            }

            Console.WriteLine();

            foreach (var n in Pernicious(888888877, 11, 11))
            {
                Console.Write("{0} ", n);
            }

            Console.ReadKey();
        }
    }
}

C++: #include <iostream>
using namespace std;

int main() {
    int cnt = 0, cnt2, cnt3, tmp, binary[8];
    for (int i = 3; cnt < 25; i++) {
        tmp = i;
        cnt2 = 0;
        cnt3 = 0;
        for (int j = 7; j > 0; j--) {
            binary[j] = tmp % 2;
            tmp /= 2;
        }
        binary[0] = tmp;
        for (int j = 0; j < 8; j++) {
            if (binary[j] == 1) {
                cnt2++;
            }
        }
        for (int j = 2; j <= (cnt2 / 2); j++) {
            if (cnt2 % j == 0) {
                cnt3++;
                break;
            }
        }
        if (cnt3 == 0 && cnt2 != 1) {
            cout << i << endl;
            cnt++;
        }
    }

    cout << endl;
    int binary2[31];

    for (int i = 888888877; i <= 888888888; i++) {
        tmp = i;
        cnt2 = 0;
        cnt3 = 0;
        for (int j = 30; j > 0; j--) {
            binary2[j] = tmp % 2;
            tmp /= 2;
        }
        binary2[0] = tmp;
        for (int j = 0; j < 31; j++) {
            if (binary2[j] == 1) {
                cnt2++;
            }
        }
        for (int j = 2; j <= (cnt2 / 2); j++) {
            if (cnt2 % j == 0) {
                cnt3++;
                break;
            }
        }
        if (cnt3 == 0 && cnt2 != 1) {
            cout << i << endl;
        }
    }
}
Task: Pernicious numbers
C++: #include <iostream>
using namespace std;

int main() {
    int cnt = 0, cnt2, cnt3, tmp, binary[8];
    for (int i = 3; cnt < 25; i++) {
        tmp = i;
        cnt2 = 0;
        cnt3 = 0;
        for (int j = 7; j > 0; j--) {
            binary[j] = tmp % 2;
            tmp /= 2;
        }
        binary[0] = tmp;
        for (int j = 0; j < 8; j++) {
            if (binary[j] == 1) {
                cnt2++;
            }
        }
        for (int j = 2; j <= (cnt2 / 2); j++) {
            if (cnt2 % j == 0) {
                cnt3++;
                break;
            }
        }
        if (cnt3 == 0 && cnt2 != 1) {
            cout << i << endl;
            cnt++;
        }
    }

    cout << endl;
    int binary2[31];

    for (int i = 888888877; i <= 888888888; i++) {
        tmp = i;
        cnt2 = 0;
        cnt3 = 0;
        for (int j = 30; j > 0; j--) {
            binary2[j] = tmp % 2;
            tmp /= 2;
        }
        binary2[0] = tmp;
        for (int j = 0; j < 31; j++) {
            if (binary2[j] == 1) {
                cnt2++;
            }
        }
        for (int j = 2; j <= (cnt2 / 2); j++) {
            if (cnt2 % j == 0) {
                cnt3++;
                break;
            }
        }
        if (cnt3 == 0 && cnt2 != 1) {
            cout << i << endl;
        }
    }
}

Java: public class Pernicious{
    
    public static boolean isPrime(int x){
        if(x < 2) return false;
        for(int i = 2; i < x; i++){
            if(x % i == 0) return false;
        }
        return true;
    }

    public static int popCount(long x){
        return Long.bitCount(x);
    }

    public static void main(String[] args){
        for(long i = 1, n = 0; n < 25; i++){
            if(isPrime(popCount(i))){
                System.out.print(i + " ");
                n++;
            }
        }
        
        System.out.println();
        
        for(long i = 888888877; i <= 888888888; i++){
            if(isPrime(popCount(i))) System.out.print(i + " ");
        }
    }
}
Task: Pernicious numbers
C++: #include <iostream>
using namespace std;

int main() {
    int cnt = 0, cnt2, cnt3, tmp, binary[8];
    for (int i = 3; cnt < 25; i++) {
        tmp = i;
        cnt2 = 0;
        cnt3 = 0;
        for (int j = 7; j > 0; j--) {
            binary[j] = tmp % 2;
            tmp /= 2;
        }
        binary[0] = tmp;
        for (int j = 0; j < 8; j++) {
            if (binary[j] == 1) {
                cnt2++;
            }
        }
        for (int j = 2; j <= (cnt2 / 2); j++) {
            if (cnt2 % j == 0) {
                cnt3++;
                break;
            }
        }
        if (cnt3 == 0 && cnt2 != 1) {
            cout << i << endl;
            cnt++;
        }
    }

    cout << endl;
    int binary2[31];

    for (int i = 888888877; i <= 888888888; i++) {
        tmp = i;
        cnt2 = 0;
        cnt3 = 0;
        for (int j = 30; j > 0; j--) {
            binary2[j] = tmp % 2;
            tmp /= 2;
        }
        binary2[0] = tmp;
        for (int j = 0; j < 31; j++) {
            if (binary2[j] == 1) {
                cnt2++;
            }
        }
        for (int j = 2; j <= (cnt2 / 2); j++) {
            if (cnt2 % j == 0) {
                cnt3++;
                break;
            }
        }
        if (cnt3 == 0 && cnt2 != 1) {
            cout << i << endl;
        }
    }
}

Python: >>> def popcount(n): return bin(n).count("1")

>>> primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61}
>>> p, i = [], 0
>>> while len(p) < 25:
        if popcount(i) in primes: p.append(i)
        i += 1

        
>>> p
[3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 17, 18, 19, 20, 21, 22, 24, 25, 26, 28, 31, 33, 34, 35, 36]
>>> p, i = [], 888888877
>>> while i <= 888888888:
        if popcount(i) in primes: p.append(i)
        i += 1

        
>>> p
[888888877, 888888878, 888888880, 888888883, 888888885, 888888886]
>>>
Task: Pernicious numbers
C++: #include <iostream>
using namespace std;

int main() {
    int cnt = 0, cnt2, cnt3, tmp, binary[8];
    for (int i = 3; cnt < 25; i++) {
        tmp = i;
        cnt2 = 0;
        cnt3 = 0;
        for (int j = 7; j > 0; j--) {
            binary[j] = tmp % 2;
            tmp /= 2;
        }
        binary[0] = tmp;
        for (int j = 0; j < 8; j++) {
            if (binary[j] == 1) {
                cnt2++;
            }
        }
        for (int j = 2; j <= (cnt2 / 2); j++) {
            if (cnt2 % j == 0) {
                cnt3++;
                break;
            }
        }
        if (cnt3 == 0 && cnt2 != 1) {
            cout << i << endl;
            cnt++;
        }
    }

    cout << endl;
    int binary2[31];

    for (int i = 888888877; i <= 888888888; i++) {
        tmp = i;
        cnt2 = 0;
        cnt3 = 0;
        for (int j = 30; j > 0; j--) {
            binary2[j] = tmp % 2;
            tmp /= 2;
        }
        binary2[0] = tmp;
        for (int j = 0; j < 31; j++) {
            if (binary2[j] == 1) {
                cnt2++;
            }
        }
        for (int j = 2; j <= (cnt2 / 2); j++) {
            if (cnt2 % j == 0) {
                cnt3++;
                break;
            }
        }
        if (cnt3 == 0 && cnt2 != 1) {
            cout << i << endl;
        }
    }
}

VB: Private Function population_count(ByVal number As Long) As Integer
    Dim result As Integer
    Dim digit As Integer
    Do While number > 0
        If number Mod 2 = 1 Then
            result = result + 1
        End If
        number = number \ 2
    Loop
    population_count = result
End Function

Function is_prime(n As Integer) As Boolean
    If n < 2 Then
        is_prime = False
        Exit Function
    End If
    For i = 2 To Sqr(n)
        If n Mod i = 0 Then
            is_prime = False
            Exit Function
        End If
    Next i
    is_prime = True
End Function
 
Function pernicious(n As Long)
    Dim tmp As Integer
    tmp = population_count(n)
    pernicious = is_prime(tmp)
End Function
 
Public Sub main()
    Dim count As Integer
    Dim n As Long: n = 1
    Do While count < 25
        If pernicious(n) Then
            Debug.Print n;
            count = count + 1
        End If
        n = n + 1
    Loop
    Debug.Print
    For n = 888888877 To 888888888
        If pernicious(n) Then
            Debug.Print n;
        End If
    Next n
End Sub
Task: Pernicious numbers
C#: using System;
using System.Linq;

namespace PerniciousNumbers
{
    class Program
    {
        public static int PopulationCount(long n)
        {
            int cnt = 0;
            do
            {
                if ((n & 1) != 0) 
                {
                    cnt++;
                }
            } while ((n >>= 1) > 0);

            return cnt;
        }

         public static bool isPrime(int x)
        {
            if (x <= 2 || (x & 1) == 0)
            {
                return x == 2;
            }

            var limit = Math.Sqrt(x);
            for (int i = 3; i <= limit; i += 2)
            {
                if (x % i == 0)
                {
                    return false;
                }
            }

            return true;
        }

        private static IEnumerable<int> Pernicious(int start, int count, int take)
        {
            return Enumerable.Range(start, count).Where(n => isPrime(PopulationCount(n))).Take(take);
        }

        static void Main(string[] args)
        {
            foreach (var n in Pernicious(0, int.MaxValue, 25))
            {
                Console.Write("{0} ", n);
            }

            Console.WriteLine();

            foreach (var n in Pernicious(888888877, 11, 11))
            {
                Console.Write("{0} ", n);
            }

            Console.ReadKey();
        }
    }
}

Python: >>> def popcount(n): return bin(n).count("1")

>>> primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61}
>>> p, i = [], 0
>>> while len(p) < 25:
        if popcount(i) in primes: p.append(i)
        i += 1

        
>>> p
[3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 17, 18, 19, 20, 21, 22, 24, 25, 26, 28, 31, 33, 34, 35, 36]
>>> p, i = [], 888888877
>>> while i <= 888888888:
        if popcount(i) in primes: p.append(i)
        i += 1

        
>>> p
[888888877, 888888878, 888888880, 888888883, 888888885, 888888886]
>>>
Task: Pernicious numbers
C#: using System;
using System.Linq;

namespace PerniciousNumbers
{
    class Program
    {
        public static int PopulationCount(long n)
        {
            int cnt = 0;
            do
            {
                if ((n & 1) != 0) 
                {
                    cnt++;
                }
            } while ((n >>= 1) > 0);

            return cnt;
        }

         public static bool isPrime(int x)
        {
            if (x <= 2 || (x & 1) == 0)
            {
                return x == 2;
            }

            var limit = Math.Sqrt(x);
            for (int i = 3; i <= limit; i += 2)
            {
                if (x % i == 0)
                {
                    return false;
                }
            }

            return true;
        }

        private static IEnumerable<int> Pernicious(int start, int count, int take)
        {
            return Enumerable.Range(start, count).Where(n => isPrime(PopulationCount(n))).Take(take);
        }

        static void Main(string[] args)
        {
            foreach (var n in Pernicious(0, int.MaxValue, 25))
            {
                Console.Write("{0} ", n);
            }

            Console.WriteLine();

            foreach (var n in Pernicious(888888877, 11, 11))
            {
                Console.Write("{0} ", n);
            }

            Console.ReadKey();
        }
    }
}

VB: Private Function population_count(ByVal number As Long) As Integer
    Dim result As Integer
    Dim digit As Integer
    Do While number > 0
        If number Mod 2 = 1 Then
            result = result + 1
        End If
        number = number \ 2
    Loop
    population_count = result
End Function

Function is_prime(n As Integer) As Boolean
    If n < 2 Then
        is_prime = False
        Exit Function
    End If
    For i = 2 To Sqr(n)
        If n Mod i = 0 Then
            is_prime = False
            Exit Function
        End If
    Next i
    is_prime = True
End Function
 
Function pernicious(n As Long)
    Dim tmp As Integer
    tmp = population_count(n)
    pernicious = is_prime(tmp)
End Function
 
Public Sub main()
    Dim count As Integer
    Dim n As Long: n = 1
    Do While count < 25
        If pernicious(n) Then
            Debug.Print n;
            count = count + 1
        End If
        n = n + 1
    Loop
    Debug.Print
    For n = 888888877 To 888888888
        If pernicious(n) Then
            Debug.Print n;
        End If
    Next n
End Sub
Task: Pernicious numbers
Go: package main

import "fmt"

func pernicious(w uint32) bool {
    const (
        ff    = 1<<32 - 1
        mask1 = ff / 3
        mask3 = ff / 5
        maskf = ff / 17
        maskp = ff / 255
    )
    w -= w >> 1 & mask1
    w = w&mask3 + w>>2&mask3
    w = (w + w>>4) & maskf
    return 0xa08a28ac>>(w*maskp>>24)&1 != 0
}

func main() {
    for i, n := 0, uint32(1); i < 25; n++ {
        if pernicious(n) {
            fmt.Printf("%d ", n)
            i++
        }
    }
    fmt.Println()
    for n := uint32(888888877); n <= 888888888; n++ {
        if pernicious(n) {
            fmt.Printf("%d ", n)
        }
    }
    fmt.Println()
}

Java: public class Pernicious{
    
    public static boolean isPrime(int x){
        if(x < 2) return false;
        for(int i = 2; i < x; i++){
            if(x % i == 0) return false;
        }
        return true;
    }

    public static int popCount(long x){
        return Long.bitCount(x);
    }

    public static void main(String[] args){
        for(long i = 1, n = 0; n < 25; i++){
            if(isPrime(popCount(i))){
                System.out.print(i + " ");
                n++;
            }
        }
        
        System.out.println();
        
        for(long i = 888888877; i <= 888888888; i++){
            if(isPrime(popCount(i))) System.out.print(i + " ");
        }
    }
}
Task: Pernicious numbers
Java: public class Pernicious{
    
    public static boolean isPrime(int x){
        if(x < 2) return false;
        for(int i = 2; i < x; i++){
            if(x % i == 0) return false;
        }
        return true;
    }

    public static int popCount(long x){
        return Long.bitCount(x);
    }

    public static void main(String[] args){
        for(long i = 1, n = 0; n < 25; i++){
            if(isPrime(popCount(i))){
                System.out.print(i + " ");
                n++;
            }
        }
        
        System.out.println();
        
        for(long i = 888888877; i <= 888888888; i++){
            if(isPrime(popCount(i))) System.out.print(i + " ");
        }
    }
}

Python: >>> def popcount(n): return bin(n).count("1")

>>> primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61}
>>> p, i = [], 0
>>> while len(p) < 25:
        if popcount(i) in primes: p.append(i)
        i += 1

        
>>> p
[3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 17, 18, 19, 20, 21, 22, 24, 25, 26, 28, 31, 33, 34, 35, 36]
>>> p, i = [], 888888877
>>> while i <= 888888888:
        if popcount(i) in primes: p.append(i)
        i += 1

        
>>> p
[888888877, 888888878, 888888880, 888888883, 888888885, 888888886]
>>>
Task: Pernicious numbers
Go: package main

import "fmt"

func pernicious(w uint32) bool {
    const (
        ff    = 1<<32 - 1
        mask1 = ff / 3
        mask3 = ff / 5
        maskf = ff / 17
        maskp = ff / 255
    )
    w -= w >> 1 & mask1
    w = w&mask3 + w>>2&mask3
    w = (w + w>>4) & maskf
    return 0xa08a28ac>>(w*maskp>>24)&1 != 0
}

func main() {
    for i, n := 0, uint32(1); i < 25; n++ {
        if pernicious(n) {
            fmt.Printf("%d ", n)
            i++
        }
    }
    fmt.Println()
    for n := uint32(888888877); n <= 888888888; n++ {
        if pernicious(n) {
            fmt.Printf("%d ", n)
        }
    }
    fmt.Println()
}

Python: >>> def popcount(n): return bin(n).count("1")

>>> primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61}
>>> p, i = [], 0
>>> while len(p) < 25:
        if popcount(i) in primes: p.append(i)
        i += 1

        
>>> p
[3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 17, 18, 19, 20, 21, 22, 24, 25, 26, 28, 31, 33, 34, 35, 36]
>>> p, i = [], 888888877
>>> while i <= 888888888:
        if popcount(i) in primes: p.append(i)
        i += 1

        
>>> p
[888888877, 888888878, 888888880, 888888883, 888888885, 888888886]
>>>