kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: Special divisors
C: #include <stdbool.h>
#include <stdio.h>

int reverse(int n) {
    int result = 0;
    while (n > 0) {
        result = 10 * result + n % 10;
        n /= 10;
    }
    return result;
}

int main() {
    const int limit1 = 200;

    int row = 0;
    int num = 0;
    int n;

    for (n = 1; n < limit1; n++) {
        bool flag = true;
        int revNum = reverse(n);
        int m;

        for (m = 1; m < n / 2; m++) {
            int revDiv = reverse(m);
            if (n % m == 0) {
                if (revNum % revDiv == 0) {
                    flag = true;
                } else {
                    flag = false;
                    break;
                }
            }
        }

        if (flag) {
            num++;
            row++;
            printf("%4d ", n);
            if (row % 10 == 0) {
                printf("\n");
            }
        }
    }

    printf("\n\nFound %d special divisors N that reverse(D) divides reverse(N) for all divisors D of N, where N < 200\n", num);

    return 0;
}

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

using uint = unsigned int;

std::vector<uint> divisors(uint n) {
    std::vector<uint> divs;
    for (uint d=1; d<=n/2; d++) {
        if (n % d == 0) divs.push_back(d);
    }
    return divs;
}

uint reverse(uint n) {
    uint r;
    for (r = 0; n; n /= 10) r = (r*10) + (n%10);
    return r;
}

bool special(uint n) {
    for (uint d : divisors(n))
        if (reverse(n) % reverse(d) != 0) return false;
    return true;
}

int main() {
    for (uint n=1, c=0; n < 200; n++) {
        if (special(n)) {
            std::cout << std::setw(4) << n;
            if (++c == 10) {
                c = 0;
                std::cout << std::endl;
            }
        }
    }
    std::cout << std::endl;
    return 0;
}
Task: Special divisors
C++: #include <iostream>
#include <iomanip>
#include <vector>

using uint = unsigned int;

std::vector<uint> divisors(uint n) {
    std::vector<uint> divs;
    for (uint d=1; d<=n/2; d++) {
        if (n % d == 0) divs.push_back(d);
    }
    return divs;
}

uint reverse(uint n) {
    uint r;
    for (r = 0; n; n /= 10) r = (r*10) + (n%10);
    return r;
}

bool special(uint n) {
    for (uint d : divisors(n))
        if (reverse(n) % reverse(d) != 0) return false;
    return true;
}

int main() {
    for (uint n=1, c=0; n < 200; n++) {
        if (special(n)) {
            std::cout << std::setw(4) << n;
            if (++c == 10) {
                c = 0;
                std::cout << std::endl;
            }
        }
    }
    std::cout << std::endl;
    return 0;
}

Python: 

def reverse(n):
    u = 0
    while n:
        u = 10 * u + n % 10
        n = int(n / 10)
    return u

c = 0
for n in range(1, 200):
    u = reverse(n)
    s = True
    
    for d in range (1, n):
        if n % d == 0:
            b = reverse(d)
            if u % b != 0:
                s = False
    if s:
        c = c + 1
        print(n, end='\t')
                
print("\nEncontrados ", c, "divisores especiales.")
Task: Special divisors
C#: using System;

namespace SpecialDivisors {
    class Program {
        static int Reverse(int n) {
            int result = 0;
            while (n > 0) {
                result = 10 * result + n % 10;
                n /= 10;
            }
            return result;
        }

        static void Main() {
            const int LIMIT = 200;

            int row = 0;
            int num = 0;

            for (int n = 1; n < LIMIT; n++) {
                bool flag = true;
                int revNum = Reverse(n);

                for (int m = 1; m < n / 2; m++) {
                    int revDiv = Reverse(m);
                    if (n % m == 0) {
                        if (revNum % revDiv == 0) {
                            flag = true;
                        } else {
                            flag = false;
                            break;
                        }
                    }
                }

                if (flag) {
                    num++;
                    row++;
                    Console.Write("{0,4}", n);
                    if (row % 10 == 0) {
                        Console.WriteLine();
                    }
                }
            }

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Found {0} special divisors N that reverse(D) divides reverse(N) for all divisors D of N, where N < 200", num);
        }
    }
}

Go: package main

import (
    "fmt"
    "rcu"
)

func reversed(n int) int {
    rev := 0
    for n > 0 {
        rev = rev*10 + n%10
        n = n / 10
    }
    return rev
}

func main() {
    var special []int
    for n := 1; n < 200; n++ {
        divs := rcu.Divisors(n)
        revN := reversed(n)
        all := true
        for _, d := range divs {
            if revN%reversed(d) != 0 {
                all = false
                break
            }
        }
        if all {
            special = append(special, n)
        }
    }
    fmt.Println("Special divisors in the range 0..199:")
    for i, n := range special {
        fmt.Printf("%3d ", n)
        if (i+1)%12 == 0 {
            fmt.Println()
        }
    }
    fmt.Printf("\n%d special divisors found.\n", len(special))
}
Task: Special divisors
C#: using System;

namespace SpecialDivisors {
    class Program {
        static int Reverse(int n) {
            int result = 0;
            while (n > 0) {
                result = 10 * result + n % 10;
                n /= 10;
            }
            return result;
        }

        static void Main() {
            const int LIMIT = 200;

            int row = 0;
            int num = 0;

            for (int n = 1; n < LIMIT; n++) {
                bool flag = true;
                int revNum = Reverse(n);

                for (int m = 1; m < n / 2; m++) {
                    int revDiv = Reverse(m);
                    if (n % m == 0) {
                        if (revNum % revDiv == 0) {
                            flag = true;
                        } else {
                            flag = false;
                            break;
                        }
                    }
                }

                if (flag) {
                    num++;
                    row++;
                    Console.Write("{0,4}", n);
                    if (row % 10 == 0) {
                        Console.WriteLine();
                    }
                }
            }

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Found {0} special divisors N that reverse(D) divides reverse(N) for all divisors D of N, where N < 200", num);
        }
    }
}

Python: 

def reverse(n):
    u = 0
    while n:
        u = 10 * u + n % 10
        n = int(n / 10)
    return u

c = 0
for n in range(1, 200):
    u = reverse(n)
    s = True
    
    for d in range (1, n):
        if n % d == 0:
            b = reverse(d)
            if u % b != 0:
                s = False
    if s:
        c = c + 1
        print(n, end='\t')
                
print("\nEncontrados ", c, "divisores especiales.")
Task: Square but not cube
C: #include <stdio.h>
#include <math.h>

int main() {
    int n = 1, count = 0, sq, cr;
    for ( ; count < 30; ++n) {
        sq = n * n;
        cr = (int)cbrt((double)sq);
        if (cr * cr * cr != sq) {
            count++;
            printf("%d\n", sq);
        }
        else {
            printf("%d is square and cube\n", sq);
        }
    }
    return 0;
}

C#: using System;
using System.Collections.Generic;
using static System.Console;
using static System.Linq.Enumerable;

public static class SquareButNotCube
{
    public static void Main() {
        var squares = from i in Integers() select i * i;
        var cubes = from i in Integers() select i * i * i;

        foreach (var x in Merge().Take(33)) {
            WriteLine(x.isCube ? x.n + " (also cube)" : x.n + "");
        }
        
        IEnumerable<int> Integers() {
            for (int i = 1; ;i++) yield return i;
        }

        IEnumerable<(int n, bool isCube)> Merge() {
            using (var s = squares.GetEnumerator())
            using (var c = cubes.GetEnumerator()) {
                s.MoveNext();
                c.MoveNext();
                while (true) {
                    if (s.Current < c.Current) {
                        yield return (s.Current, false);
                        s.MoveNext();
                    } else if (s.Current == c.Current) {
                        yield return (s.Current, true);
                        s.MoveNext();
                        c.MoveNext();
                    } else {
                        c.MoveNext();
                    }
                }
            }
        }

    }
}
Task: Square but not cube
C: #include <stdio.h>
#include <math.h>

int main() {
    int n = 1, count = 0, sq, cr;
    for ( ; count < 30; ++n) {
        sq = n * n;
        cr = (int)cbrt((double)sq);
        if (cr * cr * cr != sq) {
            count++;
            printf("%d\n", sq);
        }
        else {
            printf("%d is square and cube\n", sq);
        }
    }
    return 0;
}

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

int main() {
    int n = 1;
    int count = 0;
    int sq;
    int cr;

    for (; count < 30; ++n) {
        sq = n * n;
        cr = cbrt(sq);
        if (cr * cr * cr != sq) {
            count++;
            std::cout << sq << '\n';
        } else {
            std::cout << sq << " is square and cube\n";
        }
    }

    return 0;
}
Task: Square but not cube
C: #include <stdio.h>
#include <math.h>

int main() {
    int n = 1, count = 0, sq, cr;
    for ( ; count < 30; ++n) {
        sq = n * n;
        cr = (int)cbrt((double)sq);
        if (cr * cr * cr != sq) {
            count++;
            printf("%d\n", sq);
        }
        else {
            printf("%d is square and cube\n", sq);
        }
    }
    return 0;
}

Java: public class SquaresCubes {
    public static boolean isPerfectCube(long n) {
        long c = (long)Math.cbrt((double)n);
        return ((c * c * c) == n);
    }
    
    public static void main(String... args) {
        long n = 1;
        int squareOnlyCount = 0;
        int squareCubeCount = 0;
        while ((squareOnlyCount < 30) || (squareCubeCount < 3)) {
            long sq = n * n;
            if (isPerfectCube(sq)) {
                squareCubeCount++;
                System.out.println("Square and cube: " + sq);
            }
            else {
                squareOnlyCount++;
                System.out.println("Square: " + sq);
            }
            n++;
        }
    }
}
Task: Square but not cube
C: #include <stdio.h>
#include <math.h>

int main() {
    int n = 1, count = 0, sq, cr;
    for ( ; count < 30; ++n) {
        sq = n * n;
        cr = (int)cbrt((double)sq);
        if (cr * cr * cr != sq) {
            count++;
            printf("%d\n", sq);
        }
        else {
            printf("%d is square and cube\n", sq);
        }
    }
    return 0;
}

Python: 
def nonCubeSquares(n):
    upto = enumFromTo(1)
    ns = upto(n)
    setCubes = set(x ** 3 for x in ns)
    ms = upto(n + len(set(x * x for x in ns).intersection(
        setCubes
    )))
    return list(tuple([x * x, x in setCubes]) for x in ms)



def squareListing(xs):
    justifyIdx = justifyRight(len(str(1 + len(xs))))(' ')
    justifySqr = justifyRight(1 + len(str(xs[-1][0])))(' ')
    return list(
        '(' + str(1 + idx) + '^2 = ' + str(n) +
        ' = ' + str(round(n ** (1 / 3))) + '^3)' if bln else (
            justifyIdx(1 + idx) + ' ->' +
            justifySqr(n)
        )
        for idx, (n, bln) in enumerate(xs)
    )


def main():
    print(
        unlines(
            squareListing(
                nonCubeSquares(30)
            )
        )
    )





def enumFromTo(m):
    return lambda n: list(range(m, 1 + n))



def justifyRight(n):
    return lambda cFiller: lambda a: (
        ((n * cFiller) + str(a))[-n:]
    )



def unlines(xs):
    return '\n'.join(xs)


main()
Task: Square but not cube
C#: using System;
using System.Collections.Generic;
using static System.Console;
using static System.Linq.Enumerable;

public static class SquareButNotCube
{
    public static void Main() {
        var squares = from i in Integers() select i * i;
        var cubes = from i in Integers() select i * i * i;

        foreach (var x in Merge().Take(33)) {
            WriteLine(x.isCube ? x.n + " (also cube)" : x.n + "");
        }
        
        IEnumerable<int> Integers() {
            for (int i = 1; ;i++) yield return i;
        }

        IEnumerable<(int n, bool isCube)> Merge() {
            using (var s = squares.GetEnumerator())
            using (var c = cubes.GetEnumerator()) {
                s.MoveNext();
                c.MoveNext();
                while (true) {
                    if (s.Current < c.Current) {
                        yield return (s.Current, false);
                        s.MoveNext();
                    } else if (s.Current == c.Current) {
                        yield return (s.Current, true);
                        s.MoveNext();
                        c.MoveNext();
                    } else {
                        c.MoveNext();
                    }
                }
            }
        }

    }
}

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

int main() {
    int n = 1;
    int count = 0;
    int sq;
    int cr;

    for (; count < 30; ++n) {
        sq = n * n;
        cr = cbrt(sq);
        if (cr * cr * cr != sq) {
            count++;
            std::cout << sq << '\n';
        } else {
            std::cout << sq << " is square and cube\n";
        }
    }

    return 0;
}
Task: Square but not cube
C++: #include <iostream>
#include <cmath>

int main() {
    int n = 1;
    int count = 0;
    int sq;
    int cr;

    for (; count < 30; ++n) {
        sq = n * n;
        cr = cbrt(sq);
        if (cr * cr * cr != sq) {
            count++;
            std::cout << sq << '\n';
        } else {
            std::cout << sq << " is square and cube\n";
        }
    }

    return 0;
}

Go: package main

import (
    "fmt"
    "math"
)

func main() {
    for n, count := 1, 0; count < 30; n++ {
        sq := n * n
        cr := int(math.Cbrt(float64(sq)))
        if cr*cr*cr != sq {
            count++
            fmt.Println(sq)
        } else {
            fmt.Println(sq, "is square and cube")
        }
    }
}
Task: Square but not cube
C++: #include <iostream>
#include <cmath>

int main() {
    int n = 1;
    int count = 0;
    int sq;
    int cr;

    for (; count < 30; ++n) {
        sq = n * n;
        cr = cbrt(sq);
        if (cr * cr * cr != sq) {
            count++;
            std::cout << sq << '\n';
        } else {
            std::cout << sq << " is square and cube\n";
        }
    }

    return 0;
}

Java: public class SquaresCubes {
    public static boolean isPerfectCube(long n) {
        long c = (long)Math.cbrt((double)n);
        return ((c * c * c) == n);
    }
    
    public static void main(String... args) {
        long n = 1;
        int squareOnlyCount = 0;
        int squareCubeCount = 0;
        while ((squareOnlyCount < 30) || (squareCubeCount < 3)) {
            long sq = n * n;
            if (isPerfectCube(sq)) {
                squareCubeCount++;
                System.out.println("Square and cube: " + sq);
            }
            else {
                squareOnlyCount++;
                System.out.println("Square: " + sq);
            }
            n++;
        }
    }
}
Task: Square but not cube
C++: #include <iostream>
#include <cmath>

int main() {
    int n = 1;
    int count = 0;
    int sq;
    int cr;

    for (; count < 30; ++n) {
        sq = n * n;
        cr = cbrt(sq);
        if (cr * cr * cr != sq) {
            count++;
            std::cout << sq << '\n';
        } else {
            std::cout << sq << " is square and cube\n";
        }
    }

    return 0;
}

Python: 
def nonCubeSquares(n):
    upto = enumFromTo(1)
    ns = upto(n)
    setCubes = set(x ** 3 for x in ns)
    ms = upto(n + len(set(x * x for x in ns).intersection(
        setCubes
    )))
    return list(tuple([x * x, x in setCubes]) for x in ms)



def squareListing(xs):
    justifyIdx = justifyRight(len(str(1 + len(xs))))(' ')
    justifySqr = justifyRight(1 + len(str(xs[-1][0])))(' ')
    return list(
        '(' + str(1 + idx) + '^2 = ' + str(n) +
        ' = ' + str(round(n ** (1 / 3))) + '^3)' if bln else (
            justifyIdx(1 + idx) + ' ->' +
            justifySqr(n)
        )
        for idx, (n, bln) in enumerate(xs)
    )


def main():
    print(
        unlines(
            squareListing(
                nonCubeSquares(30)
            )
        )
    )





def enumFromTo(m):
    return lambda n: list(range(m, 1 + n))



def justifyRight(n):
    return lambda cFiller: lambda a: (
        ((n * cFiller) + str(a))[-n:]
    )



def unlines(xs):
    return '\n'.join(xs)


main()
Task: Square but not cube
C++: #include <iostream>
#include <cmath>

int main() {
    int n = 1;
    int count = 0;
    int sq;
    int cr;

    for (; count < 30; ++n) {
        sq = n * n;
        cr = cbrt(sq);
        if (cr * cr * cr != sq) {
            count++;
            std::cout << sq << '\n';
        } else {
            std::cout << sq << " is square and cube\n";
        }
    }

    return 0;
}

VB: Module Module1

  
  
  
  

  
  Function ChkFlg(flag As Integer, ByRef mask As Integer) As Boolean
    ChkFlg = (flag And mask) = mask : mask <<= 1
  End Function

  Sub SwoC(limit As Integer)
    Dim count, square, delta, cube, d1, d2, flag, mask As Integer, s as string = ""
    count = 1 : square = 1 : delta = 1 : cube = 1 : d1 = 1 : d2 = 0
    While count <= limit
      flag = {5, 7, 2}(1 + square.CompareTo(cube))
      If flag = 7 Then s = String. Format("   {0} (also cube)", square)
      If flag = 5 Then s = String.Format("{0,-2} {1}", count, square) : count += 1
      mask = 1 : If ChkFlg(flag, mask) Then delta += 2 : square += delta
      If ChkFlg(flag, mask) Then d2 += 6 : d1 += d2 : cube += d1
      If ChkFlg(flag, mask) Then Console.WriteLine(s)
    End While
  End Sub

  Sub Main()
    SwoC(30)
  End Sub

End Module
Task: Square but not cube
C#: using System;
using System.Collections.Generic;
using static System.Console;
using static System.Linq.Enumerable;

public static class SquareButNotCube
{
    public static void Main() {
        var squares = from i in Integers() select i * i;
        var cubes = from i in Integers() select i * i * i;

        foreach (var x in Merge().Take(33)) {
            WriteLine(x.isCube ? x.n + " (also cube)" : x.n + "");
        }
        
        IEnumerable<int> Integers() {
            for (int i = 1; ;i++) yield return i;
        }

        IEnumerable<(int n, bool isCube)> Merge() {
            using (var s = squares.GetEnumerator())
            using (var c = cubes.GetEnumerator()) {
                s.MoveNext();
                c.MoveNext();
                while (true) {
                    if (s.Current < c.Current) {
                        yield return (s.Current, false);
                        s.MoveNext();
                    } else if (s.Current == c.Current) {
                        yield return (s.Current, true);
                        s.MoveNext();
                        c.MoveNext();
                    } else {
                        c.MoveNext();
                    }
                }
            }
        }

    }
}

Java: public class SquaresCubes {
    public static boolean isPerfectCube(long n) {
        long c = (long)Math.cbrt((double)n);
        return ((c * c * c) == n);
    }
    
    public static void main(String... args) {
        long n = 1;
        int squareOnlyCount = 0;
        int squareCubeCount = 0;
        while ((squareOnlyCount < 30) || (squareCubeCount < 3)) {
            long sq = n * n;
            if (isPerfectCube(sq)) {
                squareCubeCount++;
                System.out.println("Square and cube: " + sq);
            }
            else {
                squareOnlyCount++;
                System.out.println("Square: " + sq);
            }
            n++;
        }
    }
}
Task: Square but not cube
C#: using System;
using System.Collections.Generic;
using static System.Console;
using static System.Linq.Enumerable;

public static class SquareButNotCube
{
    public static void Main() {
        var squares = from i in Integers() select i * i;
        var cubes = from i in Integers() select i * i * i;

        foreach (var x in Merge().Take(33)) {
            WriteLine(x.isCube ? x.n + " (also cube)" : x.n + "");
        }
        
        IEnumerable<int> Integers() {
            for (int i = 1; ;i++) yield return i;
        }

        IEnumerable<(int n, bool isCube)> Merge() {
            using (var s = squares.GetEnumerator())
            using (var c = cubes.GetEnumerator()) {
                s.MoveNext();
                c.MoveNext();
                while (true) {
                    if (s.Current < c.Current) {
                        yield return (s.Current, false);
                        s.MoveNext();
                    } else if (s.Current == c.Current) {
                        yield return (s.Current, true);
                        s.MoveNext();
                        c.MoveNext();
                    } else {
                        c.MoveNext();
                    }
                }
            }
        }

    }
}

Python: 
def nonCubeSquares(n):
    upto = enumFromTo(1)
    ns = upto(n)
    setCubes = set(x ** 3 for x in ns)
    ms = upto(n + len(set(x * x for x in ns).intersection(
        setCubes
    )))
    return list(tuple([x * x, x in setCubes]) for x in ms)



def squareListing(xs):
    justifyIdx = justifyRight(len(str(1 + len(xs))))(' ')
    justifySqr = justifyRight(1 + len(str(xs[-1][0])))(' ')
    return list(
        '(' + str(1 + idx) + '^2 = ' + str(n) +
        ' = ' + str(round(n ** (1 / 3))) + '^3)' if bln else (
            justifyIdx(1 + idx) + ' ->' +
            justifySqr(n)
        )
        for idx, (n, bln) in enumerate(xs)
    )


def main():
    print(
        unlines(
            squareListing(
                nonCubeSquares(30)
            )
        )
    )





def enumFromTo(m):
    return lambda n: list(range(m, 1 + n))



def justifyRight(n):
    return lambda cFiller: lambda a: (
        ((n * cFiller) + str(a))[-n:]
    )



def unlines(xs):
    return '\n'.join(xs)


main()