WeixiangYan/CodeTransOcean huggingface dataset:
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();
        }
    }
}


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#: 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();
        }
    }
}



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 + " ");
        }
    }
}




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: Rename a file

C: #include <stdio.h>

int main()
{
  rename("input.txt", "output.txt");
  rename("docs", "mydocs");
  rename("/input.txt", "/output.txt");
  rename("/docs", "/mydocs");
  return 0;
}



C#: using System;
using System.IO;

class Program {
    static void Main(string[] args) {
        File.Move("input.txt","output.txt");
        File.Move(@"\input.txt",@"\output.txt");

        Directory.Move("docs","mydocs");
        Directory.Move(@"\docs",@"\mydocs");
    }
}
Task: Rename a file

C: #include <stdio.h>

int main()
{
  rename("input.txt", "output.txt");
  rename("docs", "mydocs");
  rename("/input.txt", "/output.txt");
  rename("/docs", "/mydocs");
  return 0;
}


C++: #include <cstdio>

int main()
{
    std::rename("input.txt", "output.txt");
    std::rename("docs", "mydocs");
    std::rename("/input.txt", "/output.txt");
    std::rename("/docs", "/mydocs");
    return 0;
}
Task: Rename a file

C: #include <stdio.h>

int main()
{
  rename("input.txt", "output.txt");
  rename("docs", "mydocs");
  rename("/input.txt", "/output.txt");
  rename("/docs", "/mydocs");
  return 0;
}





Java: import java.io.File;
public class FileRenameTest {
   public static boolean renameFile(String oldname, String newname) {
       
       File file = new File(oldname);
   
       
       File file2 = new File(newname);
   
       
       boolean success = file.renameTo(file2);
       return success;
   }
   public static void test(String type, String oldname, String newname) {
       System.out.println("The following " + type + " called " + oldname +
           ( renameFile(oldname, newname) ? " was renamed as " : " could not be renamed into ")
           + newname + "."
       );
   }
   public static void main(String args[]) {
        test("file", "input.txt", "output.txt");
        test("file", File.separator + "input.txt", File.separator + "output.txt");
        test("directory", "docs", "mydocs");
        test("directory", File.separator + "docs" + File.separator, File.separator + "mydocs" + File.separator);
   }
}
Task: Rename a file

C: #include <stdio.h>

int main()
{
  rename("input.txt", "output.txt");
  rename("docs", "mydocs");
  rename("/input.txt", "/output.txt");
  rename("/docs", "/mydocs");
  return 0;
}







Python: from java.io import File

def setup():
    
    sketchfile = rename(sketchPath("input.txt"), sketchPath("output.txt"))
    
    sketchfold = rename(sketchPath("docs"), sketchPath("mydocs"))
    
    rootfile = rename("input.txt", "output.txt")
    
    rootfold = rename("docs", "mydocs")

    
    println(str(sketchfile) + ' ' +
            str(sketchfold) + ' ' +
            str(rootfile) +  ' ' +
            str(rootfold)) 
    
    


def rename(oldname, newname):
    
    file = File(oldname)
    
    file2 = File(newname)
    
    success = file.renameTo(file2)
    return success
Task: Rename a file

C: #include <stdio.h>

int main()
{
  rename("input.txt", "output.txt");
  rename("docs", "mydocs");
  rename("/input.txt", "/output.txt");
  rename("/docs", "/mydocs");
  return 0;
}








VB: Sub Renamer()
    Dim f As FolderItem, r As FolderItem

    f = GetFolderItem("input.txt")
    
    If f.Exists Then f.Name = "output.txt"
    
    f = GetFolderItem("docs")
    If f.Exists Then f.Name = "mydocs"

    
    r = RootDir(GetFolderItem("."))

    f = r.Child("input.txt")
    
    If f.Exists Then f.Name = "output.txt"
    f = r.Child("docs")
    If f.Exists Then f.Name = "mydocs"
End Sub

Function RootDir(what As FolderItem) As FolderItem
    
    
    If what.Parent <> Nil Then  
        Return RootDir(what.Parent) 
    Else
        Return what
    End If
End Function
Task: Rename a file


C++: #include <cstdio>

int main()
{
    std::rename("input.txt", "output.txt");
    std::rename("docs", "mydocs");
    std::rename("/input.txt", "/output.txt");
    std::rename("/docs", "/mydocs");
    return 0;
}






Python: from java.io import File

def setup():
    
    sketchfile = rename(sketchPath("input.txt"), sketchPath("output.txt"))
    
    sketchfold = rename(sketchPath("docs"), sketchPath("mydocs"))
    
    rootfile = rename("input.txt", "output.txt")
    
    rootfold = rename("docs", "mydocs")

    
    println(str(sketchfile) + ' ' +
            str(sketchfold) + ' ' +
            str(rootfile) +  ' ' +
            str(rootfold)) 
    
    


def rename(oldname, newname):
    
    file = File(oldname)
    
    file2 = File(newname)
    
    success = file.renameTo(file2)
    return success
Task: Rename a file


C++: #include <cstdio>

int main()
{
    std::rename("input.txt", "output.txt");
    std::rename("docs", "mydocs");
    std::rename("/input.txt", "/output.txt");
    std::rename("/docs", "/mydocs");
    return 0;
}







VB: Sub Renamer()
    Dim f As FolderItem, r As FolderItem

    f = GetFolderItem("input.txt")
    
    If f.Exists Then f.Name = "output.txt"
    
    f = GetFolderItem("docs")
    If f.Exists Then f.Name = "mydocs"

    
    r = RootDir(GetFolderItem("."))

    f = r.Child("input.txt")
    
    If f.Exists Then f.Name = "output.txt"
    f = r.Child("docs")
    If f.Exists Then f.Name = "mydocs"
End Sub

Function RootDir(what As FolderItem) As FolderItem
    
    
    If what.Parent <> Nil Then  
        Return RootDir(what.Parent) 
    Else
        Return what
    End If
End Function
Task: Rename a file



C#: using System;
using System.IO;

class Program {
    static void Main(string[] args) {
        File.Move("input.txt","output.txt");
        File.Move(@"\input.txt",@"\output.txt");

        Directory.Move("docs","mydocs");
        Directory.Move(@"\docs",@"\mydocs");
    }
}


Go: package main
import "os"

func main() {
  os.Rename("input.txt", "output.txt")
  os.Rename("docs", "mydocs")
  os.Rename("/input.txt", "/output.txt")
  os.Rename("/docs", "/mydocs")
}
Task: Rename a file



C#: using System;
using System.IO;

class Program {
    static void Main(string[] args) {
        File.Move("input.txt","output.txt");
        File.Move(@"\input.txt",@"\output.txt");

        Directory.Move("docs","mydocs");
        Directory.Move(@"\docs",@"\mydocs");
    }
}



Java: import java.io.File;
public class FileRenameTest {
   public static boolean renameFile(String oldname, String newname) {
       
       File file = new File(oldname);
   
       
       File file2 = new File(newname);
   
       
       boolean success = file.renameTo(file2);
       return success;
   }
   public static void test(String type, String oldname, String newname) {
       System.out.println("The following " + type + " called " + oldname +
           ( renameFile(oldname, newname) ? " was renamed as " : " could not be renamed into ")
           + newname + "."
       );
   }
   public static void main(String args[]) {
        test("file", "input.txt", "output.txt");
        test("file", File.separator + "input.txt", File.separator + "output.txt");
        test("directory", "docs", "mydocs");
        test("directory", File.separator + "docs" + File.separator, File.separator + "mydocs" + File.separator);
   }
}
Task: Rename a file



C#: using System;
using System.IO;

class Program {
    static void Main(string[] args) {
        File.Move("input.txt","output.txt");
        File.Move(@"\input.txt",@"\output.txt");

        Directory.Move("docs","mydocs");
        Directory.Move(@"\docs",@"\mydocs");
    }
}






VB: Sub Renamer()
    Dim f As FolderItem, r As FolderItem

    f = GetFolderItem("input.txt")
    
    If f.Exists Then f.Name = "output.txt"
    
    f = GetFolderItem("docs")
    If f.Exists Then f.Name = "mydocs"

    
    r = RootDir(GetFolderItem("."))

    f = r.Child("input.txt")
    
    If f.Exists Then f.Name = "output.txt"
    f = r.Child("docs")
    If f.Exists Then f.Name = "mydocs"
End Sub

Function RootDir(what As FolderItem) As FolderItem
    
    
    If what.Parent <> Nil Then  
        Return RootDir(what.Parent) 
    Else
        Return what
    End If
End Function
Task: Rename a file





Java: import java.io.File;
public class FileRenameTest {
   public static boolean renameFile(String oldname, String newname) {
       
       File file = new File(oldname);
   
       
       File file2 = new File(newname);
   
       
       boolean success = file.renameTo(file2);
       return success;
   }
   public static void test(String type, String oldname, String newname) {
       System.out.println("The following " + type + " called " + oldname +
           ( renameFile(oldname, newname) ? " was renamed as " : " could not be renamed into ")
           + newname + "."
       );
   }
   public static void main(String args[]) {
        test("file", "input.txt", "output.txt");
        test("file", File.separator + "input.txt", File.separator + "output.txt");
        test("directory", "docs", "mydocs");
        test("directory", File.separator + "docs" + File.separator, File.separator + "mydocs" + File.separator);
   }
}



Python: from java.io import File

def setup():
    
    sketchfile = rename(sketchPath("input.txt"), sketchPath("output.txt"))
    
    sketchfold = rename(sketchPath("docs"), sketchPath("mydocs"))
    
    rootfile = rename("input.txt", "output.txt")
    
    rootfold = rename("docs", "mydocs")

    
    println(str(sketchfile) + ' ' +
            str(sketchfold) + ' ' +
            str(rootfile) +  ' ' +
            str(rootfold)) 
    
    


def rename(oldname, newname):
    
    file = File(oldname)
    
    file2 = File(newname)
    
    success = file.renameTo(file2)
    return success
Task: Rename a file





Java: import java.io.File;
public class FileRenameTest {
   public static boolean renameFile(String oldname, String newname) {
       
       File file = new File(oldname);
   
       
       File file2 = new File(newname);
   
       
       boolean success = file.renameTo(file2);
       return success;
   }
   public static void test(String type, String oldname, String newname) {
       System.out.println("The following " + type + " called " + oldname +
           ( renameFile(oldname, newname) ? " was renamed as " : " could not be renamed into ")
           + newname + "."
       );
   }
   public static void main(String args[]) {
        test("file", "input.txt", "output.txt");
        test("file", File.separator + "input.txt", File.separator + "output.txt");
        test("directory", "docs", "mydocs");
        test("directory", File.separator + "docs" + File.separator, File.separator + "mydocs" + File.separator);
   }
}




VB: Sub Renamer()
    Dim f As FolderItem, r As FolderItem

    f = GetFolderItem("input.txt")
    
    If f.Exists Then f.Name = "output.txt"
    
    f = GetFolderItem("docs")
    If f.Exists Then f.Name = "mydocs"

    
    r = RootDir(GetFolderItem("."))

    f = r.Child("input.txt")
    
    If f.Exists Then f.Name = "output.txt"
    f = r.Child("docs")
    If f.Exists Then f.Name = "mydocs"
End Sub

Function RootDir(what As FolderItem) As FolderItem
    
    
    If what.Parent <> Nil Then  
        Return RootDir(what.Parent) 
    Else
        Return what
    End If
End Function
Task: Rename a file




Go: package main
import "os"

func main() {
  os.Rename("input.txt", "output.txt")
  os.Rename("docs", "mydocs")
  os.Rename("/input.txt", "/output.txt")
  os.Rename("/docs", "/mydocs")
}




Python: from java.io import File

def setup():
    
    sketchfile = rename(sketchPath("input.txt"), sketchPath("output.txt"))
    
    sketchfold = rename(sketchPath("docs"), sketchPath("mydocs"))
    
    rootfile = rename("input.txt", "output.txt")
    
    rootfold = rename("docs", "mydocs")

    
    println(str(sketchfile) + ' ' +
            str(sketchfold) + ' ' +
            str(rootfile) +  ' ' +
            str(rootfold)) 
    
    


def rename(oldname, newname):
    
    file = File(oldname)
    
    file2 = File(newname)
    
    success = file.renameTo(file2)
    return success
Task: Rename a file




Go: package main
import "os"

func main() {
  os.Rename("input.txt", "output.txt")
  os.Rename("docs", "mydocs")
  os.Rename("/input.txt", "/output.txt")
  os.Rename("/docs", "/mydocs")
}





VB: Sub Renamer()
    Dim f As FolderItem, r As FolderItem

    f = GetFolderItem("input.txt")
    
    If f.Exists Then f.Name = "output.txt"
    
    f = GetFolderItem("docs")
    If f.Exists Then f.Name = "mydocs"

    
    r = RootDir(GetFolderItem("."))

    f = r.Child("input.txt")
    
    If f.Exists Then f.Name = "output.txt"
    f = r.Child("docs")
    If f.Exists Then f.Name = "mydocs"
End Sub

Function RootDir(what As FolderItem) As FolderItem
    
    
    If what.Parent <> Nil Then  
        Return RootDir(what.Parent) 
    Else
        Return what
    End If
End Function
Task: Rename a file







Python: from java.io import File

def setup():
    
    sketchfile = rename(sketchPath("input.txt"), sketchPath("output.txt"))
    
    sketchfold = rename(sketchPath("docs"), sketchPath("mydocs"))
    
    rootfile = rename("input.txt", "output.txt")
    
    rootfold = rename("docs", "mydocs")

    
    println(str(sketchfile) + ' ' +
            str(sketchfold) + ' ' +
            str(rootfile) +  ' ' +
            str(rootfold)) 
    
    


def rename(oldname, newname):
    
    file = File(oldname)
    
    file2 = File(newname)
    
    success = file.renameTo(file2)
    return success


VB: Sub Renamer()
    Dim f As FolderItem, r As FolderItem

    f = GetFolderItem("input.txt")
    
    If f.Exists Then f.Name = "output.txt"
    
    f = GetFolderItem("docs")
    If f.Exists Then f.Name = "mydocs"

    
    r = RootDir(GetFolderItem("."))

    f = r.Child("input.txt")
    
    If f.Exists Then f.Name = "output.txt"
    f = r.Child("docs")
    If f.Exists Then f.Name = "mydocs"
End Sub

Function RootDir(what As FolderItem) As FolderItem
    
    
    If what.Parent <> Nil Then  
        Return RootDir(what.Parent) 
    Else
        Return what
    End If
End Function
Task: Rename a file

C: #include <stdio.h>

int main()
{
  rename("input.txt", "output.txt");
  rename("docs", "mydocs");
  rename("/input.txt", "/output.txt");
  rename("/docs", "/mydocs");
  return 0;
}




Go: package main
import "os"

func main() {
  os.Rename("input.txt", "output.txt")
  os.Rename("docs", "mydocs")
  os.Rename("/input.txt", "/output.txt")
  os.Rename("/docs", "/mydocs")
}
Task: Rename a file


C++: #include <cstdio>

int main()
{
    std::rename("input.txt", "output.txt");
    std::rename("docs", "mydocs");
    std::rename("/input.txt", "/output.txt");
    std::rename("/docs", "/mydocs");
    return 0;
}


C#: using System;
using System.IO;

class Program {
    static void Main(string[] args) {
        File.Move("input.txt","output.txt");
        File.Move(@"\input.txt",@"\output.txt");

        Directory.Move("docs","mydocs");
        Directory.Move(@"\docs",@"\mydocs");
    }
}
Task: Rename a file


C++: #include <cstdio>

int main()
{
    std::rename("input.txt", "output.txt");
    std::rename("docs", "mydocs");
    std::rename("/input.txt", "/output.txt");
    std::rename("/docs", "/mydocs");
    return 0;
}



Go: package main
import "os"

func main() {
  os.Rename("input.txt", "output.txt")
  os.Rename("docs", "mydocs")
  os.Rename("/input.txt", "/output.txt")
  os.Rename("/docs", "/mydocs")
}
Task: Rename a file



C#: using System;
using System.IO;

class Program {
    static void Main(string[] args) {
        File.Move("input.txt","output.txt");
        File.Move(@"\input.txt",@"\output.txt");

        Directory.Move("docs","mydocs");
        Directory.Move(@"\docs",@"\mydocs");
    }
}





Python: from java.io import File

def setup():
    
    sketchfile = rename(sketchPath("input.txt"), sketchPath("output.txt"))
    
    sketchfold = rename(sketchPath("docs"), sketchPath("mydocs"))
    
    rootfile = rename("input.txt", "output.txt")
    
    rootfold = rename("docs", "mydocs")

    
    println(str(sketchfile) + ' ' +
            str(sketchfold) + ' ' +
            str(rootfile) +  ' ' +
            str(rootfold)) 
    
    


def rename(oldname, newname):
    
    file = File(oldname)
    
    file2 = File(newname)
    
    success = file.renameTo(file2)
    return success
Task: Rename a file


C++: #include <cstdio>

int main()
{
    std::rename("input.txt", "output.txt");
    std::rename("docs", "mydocs");
    std::rename("/input.txt", "/output.txt");
    std::rename("/docs", "/mydocs");
    return 0;
}




Java: import java.io.File;
public class FileRenameTest {
   public static boolean renameFile(String oldname, String newname) {
       
       File file = new File(oldname);
   
       
       File file2 = new File(newname);
   
       
       boolean success = file.renameTo(file2);
       return success;
   }
   public static void test(String type, String oldname, String newname) {
       System.out.println("The following " + type + " called " + oldname +
           ( renameFile(oldname, newname) ? " was renamed as " : " could not be renamed into ")
           + newname + "."
       );
   }
   public static void main(String args[]) {
        test("file", "input.txt", "output.txt");
        test("file", File.separator + "input.txt", File.separator + "output.txt");
        test("directory", "docs", "mydocs");
        test("directory", File.separator + "docs" + File.separator, File.separator + "mydocs" + File.separator);
   }
}