WeixiangYan/CodeTransOcean huggingface dataset:
Task: Documentation







Python: class Doc(object):
   
   def method(self, num):
      
      pass
Task: Documentation




Go: 



package example


var (
    
    X, Y, Z int 
)


func XP() { 
    
}


func nonXP() {}



var MEMEME int
Task: Documentation



C#: 


public static class XMLSystem
{
    static XMLSystem()
    {
        
    }

    
    
    
    
    
    public static XmlDocument GetXML(string name) 
    {
        return null;
    }
}








Fortran:       SUBROUTINE SHOW(A,N)   
        REAL*8 A    
        INTEGER N
Task: Documentation

C: 
int add(int a, int b) {
    return a + b;
}










Fortran:       SUBROUTINE SHOW(A,N)   
        REAL*8 A    
        INTEGER N
Task: Documentation





Java: 
public class Doc{
   
   private String field;

   
   public int method(long num) throws BadException{
      
   }
}






Fortran:       SUBROUTINE SHOW(A,N)   
        REAL*8 A    
        INTEGER N
Task: Documentation







Python: class Doc(object):
   
   def method(self, num):
      
      pass




Fortran:       SUBROUTINE SHOW(A,N)   
        REAL*8 A    
        INTEGER N
Task: Documentation

C: 
int add(int a, int b) {
    return a + b;
}









COBOL:       
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
       REPLACE ==FIELDSIZE== BY ==80==
               ==AREASIZE==  BY ==32768==
               ==FILESIZE==  BY ==65536==.

id     identification division.
       program-id. cobweb-gtk.

       ...

done   goback.
       end program cobweb-gtk.
Task: Documentation



C#: 


public static class XMLSystem
{
    static XMLSystem()
    {
        
    }

    
    
    
    
    
    public static XmlDocument GetXML(string name) 
    {
        return null;
    }
}







COBOL:       
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
       REPLACE ==FIELDSIZE== BY ==80==
               ==AREASIZE==  BY ==32768==
               ==FILESIZE==  BY ==65536==.

id     identification division.
       program-id. cobweb-gtk.

       ...

done   goback.
       end program cobweb-gtk.
Task: Documentation





Java: 
public class Doc{
   
   private String field;

   
   public int method(long num) throws BadException{
      
   }
}





COBOL:       
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
       REPLACE ==FIELDSIZE== BY ==80==
               ==AREASIZE==  BY ==32768==
               ==FILESIZE==  BY ==65536==.

id     identification division.
       program-id. cobweb-gtk.

       ...

done   goback.
       end program cobweb-gtk.
Task: Documentation







Python: class Doc(object):
   
   def method(self, num):
      
      pass



COBOL:       
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
       REPLACE ==FIELDSIZE== BY ==80==
               ==AREASIZE==  BY ==32768==
               ==FILESIZE==  BY ==65536==.

id     identification division.
       program-id. cobweb-gtk.

       ...

done   goback.
       end program cobweb-gtk.
Task: Documentation




Go: 



package example


var (
    
    X, Y, Z int 
)


func XP() { 
    
}


func nonXP() {}



var MEMEME int






COBOL:       
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
       REPLACE ==FIELDSIZE== BY ==80==
               ==AREASIZE==  BY ==32768==
               ==FILESIZE==  BY ==65536==.

id     identification division.
       program-id. cobweb-gtk.

       ...

done   goback.
       end program cobweb-gtk.
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");
    }
}









Ada: with Ada.Directories;  use Ada.Directories;
   ...
Rename ("input.txt", "output.txt");
Rename ("docs", "mydocs");
Rename ("/input.txt", "/output.txt");
Rename ("/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;
}











Ada: with Ada.Directories;  use Ada.Directories;
   ...
Rename ("input.txt", "output.txt");
Rename ("docs", "mydocs");
Rename ("/input.txt", "/output.txt");
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;
}










Ada: with Ada.Directories;  use Ada.Directories;
   ...
Rename ("input.txt", "output.txt");
Rename ("docs", "mydocs");
Rename ("/input.txt", "/output.txt");
Rename ("/docs", "/mydocs");
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")
}








Ada: with Ada.Directories;  use Ada.Directories;
   ...
Rename ("input.txt", "output.txt");
Rename ("docs", "mydocs");
Rename ("/input.txt", "/output.txt");
Rename ("/docs", "/mydocs");
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);
   }
}







Ada: with Ada.Directories;  use Ada.Directories;
   ...
Rename ("input.txt", "output.txt");
Rename ("docs", "mydocs");
Rename ("/input.txt", "/output.txt");
Rename ("/docs", "/mydocs");
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





Ada: with Ada.Directories;  use Ada.Directories;
   ...
Rename ("input.txt", "output.txt");
Rename ("docs", "mydocs");
Rename ("/input.txt", "/output.txt");
Rename ("/docs", "/mydocs");
Task: Rename a file








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




Ada: with Ada.Directories;  use Ada.Directories;
   ...
Rename ("input.txt", "output.txt");
Rename ("docs", "mydocs");
Rename ("/input.txt", "/output.txt");
Rename ("/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;
}
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");
    }
}
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;
}
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);
   }
}
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
Task: Rename a file








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








Fortran:       PROGRAM EX_RENAME
      CALL RENAME('input.txt','output.txt')
      CALL RENAME('docs','mydocs')
      CALL RENAME('/input.txt','/output.txt')
      CALL RENAME('/docs','/mydocs')
      END
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;
}









Fortran:       PROGRAM EX_RENAME
      CALL RENAME('input.txt','output.txt')
      CALL RENAME('docs','mydocs')
      CALL RENAME('/input.txt','/output.txt')
      CALL RENAME('/docs','/mydocs')
      END
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;
}










Fortran:       PROGRAM EX_RENAME
      CALL RENAME('input.txt','output.txt')
      CALL RENAME('docs','mydocs')
      CALL RENAME('/input.txt','/output.txt')
      CALL RENAME('/docs','/mydocs')
      END
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);
   }
}






Fortran:       PROGRAM EX_RENAME
      CALL RENAME('input.txt','output.txt')
      CALL RENAME('docs','mydocs')
      CALL RENAME('/input.txt','/output.txt')
      CALL RENAME('/docs','/mydocs')
      END
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




Fortran:       PROGRAM EX_RENAME
      CALL RENAME('input.txt','output.txt')
      CALL RENAME('docs','mydocs')
      CALL RENAME('/input.txt','/output.txt')
      CALL RENAME('/docs','/mydocs')
      END
Task: Rename a file








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



Fortran:       PROGRAM EX_RENAME
      CALL RENAME('input.txt','output.txt')
      CALL RENAME('docs','mydocs')
      CALL RENAME('/input.txt','/output.txt')
      CALL RENAME('/docs','/mydocs')
      END
Task: Rename a file






PHP: <?php
rename('input.txt', 'output.txt');
rename('docs', 'mydocs');
rename('/input.txt', '/output.txt');
rename('/docs', '/mydocs');
?>





Fortran:       PROGRAM EX_RENAME
      CALL RENAME('input.txt','output.txt')
      CALL RENAME('docs','mydocs')
      CALL RENAME('/input.txt','/output.txt')
      CALL RENAME('/docs','/mydocs')
      END
Task: Rename a file






PHP: <?php
rename('input.txt', 'output.txt');
rename('docs', 'mydocs');
rename('/input.txt', '/output.txt');
rename('/docs', '/mydocs');
?>
Task: Rename a file






PHP: <?php
rename('input.txt', 'output.txt');
rename('docs', 'mydocs');
rename('/input.txt', '/output.txt');
rename('/docs', '/mydocs');
?>






Ada: with Ada.Directories;  use Ada.Directories;
   ...
Rename ("input.txt", "output.txt");
Rename ("docs", "mydocs");
Rename ("/input.txt", "/output.txt");
Rename ("/docs", "/mydocs");
Task: Vigenère cipher



C#: using System;

namespace VigenereCipher
{
    class VCipher
    {
        public string encrypt(string txt, string pw, int d)
        {
            int pwi = 0, tmp;
            string ns = "";
            txt = txt.ToUpper();
            pw = pw.ToUpper();
            foreach (char t in txt)
            {
                if (t < 65) continue;
                tmp = t - 65 + d * (pw[pwi] - 65);
                if (tmp < 0) tmp += 26;
                ns += Convert.ToChar(65 + ( tmp % 26) );
                if (++pwi == pw.Length) pwi = 0;
            }

            return ns;
        }
    };

    class Program
    {
        static void Main(string[] args)
        {
            VCipher v = new VCipher();

            string s0 = "Beware the Jabberwock, my son! The jaws that bite, the claws that catch!",
                   pw = "VIGENERECIPHER";

            Console.WriteLine(s0 + "\n" + pw + "\n");
            string s1 = v.encrypt(s0, pw, 1);
            Console.WriteLine("Encrypted: " + s1);
            s1 = v.encrypt(s1, "VIGENERECIPHER", -1);
            Console.WriteLine("Decrypted: " + s1);
            Console.WriteLine("\nPress any key to continue...");
            Console.ReadKey();
        }
    }
}









Ada: WITH Ada.Text_IO, Ada.Characters.Handling;
USE Ada.Text_IO, Ada.Characters.Handling;

PROCEDURE Main IS
   SUBTYPE Alpha IS Character RANGE 'A' .. 'Z';
   TYPE Ring IS MOD (Alpha'Range_length);
   TYPE Seq IS ARRAY (Integer RANGE <>) OF Ring;
   
   FUNCTION "+" (S, Key : Seq) RETURN Seq IS
      R : Seq (S'Range);
   BEGIN
      FOR I IN R'Range LOOP
         R (I) := S (I) + Key (Key'First + (I - R'First) MOD Key'Length);
      END LOOP;
      RETURN R;
   END "+";
   
   FUNCTION "-" (S : Seq) RETURN Seq IS
      R : Seq (S'Range);
   BEGIN
      FOR I IN R'Range LOOP
         R (I) := - S (I);
      END LOOP; 
      RETURN R;
   END "-";
   
   FUNCTION To_Seq (S : String) RETURN Seq IS
      R  : Seq (S'Range);
      I  : Integer := R'First;
   BEGIN
      FOR C OF To_Upper (S) LOOP
         IF C IN Alpha THEN
            R (I) := Ring'Mod (Alpha'Pos (C) - Alpha'Pos (Alpha'First));
            I := I + 1;
         END IF;
      END LOOP;
      RETURN R (R'First .. I - 1);
   END To_Seq;
   
   FUNCTION To_String (S : Seq ) RETURN String IS
      R : String (S'Range);
   BEGIN
      FOR I IN R'Range LOOP
         R (I) := Alpha'Val ( Integer (S (I)) + Alpha'Pos (Alpha'First));
      END LOOP;
      RETURN R;
   END To_String;
   
   Input : Seq := To_Seq (Get_Line);
   Key : Seq := To_Seq (Get_Line);
   Crypt : Seq := Input + Key;
BEGIN
   Put_Line ("Encrypted: " & To_String (Crypt));
   Put_Line ("Decrypted: " & To_String (Crypt + (-Key)));
END Main;
Task: Vigenère cipher


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

class Vigenere
{
public:
  string key;

  Vigenere(string key)
  {
    for(int i = 0; i < key.size(); ++i)
    {
      if(key[i] >= 'A' && key[i] <= 'Z')
        this->key += key[i];
      else if(key[i] >= 'a' && key[i] <= 'z')
        this->key += key[i] + 'A' - 'a';
    }
  }

  string encrypt(string text)
  {
    string out;

    for(int i = 0, j = 0; i < text.length(); ++i)
    {
      char c = text[i];
      
      if(c >= 'a' && c <= 'z')
        c += 'A' - 'a';
      else if(c < 'A' || c > 'Z')
        continue;

      out += (c + key[j] - 2*'A') % 26 + 'A'; 
      j = (j + 1) % key.length();
    }

    return out;
  }

  string decrypt(string text)
  {
    string out;

    for(int i = 0, j = 0; i < text.length(); ++i)
    {
      char c = text[i];
      
      if(c >= 'a' && c <= 'z')
        c += 'A' - 'a';
      else if(c < 'A' || c > 'Z')
        continue;

      out += (c - key[j] + 26) % 26 + 'A'; 
      j = (j + 1) % key.length();
    }

    return out;
  }
};

int main()
{
  Vigenere cipher("VIGENERECIPHER");

  string original = "Beware the Jabberwock, my son! The jaws that bite, the claws that catch!";
  string encrypted = cipher.encrypt(original);
  string decrypted = cipher.decrypt(encrypted);

  cout << original << endl;
  cout << "Encrypted: " << encrypted << endl;
  cout << "Decrypted: " << decrypted << endl;
}










Ada: WITH Ada.Text_IO, Ada.Characters.Handling;
USE Ada.Text_IO, Ada.Characters.Handling;

PROCEDURE Main IS
   SUBTYPE Alpha IS Character RANGE 'A' .. 'Z';
   TYPE Ring IS MOD (Alpha'Range_length);
   TYPE Seq IS ARRAY (Integer RANGE <>) OF Ring;
   
   FUNCTION "+" (S, Key : Seq) RETURN Seq IS
      R : Seq (S'Range);
   BEGIN
      FOR I IN R'Range LOOP
         R (I) := S (I) + Key (Key'First + (I - R'First) MOD Key'Length);
      END LOOP;
      RETURN R;
   END "+";
   
   FUNCTION "-" (S : Seq) RETURN Seq IS
      R : Seq (S'Range);
   BEGIN
      FOR I IN R'Range LOOP
         R (I) := - S (I);
      END LOOP; 
      RETURN R;
   END "-";
   
   FUNCTION To_Seq (S : String) RETURN Seq IS
      R  : Seq (S'Range);
      I  : Integer := R'First;
   BEGIN
      FOR C OF To_Upper (S) LOOP
         IF C IN Alpha THEN
            R (I) := Ring'Mod (Alpha'Pos (C) - Alpha'Pos (Alpha'First));
            I := I + 1;
         END IF;
      END LOOP;
      RETURN R (R'First .. I - 1);
   END To_Seq;
   
   FUNCTION To_String (S : Seq ) RETURN String IS
      R : String (S'Range);
   BEGIN
      FOR I IN R'Range LOOP
         R (I) := Alpha'Val ( Integer (S (I)) + Alpha'Pos (Alpha'First));
      END LOOP;
      RETURN R;
   END To_String;
   
   Input : Seq := To_Seq (Get_Line);
   Key : Seq := To_Seq (Get_Line);
   Crypt : Seq := Input + Key;
BEGIN
   Put_Line ("Encrypted: " & To_String (Crypt));
   Put_Line ("Decrypted: " & To_String (Crypt + (-Key)));
END Main;