WeixiangYan/CodeTransOcean huggingface dataset:
Task: Cheryl's birthday



C#: public static class CherylsBirthday
{
    public static void Main() {
        var dates = new HashSet<(string month, int day)> {
            ("May", 15),
            ("May", 16),
            ("May", 19),
            ("June", 17),
            ("June", 18),
            ("July", 14),
            ("July", 16),
            ("August", 14),
            ("August", 15),
            ("August", 17)
        };

        Console.WriteLine(dates.Count + " remaining.");
        
        var monthsWithUniqueDays = dates.GroupBy(d => d.day).Where(g => g.Count() == 1).Select(g => g.First().month).ToHashSet();
        dates.RemoveWhere(d => monthsWithUniqueDays.Contains(d.month));
        Console.WriteLine(dates.Count + " remaining.");
        
        dates.IntersectWith(dates.GroupBy(d => d.day).Where(g => g.Count() == 1).Select(g => g.First()));
        Console.WriteLine(dates.Count + " remaining.");
        
        dates.IntersectWith(dates.GroupBy(d => d.month).Where(g => g.Count() == 1).Select(g => g.First()));
        Console.WriteLine(dates.Single());
    }
    
}


Go: package main

import (
    "fmt"
    "time"
)

type birthday struct{ month, day int }

func (b birthday) String() string {
    return fmt.Sprintf("%s %d", time.Month(b.month), b.day)
}

func (b birthday) monthUniqueIn(bds []birthday) bool {
    count := 0
    for _, bd := range bds {
        if bd.month == b.month {
            count++
        }
    }
    if count == 1 {
        return true
    }
    return false
}

func (b birthday) dayUniqueIn(bds []birthday) bool {
    count := 0
    for _, bd := range bds {
        if bd.day == b.day {
            count++
        }
    }
    if count == 1 {
        return true
    }
    return false
}

func (b birthday) monthWithUniqueDayIn(bds []birthday) bool {
    for _, bd := range bds {
        if bd.month == b.month && bd.dayUniqueIn(bds) {
            return true
        }
    }
    return false
}

func main() {
    choices := []birthday{
        {5, 15}, {5, 16}, {5, 19}, {6, 17}, {6, 18},
        {7, 14}, {7, 16}, {8, 14}, {8, 15}, {8, 17},
    }

    
    
    var filtered []birthday
    for _, bd := range choices {
        if !bd.monthUniqueIn(choices) {
            filtered = append(filtered, bd)
        }
    }

    
    
    var filtered2 []birthday
    for _, bd := range filtered {
        if !bd.monthWithUniqueDayIn(filtered) {
            filtered2 = append(filtered2, bd)
        }
    }

    
    
    var filtered3 []birthday
    for _, bd := range filtered2 {
        if bd.dayUniqueIn(filtered2) {
            filtered3 = append(filtered3, bd)
        }
    }

    
    
    var filtered4 []birthday
    for _, bd := range filtered3 {
        if bd.monthUniqueIn(filtered3) {
            filtered4 = append(filtered4, bd)
        }
    }

    if len(filtered4) == 1 {
        fmt.Println("Cheryl's birthday is", filtered4[0])
    } else {
        fmt.Println("Something went wrong!")
    }
}
Task: Cheryl's birthday



C#: public static class CherylsBirthday
{
    public static void Main() {
        var dates = new HashSet<(string month, int day)> {
            ("May", 15),
            ("May", 16),
            ("May", 19),
            ("June", 17),
            ("June", 18),
            ("July", 14),
            ("July", 16),
            ("August", 14),
            ("August", 15),
            ("August", 17)
        };

        Console.WriteLine(dates.Count + " remaining.");
        
        var monthsWithUniqueDays = dates.GroupBy(d => d.day).Where(g => g.Count() == 1).Select(g => g.First().month).ToHashSet();
        dates.RemoveWhere(d => monthsWithUniqueDays.Contains(d.month));
        Console.WriteLine(dates.Count + " remaining.");
        
        dates.IntersectWith(dates.GroupBy(d => d.day).Where(g => g.Count() == 1).Select(g => g.First()));
        Console.WriteLine(dates.Count + " remaining.");
        
        dates.IntersectWith(dates.GroupBy(d => d.month).Where(g => g.Count() == 1).Select(g => g.First()));
        Console.WriteLine(dates.Single());
    }
    
}





Python: 

from itertools import groupby
from re import split



def main():
    

    month, day = 0, 1
    print(
        
        
        uniquePairing(month)(
            
            
            uniquePairing(day)(
                
                
                monthsWithUniqueDays(False)([
                    
                    tuple(x.split()) for x in
                    split(
                        ', ',
                        'May 15, May 16, May 19, ' +
                        'June 17, June 18, ' +
                        'July 14, July 16, ' +
                        'Aug 14, Aug 15, Aug 17'
                    )
                ])
            )
        )
    )





def monthsWithUniqueDays(blnInclude):
    
    def go(xs):
        month, day = 0, 1
        months = [fst(x) for x in uniquePairing(day)(xs)]
        return [
            md for md in xs
            if blnInclude or not (md[month] in months)
        ]
    return go



def uniquePairing(i):
    
    def go(xs):
        def inner(md):
            dct = md[i]
            uniques = [
                k for k in dct.keys()
                if 1 == len(dct[k])
            ]
            return [tpl for tpl in xs if tpl[i] in uniques]
        return inner
    return ap(bindPairs)(go)





def bindPairs(xs):
    
    return lambda f: f(
        (
            dictFromPairs(xs),
            dictFromPairs(
                [(b, a) for (a, b) in xs]
            )
        )
    )



def dictFromPairs(xs):
    
    return {
        k: [snd(x) for x in m] for k, m in groupby(
            sorted(xs, key=fst), key=fst
        )
    }





def ap(f):
    
    def go(g):
        def fxgx(x):
            return f(x)(
                g(x)
            )
        return fxgx
    return go



def fst(tpl):
    
    return tpl[0]



def snd(tpl):
    
    return tpl[1]


if __name__ == '__main__':
    main()
Task: Cheryl's birthday



C#: public static class CherylsBirthday
{
    public static void Main() {
        var dates = new HashSet<(string month, int day)> {
            ("May", 15),
            ("May", 16),
            ("May", 19),
            ("June", 17),
            ("June", 18),
            ("July", 14),
            ("July", 16),
            ("August", 14),
            ("August", 15),
            ("August", 17)
        };

        Console.WriteLine(dates.Count + " remaining.");
        
        var monthsWithUniqueDays = dates.GroupBy(d => d.day).Where(g => g.Count() == 1).Select(g => g.First().month).ToHashSet();
        dates.RemoveWhere(d => monthsWithUniqueDays.Contains(d.month));
        Console.WriteLine(dates.Count + " remaining.");
        
        dates.IntersectWith(dates.GroupBy(d => d.day).Where(g => g.Count() == 1).Select(g => g.First()));
        Console.WriteLine(dates.Count + " remaining.");
        
        dates.IntersectWith(dates.GroupBy(d => d.month).Where(g => g.Count() == 1).Select(g => g.First()));
        Console.WriteLine(dates.Single());
    }
    
}






VB: Private Sub exclude_unique_days(w As Collection)
    Dim number_of_dates(31) As Integer
    Dim months_to_exclude As New Collection
    For Each v In w
        number_of_dates(v(1)) = number_of_dates(v(1)) + 1
    Next v
    For i = w.Count To 1 Step -1
        If number_of_dates(w(i)(1)) = 1 Then
            months_to_exclude.Add w(i)(0)
            w.Remove i
        End If
    Next i
    For Each m In months_to_exclude
        exclude_month w, m
    Next m
End Sub
Private Sub exclude_month(x As Collection, v As Variant)
    For i = x.Count To 1 Step -1
        If x(i)(0) = v Then x.Remove i
    Next i
End Sub
Private Sub exclude_non_unique_days(w As Collection)
    Dim number_of_dates(31) As Integer
    For Each v In w
        number_of_dates(v(1)) = number_of_dates(v(1)) + 1
    Next v
    For i = w.Count To 1 Step -1
        If number_of_dates(w(i)(1)) > 1 Then
            w.Remove i
        End If
    Next i
End Sub
Private Sub exclude_non_unique_months(w As Collection)
    Dim months As New Collection
    For Each v In w
        On Error GoTo 1
        months.Add v(0), v(0)
    Next v
1:
    For i = w.Count To 1 Step -1
        If w(i)(0) = v(0) Then
            w.Remove i
        End If
    Next i
End Sub
Public Sub cherylsbirthday()
    Dim v As New Collection
    s = "May 15, May 16, May 19, June 17, June 18, July 14, July 16, August 14, August 15, August 17"
    t = Split(s, ",")
    For Each u In t
        v.Add Split(Trim(u), " ")
    Next u
    
    exclude_unique_days v
    
    exclude_non_unique_days v
    
    exclude_non_unique_months v
    Debug.Print v(1)(0); " "; v(1)(1)
End Sub
Task: Jump anywhere

C: 	if (x > 0) goto positive;
	else goto negative;

positive:
	printf("pos\n"); goto both;

negative:
	printf("neg\n");

both:
	...



C#: if (x > 0) goto positive;
else goto negative;

positive:
    Console.WriteLine("pos\n"); goto both;

negative:
    Console.WriteLine("neg\n");

both:
    ...
Task: Jump anywhere

C: 	if (x > 0) goto positive;
	else goto negative;

positive:
	printf("pos\n"); goto both;

negative:
	printf("neg\n");

both:
	...


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

using namespace std;

int main(void) 
{
    cout << "Find a solution to i = 2 * j - 7\n";
    pair<int, int> answer;
    for(int i = 0; true; i++)
    {
        for(int j = 0; j < i; j++)
        {
            if( i == 2 * j - 7)
            {
                
                answer = make_pair(i, j);
                goto loopexit;
            }
        }
    }
    
loopexit:
    cout << answer.first << " = 2 * " << answer.second << " - 7\n\n"; 
    
    
    
    
    
    

    goto spagetti;
        
    int k;
    k = 9;  
    
    

spagetti:
    
    cout << "k = " << k << "\n";  
    
}
Task: Jump anywhere

C: 	if (x > 0) goto positive;
	else goto negative;

positive:
	printf("pos\n"); goto both;

negative:
	printf("neg\n");

both:
	...




Go: package main

import "fmt"

func main() {
    outer:
    for i := 0; i < 4; i++ {
        for j := 0; j < 4; j++ {
            if i + j == 4 { continue outer }
            if i + j == 5 { break outer }
            fmt.Println(i + j)
        }
    }

    k := 3
    if k == 3 { goto later }
    fmt.Println(k)  
    later:
    k++
    fmt.Println(k)
}
Task: Jump anywhere

C: 	if (x > 0) goto positive;
	else goto negative;

positive:
	printf("pos\n"); goto both;

negative:
	printf("neg\n");

both:
	...





Java: loop1: while (x != 0) {
    loop2: for (int i = 0; i < 10; i++) {
        loop3: do {
            
            if () {
                
                continue loop1;
            }
            
            if () {
                
                break loop2;
            }
        } while (y < 10);
        
    }
    
}
Task: Jump anywhere

C: 	if (x > 0) goto positive;
	else goto negative;

positive:
	printf("pos\n"); goto both;

negative:
	printf("neg\n");

both:
	...







Python: 
from goto import goto, label
label .start
for i in range(1, 4):
    print i
    if i == 2:
        try:
            output = message
        except NameError:
            print "Oops - forgot to define 'message'!  Start again."
            message = "Hello world"
            goto .start
print output, "\n"
Task: Jump anywhere

C: 	if (x > 0) goto positive;
	else goto negative;

positive:
	printf("pos\n"); goto both;

negative:
	printf("neg\n");

both:
	...








VB: Public Sub jump()
    Debug.Print "VBA only allows"
    GoTo 1
    Debug.Print "no global jumps"
1:
    Debug.Print "jumps in procedures with GoTo"
    Debug.Print "However,"
    On 2 GoSub one, two
    Debug.Print "named in the list after 
    Debug.Print "and execution will continue on the next line"
    On 1 GoTo one, two
    Debug.Print "For On Error, see Exceptions"
one:
    Debug.Print "On <n> GoTo let you jump to the n-th label"
    Debug.Print "and won
    Exit Sub
two:
    Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub
Task: Jump anywhere


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

using namespace std;

int main(void) 
{
    cout << "Find a solution to i = 2 * j - 7\n";
    pair<int, int> answer;
    for(int i = 0; true; i++)
    {
        for(int j = 0; j < i; j++)
        {
            if( i == 2 * j - 7)
            {
                
                answer = make_pair(i, j);
                goto loopexit;
            }
        }
    }
    
loopexit:
    cout << answer.first << " = 2 * " << answer.second << " - 7\n\n"; 
    
    
    
    
    
    

    goto spagetti;
        
    int k;
    k = 9;  
    
    

spagetti:
    
    cout << "k = " << k << "\n";  
    
}


C#: if (x > 0) goto positive;
else goto negative;

positive:
    Console.WriteLine("pos\n"); goto both;

negative:
    Console.WriteLine("neg\n");

both:
    ...
Task: Jump anywhere


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

using namespace std;

int main(void) 
{
    cout << "Find a solution to i = 2 * j - 7\n";
    pair<int, int> answer;
    for(int i = 0; true; i++)
    {
        for(int j = 0; j < i; j++)
        {
            if( i == 2 * j - 7)
            {
                
                answer = make_pair(i, j);
                goto loopexit;
            }
        }
    }
    
loopexit:
    cout << answer.first << " = 2 * " << answer.second << " - 7\n\n"; 
    
    
    
    
    
    

    goto spagetti;
        
    int k;
    k = 9;  
    
    

spagetti:
    
    cout << "k = " << k << "\n";  
    
}



Go: package main

import "fmt"

func main() {
    outer:
    for i := 0; i < 4; i++ {
        for j := 0; j < 4; j++ {
            if i + j == 4 { continue outer }
            if i + j == 5 { break outer }
            fmt.Println(i + j)
        }
    }

    k := 3
    if k == 3 { goto later }
    fmt.Println(k)  
    later:
    k++
    fmt.Println(k)
}
Task: Jump anywhere


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

using namespace std;

int main(void) 
{
    cout << "Find a solution to i = 2 * j - 7\n";
    pair<int, int> answer;
    for(int i = 0; true; i++)
    {
        for(int j = 0; j < i; j++)
        {
            if( i == 2 * j - 7)
            {
                
                answer = make_pair(i, j);
                goto loopexit;
            }
        }
    }
    
loopexit:
    cout << answer.first << " = 2 * " << answer.second << " - 7\n\n"; 
    
    
    
    
    
    

    goto spagetti;
        
    int k;
    k = 9;  
    
    

spagetti:
    
    cout << "k = " << k << "\n";  
    
}




Java: loop1: while (x != 0) {
    loop2: for (int i = 0; i < 10; i++) {
        loop3: do {
            
            if () {
                
                continue loop1;
            }
            
            if () {
                
                break loop2;
            }
        } while (y < 10);
        
    }
    
}
Task: Jump anywhere


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

using namespace std;

int main(void) 
{
    cout << "Find a solution to i = 2 * j - 7\n";
    pair<int, int> answer;
    for(int i = 0; true; i++)
    {
        for(int j = 0; j < i; j++)
        {
            if( i == 2 * j - 7)
            {
                
                answer = make_pair(i, j);
                goto loopexit;
            }
        }
    }
    
loopexit:
    cout << answer.first << " = 2 * " << answer.second << " - 7\n\n"; 
    
    
    
    
    
    

    goto spagetti;
        
    int k;
    k = 9;  
    
    

spagetti:
    
    cout << "k = " << k << "\n";  
    
}






Python: 
from goto import goto, label
label .start
for i in range(1, 4):
    print i
    if i == 2:
        try:
            output = message
        except NameError:
            print "Oops - forgot to define 'message'!  Start again."
            message = "Hello world"
            goto .start
print output, "\n"
Task: Jump anywhere


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

using namespace std;

int main(void) 
{
    cout << "Find a solution to i = 2 * j - 7\n";
    pair<int, int> answer;
    for(int i = 0; true; i++)
    {
        for(int j = 0; j < i; j++)
        {
            if( i == 2 * j - 7)
            {
                
                answer = make_pair(i, j);
                goto loopexit;
            }
        }
    }
    
loopexit:
    cout << answer.first << " = 2 * " << answer.second << " - 7\n\n"; 
    
    
    
    
    
    

    goto spagetti;
        
    int k;
    k = 9;  
    
    

spagetti:
    
    cout << "k = " << k << "\n";  
    
}







VB: Public Sub jump()
    Debug.Print "VBA only allows"
    GoTo 1
    Debug.Print "no global jumps"
1:
    Debug.Print "jumps in procedures with GoTo"
    Debug.Print "However,"
    On 2 GoSub one, two
    Debug.Print "named in the list after 
    Debug.Print "and execution will continue on the next line"
    On 1 GoTo one, two
    Debug.Print "For On Error, see Exceptions"
one:
    Debug.Print "On <n> GoTo let you jump to the n-th label"
    Debug.Print "and won
    Exit Sub
two:
    Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub
Task: Jump anywhere



C#: if (x > 0) goto positive;
else goto negative;

positive:
    Console.WriteLine("pos\n"); goto both;

negative:
    Console.WriteLine("neg\n");

both:
    ...


Go: package main

import "fmt"

func main() {
    outer:
    for i := 0; i < 4; i++ {
        for j := 0; j < 4; j++ {
            if i + j == 4 { continue outer }
            if i + j == 5 { break outer }
            fmt.Println(i + j)
        }
    }

    k := 3
    if k == 3 { goto later }
    fmt.Println(k)  
    later:
    k++
    fmt.Println(k)
}
Task: Jump anywhere



C#: if (x > 0) goto positive;
else goto negative;

positive:
    Console.WriteLine("pos\n"); goto both;

negative:
    Console.WriteLine("neg\n");

both:
    ...



Java: loop1: while (x != 0) {
    loop2: for (int i = 0; i < 10; i++) {
        loop3: do {
            
            if () {
                
                continue loop1;
            }
            
            if () {
                
                break loop2;
            }
        } while (y < 10);
        
    }
    
}
Task: Jump anywhere



C#: if (x > 0) goto positive;
else goto negative;

positive:
    Console.WriteLine("pos\n"); goto both;

negative:
    Console.WriteLine("neg\n");

both:
    ...





Python: 
from goto import goto, label
label .start
for i in range(1, 4):
    print i
    if i == 2:
        try:
            output = message
        except NameError:
            print "Oops - forgot to define 'message'!  Start again."
            message = "Hello world"
            goto .start
print output, "\n"
Task: Jump anywhere



C#: if (x > 0) goto positive;
else goto negative;

positive:
    Console.WriteLine("pos\n"); goto both;

negative:
    Console.WriteLine("neg\n");

both:
    ...






VB: Public Sub jump()
    Debug.Print "VBA only allows"
    GoTo 1
    Debug.Print "no global jumps"
1:
    Debug.Print "jumps in procedures with GoTo"
    Debug.Print "However,"
    On 2 GoSub one, two
    Debug.Print "named in the list after 
    Debug.Print "and execution will continue on the next line"
    On 1 GoTo one, two
    Debug.Print "For On Error, see Exceptions"
one:
    Debug.Print "On <n> GoTo let you jump to the n-th label"
    Debug.Print "and won
    Exit Sub
two:
    Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub
Task: Jump anywhere




Go: package main

import "fmt"

func main() {
    outer:
    for i := 0; i < 4; i++ {
        for j := 0; j < 4; j++ {
            if i + j == 4 { continue outer }
            if i + j == 5 { break outer }
            fmt.Println(i + j)
        }
    }

    k := 3
    if k == 3 { goto later }
    fmt.Println(k)  
    later:
    k++
    fmt.Println(k)
}


Java: loop1: while (x != 0) {
    loop2: for (int i = 0; i < 10; i++) {
        loop3: do {
            
            if () {
                
                continue loop1;
            }
            
            if () {
                
                break loop2;
            }
        } while (y < 10);
        
    }
    
}
Task: Jump anywhere





Java: loop1: while (x != 0) {
    loop2: for (int i = 0; i < 10; i++) {
        loop3: do {
            
            if () {
                
                continue loop1;
            }
            
            if () {
                
                break loop2;
            }
        } while (y < 10);
        
    }
    
}



Python: 
from goto import goto, label
label .start
for i in range(1, 4):
    print i
    if i == 2:
        try:
            output = message
        except NameError:
            print "Oops - forgot to define 'message'!  Start again."
            message = "Hello world"
            goto .start
print output, "\n"
Task: Jump anywhere





Java: loop1: while (x != 0) {
    loop2: for (int i = 0; i < 10; i++) {
        loop3: do {
            
            if () {
                
                continue loop1;
            }
            
            if () {
                
                break loop2;
            }
        } while (y < 10);
        
    }
    
}




VB: Public Sub jump()
    Debug.Print "VBA only allows"
    GoTo 1
    Debug.Print "no global jumps"
1:
    Debug.Print "jumps in procedures with GoTo"
    Debug.Print "However,"
    On 2 GoSub one, two
    Debug.Print "named in the list after 
    Debug.Print "and execution will continue on the next line"
    On 1 GoTo one, two
    Debug.Print "For On Error, see Exceptions"
one:
    Debug.Print "On <n> GoTo let you jump to the n-th label"
    Debug.Print "and won
    Exit Sub
two:
    Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub
Task: Jump anywhere




Go: package main

import "fmt"

func main() {
    outer:
    for i := 0; i < 4; i++ {
        for j := 0; j < 4; j++ {
            if i + j == 4 { continue outer }
            if i + j == 5 { break outer }
            fmt.Println(i + j)
        }
    }

    k := 3
    if k == 3 { goto later }
    fmt.Println(k)  
    later:
    k++
    fmt.Println(k)
}




Python: 
from goto import goto, label
label .start
for i in range(1, 4):
    print i
    if i == 2:
        try:
            output = message
        except NameError:
            print "Oops - forgot to define 'message'!  Start again."
            message = "Hello world"
            goto .start
print output, "\n"
Task: Jump anywhere




Go: package main

import "fmt"

func main() {
    outer:
    for i := 0; i < 4; i++ {
        for j := 0; j < 4; j++ {
            if i + j == 4 { continue outer }
            if i + j == 5 { break outer }
            fmt.Println(i + j)
        }
    }

    k := 3
    if k == 3 { goto later }
    fmt.Println(k)  
    later:
    k++
    fmt.Println(k)
}





VB: Public Sub jump()
    Debug.Print "VBA only allows"
    GoTo 1
    Debug.Print "no global jumps"
1:
    Debug.Print "jumps in procedures with GoTo"
    Debug.Print "However,"
    On 2 GoSub one, two
    Debug.Print "named in the list after 
    Debug.Print "and execution will continue on the next line"
    On 1 GoTo one, two
    Debug.Print "For On Error, see Exceptions"
one:
    Debug.Print "On <n> GoTo let you jump to the n-th label"
    Debug.Print "and won
    Exit Sub
two:
    Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub
Task: Jump anywhere







Python: 
from goto import goto, label
label .start
for i in range(1, 4):
    print i
    if i == 2:
        try:
            output = message
        except NameError:
            print "Oops - forgot to define 'message'!  Start again."
            message = "Hello world"
            goto .start
print output, "\n"


VB: Public Sub jump()
    Debug.Print "VBA only allows"
    GoTo 1
    Debug.Print "no global jumps"
1:
    Debug.Print "jumps in procedures with GoTo"
    Debug.Print "However,"
    On 2 GoSub one, two
    Debug.Print "named in the list after 
    Debug.Print "and execution will continue on the next line"
    On 1 GoTo one, two
    Debug.Print "For On Error, see Exceptions"
one:
    Debug.Print "On <n> GoTo let you jump to the n-th label"
    Debug.Print "and won
    Exit Sub
two:
    Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub