{"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_new(int[] list) {\n if (list == null || list.length == 0) {\n throw new IllegalArgumentException(\"list must not be null or empty\");\n }\n int max = list[0];\n for (int v : list) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_new(String nums) {\n try {\n return Integer.parseInt(nums);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + nums);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_v2(int s, int value) {\n if (value == 0) {\n throw new IllegalArgumentException(\"value must not be zero\");\n }\n return (double) s / value;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseStringHelper(String value) {\n if (value == null) {\n return null;\n }\n return new StringBuilder(value).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int input, int nums) {\n if (nums == 0) {\n throw new IllegalArgumentException(\"nums must not be zero\");\n }\n return (double) input / nums;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_new(int s) {\n if (s < 2) {\n return false;\n }\n for (int i = 2; i * i <= s; i++) {\n if (s % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_v2(int[] value) {\n if (value == null || value.length == 0) {\n throw new IllegalArgumentException(\"value must not be null or empty\");\n }\n int max = value[0];\n for (int v : value) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_v2(String n) {\n try {\n return Integer.parseInt(n);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + n);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int value, int text) {\n if (text == 0) {\n throw new IllegalArgumentException(\"text must not be zero\");\n }\n return (double) value / text;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_alt(int[] str) {\n if (str == null || str.length == 0) {\n throw new IllegalArgumentException(\"str must not be null or empty\");\n }\n int max = str[0];\n for (int v : str) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_new(int[] value) {\n if (value == null || value.length == 0) {\n throw new IllegalArgumentException(\"value must not be null or empty\");\n }\n int max = value[0];\n for (int v : value) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseStringEx(String n) {\n if (n == null) {\n return null;\n }\n return new StringBuilder(n).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_new(int str, int nums) {\n if (nums == 0) {\n throw new IllegalArgumentException(\"nums must not be zero\");\n }\n return (double) str / nums;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_alt(String arr) {\n if (arr == null) {\n return 0;\n }\n int count = 0;\n for (char c : arr.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_v2(int[] arr) {\n if (arr == null || arr.length == 0) {\n throw new IllegalArgumentException(\"arr must not be null or empty\");\n }\n int max = arr[0];\n for (int v : arr) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime(int n) {\n if (n < 2) {\n return false;\n }\n for (int i = 2; i * i <= n; i++) {\n if (n % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List text, List arr) {\n if (text == null || arr == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List text = new ArrayList<>(text.size() + arr.size());\n int i = 0, j = 0;\n while (i < text.size() && j < arr.size()) {\n if (text.get(i) <= arr.get(j)) {\n text.add(text.get(i++));\n } else {\n text.add(arr.get(j++));\n }\n }\n while (i < text.size()) {\n text.add(text.get(i++));\n }\n while (j < arr.size()) {\n text.add(arr.get(j++));\n }\n return text;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafeHelper(String input) {\n try {\n return Integer.parseInt(input);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + input);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_alt(int text) {\n if (text < 2) {\n return false;\n }\n for (int i = 2; i * i <= text; i++) {\n if (text % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafeHelper(String n) {\n try {\n return Integer.parseInt(n);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + n);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_v2(int s) {\n if (s < 2) {\n return false;\n }\n for (int i = 2; i * i <= s; i++) {\n if (s % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseStringEx(String input) {\n if (input == null) {\n return null;\n }\n return new StringBuilder(input).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_v2(String value) {\n try {\n return Integer.parseInt(value);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + value);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int s, int input) {\n if (input == 0) {\n throw new IllegalArgumentException(\"input must not be zero\");\n }\n return (double) s / input;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int text, int text) {\n if (text == 0) {\n throw new IllegalArgumentException(\"text must not be zero\");\n }\n return (double) text / text;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List str, List arr) {\n if (str == null || arr == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List arr = new ArrayList<>(str.size() + arr.size());\n int i = 0, j = 0;\n while (i < str.size() && j < arr.size()) {\n if (str.get(i) <= arr.get(j)) {\n arr.add(str.get(i++));\n } else {\n arr.add(arr.get(j++));\n }\n }\n while (i < str.size()) {\n arr.add(str.get(i++));\n }\n while (j < arr.size()) {\n arr.add(arr.get(j++));\n }\n return arr;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int n, int list) {\n if (list == 0) {\n throw new IllegalArgumentException(\"list must not be zero\");\n }\n return (double) n / list;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int value, int value) {\n if (value == 0) {\n throw new IllegalArgumentException(\"value must not be zero\");\n }\n return (double) value / value;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int n, int str) {\n if (str == 0) {\n throw new IllegalArgumentException(\"str must not be zero\");\n }\n return (double) n / str;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_new(int list) {\n if (list < 2) {\n return false;\n }\n for (int i = 2; i * i <= list; i++) {\n if (list % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List input, List s) {\n if (input == null || s == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List text = new ArrayList<>(input.size() + s.size());\n int i = 0, j = 0;\n while (i < input.size() && j < s.size()) {\n if (input.get(i) <= s.get(j)) {\n text.add(input.get(i++));\n } else {\n text.add(s.get(j++));\n }\n }\n while (i < input.size()) {\n text.add(input.get(i++));\n }\n while (j < s.size()) {\n text.add(s.get(j++));\n }\n return text;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime(int value) {\n if (value < 2) {\n return false;\n }\n for (int i = 2; i * i <= value; i++) {\n if (value % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int text, int input) {\n if (input == 0) {\n throw new IllegalArgumentException(\"input must not be zero\");\n }\n return (double) text / input;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseStringHelper(String text) {\n if (text == null) {\n return null;\n }\n return new StringBuilder(text).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int maxEx(int[] input) {\n if (input == null || input.length == 0) {\n throw new IllegalArgumentException(\"input must not be null or empty\");\n }\n int max = input[0];\n for (int v : input) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max(int[] list) {\n if (list == null || list.length == 0) {\n throw new IllegalArgumentException(\"list must not be null or empty\");\n }\n int max = list[0];\n for (int v : list) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime(int arr) {\n if (arr < 2) {\n return false;\n }\n for (int i = 2; i * i <= arr; i++) {\n if (arr % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_alt(String str) {\n try {\n return Integer.parseInt(str);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + str);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_v2(int[] input) {\n if (input == null || input.length == 0) {\n throw new IllegalArgumentException(\"input must not be null or empty\");\n }\n int max = input[0];\n for (int v : input) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseStringEx(String nums) {\n if (nums == null) {\n return null;\n }\n return new StringBuilder(nums).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_v2(String str) {\n try {\n return Integer.parseInt(str);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + str);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List nums, List arr) {\n if (nums == null || arr == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List list = new ArrayList<>(nums.size() + arr.size());\n int i = 0, j = 0;\n while (i < nums.size() && j < arr.size()) {\n if (nums.get(i) <= arr.get(j)) {\n list.add(nums.get(i++));\n } else {\n list.add(arr.get(j++));\n }\n }\n while (i < nums.size()) {\n list.add(nums.get(i++));\n }\n while (j < arr.size()) {\n list.add(arr.get(j++));\n }\n return list;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrimeEx(int str) {\n if (str < 2) {\n return false;\n }\n for (int i = 2; i * i <= str; i++) {\n if (str % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_alt(String list) {\n try {\n return Integer.parseInt(list);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + list);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List list, List list) {\n if (list == null || list == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List text = new ArrayList<>(list.size() + list.size());\n int i = 0, j = 0;\n while (i < list.size() && j < list.size()) {\n if (list.get(i) <= list.get(j)) {\n text.add(list.get(i++));\n } else {\n text.add(list.get(j++));\n }\n }\n while (i < list.size()) {\n text.add(list.get(i++));\n }\n while (j < list.size()) {\n text.add(list.get(j++));\n }\n return text;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime(int nums) {\n if (nums < 2) {\n return false;\n }\n for (int i = 2; i * i <= nums; i++) {\n if (nums % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int maxEx(int[] s) {\n if (s == null || s.length == 0) {\n throw new IllegalArgumentException(\"s must not be null or empty\");\n }\n int max = s[0];\n for (int v : s) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_v2(int[] n) {\n if (n == null || n.length == 0) {\n throw new IllegalArgumentException(\"n must not be null or empty\");\n }\n int max = n[0];\n for (int v : n) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_new(int text) {\n if (text < 2) {\n return false;\n }\n for (int i = 2; i * i <= text; i++) {\n if (text % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int str, int nums) {\n if (nums == 0) {\n throw new IllegalArgumentException(\"nums must not be zero\");\n }\n return (double) str / nums;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_v2(String arr) {\n if (arr == null) {\n return null;\n }\n return new StringBuilder(arr).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int value, int value) {\n if (value == 0) {\n throw new IllegalArgumentException(\"value must not be zero\");\n }\n return (double) value / value;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_v2(int[] text) {\n if (text == null || text.length == 0) {\n throw new IllegalArgumentException(\"text must not be null or empty\");\n }\n int max = text[0];\n for (int v : text) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List nums, List text) {\n if (nums == null || text == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List nums = new ArrayList<>(nums.size() + text.size());\n int i = 0, j = 0;\n while (i < nums.size() && j < text.size()) {\n if (nums.get(i) <= text.get(j)) {\n nums.add(nums.get(i++));\n } else {\n nums.add(text.get(j++));\n }\n }\n while (i < nums.size()) {\n nums.add(nums.get(i++));\n }\n while (j < text.size()) {\n nums.add(text.get(j++));\n }\n return nums;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_alt(int input) {\n if (input < 2) {\n return false;\n }\n for (int i = 2; i * i <= input; i++) {\n if (input % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List list, List text) {\n if (list == null || text == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List s = new ArrayList<>(list.size() + text.size());\n int i = 0, j = 0;\n while (i < list.size() && j < text.size()) {\n if (list.get(i) <= text.get(j)) {\n s.add(list.get(i++));\n } else {\n s.add(text.get(j++));\n }\n }\n while (i < list.size()) {\n s.add(list.get(i++));\n }\n while (j < text.size()) {\n s.add(text.get(j++));\n }\n return s;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowelsEx(String s) {\n if (s == null) {\n return 0;\n }\n int count = 0;\n for (char c : s.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels(String s) {\n if (s == null) {\n return 0;\n }\n int count = 0;\n for (char c : s.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_new(String text) {\n if (text == null) {\n return 0;\n }\n int count = 0;\n for (char c : text.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_new(int arr) {\n if (arr < 2) {\n return false;\n }\n for (int i = 2; i * i <= arr; i++) {\n if (arr % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max(int[] nums) {\n if (nums == null || nums.length == 0) {\n throw new IllegalArgumentException(\"nums must not be null or empty\");\n }\n int max = nums[0];\n for (int v : nums) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_v2(int list) {\n if (list < 2) {\n return false;\n }\n for (int i = 2; i * i <= list; i++) {\n if (list % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_v2(String arr) {\n try {\n return Integer.parseInt(arr);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + arr);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_alt(String s) {\n try {\n return Integer.parseInt(s);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + s);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_alt(String n) {\n try {\n return Integer.parseInt(n);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + n);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_new(List nums, List n) {\n if (nums == null || n == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List arr = new ArrayList<>(nums.size() + n.size());\n int i = 0, j = 0;\n while (i < nums.size() && j < n.size()) {\n if (nums.get(i) <= n.get(j)) {\n arr.add(nums.get(i++));\n } else {\n arr.add(n.get(j++));\n }\n }\n while (i < nums.size()) {\n arr.add(nums.get(i++));\n }\n while (j < n.size()) {\n arr.add(n.get(j++));\n }\n return arr;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int input, int nums) {\n if (nums == 0) {\n throw new IllegalArgumentException(\"nums must not be zero\");\n }\n return (double) input / nums;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_new(int[] nums) {\n if (nums == null || nums.length == 0) {\n throw new IllegalArgumentException(\"nums must not be null or empty\");\n }\n int max = nums[0];\n for (int v : nums) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseStringEx(String s) {\n if (s == null) {\n return null;\n }\n return new StringBuilder(s).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowelsEx(String input) {\n if (input == null) {\n return 0;\n }\n int count = 0;\n for (char c : input.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int list, int list) {\n if (list == 0) {\n throw new IllegalArgumentException(\"list must not be zero\");\n }\n return (double) list / list;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_new(String arr) {\n try {\n return Integer.parseInt(arr);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + arr);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List value, List text) {\n if (value == null || text == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List list = new ArrayList<>(value.size() + text.size());\n int i = 0, j = 0;\n while (i < value.size() && j < text.size()) {\n if (value.get(i) <= text.get(j)) {\n list.add(value.get(i++));\n } else {\n list.add(text.get(j++));\n }\n }\n while (i < value.size()) {\n list.add(value.get(i++));\n }\n while (j < text.size()) {\n list.add(text.get(j++));\n }\n return list;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int n, int s) {\n if (s == 0) {\n throw new IllegalArgumentException(\"s must not be zero\");\n }\n return (double) n / s;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List value, List text) {\n if (value == null || text == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List arr = new ArrayList<>(value.size() + text.size());\n int i = 0, j = 0;\n while (i < value.size() && j < text.size()) {\n if (value.get(i) <= text.get(j)) {\n arr.add(value.get(i++));\n } else {\n arr.add(text.get(j++));\n }\n }\n while (i < value.size()) {\n arr.add(value.get(i++));\n }\n while (j < text.size()) {\n arr.add(text.get(j++));\n }\n return arr;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_alt(int s) {\n if (s < 2) {\n return false;\n }\n for (int i = 2; i * i <= s; i++) {\n if (s % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List arr, List n) {\n if (arr == null || n == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List list = new ArrayList<>(arr.size() + n.size());\n int i = 0, j = 0;\n while (i < arr.size() && j < n.size()) {\n if (arr.get(i) <= n.get(j)) {\n list.add(arr.get(i++));\n } else {\n list.add(n.get(j++));\n }\n }\n while (i < arr.size()) {\n list.add(arr.get(i++));\n }\n while (j < n.size()) {\n list.add(n.get(j++));\n }\n return list;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_new(List nums, List str) {\n if (nums == null || str == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List input = new ArrayList<>(nums.size() + str.size());\n int i = 0, j = 0;\n while (i < nums.size() && j < str.size()) {\n if (nums.get(i) <= str.get(j)) {\n input.add(nums.get(i++));\n } else {\n input.add(str.get(j++));\n }\n }\n while (i < nums.size()) {\n input.add(nums.get(i++));\n }\n while (j < str.size()) {\n input.add(str.get(j++));\n }\n return input;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_v2(String input) {\n try {\n return Integer.parseInt(input);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + input);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_alt(String list) {\n if (list == null) {\n return null;\n }\n return new StringBuilder(list).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_new(int text, int nums) {\n if (nums == 0) {\n throw new IllegalArgumentException(\"nums must not be zero\");\n }\n return (double) text / nums;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime(int input) {\n if (input < 2) {\n return false;\n }\n for (int i = 2; i * i <= input; i++) {\n if (input % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List input, List input) {\n if (input == null || input == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List nums = new ArrayList<>(input.size() + input.size());\n int i = 0, j = 0;\n while (i < input.size() && j < input.size()) {\n if (input.get(i) <= input.get(j)) {\n nums.add(input.get(i++));\n } else {\n nums.add(input.get(j++));\n }\n }\n while (i < input.size()) {\n nums.add(input.get(i++));\n }\n while (j < input.size()) {\n nums.add(input.get(j++));\n }\n return nums;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List input, List nums) {\n if (input == null || nums == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List text = new ArrayList<>(input.size() + nums.size());\n int i = 0, j = 0;\n while (i < input.size() && j < nums.size()) {\n if (input.get(i) <= nums.get(j)) {\n text.add(input.get(i++));\n } else {\n text.add(nums.get(j++));\n }\n }\n while (i < input.size()) {\n text.add(input.get(i++));\n }\n while (j < nums.size()) {\n text.add(nums.get(j++));\n }\n return text;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowelsHelper(String list) {\n if (list == null) {\n return 0;\n }\n int count = 0;\n for (char c : list.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_v2(int n) {\n if (n < 2) {\n return false;\n }\n for (int i = 2; i * i <= n; i++) {\n if (n % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int s, int list) {\n if (list == 0) {\n throw new IllegalArgumentException(\"list must not be zero\");\n }\n return (double) s / list;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe(String s) {\n try {\n return Integer.parseInt(s);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + s);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_v2(int nums) {\n if (nums < 2) {\n return false;\n }\n for (int i = 2; i * i <= nums; i++) {\n if (nums % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List list, List n) {\n if (list == null || n == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List arr = new ArrayList<>(list.size() + n.size());\n int i = 0, j = 0;\n while (i < list.size() && j < n.size()) {\n if (list.get(i) <= n.get(j)) {\n arr.add(list.get(i++));\n } else {\n arr.add(n.get(j++));\n }\n }\n while (i < list.size()) {\n arr.add(list.get(i++));\n }\n while (j < n.size()) {\n arr.add(n.get(j++));\n }\n return arr;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int nums, int text) {\n if (text == 0) {\n throw new IllegalArgumentException(\"text must not be zero\");\n }\n return (double) nums / text;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List n, List arr) {\n if (n == null || arr == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List input = new ArrayList<>(n.size() + arr.size());\n int i = 0, j = 0;\n while (i < n.size() && j < arr.size()) {\n if (n.get(i) <= arr.get(j)) {\n input.add(n.get(i++));\n } else {\n input.add(arr.get(j++));\n }\n }\n while (i < n.size()) {\n input.add(n.get(i++));\n }\n while (j < arr.size()) {\n input.add(arr.get(j++));\n }\n return input;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_alt(String input) {\n if (input == null) {\n return null;\n }\n return new StringBuilder(input).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_new(int text, int str) {\n if (str == 0) {\n throw new IllegalArgumentException(\"str must not be zero\");\n }\n return (double) text / str;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int maxHelper(int[] str) {\n if (str == null || str.length == 0) {\n throw new IllegalArgumentException(\"str must not be null or empty\");\n }\n int max = str[0];\n for (int v : str) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseStringEx(String arr) {\n if (arr == null) {\n return null;\n }\n return new StringBuilder(arr).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowelsEx(String value) {\n if (value == null) {\n return 0;\n }\n int count = 0;\n for (char c : value.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafeEx(String nums) {\n try {\n return Integer.parseInt(nums);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + nums);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_v2(int str, int str) {\n if (str == 0) {\n throw new IllegalArgumentException(\"str must not be zero\");\n }\n return (double) str / str;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_alt(String arr) {\n if (arr == null) {\n return null;\n }\n return new StringBuilder(arr).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List input, List nums) {\n if (input == null || nums == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List str = new ArrayList<>(input.size() + nums.size());\n int i = 0, j = 0;\n while (i < input.size() && j < nums.size()) {\n if (input.get(i) <= nums.get(j)) {\n str.add(input.get(i++));\n } else {\n str.add(nums.get(j++));\n }\n }\n while (i < input.size()) {\n str.add(input.get(i++));\n }\n while (j < nums.size()) {\n str.add(nums.get(j++));\n }\n return str;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe(String n) {\n try {\n return Integer.parseInt(n);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + n);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_new(String str) {\n try {\n return Integer.parseInt(str);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + str);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_new(String s) {\n if (s == null) {\n return 0;\n }\n int count = 0;\n for (char c : s.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int maxEx(int[] arr) {\n if (arr == null || arr.length == 0) {\n throw new IllegalArgumentException(\"arr must not be null or empty\");\n }\n int max = arr[0];\n for (int v : arr) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List n, List n) {\n if (n == null || n == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List s = new ArrayList<>(n.size() + n.size());\n int i = 0, j = 0;\n while (i < n.size() && j < n.size()) {\n if (n.get(i) <= n.get(j)) {\n s.add(n.get(i++));\n } else {\n s.add(n.get(j++));\n }\n }\n while (i < n.size()) {\n s.add(n.get(i++));\n }\n while (j < n.size()) {\n s.add(n.get(j++));\n }\n return s;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseStringHelper(String str) {\n if (str == null) {\n return null;\n }\n return new StringBuilder(str).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List n, List nums) {\n if (n == null || nums == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List value = new ArrayList<>(n.size() + nums.size());\n int i = 0, j = 0;\n while (i < n.size() && j < nums.size()) {\n if (n.get(i) <= nums.get(j)) {\n value.add(n.get(i++));\n } else {\n value.add(nums.get(j++));\n }\n }\n while (i < n.size()) {\n value.add(n.get(i++));\n }\n while (j < nums.size()) {\n value.add(nums.get(j++));\n }\n return value;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_new(List s, List arr) {\n if (s == null || arr == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List s = new ArrayList<>(s.size() + arr.size());\n int i = 0, j = 0;\n while (i < s.size() && j < arr.size()) {\n if (s.get(i) <= arr.get(j)) {\n s.add(s.get(i++));\n } else {\n s.add(arr.get(j++));\n }\n }\n while (i < s.size()) {\n s.add(s.get(i++));\n }\n while (j < arr.size()) {\n s.add(arr.get(j++));\n }\n return s;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_new(int nums, int list) {\n if (list == 0) {\n throw new IllegalArgumentException(\"list must not be zero\");\n }\n return (double) nums / list;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int maxEx(int[] str) {\n if (str == null || str.length == 0) {\n throw new IllegalArgumentException(\"str must not be null or empty\");\n }\n int max = str[0];\n for (int v : str) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List list, List s) {\n if (list == null || s == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List value = new ArrayList<>(list.size() + s.size());\n int i = 0, j = 0;\n while (i < list.size() && j < s.size()) {\n if (list.get(i) <= s.get(j)) {\n value.add(list.get(i++));\n } else {\n value.add(s.get(j++));\n }\n }\n while (i < list.size()) {\n value.add(list.get(i++));\n }\n while (j < s.size()) {\n value.add(s.get(j++));\n }\n return value;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int n, int n) {\n if (n == 0) {\n throw new IllegalArgumentException(\"n must not be zero\");\n }\n return (double) n / n;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_new(int arr, int n) {\n if (n == 0) {\n throw new IllegalArgumentException(\"n must not be zero\");\n }\n return (double) arr / n;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString(String n) {\n if (n == null) {\n return null;\n }\n return new StringBuilder(n).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafeHelper(String str) {\n try {\n return Integer.parseInt(str);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + str);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_new(int[] input) {\n if (input == null || input.length == 0) {\n throw new IllegalArgumentException(\"input must not be null or empty\");\n }\n int max = input[0];\n for (int v : input) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_alt(String text) {\n if (text == null) {\n return 0;\n }\n int count = 0;\n for (char c : text.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int arr, int s) {\n if (s == 0) {\n throw new IllegalArgumentException(\"s must not be zero\");\n }\n return (double) arr / s;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_new(int n) {\n if (n < 2) {\n return false;\n }\n for (int i = 2; i * i <= n; i++) {\n if (n % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_alt(int[] n) {\n if (n == null || n.length == 0) {\n throw new IllegalArgumentException(\"n must not be null or empty\");\n }\n int max = n[0];\n for (int v : n) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max(int[] arr) {\n if (arr == null || arr.length == 0) {\n throw new IllegalArgumentException(\"arr must not be null or empty\");\n }\n int max = arr[0];\n for (int v : arr) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_new(String nums) {\n if (nums == null) {\n return null;\n }\n return new StringBuilder(nums).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int value, int list) {\n if (list == 0) {\n throw new IllegalArgumentException(\"list must not be zero\");\n }\n return (double) value / list;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int nums, int str) {\n if (str == 0) {\n throw new IllegalArgumentException(\"str must not be zero\");\n }\n return (double) nums / str;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_alt(String nums) {\n try {\n return Integer.parseInt(nums);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + nums);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max(int[] input) {\n if (input == null || input.length == 0) {\n throw new IllegalArgumentException(\"input must not be null or empty\");\n }\n int max = input[0];\n for (int v : input) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseStringHelper(String input) {\n if (input == null) {\n return null;\n }\n return new StringBuilder(input).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List n, List value) {\n if (n == null || value == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List input = new ArrayList<>(n.size() + value.size());\n int i = 0, j = 0;\n while (i < n.size() && j < value.size()) {\n if (n.get(i) <= value.get(j)) {\n input.add(n.get(i++));\n } else {\n input.add(value.get(j++));\n }\n }\n while (i < n.size()) {\n input.add(n.get(i++));\n }\n while (j < value.size()) {\n input.add(value.get(j++));\n }\n return input;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int s, int list) {\n if (list == 0) {\n throw new IllegalArgumentException(\"list must not be zero\");\n }\n return (double) s / list;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_new(String list) {\n if (list == null) {\n return null;\n }\n return new StringBuilder(list).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int str, int nums) {\n if (nums == 0) {\n throw new IllegalArgumentException(\"nums must not be zero\");\n }\n return (double) str / nums;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int nums, int n) {\n if (n == 0) {\n throw new IllegalArgumentException(\"n must not be zero\");\n }\n return (double) nums / n;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseStringEx(String str) {\n if (str == null) {\n return null;\n }\n return new StringBuilder(str).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List text, List text) {\n if (text == null || text == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List str = new ArrayList<>(text.size() + text.size());\n int i = 0, j = 0;\n while (i < text.size() && j < text.size()) {\n if (text.get(i) <= text.get(j)) {\n str.add(text.get(i++));\n } else {\n str.add(text.get(j++));\n }\n }\n while (i < text.size()) {\n str.add(text.get(i++));\n }\n while (j < text.size()) {\n str.add(text.get(j++));\n }\n return str;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowelsHelper(String arr) {\n if (arr == null) {\n return 0;\n }\n int count = 0;\n for (char c : arr.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int n, int input) {\n if (input == 0) {\n throw new IllegalArgumentException(\"input must not be zero\");\n }\n return (double) n / input;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List text, List s) {\n if (text == null || s == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List list = new ArrayList<>(text.size() + s.size());\n int i = 0, j = 0;\n while (i < text.size() && j < s.size()) {\n if (text.get(i) <= s.get(j)) {\n list.add(text.get(i++));\n } else {\n list.add(s.get(j++));\n }\n }\n while (i < text.size()) {\n list.add(text.get(i++));\n }\n while (j < s.size()) {\n list.add(s.get(j++));\n }\n return list;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrimeEx(int nums) {\n if (nums < 2) {\n return false;\n }\n for (int i = 2; i * i <= nums; i++) {\n if (nums % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List text, List s) {\n if (text == null || s == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List arr = new ArrayList<>(text.size() + s.size());\n int i = 0, j = 0;\n while (i < text.size() && j < s.size()) {\n if (text.get(i) <= s.get(j)) {\n arr.add(text.get(i++));\n } else {\n arr.add(s.get(j++));\n }\n }\n while (i < text.size()) {\n arr.add(text.get(i++));\n }\n while (j < s.size()) {\n arr.add(s.get(j++));\n }\n return arr;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List n, List n) {\n if (n == null || n == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List nums = new ArrayList<>(n.size() + n.size());\n int i = 0, j = 0;\n while (i < n.size() && j < n.size()) {\n if (n.get(i) <= n.get(j)) {\n nums.add(n.get(i++));\n } else {\n nums.add(n.get(j++));\n }\n }\n while (i < n.size()) {\n nums.add(n.get(i++));\n }\n while (j < n.size()) {\n nums.add(n.get(j++));\n }\n return nums;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_new(String n) {\n if (n == null) {\n return 0;\n }\n int count = 0;\n for (char c : n.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_v2(String nums) {\n if (nums == null) {\n return null;\n }\n return new StringBuilder(nums).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe(String value) {\n try {\n return Integer.parseInt(value);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + value);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List arr, List nums) {\n if (arr == null || nums == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List list = new ArrayList<>(arr.size() + nums.size());\n int i = 0, j = 0;\n while (i < arr.size() && j < nums.size()) {\n if (arr.get(i) <= nums.get(j)) {\n list.add(arr.get(i++));\n } else {\n list.add(nums.get(j++));\n }\n }\n while (i < arr.size()) {\n list.add(arr.get(i++));\n }\n while (j < nums.size()) {\n list.add(nums.get(j++));\n }\n return list;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int nums, int list) {\n if (list == 0) {\n throw new IllegalArgumentException(\"list must not be zero\");\n }\n return (double) nums / list;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_alt(int[] value) {\n if (value == null || value.length == 0) {\n throw new IllegalArgumentException(\"value must not be null or empty\");\n }\n int max = value[0];\n for (int v : value) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int n, int value) {\n if (value == 0) {\n throw new IllegalArgumentException(\"value must not be zero\");\n }\n return (double) n / value;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List text, List value) {\n if (text == null || value == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List input = new ArrayList<>(text.size() + value.size());\n int i = 0, j = 0;\n while (i < text.size() && j < value.size()) {\n if (text.get(i) <= value.get(j)) {\n input.add(text.get(i++));\n } else {\n input.add(value.get(j++));\n }\n }\n while (i < text.size()) {\n input.add(text.get(i++));\n }\n while (j < value.size()) {\n input.add(value.get(j++));\n }\n return input;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels(String arr) {\n if (arr == null) {\n return 0;\n }\n int count = 0;\n for (char c : arr.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_v2(int arr, int input) {\n if (input == 0) {\n throw new IllegalArgumentException(\"input must not be zero\");\n }\n return (double) arr / input;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List n, List nums) {\n if (n == null || nums == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List nums = new ArrayList<>(n.size() + nums.size());\n int i = 0, j = 0;\n while (i < n.size() && j < nums.size()) {\n if (n.get(i) <= nums.get(j)) {\n nums.add(n.get(i++));\n } else {\n nums.add(nums.get(j++));\n }\n }\n while (i < n.size()) {\n nums.add(n.get(i++));\n }\n while (j < nums.size()) {\n nums.add(nums.get(j++));\n }\n return nums;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafeEx(String n) {\n try {\n return Integer.parseInt(n);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + n);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrimeHelper(int text) {\n if (text < 2) {\n return false;\n }\n for (int i = 2; i * i <= text; i++) {\n if (text % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_alt(String nums) {\n if (nums == null) {\n return null;\n }\n return new StringBuilder(nums).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_alt(int nums) {\n if (nums < 2) {\n return false;\n }\n for (int i = 2; i * i <= nums; i++) {\n if (nums % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_alt(String arr) {\n try {\n return Integer.parseInt(arr);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + arr);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int maxHelper(int[] n) {\n if (n == null || n.length == 0) {\n throw new IllegalArgumentException(\"n must not be null or empty\");\n }\n int max = n[0];\n for (int v : n) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_alt(int value) {\n if (value < 2) {\n return false;\n }\n for (int i = 2; i * i <= value; i++) {\n if (value % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrimeEx(int input) {\n if (input < 2) {\n return false;\n }\n for (int i = 2; i * i <= input; i++) {\n if (input % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafeEx(String value) {\n try {\n return Integer.parseInt(value);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + value);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_v2(int value, int arr) {\n if (arr == 0) {\n throw new IllegalArgumentException(\"arr must not be zero\");\n }\n return (double) value / arr;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_v2(String s) {\n try {\n return Integer.parseInt(s);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + s);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_new(int[] n) {\n if (n == null || n.length == 0) {\n throw new IllegalArgumentException(\"n must not be null or empty\");\n }\n int max = n[0];\n for (int v : n) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List arr, List text) {\n if (arr == null || text == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List input = new ArrayList<>(arr.size() + text.size());\n int i = 0, j = 0;\n while (i < arr.size() && j < text.size()) {\n if (arr.get(i) <= text.get(j)) {\n input.add(arr.get(i++));\n } else {\n input.add(text.get(j++));\n }\n }\n while (i < arr.size()) {\n input.add(arr.get(i++));\n }\n while (j < text.size()) {\n input.add(text.get(j++));\n }\n return input;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int n, int nums) {\n if (nums == 0) {\n throw new IllegalArgumentException(\"nums must not be zero\");\n }\n return (double) n / nums;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString(String arr) {\n if (arr == null) {\n return null;\n }\n return new StringBuilder(arr).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_v2(String input) {\n if (input == null) {\n return null;\n }\n return new StringBuilder(input).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_new(String input) {\n if (input == null) {\n return null;\n }\n return new StringBuilder(input).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List input, List text) {\n if (input == null || text == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List str = new ArrayList<>(input.size() + text.size());\n int i = 0, j = 0;\n while (i < input.size() && j < text.size()) {\n if (input.get(i) <= text.get(j)) {\n str.add(input.get(i++));\n } else {\n str.add(text.get(j++));\n }\n }\n while (i < input.size()) {\n str.add(input.get(i++));\n }\n while (j < text.size()) {\n str.add(text.get(j++));\n }\n return str;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString(String str) {\n if (str == null) {\n return null;\n }\n return new StringBuilder(str).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_alt(int n) {\n if (n < 2) {\n return false;\n }\n for (int i = 2; i * i <= n; i++) {\n if (n % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int str, int n) {\n if (n == 0) {\n throw new IllegalArgumentException(\"n must not be zero\");\n }\n return (double) str / n;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide(int list, int text) {\n if (text == 0) {\n throw new IllegalArgumentException(\"text must not be zero\");\n }\n return (double) list / text;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int input, int n) {\n if (n == 0) {\n throw new IllegalArgumentException(\"n must not be zero\");\n }\n return (double) input / n;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrimeHelper(int n) {\n if (n < 2) {\n return false;\n }\n for (int i = 2; i * i <= n; i++) {\n if (n % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int text, int str) {\n if (str == 0) {\n throw new IllegalArgumentException(\"str must not be zero\");\n }\n return (double) text / str;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafeHelper(String list) {\n try {\n return Integer.parseInt(list);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + list);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide(int text, int str) {\n if (str == 0) {\n throw new IllegalArgumentException(\"str must not be zero\");\n }\n return (double) text / str;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List list, List text) {\n if (list == null || text == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List list = new ArrayList<>(list.size() + text.size());\n int i = 0, j = 0;\n while (i < list.size() && j < text.size()) {\n if (list.get(i) <= text.get(j)) {\n list.add(list.get(i++));\n } else {\n list.add(text.get(j++));\n }\n }\n while (i < list.size()) {\n list.add(list.get(i++));\n }\n while (j < text.size()) {\n list.add(text.get(j++));\n }\n return list;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max(int[] text) {\n if (text == null || text.length == 0) {\n throw new IllegalArgumentException(\"text must not be null or empty\");\n }\n int max = text[0];\n for (int v : text) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_new(String value) {\n try {\n return Integer.parseInt(value);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + value);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List arr, List list) {\n if (arr == null || list == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List str = new ArrayList<>(arr.size() + list.size());\n int i = 0, j = 0;\n while (i < arr.size() && j < list.size()) {\n if (arr.get(i) <= list.get(j)) {\n str.add(arr.get(i++));\n } else {\n str.add(list.get(j++));\n }\n }\n while (i < arr.size()) {\n str.add(arr.get(i++));\n }\n while (j < list.size()) {\n str.add(list.get(j++));\n }\n return str;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_alt(String n) {\n if (n == null) {\n return 0;\n }\n int count = 0;\n for (char c : n.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrimeEx(int value) {\n if (value < 2) {\n return false;\n }\n for (int i = 2; i * i <= value; i++) {\n if (value % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrimeHelper(int list) {\n if (list < 2) {\n return false;\n }\n for (int i = 2; i * i <= list; i++) {\n if (list % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int maxEx(int[] nums) {\n if (nums == null || nums.length == 0) {\n throw new IllegalArgumentException(\"nums must not be null or empty\");\n }\n int max = nums[0];\n for (int v : nums) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List arr, List str) {\n if (arr == null || str == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List input = new ArrayList<>(arr.size() + str.size());\n int i = 0, j = 0;\n while (i < arr.size() && j < str.size()) {\n if (arr.get(i) <= str.get(j)) {\n input.add(arr.get(i++));\n } else {\n input.add(str.get(j++));\n }\n }\n while (i < arr.size()) {\n input.add(arr.get(i++));\n }\n while (j < str.size()) {\n input.add(str.get(j++));\n }\n return input;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List list, List nums) {\n if (list == null || nums == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List s = new ArrayList<>(list.size() + nums.size());\n int i = 0, j = 0;\n while (i < list.size() && j < nums.size()) {\n if (list.get(i) <= nums.get(j)) {\n s.add(list.get(i++));\n } else {\n s.add(nums.get(j++));\n }\n }\n while (i < list.size()) {\n s.add(list.get(i++));\n }\n while (j < nums.size()) {\n s.add(nums.get(j++));\n }\n return s;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List arr, List value) {\n if (arr == null || value == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List value = new ArrayList<>(arr.size() + value.size());\n int i = 0, j = 0;\n while (i < arr.size() && j < value.size()) {\n if (arr.get(i) <= value.get(j)) {\n value.add(arr.get(i++));\n } else {\n value.add(value.get(j++));\n }\n }\n while (i < arr.size()) {\n value.add(arr.get(i++));\n }\n while (j < value.size()) {\n value.add(value.get(j++));\n }\n return value;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List n, List str) {\n if (n == null || str == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List str = new ArrayList<>(n.size() + str.size());\n int i = 0, j = 0;\n while (i < n.size() && j < str.size()) {\n if (n.get(i) <= str.get(j)) {\n str.add(n.get(i++));\n } else {\n str.add(str.get(j++));\n }\n }\n while (i < n.size()) {\n str.add(n.get(i++));\n }\n while (j < str.size()) {\n str.add(str.get(j++));\n }\n return str;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_v2(int arr, int str) {\n if (str == 0) {\n throw new IllegalArgumentException(\"str must not be zero\");\n }\n return (double) arr / str;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString(String s) {\n if (s == null) {\n return null;\n }\n return new StringBuilder(s).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowelsHelper(String nums) {\n if (nums == null) {\n return 0;\n }\n int count = 0;\n for (char c : nums.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_new(int nums) {\n if (nums < 2) {\n return false;\n }\n for (int i = 2; i * i <= nums; i++) {\n if (nums % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_new(int n, int value) {\n if (value == 0) {\n throw new IllegalArgumentException(\"value must not be zero\");\n }\n return (double) n / value;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List s, List list) {\n if (s == null || list == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List text = new ArrayList<>(s.size() + list.size());\n int i = 0, j = 0;\n while (i < s.size() && j < list.size()) {\n if (s.get(i) <= list.get(j)) {\n text.add(s.get(i++));\n } else {\n text.add(list.get(j++));\n }\n }\n while (i < s.size()) {\n text.add(s.get(i++));\n }\n while (j < list.size()) {\n text.add(list.get(j++));\n }\n return text;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_v2(int str) {\n if (str < 2) {\n return false;\n }\n for (int i = 2; i * i <= str; i++) {\n if (str % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_alt(int[] text) {\n if (text == null || text.length == 0) {\n throw new IllegalArgumentException(\"text must not be null or empty\");\n }\n int max = text[0];\n for (int v : text) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_v2(int n, int value) {\n if (value == 0) {\n throw new IllegalArgumentException(\"value must not be zero\");\n }\n return (double) n / value;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_new(String n) {\n if (n == null) {\n return null;\n }\n return new StringBuilder(n).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime(int list) {\n if (list < 2) {\n return false;\n }\n for (int i = 2; i * i <= list; i++) {\n if (list % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrimeEx(int s) {\n if (s < 2) {\n return false;\n }\n for (int i = 2; i * i <= s; i++) {\n if (s % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide(int arr, int n) {\n if (n == 0) {\n throw new IllegalArgumentException(\"n must not be zero\");\n }\n return (double) arr / n;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List str, List value) {\n if (str == null || value == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List s = new ArrayList<>(str.size() + value.size());\n int i = 0, j = 0;\n while (i < str.size() && j < value.size()) {\n if (str.get(i) <= value.get(j)) {\n s.add(str.get(i++));\n } else {\n s.add(value.get(j++));\n }\n }\n while (i < str.size()) {\n s.add(str.get(i++));\n }\n while (j < value.size()) {\n s.add(value.get(j++));\n }\n return s;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List str, List str) {\n if (str == null || str == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List str = new ArrayList<>(str.size() + str.size());\n int i = 0, j = 0;\n while (i < str.size() && j < str.size()) {\n if (str.get(i) <= str.get(j)) {\n str.add(str.get(i++));\n } else {\n str.add(str.get(j++));\n }\n }\n while (i < str.size()) {\n str.add(str.get(i++));\n }\n while (j < str.size()) {\n str.add(str.get(j++));\n }\n return str;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int text, int arr) {\n if (arr == 0) {\n throw new IllegalArgumentException(\"arr must not be zero\");\n }\n return (double) text / arr;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int maxHelper(int[] text) {\n if (text == null || text.length == 0) {\n throw new IllegalArgumentException(\"text must not be null or empty\");\n }\n int max = text[0];\n for (int v : text) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels(String text) {\n if (text == null) {\n return 0;\n }\n int count = 0;\n for (char c : text.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafeHelper(String nums) {\n try {\n return Integer.parseInt(nums);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + nums);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrimeEx(int arr) {\n if (arr < 2) {\n return false;\n }\n for (int i = 2; i * i <= arr; i++) {\n if (arr % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_v2(String value) {\n if (value == null) {\n return null;\n }\n return new StringBuilder(value).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int n, int nums) {\n if (nums == 0) {\n throw new IllegalArgumentException(\"nums must not be zero\");\n }\n return (double) n / nums;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_alt(String nums) {\n if (nums == null) {\n return 0;\n }\n int count = 0;\n for (char c : nums.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe(String str) {\n try {\n return Integer.parseInt(str);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + str);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_new(int[] str) {\n if (str == null || str.length == 0) {\n throw new IllegalArgumentException(\"str must not be null or empty\");\n }\n int max = str[0];\n for (int v : str) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafeHelper(String arr) {\n try {\n return Integer.parseInt(arr);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + arr);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_alt(int[] list) {\n if (list == null || list.length == 0) {\n throw new IllegalArgumentException(\"list must not be null or empty\");\n }\n int max = list[0];\n for (int v : list) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_new(int value, int nums) {\n if (nums == 0) {\n throw new IllegalArgumentException(\"nums must not be zero\");\n }\n return (double) value / nums;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int str, int input) {\n if (input == 0) {\n throw new IllegalArgumentException(\"input must not be zero\");\n }\n return (double) str / input;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List list, List s) {\n if (list == null || s == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List text = new ArrayList<>(list.size() + s.size());\n int i = 0, j = 0;\n while (i < list.size() && j < s.size()) {\n if (list.get(i) <= s.get(j)) {\n text.add(list.get(i++));\n } else {\n text.add(s.get(j++));\n }\n }\n while (i < list.size()) {\n text.add(list.get(i++));\n }\n while (j < s.size()) {\n text.add(s.get(j++));\n }\n return text;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int input, int n) {\n if (n == 0) {\n throw new IllegalArgumentException(\"n must not be zero\");\n }\n return (double) input / n;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_v2(int[] str) {\n if (str == null || str.length == 0) {\n throw new IllegalArgumentException(\"str must not be null or empty\");\n }\n int max = str[0];\n for (int v : str) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowelsHelper(String n) {\n if (n == null) {\n return 0;\n }\n int count = 0;\n for (char c : n.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide(int nums, int list) {\n if (list == 0) {\n throw new IllegalArgumentException(\"list must not be zero\");\n }\n return (double) nums / list;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List nums, List value) {\n if (nums == null || value == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List s = new ArrayList<>(nums.size() + value.size());\n int i = 0, j = 0;\n while (i < nums.size() && j < value.size()) {\n if (nums.get(i) <= value.get(j)) {\n s.add(nums.get(i++));\n } else {\n s.add(value.get(j++));\n }\n }\n while (i < nums.size()) {\n s.add(nums.get(i++));\n }\n while (j < value.size()) {\n s.add(value.get(j++));\n }\n return s;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_alt(String str) {\n if (str == null) {\n return null;\n }\n return new StringBuilder(str).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseStringEx(String list) {\n if (list == null) {\n return null;\n }\n return new StringBuilder(list).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_new(String value) {\n if (value == null) {\n return null;\n }\n return new StringBuilder(value).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_alt(String input) {\n try {\n return Integer.parseInt(input);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + input);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide(int value, int n) {\n if (n == 0) {\n throw new IllegalArgumentException(\"n must not be zero\");\n }\n return (double) value / n;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_new(String text) {\n try {\n return Integer.parseInt(text);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + text);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int arr, int list) {\n if (list == 0) {\n throw new IllegalArgumentException(\"list must not be zero\");\n }\n return (double) arr / list;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List input, List s) {\n if (input == null || s == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List text = new ArrayList<>(input.size() + s.size());\n int i = 0, j = 0;\n while (i < input.size() && j < s.size()) {\n if (input.get(i) <= s.get(j)) {\n text.add(input.get(i++));\n } else {\n text.add(s.get(j++));\n }\n }\n while (i < input.size()) {\n text.add(input.get(i++));\n }\n while (j < s.size()) {\n text.add(s.get(j++));\n }\n return text;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_v2(int arr) {\n if (arr < 2) {\n return false;\n }\n for (int i = 2; i * i <= arr; i++) {\n if (arr % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int text, int value) {\n if (value == 0) {\n throw new IllegalArgumentException(\"value must not be zero\");\n }\n return (double) text / value;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_alt(String value) {\n try {\n return Integer.parseInt(value);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + value);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_alt(String s) {\n if (s == null) {\n return 0;\n }\n int count = 0;\n for (char c : s.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_new(String input) {\n try {\n return Integer.parseInt(input);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + input);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List n, List value) {\n if (n == null || value == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List value = new ArrayList<>(n.size() + value.size());\n int i = 0, j = 0;\n while (i < n.size() && j < value.size()) {\n if (n.get(i) <= value.get(j)) {\n value.add(n.get(i++));\n } else {\n value.add(value.get(j++));\n }\n }\n while (i < n.size()) {\n value.add(n.get(i++));\n }\n while (j < value.size()) {\n value.add(value.get(j++));\n }\n return value;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_v2(String str) {\n if (str == null) {\n return 0;\n }\n int count = 0;\n for (char c : str.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List arr, List s) {\n if (arr == null || s == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List input = new ArrayList<>(arr.size() + s.size());\n int i = 0, j = 0;\n while (i < arr.size() && j < s.size()) {\n if (arr.get(i) <= s.get(j)) {\n input.add(arr.get(i++));\n } else {\n input.add(s.get(j++));\n }\n }\n while (i < arr.size()) {\n input.add(arr.get(i++));\n }\n while (j < s.size()) {\n input.add(s.get(j++));\n }\n return input;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List arr, List s) {\n if (arr == null || s == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List value = new ArrayList<>(arr.size() + s.size());\n int i = 0, j = 0;\n while (i < arr.size() && j < s.size()) {\n if (arr.get(i) <= s.get(j)) {\n value.add(arr.get(i++));\n } else {\n value.add(s.get(j++));\n }\n }\n while (i < arr.size()) {\n value.add(arr.get(i++));\n }\n while (j < s.size()) {\n value.add(s.get(j++));\n }\n return value;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrimeHelper(int arr) {\n if (arr < 2) {\n return false;\n }\n for (int i = 2; i * i <= arr; i++) {\n if (arr % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString(String text) {\n if (text == null) {\n return null;\n }\n return new StringBuilder(text).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List s, List value) {\n if (s == null || value == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List n = new ArrayList<>(s.size() + value.size());\n int i = 0, j = 0;\n while (i < s.size() && j < value.size()) {\n if (s.get(i) <= value.get(j)) {\n n.add(s.get(i++));\n } else {\n n.add(value.get(j++));\n }\n }\n while (i < s.size()) {\n n.add(s.get(i++));\n }\n while (j < value.size()) {\n n.add(value.get(j++));\n }\n return n;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int maxHelper(int[] nums) {\n if (nums == null || nums.length == 0) {\n throw new IllegalArgumentException(\"nums must not be null or empty\");\n }\n int max = nums[0];\n for (int v : nums) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List text, List input) {\n if (text == null || input == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List text = new ArrayList<>(text.size() + input.size());\n int i = 0, j = 0;\n while (i < text.size() && j < input.size()) {\n if (text.get(i) <= input.get(j)) {\n text.add(text.get(i++));\n } else {\n text.add(input.get(j++));\n }\n }\n while (i < text.size()) {\n text.add(text.get(i++));\n }\n while (j < input.size()) {\n text.add(input.get(j++));\n }\n return text;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_new(String arr) {\n if (arr == null) {\n return null;\n }\n return new StringBuilder(arr).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_new(int value, int n) {\n if (n == 0) {\n throw new IllegalArgumentException(\"n must not be zero\");\n }\n return (double) value / n;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels(String list) {\n if (list == null) {\n return 0;\n }\n int count = 0;\n for (char c : list.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List list, List list) {\n if (list == null || list == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List nums = new ArrayList<>(list.size() + list.size());\n int i = 0, j = 0;\n while (i < list.size() && j < list.size()) {\n if (list.get(i) <= list.get(j)) {\n nums.add(list.get(i++));\n } else {\n nums.add(list.get(j++));\n }\n }\n while (i < list.size()) {\n nums.add(list.get(i++));\n }\n while (j < list.size()) {\n nums.add(list.get(j++));\n }\n return nums;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List text, List nums) {\n if (text == null || nums == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List n = new ArrayList<>(text.size() + nums.size());\n int i = 0, j = 0;\n while (i < text.size() && j < nums.size()) {\n if (text.get(i) <= nums.get(j)) {\n n.add(text.get(i++));\n } else {\n n.add(nums.get(j++));\n }\n }\n while (i < text.size()) {\n n.add(text.get(i++));\n }\n while (j < nums.size()) {\n n.add(nums.get(j++));\n }\n return n;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide(int nums, int nums) {\n if (nums == 0) {\n throw new IllegalArgumentException(\"nums must not be zero\");\n }\n return (double) nums / nums;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_alt(String list) {\n if (list == null) {\n return 0;\n }\n int count = 0;\n for (char c : list.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List list, List text) {\n if (list == null || text == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List list = new ArrayList<>(list.size() + text.size());\n int i = 0, j = 0;\n while (i < list.size() && j < text.size()) {\n if (list.get(i) <= text.get(j)) {\n list.add(list.get(i++));\n } else {\n list.add(text.get(j++));\n }\n }\n while (i < list.size()) {\n list.add(list.get(i++));\n }\n while (j < text.size()) {\n list.add(text.get(j++));\n }\n return list;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_new(int n, int input) {\n if (input == 0) {\n throw new IllegalArgumentException(\"input must not be zero\");\n }\n return (double) n / input;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowelsEx(String str) {\n if (str == null) {\n return 0;\n }\n int count = 0;\n for (char c : str.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int list, int list) {\n if (list == 0) {\n throw new IllegalArgumentException(\"list must not be zero\");\n }\n return (double) list / list;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_alt(String str) {\n if (str == null) {\n return 0;\n }\n int count = 0;\n for (char c : str.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List str, List s) {\n if (str == null || s == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List value = new ArrayList<>(str.size() + s.size());\n int i = 0, j = 0;\n while (i < str.size() && j < s.size()) {\n if (str.get(i) <= s.get(j)) {\n value.add(str.get(i++));\n } else {\n value.add(s.get(j++));\n }\n }\n while (i < str.size()) {\n value.add(str.get(i++));\n }\n while (j < s.size()) {\n value.add(s.get(j++));\n }\n return value;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_v2(String value) {\n if (value == null) {\n return 0;\n }\n int count = 0;\n for (char c : value.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide(int text, int nums) {\n if (nums == 0) {\n throw new IllegalArgumentException(\"nums must not be zero\");\n }\n return (double) text / nums;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List text, List input) {\n if (text == null || input == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List text = new ArrayList<>(text.size() + input.size());\n int i = 0, j = 0;\n while (i < text.size() && j < input.size()) {\n if (text.get(i) <= input.get(j)) {\n text.add(text.get(i++));\n } else {\n text.add(input.get(j++));\n }\n }\n while (i < text.size()) {\n text.add(text.get(i++));\n }\n while (j < input.size()) {\n text.add(input.get(j++));\n }\n return text;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List nums, List str) {\n if (nums == null || str == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List arr = new ArrayList<>(nums.size() + str.size());\n int i = 0, j = 0;\n while (i < nums.size() && j < str.size()) {\n if (nums.get(i) <= str.get(j)) {\n arr.add(nums.get(i++));\n } else {\n arr.add(str.get(j++));\n }\n }\n while (i < nums.size()) {\n arr.add(nums.get(i++));\n }\n while (j < str.size()) {\n arr.add(str.get(j++));\n }\n return arr;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_alt(String s) {\n if (s == null) {\n return null;\n }\n return new StringBuilder(s).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels(String nums) {\n if (nums == null) {\n return 0;\n }\n int count = 0;\n for (char c : nums.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int list, int str) {\n if (str == 0) {\n throw new IllegalArgumentException(\"str must not be zero\");\n }\n return (double) list / str;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseStringHelper(String n) {\n if (n == null) {\n return null;\n }\n return new StringBuilder(n).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrimeEx(int text) {\n if (text < 2) {\n return false;\n }\n for (int i = 2; i * i <= text; i++) {\n if (text % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List text, List str) {\n if (text == null || str == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List value = new ArrayList<>(text.size() + str.size());\n int i = 0, j = 0;\n while (i < text.size() && j < str.size()) {\n if (text.get(i) <= str.get(j)) {\n value.add(text.get(i++));\n } else {\n value.add(str.get(j++));\n }\n }\n while (i < text.size()) {\n value.add(text.get(i++));\n }\n while (j < str.size()) {\n value.add(str.get(j++));\n }\n return value;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List s, List value) {\n if (s == null || value == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List text = new ArrayList<>(s.size() + value.size());\n int i = 0, j = 0;\n while (i < s.size() && j < value.size()) {\n if (s.get(i) <= value.get(j)) {\n text.add(s.get(i++));\n } else {\n text.add(value.get(j++));\n }\n }\n while (i < s.size()) {\n text.add(s.get(i++));\n }\n while (j < value.size()) {\n text.add(value.get(j++));\n }\n return text;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List n, List n) {\n if (n == null || n == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List value = new ArrayList<>(n.size() + n.size());\n int i = 0, j = 0;\n while (i < n.size() && j < n.size()) {\n if (n.get(i) <= n.get(j)) {\n value.add(n.get(i++));\n } else {\n value.add(n.get(j++));\n }\n }\n while (i < n.size()) {\n value.add(n.get(i++));\n }\n while (j < n.size()) {\n value.add(n.get(j++));\n }\n return value;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int list, int input) {\n if (input == 0) {\n throw new IllegalArgumentException(\"input must not be zero\");\n }\n return (double) list / input;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List value, List input) {\n if (value == null || input == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List s = new ArrayList<>(value.size() + input.size());\n int i = 0, j = 0;\n while (i < value.size() && j < input.size()) {\n if (value.get(i) <= input.get(j)) {\n s.add(value.get(i++));\n } else {\n s.add(input.get(j++));\n }\n }\n while (i < value.size()) {\n s.add(value.get(i++));\n }\n while (j < input.size()) {\n s.add(input.get(j++));\n }\n return s;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_new(List input, List nums) {\n if (input == null || nums == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List arr = new ArrayList<>(input.size() + nums.size());\n int i = 0, j = 0;\n while (i < input.size() && j < nums.size()) {\n if (input.get(i) <= nums.get(j)) {\n arr.add(input.get(i++));\n } else {\n arr.add(nums.get(j++));\n }\n }\n while (i < input.size()) {\n arr.add(input.get(i++));\n }\n while (j < nums.size()) {\n arr.add(nums.get(j++));\n }\n return arr;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_v2(int text) {\n if (text < 2) {\n return false;\n }\n for (int i = 2; i * i <= text; i++) {\n if (text % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_new(int list, int str) {\n if (str == 0) {\n throw new IllegalArgumentException(\"str must not be zero\");\n }\n return (double) list / str;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide(int s, int text) {\n if (text == 0) {\n throw new IllegalArgumentException(\"text must not be zero\");\n }\n return (double) s / text;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_v2(String input) {\n if (input == null) {\n return 0;\n }\n int count = 0;\n for (char c : input.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_v2(int arr, int nums) {\n if (nums == 0) {\n throw new IllegalArgumentException(\"nums must not be zero\");\n }\n return (double) arr / nums;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List s, List s) {\n if (s == null || s == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List text = new ArrayList<>(s.size() + s.size());\n int i = 0, j = 0;\n while (i < s.size() && j < s.size()) {\n if (s.get(i) <= s.get(j)) {\n text.add(s.get(i++));\n } else {\n text.add(s.get(j++));\n }\n }\n while (i < s.size()) {\n text.add(s.get(i++));\n }\n while (j < s.size()) {\n text.add(s.get(j++));\n }\n return text;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_v2(String arr) {\n if (arr == null) {\n return 0;\n }\n int count = 0;\n for (char c : arr.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_v2(int[] nums) {\n if (nums == null || nums.length == 0) {\n throw new IllegalArgumentException(\"nums must not be null or empty\");\n }\n int max = nums[0];\n for (int v : nums) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime(int text) {\n if (text < 2) {\n return false;\n }\n for (int i = 2; i * i <= text; i++) {\n if (text % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List text, List list) {\n if (text == null || list == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List arr = new ArrayList<>(text.size() + list.size());\n int i = 0, j = 0;\n while (i < text.size() && j < list.size()) {\n if (text.get(i) <= list.get(j)) {\n arr.add(text.get(i++));\n } else {\n arr.add(list.get(j++));\n }\n }\n while (i < text.size()) {\n arr.add(text.get(i++));\n }\n while (j < list.size()) {\n arr.add(list.get(j++));\n }\n return arr;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafeHelper(String value) {\n try {\n return Integer.parseInt(value);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + value);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List input, List nums) {\n if (input == null || nums == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List nums = new ArrayList<>(input.size() + nums.size());\n int i = 0, j = 0;\n while (i < input.size() && j < nums.size()) {\n if (input.get(i) <= nums.get(j)) {\n nums.add(input.get(i++));\n } else {\n nums.add(nums.get(j++));\n }\n }\n while (i < input.size()) {\n nums.add(input.get(i++));\n }\n while (j < nums.size()) {\n nums.add(nums.get(j++));\n }\n return nums;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_v2(int value, int nums) {\n if (nums == 0) {\n throw new IllegalArgumentException(\"nums must not be zero\");\n }\n return (double) value / nums;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_alt(String text) {\n if (text == null) {\n return null;\n }\n return new StringBuilder(text).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int text, int value) {\n if (value == 0) {\n throw new IllegalArgumentException(\"value must not be zero\");\n }\n return (double) text / value;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_v2(int[] list) {\n if (list == null || list.length == 0) {\n throw new IllegalArgumentException(\"list must not be null or empty\");\n }\n int max = list[0];\n for (int v : list) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List arr, List text) {\n if (arr == null || text == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List text = new ArrayList<>(arr.size() + text.size());\n int i = 0, j = 0;\n while (i < arr.size() && j < text.size()) {\n if (arr.get(i) <= text.get(j)) {\n text.add(arr.get(i++));\n } else {\n text.add(text.get(j++));\n }\n }\n while (i < arr.size()) {\n text.add(arr.get(i++));\n }\n while (j < text.size()) {\n text.add(text.get(j++));\n }\n return text;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_alt(int[] input) {\n if (input == null || input.length == 0) {\n throw new IllegalArgumentException(\"input must not be null or empty\");\n }\n int max = input[0];\n for (int v : input) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List s, List input) {\n if (s == null || input == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List nums = new ArrayList<>(s.size() + input.size());\n int i = 0, j = 0;\n while (i < s.size() && j < input.size()) {\n if (s.get(i) <= input.get(j)) {\n nums.add(s.get(i++));\n } else {\n nums.add(input.get(j++));\n }\n }\n while (i < s.size()) {\n nums.add(s.get(i++));\n }\n while (j < input.size()) {\n nums.add(input.get(j++));\n }\n return nums;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseStringHelper(String list) {\n if (list == null) {\n return null;\n }\n return new StringBuilder(list).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int s, int arr) {\n if (arr == 0) {\n throw new IllegalArgumentException(\"arr must not be zero\");\n }\n return (double) s / arr;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide(int value, int arr) {\n if (arr == 0) {\n throw new IllegalArgumentException(\"arr must not be zero\");\n }\n return (double) value / arr;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe(String nums) {\n try {\n return Integer.parseInt(nums);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + nums);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_alt(String value) {\n if (value == null) {\n return 0;\n }\n int count = 0;\n for (char c : value.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List value, List str) {\n if (value == null || str == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List value = new ArrayList<>(value.size() + str.size());\n int i = 0, j = 0;\n while (i < value.size() && j < str.size()) {\n if (value.get(i) <= str.get(j)) {\n value.add(value.get(i++));\n } else {\n value.add(str.get(j++));\n }\n }\n while (i < value.size()) {\n value.add(value.get(i++));\n }\n while (j < str.size()) {\n value.add(str.get(j++));\n }\n return value;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List arr, List list) {\n if (arr == null || list == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List s = new ArrayList<>(arr.size() + list.size());\n int i = 0, j = 0;\n while (i < arr.size() && j < list.size()) {\n if (arr.get(i) <= list.get(j)) {\n s.add(arr.get(i++));\n } else {\n s.add(list.get(j++));\n }\n }\n while (i < arr.size()) {\n s.add(arr.get(i++));\n }\n while (j < list.size()) {\n s.add(list.get(j++));\n }\n return s;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List s, List text) {\n if (s == null || text == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List n = new ArrayList<>(s.size() + text.size());\n int i = 0, j = 0;\n while (i < s.size() && j < text.size()) {\n if (s.get(i) <= text.get(j)) {\n n.add(s.get(i++));\n } else {\n n.add(text.get(j++));\n }\n }\n while (i < s.size()) {\n n.add(s.get(i++));\n }\n while (j < text.size()) {\n n.add(text.get(j++));\n }\n return n;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_alt(int[] arr) {\n if (arr == null || arr.length == 0) {\n throw new IllegalArgumentException(\"arr must not be null or empty\");\n }\n int max = arr[0];\n for (int v : arr) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafeEx(String s) {\n try {\n return Integer.parseInt(s);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + s);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_new(int value, int s) {\n if (s == 0) {\n throw new IllegalArgumentException(\"s must not be zero\");\n }\n return (double) value / s;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_alt(int str) {\n if (str < 2) {\n return false;\n }\n for (int i = 2; i * i <= str; i++) {\n if (str % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List str, List n) {\n if (str == null || n == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List value = new ArrayList<>(str.size() + n.size());\n int i = 0, j = 0;\n while (i < str.size() && j < n.size()) {\n if (str.get(i) <= n.get(j)) {\n value.add(str.get(i++));\n } else {\n value.add(n.get(j++));\n }\n }\n while (i < str.size()) {\n value.add(str.get(i++));\n }\n while (j < n.size()) {\n value.add(n.get(j++));\n }\n return value;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_new(int arr, int input) {\n if (input == 0) {\n throw new IllegalArgumentException(\"input must not be zero\");\n }\n return (double) arr / input;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_v2(int[] s) {\n if (s == null || s.length == 0) {\n throw new IllegalArgumentException(\"s must not be null or empty\");\n }\n int max = s[0];\n for (int v : s) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List input, List s) {\n if (input == null || s == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List n = new ArrayList<>(input.size() + s.size());\n int i = 0, j = 0;\n while (i < input.size() && j < s.size()) {\n if (input.get(i) <= s.get(j)) {\n n.add(input.get(i++));\n } else {\n n.add(s.get(j++));\n }\n }\n while (i < input.size()) {\n n.add(input.get(i++));\n }\n while (j < s.size()) {\n n.add(s.get(j++));\n }\n return n;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels(String n) {\n if (n == null) {\n return 0;\n }\n int count = 0;\n for (char c : n.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List nums, List list) {\n if (nums == null || list == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List list = new ArrayList<>(nums.size() + list.size());\n int i = 0, j = 0;\n while (i < nums.size() && j < list.size()) {\n if (nums.get(i) <= list.get(j)) {\n list.add(nums.get(i++));\n } else {\n list.add(list.get(j++));\n }\n }\n while (i < nums.size()) {\n list.add(nums.get(i++));\n }\n while (j < list.size()) {\n list.add(list.get(j++));\n }\n return list;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_v2(String str) {\n if (str == null) {\n return null;\n }\n return new StringBuilder(str).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_new(String text) {\n if (text == null) {\n return null;\n }\n return new StringBuilder(text).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int arr, int n) {\n if (n == 0) {\n throw new IllegalArgumentException(\"n must not be zero\");\n }\n return (double) arr / n;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrimeHelper(int input) {\n if (input < 2) {\n return false;\n }\n for (int i = 2; i * i <= input; i++) {\n if (input % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_new(String s) {\n if (s == null) {\n return null;\n }\n return new StringBuilder(s).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List nums, List nums) {\n if (nums == null || nums == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List n = new ArrayList<>(nums.size() + nums.size());\n int i = 0, j = 0;\n while (i < nums.size() && j < nums.size()) {\n if (nums.get(i) <= nums.get(j)) {\n n.add(nums.get(i++));\n } else {\n n.add(nums.get(j++));\n }\n }\n while (i < nums.size()) {\n n.add(nums.get(i++));\n }\n while (j < nums.size()) {\n n.add(nums.get(j++));\n }\n return n;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafeEx(String arr) {\n try {\n return Integer.parseInt(arr);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + arr);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseStringHelper(String s) {\n if (s == null) {\n return null;\n }\n return new StringBuilder(s).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowelsEx(String text) {\n if (text == null) {\n return 0;\n }\n int count = 0;\n for (char c : text.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int value, int str) {\n if (str == 0) {\n throw new IllegalArgumentException(\"str must not be zero\");\n }\n return (double) value / str;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max(int[] str) {\n if (str == null || str.length == 0) {\n throw new IllegalArgumentException(\"str must not be null or empty\");\n }\n int max = str[0];\n for (int v : str) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_alt(int[] nums) {\n if (nums == null || nums.length == 0) {\n throw new IllegalArgumentException(\"nums must not be null or empty\");\n }\n int max = nums[0];\n for (int v : nums) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List arr, List value) {\n if (arr == null || value == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List str = new ArrayList<>(arr.size() + value.size());\n int i = 0, j = 0;\n while (i < arr.size() && j < value.size()) {\n if (arr.get(i) <= value.get(j)) {\n str.add(arr.get(i++));\n } else {\n str.add(value.get(j++));\n }\n }\n while (i < arr.size()) {\n str.add(arr.get(i++));\n }\n while (j < value.size()) {\n str.add(value.get(j++));\n }\n return str;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List n, List input) {\n if (n == null || input == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List list = new ArrayList<>(n.size() + input.size());\n int i = 0, j = 0;\n while (i < n.size() && j < input.size()) {\n if (n.get(i) <= input.get(j)) {\n list.add(n.get(i++));\n } else {\n list.add(input.get(j++));\n }\n }\n while (i < n.size()) {\n list.add(n.get(i++));\n }\n while (j < input.size()) {\n list.add(input.get(j++));\n }\n return list;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int value, int s) {\n if (s == 0) {\n throw new IllegalArgumentException(\"s must not be zero\");\n }\n return (double) value / s;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List list, List input) {\n if (list == null || input == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List s = new ArrayList<>(list.size() + input.size());\n int i = 0, j = 0;\n while (i < list.size() && j < input.size()) {\n if (list.get(i) <= input.get(j)) {\n s.add(list.get(i++));\n } else {\n s.add(input.get(j++));\n }\n }\n while (i < list.size()) {\n s.add(list.get(i++));\n }\n while (j < input.size()) {\n s.add(input.get(j++));\n }\n return s;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List arr, List text) {\n if (arr == null || text == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List list = new ArrayList<>(arr.size() + text.size());\n int i = 0, j = 0;\n while (i < arr.size() && j < text.size()) {\n if (arr.get(i) <= text.get(j)) {\n list.add(arr.get(i++));\n } else {\n list.add(text.get(j++));\n }\n }\n while (i < arr.size()) {\n list.add(arr.get(i++));\n }\n while (j < text.size()) {\n list.add(text.get(j++));\n }\n return list;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int input, int text) {\n if (text == 0) {\n throw new IllegalArgumentException(\"text must not be zero\");\n }\n return (double) input / text;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_v2(String list) {\n if (list == null) {\n return null;\n }\n return new StringBuilder(list).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int str, int s) {\n if (s == 0) {\n throw new IllegalArgumentException(\"s must not be zero\");\n }\n return (double) str / s;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List s, List input) {\n if (s == null || input == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List input = new ArrayList<>(s.size() + input.size());\n int i = 0, j = 0;\n while (i < s.size() && j < input.size()) {\n if (s.get(i) <= input.get(j)) {\n input.add(s.get(i++));\n } else {\n input.add(input.get(j++));\n }\n }\n while (i < s.size()) {\n input.add(s.get(i++));\n }\n while (j < input.size()) {\n input.add(input.get(j++));\n }\n return input;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int arr, int s) {\n if (s == 0) {\n throw new IllegalArgumentException(\"s must not be zero\");\n }\n return (double) arr / s;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List n, List list) {\n if (n == null || list == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List str = new ArrayList<>(n.size() + list.size());\n int i = 0, j = 0;\n while (i < n.size() && j < list.size()) {\n if (n.get(i) <= list.get(j)) {\n str.add(n.get(i++));\n } else {\n str.add(list.get(j++));\n }\n }\n while (i < n.size()) {\n str.add(n.get(i++));\n }\n while (j < list.size()) {\n str.add(list.get(j++));\n }\n return str;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int s, int arr) {\n if (arr == 0) {\n throw new IllegalArgumentException(\"arr must not be zero\");\n }\n return (double) s / arr;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List value, List list) {\n if (value == null || list == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List nums = new ArrayList<>(value.size() + list.size());\n int i = 0, j = 0;\n while (i < value.size() && j < list.size()) {\n if (value.get(i) <= list.get(j)) {\n nums.add(value.get(i++));\n } else {\n nums.add(list.get(j++));\n }\n }\n while (i < value.size()) {\n nums.add(value.get(i++));\n }\n while (j < list.size()) {\n nums.add(list.get(j++));\n }\n return nums;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_new(List nums, List value) {\n if (nums == null || value == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List list = new ArrayList<>(nums.size() + value.size());\n int i = 0, j = 0;\n while (i < nums.size() && j < value.size()) {\n if (nums.get(i) <= value.get(j)) {\n list.add(nums.get(i++));\n } else {\n list.add(value.get(j++));\n }\n }\n while (i < nums.size()) {\n list.add(nums.get(i++));\n }\n while (j < value.size()) {\n list.add(value.get(j++));\n }\n return list;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List input, List input) {\n if (input == null || input == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List list = new ArrayList<>(input.size() + input.size());\n int i = 0, j = 0;\n while (i < input.size() && j < input.size()) {\n if (input.get(i) <= input.get(j)) {\n list.add(input.get(i++));\n } else {\n list.add(input.get(j++));\n }\n }\n while (i < input.size()) {\n list.add(input.get(i++));\n }\n while (j < input.size()) {\n list.add(input.get(j++));\n }\n return list;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List s, List list) {\n if (s == null || list == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List arr = new ArrayList<>(s.size() + list.size());\n int i = 0, j = 0;\n while (i < s.size() && j < list.size()) {\n if (s.get(i) <= list.get(j)) {\n arr.add(s.get(i++));\n } else {\n arr.add(list.get(j++));\n }\n }\n while (i < s.size()) {\n arr.add(s.get(i++));\n }\n while (j < list.size()) {\n arr.add(list.get(j++));\n }\n return arr;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List value, List str) {\n if (value == null || str == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List s = new ArrayList<>(value.size() + str.size());\n int i = 0, j = 0;\n while (i < value.size() && j < str.size()) {\n if (value.get(i) <= str.get(j)) {\n s.add(value.get(i++));\n } else {\n s.add(str.get(j++));\n }\n }\n while (i < value.size()) {\n s.add(value.get(i++));\n }\n while (j < str.size()) {\n s.add(str.get(j++));\n }\n return s;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int maxEx(int[] value) {\n if (value == null || value.length == 0) {\n throw new IllegalArgumentException(\"value must not be null or empty\");\n }\n int max = value[0];\n for (int v : value) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int text, int list) {\n if (list == 0) {\n throw new IllegalArgumentException(\"list must not be zero\");\n }\n return (double) text / list;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_new(List s, List list) {\n if (s == null || list == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List n = new ArrayList<>(s.size() + list.size());\n int i = 0, j = 0;\n while (i < s.size() && j < list.size()) {\n if (s.get(i) <= list.get(j)) {\n n.add(s.get(i++));\n } else {\n n.add(list.get(j++));\n }\n }\n while (i < s.size()) {\n n.add(s.get(i++));\n }\n while (j < list.size()) {\n n.add(list.get(j++));\n }\n return n;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseStringHelper(String arr) {\n if (arr == null) {\n return null;\n }\n return new StringBuilder(arr).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_v2(int input, int list) {\n if (list == 0) {\n throw new IllegalArgumentException(\"list must not be zero\");\n }\n return (double) input / list;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List text, List value) {\n if (text == null || value == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List input = new ArrayList<>(text.size() + value.size());\n int i = 0, j = 0;\n while (i < text.size() && j < value.size()) {\n if (text.get(i) <= value.get(j)) {\n input.add(text.get(i++));\n } else {\n input.add(value.get(j++));\n }\n }\n while (i < text.size()) {\n input.add(text.get(i++));\n }\n while (j < value.size()) {\n input.add(value.get(j++));\n }\n return input;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafeEx(String list) {\n try {\n return Integer.parseInt(list);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + list);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int arr, int n) {\n if (n == 0) {\n throw new IllegalArgumentException(\"n must not be zero\");\n }\n return (double) arr / n;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_v2(String s) {\n if (s == null) {\n return 0;\n }\n int count = 0;\n for (char c : s.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List text, List n) {\n if (text == null || n == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List s = new ArrayList<>(text.size() + n.size());\n int i = 0, j = 0;\n while (i < text.size() && j < n.size()) {\n if (text.get(i) <= n.get(j)) {\n s.add(text.get(i++));\n } else {\n s.add(n.get(j++));\n }\n }\n while (i < text.size()) {\n s.add(text.get(i++));\n }\n while (j < n.size()) {\n s.add(n.get(j++));\n }\n return s;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List s, List str) {\n if (s == null || str == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List n = new ArrayList<>(s.size() + str.size());\n int i = 0, j = 0;\n while (i < s.size() && j < str.size()) {\n if (s.get(i) <= str.get(j)) {\n n.add(s.get(i++));\n } else {\n n.add(str.get(j++));\n }\n }\n while (i < s.size()) {\n n.add(s.get(i++));\n }\n while (j < str.size()) {\n n.add(str.get(j++));\n }\n return n;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe(String input) {\n try {\n return Integer.parseInt(input);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + input);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_new(List value, List text) {\n if (value == null || text == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List nums = new ArrayList<>(value.size() + text.size());\n int i = 0, j = 0;\n while (i < value.size() && j < text.size()) {\n if (value.get(i) <= text.get(j)) {\n nums.add(value.get(i++));\n } else {\n nums.add(text.get(j++));\n }\n }\n while (i < value.size()) {\n nums.add(value.get(i++));\n }\n while (j < text.size()) {\n nums.add(text.get(j++));\n }\n return nums;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowelsHelper(String str) {\n if (str == null) {\n return 0;\n }\n int count = 0;\n for (char c : str.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrimeEx(int n) {\n if (n < 2) {\n return false;\n }\n for (int i = 2; i * i <= n; i++) {\n if (n % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List str, List list) {\n if (str == null || list == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List n = new ArrayList<>(str.size() + list.size());\n int i = 0, j = 0;\n while (i < str.size() && j < list.size()) {\n if (str.get(i) <= list.get(j)) {\n n.add(str.get(i++));\n } else {\n n.add(list.get(j++));\n }\n }\n while (i < str.size()) {\n n.add(str.get(i++));\n }\n while (j < list.size()) {\n n.add(list.get(j++));\n }\n return n;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int maxHelper(int[] input) {\n if (input == null || input.length == 0) {\n throw new IllegalArgumentException(\"input must not be null or empty\");\n }\n int max = input[0];\n for (int v : input) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_new(int n, int text) {\n if (text == 0) {\n throw new IllegalArgumentException(\"text must not be zero\");\n }\n return (double) n / text;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int text, int s) {\n if (s == 0) {\n throw new IllegalArgumentException(\"s must not be zero\");\n }\n return (double) text / s;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_new(int[] arr) {\n if (arr == null || arr.length == 0) {\n throw new IllegalArgumentException(\"arr must not be null or empty\");\n }\n int max = arr[0];\n for (int v : arr) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int maxHelper(int[] list) {\n if (list == null || list.length == 0) {\n throw new IllegalArgumentException(\"list must not be null or empty\");\n }\n int max = list[0];\n for (int v : list) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List s, List input) {\n if (s == null || input == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List str = new ArrayList<>(s.size() + input.size());\n int i = 0, j = 0;\n while (i < s.size() && j < input.size()) {\n if (s.get(i) <= input.get(j)) {\n str.add(s.get(i++));\n } else {\n str.add(input.get(j++));\n }\n }\n while (i < s.size()) {\n str.add(s.get(i++));\n }\n while (j < input.size()) {\n str.add(input.get(j++));\n }\n return str;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrimeHelper(int s) {\n if (s < 2) {\n return false;\n }\n for (int i = 2; i * i <= s; i++) {\n if (s % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_v2(int nums, int arr) {\n if (arr == 0) {\n throw new IllegalArgumentException(\"arr must not be zero\");\n }\n return (double) nums / arr;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafeHelper(String s) {\n try {\n return Integer.parseInt(s);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + s);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide(int nums, int value) {\n if (value == 0) {\n throw new IllegalArgumentException(\"value must not be zero\");\n }\n return (double) nums / value;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List input, List value) {\n if (input == null || value == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List arr = new ArrayList<>(input.size() + value.size());\n int i = 0, j = 0;\n while (i < input.size() && j < value.size()) {\n if (input.get(i) <= value.get(j)) {\n arr.add(input.get(i++));\n } else {\n arr.add(value.get(j++));\n }\n }\n while (i < input.size()) {\n arr.add(input.get(i++));\n }\n while (j < value.size()) {\n arr.add(value.get(j++));\n }\n return arr;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_v2(String s) {\n if (s == null) {\n return null;\n }\n return new StringBuilder(s).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_alt(String text) {\n try {\n return Integer.parseInt(text);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + text);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_v2(String text) {\n try {\n return Integer.parseInt(text);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + text);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List arr, List nums) {\n if (arr == null || nums == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List str = new ArrayList<>(arr.size() + nums.size());\n int i = 0, j = 0;\n while (i < arr.size() && j < nums.size()) {\n if (arr.get(i) <= nums.get(j)) {\n str.add(arr.get(i++));\n } else {\n str.add(nums.get(j++));\n }\n }\n while (i < arr.size()) {\n str.add(arr.get(i++));\n }\n while (j < nums.size()) {\n str.add(nums.get(j++));\n }\n return str;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int value, int list) {\n if (list == 0) {\n throw new IllegalArgumentException(\"list must not be zero\");\n }\n return (double) value / list;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseStringHelper(String nums) {\n if (nums == null) {\n return null;\n }\n return new StringBuilder(nums).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List str, List value) {\n if (str == null || value == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List value = new ArrayList<>(str.size() + value.size());\n int i = 0, j = 0;\n while (i < str.size() && j < value.size()) {\n if (str.get(i) <= value.get(j)) {\n value.add(str.get(i++));\n } else {\n value.add(value.get(j++));\n }\n }\n while (i < str.size()) {\n value.add(str.get(i++));\n }\n while (j < value.size()) {\n value.add(value.get(j++));\n }\n return value;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_v2(int nums, int s) {\n if (s == 0) {\n throw new IllegalArgumentException(\"s must not be zero\");\n }\n return (double) nums / s;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List text, List text) {\n if (text == null || text == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List list = new ArrayList<>(text.size() + text.size());\n int i = 0, j = 0;\n while (i < text.size() && j < text.size()) {\n if (text.get(i) <= text.get(j)) {\n list.add(text.get(i++));\n } else {\n list.add(text.get(j++));\n }\n }\n while (i < text.size()) {\n list.add(text.get(i++));\n }\n while (j < text.size()) {\n list.add(text.get(j++));\n }\n return list;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int value, int text) {\n if (text == 0) {\n throw new IllegalArgumentException(\"text must not be zero\");\n }\n return (double) value / text;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List s, List text) {\n if (s == null || text == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List input = new ArrayList<>(s.size() + text.size());\n int i = 0, j = 0;\n while (i < s.size() && j < text.size()) {\n if (s.get(i) <= text.get(j)) {\n input.add(s.get(i++));\n } else {\n input.add(text.get(j++));\n }\n }\n while (i < s.size()) {\n input.add(s.get(i++));\n }\n while (j < text.size()) {\n input.add(text.get(j++));\n }\n return input;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List list, List input) {\n if (list == null || input == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List input = new ArrayList<>(list.size() + input.size());\n int i = 0, j = 0;\n while (i < list.size() && j < input.size()) {\n if (list.get(i) <= input.get(j)) {\n input.add(list.get(i++));\n } else {\n input.add(input.get(j++));\n }\n }\n while (i < list.size()) {\n input.add(list.get(i++));\n }\n while (j < input.size()) {\n input.add(input.get(j++));\n }\n return input;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List value, List list) {\n if (value == null || list == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List text = new ArrayList<>(value.size() + list.size());\n int i = 0, j = 0;\n while (i < value.size() && j < list.size()) {\n if (value.get(i) <= list.get(j)) {\n text.add(value.get(i++));\n } else {\n text.add(list.get(j++));\n }\n }\n while (i < value.size()) {\n text.add(value.get(i++));\n }\n while (j < list.size()) {\n text.add(list.get(j++));\n }\n return text;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_v2(String list) {\n try {\n return Integer.parseInt(list);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + list);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int maxEx(int[] n) {\n if (n == null || n.length == 0) {\n throw new IllegalArgumentException(\"n must not be null or empty\");\n }\n int max = n[0];\n for (int v : n) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString(String value) {\n if (value == null) {\n return null;\n }\n return new StringBuilder(value).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_alt(int[] s) {\n if (s == null || s.length == 0) {\n throw new IllegalArgumentException(\"s must not be null or empty\");\n }\n int max = s[0];\n for (int v : s) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List text, List arr) {\n if (text == null || arr == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List nums = new ArrayList<>(text.size() + arr.size());\n int i = 0, j = 0;\n while (i < text.size() && j < arr.size()) {\n if (text.get(i) <= arr.get(j)) {\n nums.add(text.get(i++));\n } else {\n nums.add(arr.get(j++));\n }\n }\n while (i < text.size()) {\n nums.add(text.get(i++));\n }\n while (j < arr.size()) {\n nums.add(arr.get(j++));\n }\n return nums;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int value, int arr) {\n if (arr == 0) {\n throw new IllegalArgumentException(\"arr must not be zero\");\n }\n return (double) value / arr;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int str, int text) {\n if (text == 0) {\n throw new IllegalArgumentException(\"text must not be zero\");\n }\n return (double) str / text;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide(int value, int list) {\n if (list == 0) {\n throw new IllegalArgumentException(\"list must not be zero\");\n }\n return (double) value / list;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_new(String arr) {\n if (arr == null) {\n return 0;\n }\n int count = 0;\n for (char c : arr.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowelsHelper(String text) {\n if (text == null) {\n return 0;\n }\n int count = 0;\n for (char c : text.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List s, List arr) {\n if (s == null || arr == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List text = new ArrayList<>(s.size() + arr.size());\n int i = 0, j = 0;\n while (i < s.size() && j < arr.size()) {\n if (s.get(i) <= arr.get(j)) {\n text.add(s.get(i++));\n } else {\n text.add(arr.get(j++));\n }\n }\n while (i < s.size()) {\n text.add(s.get(i++));\n }\n while (j < arr.size()) {\n text.add(arr.get(j++));\n }\n return text;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_v2(int s, int n) {\n if (n == 0) {\n throw new IllegalArgumentException(\"n must not be zero\");\n }\n return (double) s / n;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrimeEx(int list) {\n if (list < 2) {\n return false;\n }\n for (int i = 2; i * i <= list; i++) {\n if (list % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int nums, int list) {\n if (list == 0) {\n throw new IllegalArgumentException(\"list must not be zero\");\n }\n return (double) nums / list;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrimeHelper(int value) {\n if (value < 2) {\n return false;\n }\n for (int i = 2; i * i <= value; i++) {\n if (value % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels(String input) {\n if (input == null) {\n return 0;\n }\n int count = 0;\n for (char c : input.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowelsEx(String list) {\n if (list == null) {\n return 0;\n }\n int count = 0;\n for (char c : list.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrimeHelper(int nums) {\n if (nums < 2) {\n return false;\n }\n for (int i = 2; i * i <= nums; i++) {\n if (nums % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_new(int s, int nums) {\n if (nums == 0) {\n throw new IllegalArgumentException(\"nums must not be zero\");\n }\n return (double) s / nums;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_new(int[] s) {\n if (s == null || s.length == 0) {\n throw new IllegalArgumentException(\"s must not be null or empty\");\n }\n int max = s[0];\n for (int v : s) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int value, int n) {\n if (n == 0) {\n throw new IllegalArgumentException(\"n must not be zero\");\n }\n return (double) value / n;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List arr, List list) {\n if (arr == null || list == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List value = new ArrayList<>(arr.size() + list.size());\n int i = 0, j = 0;\n while (i < arr.size() && j < list.size()) {\n if (arr.get(i) <= list.get(j)) {\n value.add(arr.get(i++));\n } else {\n value.add(list.get(j++));\n }\n }\n while (i < arr.size()) {\n value.add(arr.get(i++));\n }\n while (j < list.size()) {\n value.add(list.get(j++));\n }\n return value;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_new(int input, int list) {\n if (list == 0) {\n throw new IllegalArgumentException(\"list must not be zero\");\n }\n return (double) input / list;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide(int input, int input) {\n if (input == 0) {\n throw new IllegalArgumentException(\"input must not be zero\");\n }\n return (double) input / input;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List list, List nums) {\n if (list == null || nums == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List input = new ArrayList<>(list.size() + nums.size());\n int i = 0, j = 0;\n while (i < list.size() && j < nums.size()) {\n if (list.get(i) <= nums.get(j)) {\n input.add(list.get(i++));\n } else {\n input.add(nums.get(j++));\n }\n }\n while (i < list.size()) {\n input.add(list.get(i++));\n }\n while (j < nums.size()) {\n input.add(nums.get(j++));\n }\n return input;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowelsEx(String arr) {\n if (arr == null) {\n return 0;\n }\n int count = 0;\n for (char c : arr.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int maxHelper(int[] value) {\n if (value == null || value.length == 0) {\n throw new IllegalArgumentException(\"value must not be null or empty\");\n }\n int max = value[0];\n for (int v : value) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int nums, int n) {\n if (n == 0) {\n throw new IllegalArgumentException(\"n must not be zero\");\n }\n return (double) nums / n;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max_new(int[] text) {\n if (text == null || text.length == 0) {\n throw new IllegalArgumentException(\"text must not be null or empty\");\n }\n int max = text[0];\n for (int v : text) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List n, List input) {\n if (n == null || input == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List list = new ArrayList<>(n.size() + input.size());\n int i = 0, j = 0;\n while (i < n.size() && j < input.size()) {\n if (n.get(i) <= input.get(j)) {\n list.add(n.get(i++));\n } else {\n list.add(input.get(j++));\n }\n }\n while (i < n.size()) {\n list.add(n.get(i++));\n }\n while (j < input.size()) {\n list.add(input.get(j++));\n }\n return list;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int arr, int arr) {\n if (arr == 0) {\n throw new IllegalArgumentException(\"arr must not be zero\");\n }\n return (double) arr / arr;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_new(List n, List value) {\n if (n == null || value == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List input = new ArrayList<>(n.size() + value.size());\n int i = 0, j = 0;\n while (i < n.size() && j < value.size()) {\n if (n.get(i) <= value.get(j)) {\n input.add(n.get(i++));\n } else {\n input.add(value.get(j++));\n }\n }\n while (i < n.size()) {\n input.add(n.get(i++));\n }\n while (j < value.size()) {\n input.add(value.get(j++));\n }\n return input;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List s, List nums) {\n if (s == null || nums == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List value = new ArrayList<>(s.size() + nums.size());\n int i = 0, j = 0;\n while (i < s.size() && j < nums.size()) {\n if (s.get(i) <= nums.get(j)) {\n value.add(s.get(i++));\n } else {\n value.add(nums.get(j++));\n }\n }\n while (i < s.size()) {\n value.add(s.get(i++));\n }\n while (j < nums.size()) {\n value.add(nums.get(j++));\n }\n return value;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafeHelper(String text) {\n try {\n return Integer.parseInt(text);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + text);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_v2(int list, int text) {\n if (text == 0) {\n throw new IllegalArgumentException(\"text must not be zero\");\n }\n return (double) list / text;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime(int s) {\n if (s < 2) {\n return false;\n }\n for (int i = 2; i * i <= s; i++) {\n if (s % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide(int s, int input) {\n if (input == 0) {\n throw new IllegalArgumentException(\"input must not be zero\");\n }\n return (double) s / input;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_v2(String nums) {\n try {\n return Integer.parseInt(nums);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + nums);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List str, List arr) {\n if (str == null || arr == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List text = new ArrayList<>(str.size() + arr.size());\n int i = 0, j = 0;\n while (i < str.size() && j < arr.size()) {\n if (str.get(i) <= arr.get(j)) {\n text.add(str.get(i++));\n } else {\n text.add(arr.get(j++));\n }\n }\n while (i < str.size()) {\n text.add(str.get(i++));\n }\n while (j < arr.size()) {\n text.add(arr.get(j++));\n }\n return text;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_new(int str) {\n if (str < 2) {\n return false;\n }\n for (int i = 2; i * i <= str; i++) {\n if (str % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_new(List s, List str) {\n if (s == null || str == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List n = new ArrayList<>(s.size() + str.size());\n int i = 0, j = 0;\n while (i < s.size() && j < str.size()) {\n if (s.get(i) <= str.get(j)) {\n n.add(s.get(i++));\n } else {\n n.add(str.get(j++));\n }\n }\n while (i < s.size()) {\n n.add(s.get(i++));\n }\n while (j < str.size()) {\n n.add(str.get(j++));\n }\n return n;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafeEx(String text) {\n try {\n return Integer.parseInt(text);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + text);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int arr, int str) {\n if (str == 0) {\n throw new IllegalArgumentException(\"str must not be zero\");\n }\n return (double) arr / str;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_new(String nums) {\n if (nums == null) {\n return 0;\n }\n int count = 0;\n for (char c : nums.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int list, int text) {\n if (text == 0) {\n throw new IllegalArgumentException(\"text must not be zero\");\n }\n return (double) list / text;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe_new(String n) {\n try {\n return Integer.parseInt(n);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + n);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_v2(int text, int input) {\n if (input == 0) {\n throw new IllegalArgumentException(\"input must not be zero\");\n }\n return (double) text / input;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List n, List input) {\n if (n == null || input == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List value = new ArrayList<>(n.size() + input.size());\n int i = 0, j = 0;\n while (i < n.size() && j < input.size()) {\n if (n.get(i) <= input.get(j)) {\n value.add(n.get(i++));\n } else {\n value.add(input.get(j++));\n }\n }\n while (i < n.size()) {\n value.add(n.get(i++));\n }\n while (j < input.size()) {\n value.add(input.get(j++));\n }\n return value;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List text, List arr) {\n if (text == null || arr == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List list = new ArrayList<>(text.size() + arr.size());\n int i = 0, j = 0;\n while (i < text.size() && j < arr.size()) {\n if (text.get(i) <= arr.get(j)) {\n list.add(text.get(i++));\n } else {\n list.add(arr.get(j++));\n }\n }\n while (i < text.size()) {\n list.add(text.get(i++));\n }\n while (j < arr.size()) {\n list.add(arr.get(j++));\n }\n return list;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_v2(int input) {\n if (input < 2) {\n return false;\n }\n for (int i = 2; i * i <= input; i++) {\n if (input % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int n, int input) {\n if (input == 0) {\n throw new IllegalArgumentException(\"input must not be zero\");\n }\n return (double) n / input;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List str, List arr) {\n if (str == null || arr == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List arr = new ArrayList<>(str.size() + arr.size());\n int i = 0, j = 0;\n while (i < str.size() && j < arr.size()) {\n if (str.get(i) <= arr.get(j)) {\n arr.add(str.get(i++));\n } else {\n arr.add(arr.get(j++));\n }\n }\n while (i < str.size()) {\n arr.add(str.get(i++));\n }\n while (j < arr.size()) {\n arr.add(arr.get(j++));\n }\n return arr;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_v2(int text, int list) {\n if (list == 0) {\n throw new IllegalArgumentException(\"list must not be zero\");\n }\n return (double) text / list;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_v2(int nums, int n) {\n if (n == 0) {\n throw new IllegalArgumentException(\"n must not be zero\");\n }\n return (double) nums / n;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List text, List list) {\n if (text == null || list == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List n = new ArrayList<>(text.size() + list.size());\n int i = 0, j = 0;\n while (i < text.size() && j < list.size()) {\n if (text.get(i) <= list.get(j)) {\n n.add(text.get(i++));\n } else {\n n.add(list.get(j++));\n }\n }\n while (i < text.size()) {\n n.add(text.get(i++));\n }\n while (j < list.size()) {\n n.add(list.get(j++));\n }\n return n;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List list, List list) {\n if (list == null || list == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List text = new ArrayList<>(list.size() + list.size());\n int i = 0, j = 0;\n while (i < list.size() && j < list.size()) {\n if (list.get(i) <= list.get(j)) {\n text.add(list.get(i++));\n } else {\n text.add(list.get(j++));\n }\n }\n while (i < list.size()) {\n text.add(list.get(i++));\n }\n while (j < list.size()) {\n text.add(list.get(j++));\n }\n return text;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int text, int s) {\n if (s == 0) {\n throw new IllegalArgumentException(\"s must not be zero\");\n }\n return (double) text / s;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_alt(int arr) {\n if (arr < 2) {\n return false;\n }\n for (int i = 2; i * i <= arr; i++) {\n if (arr % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List s, List list) {\n if (s == null || list == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List s = new ArrayList<>(s.size() + list.size());\n int i = 0, j = 0;\n while (i < s.size() && j < list.size()) {\n if (s.get(i) <= list.get(j)) {\n s.add(s.get(i++));\n } else {\n s.add(list.get(j++));\n }\n }\n while (i < s.size()) {\n s.add(s.get(i++));\n }\n while (j < list.size()) {\n s.add(list.get(j++));\n }\n return s;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List arr, List n) {\n if (arr == null || n == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List input = new ArrayList<>(arr.size() + n.size());\n int i = 0, j = 0;\n while (i < arr.size() && j < n.size()) {\n if (arr.get(i) <= n.get(j)) {\n input.add(arr.get(i++));\n } else {\n input.add(n.get(j++));\n }\n }\n while (i < arr.size()) {\n input.add(arr.get(i++));\n }\n while (j < n.size()) {\n input.add(n.get(j++));\n }\n return input;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafe(String text) {\n try {\n return Integer.parseInt(text);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + text);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_new(int input, int arr) {\n if (arr == 0) {\n throw new IllegalArgumentException(\"arr must not be zero\");\n }\n return (double) input / arr;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_v2(String text) {\n if (text == null) {\n return 0;\n }\n int count = 0;\n for (char c : text.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString(String list) {\n if (list == null) {\n return null;\n }\n return new StringBuilder(list).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseStringEx(String value) {\n if (value == null) {\n return null;\n }\n return new StringBuilder(value).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int value, int nums) {\n if (nums == 0) {\n throw new IllegalArgumentException(\"nums must not be zero\");\n }\n return (double) value / nums;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List nums, List str) {\n if (nums == null || str == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List value = new ArrayList<>(nums.size() + str.size());\n int i = 0, j = 0;\n while (i < nums.size() && j < str.size()) {\n if (nums.get(i) <= str.get(j)) {\n value.add(nums.get(i++));\n } else {\n value.add(str.get(j++));\n }\n }\n while (i < nums.size()) {\n value.add(nums.get(i++));\n }\n while (j < str.size()) {\n value.add(str.get(j++));\n }\n return value;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List list, List n) {\n if (list == null || n == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List input = new ArrayList<>(list.size() + n.size());\n int i = 0, j = 0;\n while (i < list.size() && j < n.size()) {\n if (list.get(i) <= n.get(j)) {\n input.add(list.get(i++));\n } else {\n input.add(n.get(j++));\n }\n }\n while (i < list.size()) {\n input.add(list.get(i++));\n }\n while (j < n.size()) {\n input.add(n.get(j++));\n }\n return input;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_new(List nums, List str) {\n if (nums == null || str == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List str = new ArrayList<>(nums.size() + str.size());\n int i = 0, j = 0;\n while (i < nums.size() && j < str.size()) {\n if (nums.get(i) <= str.get(j)) {\n str.add(nums.get(i++));\n } else {\n str.add(str.get(j++));\n }\n }\n while (i < nums.size()) {\n str.add(nums.get(i++));\n }\n while (j < str.size()) {\n str.add(str.get(j++));\n }\n return str;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List list, List nums) {\n if (list == null || nums == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List str = new ArrayList<>(list.size() + nums.size());\n int i = 0, j = 0;\n while (i < list.size() && j < nums.size()) {\n if (list.get(i) <= nums.get(j)) {\n str.add(list.get(i++));\n } else {\n str.add(nums.get(j++));\n }\n }\n while (i < list.size()) {\n str.add(list.get(i++));\n }\n while (j < nums.size()) {\n str.add(nums.get(j++));\n }\n return str;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List str, List n) {\n if (str == null || n == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List value = new ArrayList<>(str.size() + n.size());\n int i = 0, j = 0;\n while (i < str.size() && j < n.size()) {\n if (str.get(i) <= n.get(j)) {\n value.add(str.get(i++));\n } else {\n value.add(n.get(j++));\n }\n }\n while (i < str.size()) {\n value.add(str.get(i++));\n }\n while (j < n.size()) {\n value.add(n.get(j++));\n }\n return value;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that parses an integer from a string safely using try-catch.", "input": "", "output": "public class Utils {\n\n public static int parseIntSafeEx(String str) {\n try {\n return Integer.parseInt(str);\n } catch (NumberFormatException e) {\n System.err.println(\"Invalid number format: \" + str);\n return 0;\n }\n }\n}", "language": "java", "category": "exception-handling", "difficulty": "medium"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseStringEx(String text) {\n if (text == null) {\n return null;\n }\n return new StringBuilder(text).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int s, int str) {\n if (str == 0) {\n throw new IllegalArgumentException(\"str must not be zero\");\n }\n return (double) s / str;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List input, List value) {\n if (input == null || value == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List arr = new ArrayList<>(input.size() + value.size());\n int i = 0, j = 0;\n while (i < input.size() && j < value.size()) {\n if (input.get(i) <= value.get(j)) {\n arr.add(input.get(i++));\n } else {\n arr.add(value.get(j++));\n }\n }\n while (i < input.size()) {\n arr.add(input.get(i++));\n }\n while (j < value.size()) {\n arr.add(value.get(j++));\n }\n return arr;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List s, List str) {\n if (s == null || str == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List nums = new ArrayList<>(s.size() + str.size());\n int i = 0, j = 0;\n while (i < s.size() && j < str.size()) {\n if (s.get(i) <= str.get(j)) {\n nums.add(s.get(i++));\n } else {\n nums.add(str.get(j++));\n }\n }\n while (i < s.size()) {\n nums.add(s.get(i++));\n }\n while (j < str.size()) {\n nums.add(str.get(j++));\n }\n return nums;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List list, List value) {\n if (list == null || value == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List text = new ArrayList<>(list.size() + value.size());\n int i = 0, j = 0;\n while (i < list.size() && j < value.size()) {\n if (list.get(i) <= value.get(j)) {\n text.add(list.get(i++));\n } else {\n text.add(value.get(j++));\n }\n }\n while (i < list.size()) {\n text.add(list.get(i++));\n }\n while (j < value.size()) {\n text.add(value.get(j++));\n }\n return text;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List arr, List input) {\n if (arr == null || input == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List list = new ArrayList<>(arr.size() + input.size());\n int i = 0, j = 0;\n while (i < arr.size() && j < input.size()) {\n if (arr.get(i) <= input.get(j)) {\n list.add(arr.get(i++));\n } else {\n list.add(input.get(j++));\n }\n }\n while (i < arr.size()) {\n list.add(arr.get(i++));\n }\n while (j < input.size()) {\n list.add(input.get(j++));\n }\n return list;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_alt(String input) {\n if (input == null) {\n return 0;\n }\n int count = 0;\n for (char c : input.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_new(List value, List s) {\n if (value == null || s == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List value = new ArrayList<>(value.size() + s.size());\n int i = 0, j = 0;\n while (i < value.size() && j < s.size()) {\n if (value.get(i) <= s.get(j)) {\n value.add(value.get(i++));\n } else {\n value.add(s.get(j++));\n }\n }\n while (i < value.size()) {\n value.add(value.get(i++));\n }\n while (j < s.size()) {\n value.add(s.get(j++));\n }\n return value;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List text, List str) {\n if (text == null || str == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List str = new ArrayList<>(text.size() + str.size());\n int i = 0, j = 0;\n while (i < text.size() && j < str.size()) {\n if (text.get(i) <= str.get(j)) {\n str.add(text.get(i++));\n } else {\n str.add(str.get(j++));\n }\n }\n while (i < text.size()) {\n str.add(text.get(i++));\n }\n while (j < str.size()) {\n str.add(str.get(j++));\n }\n return str;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowelsHelper(String value) {\n if (value == null) {\n return 0;\n }\n int count = 0;\n for (char c : value.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List str, List text) {\n if (str == null || text == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List arr = new ArrayList<>(str.size() + text.size());\n int i = 0, j = 0;\n while (i < str.size() && j < text.size()) {\n if (str.get(i) <= text.get(j)) {\n arr.add(str.get(i++));\n } else {\n arr.add(text.get(j++));\n }\n }\n while (i < str.size()) {\n arr.add(str.get(i++));\n }\n while (j < text.size()) {\n arr.add(text.get(j++));\n }\n return arr;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List s, List n) {\n if (s == null || n == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List input = new ArrayList<>(s.size() + n.size());\n int i = 0, j = 0;\n while (i < s.size() && j < n.size()) {\n if (s.get(i) <= n.get(j)) {\n input.add(s.get(i++));\n } else {\n input.add(n.get(j++));\n }\n }\n while (i < s.size()) {\n input.add(s.get(i++));\n }\n while (j < n.size()) {\n input.add(n.get(j++));\n }\n return input;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List str, List arr) {\n if (str == null || arr == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List str = new ArrayList<>(str.size() + arr.size());\n int i = 0, j = 0;\n while (i < str.size() && j < arr.size()) {\n if (str.get(i) <= arr.get(j)) {\n str.add(str.get(i++));\n } else {\n str.add(arr.get(j++));\n }\n }\n while (i < str.size()) {\n str.add(str.get(i++));\n }\n while (j < arr.size()) {\n str.add(arr.get(j++));\n }\n return str;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int text, int nums) {\n if (nums == 0) {\n throw new IllegalArgumentException(\"nums must not be zero\");\n }\n return (double) text / nums;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int list, int str) {\n if (str == 0) {\n throw new IllegalArgumentException(\"str must not be zero\");\n }\n return (double) list / str;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List s, List text) {\n if (s == null || text == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List str = new ArrayList<>(s.size() + text.size());\n int i = 0, j = 0;\n while (i < s.size() && j < text.size()) {\n if (s.get(i) <= text.get(j)) {\n str.add(s.get(i++));\n } else {\n str.add(text.get(j++));\n }\n }\n while (i < s.size()) {\n str.add(s.get(i++));\n }\n while (j < text.size()) {\n str.add(text.get(j++));\n }\n return str;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List s, List arr) {\n if (s == null || arr == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List value = new ArrayList<>(s.size() + arr.size());\n int i = 0, j = 0;\n while (i < s.size() && j < arr.size()) {\n if (s.get(i) <= arr.get(j)) {\n value.add(s.get(i++));\n } else {\n value.add(arr.get(j++));\n }\n }\n while (i < s.size()) {\n value.add(s.get(i++));\n }\n while (j < arr.size()) {\n value.add(arr.get(j++));\n }\n return value;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List input, List arr) {\n if (input == null || arr == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List value = new ArrayList<>(input.size() + arr.size());\n int i = 0, j = 0;\n while (i < input.size() && j < arr.size()) {\n if (input.get(i) <= arr.get(j)) {\n value.add(input.get(i++));\n } else {\n value.add(arr.get(j++));\n }\n }\n while (i < input.size()) {\n value.add(input.get(i++));\n }\n while (j < arr.size()) {\n value.add(arr.get(j++));\n }\n return value;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int text, int input) {\n if (input == 0) {\n throw new IllegalArgumentException(\"input must not be zero\");\n }\n return (double) text / input;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_new(int text, int list) {\n if (list == 0) {\n throw new IllegalArgumentException(\"list must not be zero\");\n }\n return (double) text / list;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowelsEx(String n) {\n if (n == null) {\n return 0;\n }\n int count = 0;\n for (char c : n.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int maxEx(int[] list) {\n if (list == null || list.length == 0) {\n throw new IllegalArgumentException(\"list must not be null or empty\");\n }\n int max = list[0];\n for (int v : list) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List arr, List arr) {\n if (arr == null || arr == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List str = new ArrayList<>(arr.size() + arr.size());\n int i = 0, j = 0;\n while (i < arr.size() && j < arr.size()) {\n if (arr.get(i) <= arr.get(j)) {\n str.add(arr.get(i++));\n } else {\n str.add(arr.get(j++));\n }\n }\n while (i < arr.size()) {\n str.add(arr.get(i++));\n }\n while (j < arr.size()) {\n str.add(arr.get(j++));\n }\n return str;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_new(List s, List value) {\n if (s == null || value == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List s = new ArrayList<>(s.size() + value.size());\n int i = 0, j = 0;\n while (i < s.size() && j < value.size()) {\n if (s.get(i) <= value.get(j)) {\n s.add(s.get(i++));\n } else {\n s.add(value.get(j++));\n }\n }\n while (i < s.size()) {\n s.add(s.get(i++));\n }\n while (j < value.size()) {\n s.add(value.get(j++));\n }\n return s;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List input, List value) {\n if (input == null || value == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List text = new ArrayList<>(input.size() + value.size());\n int i = 0, j = 0;\n while (i < input.size() && j < value.size()) {\n if (input.get(i) <= value.get(j)) {\n text.add(input.get(i++));\n } else {\n text.add(value.get(j++));\n }\n }\n while (i < input.size()) {\n text.add(input.get(i++));\n }\n while (j < value.size()) {\n text.add(value.get(j++));\n }\n return text;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List value, List s) {\n if (value == null || s == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List n = new ArrayList<>(value.size() + s.size());\n int i = 0, j = 0;\n while (i < value.size() && j < s.size()) {\n if (value.get(i) <= s.get(j)) {\n n.add(value.get(i++));\n } else {\n n.add(s.get(j++));\n }\n }\n while (i < value.size()) {\n n.add(value.get(i++));\n }\n while (j < s.size()) {\n n.add(s.get(j++));\n }\n return n;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List list, List text) {\n if (list == null || text == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List arr = new ArrayList<>(list.size() + text.size());\n int i = 0, j = 0;\n while (i < list.size() && j < text.size()) {\n if (list.get(i) <= text.get(j)) {\n arr.add(list.get(i++));\n } else {\n arr.add(text.get(j++));\n }\n }\n while (i < list.size()) {\n arr.add(list.get(i++));\n }\n while (j < text.size()) {\n arr.add(text.get(j++));\n }\n return arr;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List arr, List input) {\n if (arr == null || input == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List list = new ArrayList<>(arr.size() + input.size());\n int i = 0, j = 0;\n while (i < arr.size() && j < input.size()) {\n if (arr.get(i) <= input.get(j)) {\n list.add(arr.get(i++));\n } else {\n list.add(input.get(j++));\n }\n }\n while (i < arr.size()) {\n list.add(arr.get(i++));\n }\n while (j < input.size()) {\n list.add(input.get(j++));\n }\n return list;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List nums, List value) {\n if (nums == null || value == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List value = new ArrayList<>(nums.size() + value.size());\n int i = 0, j = 0;\n while (i < nums.size() && j < value.size()) {\n if (nums.get(i) <= value.get(j)) {\n value.add(nums.get(i++));\n } else {\n value.add(value.get(j++));\n }\n }\n while (i < nums.size()) {\n value.add(nums.get(i++));\n }\n while (j < value.size()) {\n value.add(value.get(j++));\n }\n return value;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List value, List list) {\n if (value == null || list == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List text = new ArrayList<>(value.size() + list.size());\n int i = 0, j = 0;\n while (i < value.size() && j < list.size()) {\n if (value.get(i) <= list.get(j)) {\n text.add(value.get(i++));\n } else {\n text.add(list.get(j++));\n }\n }\n while (i < value.size()) {\n text.add(value.get(i++));\n }\n while (j < list.size()) {\n text.add(list.get(j++));\n }\n return text;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List n, List str) {\n if (n == null || str == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List s = new ArrayList<>(n.size() + str.size());\n int i = 0, j = 0;\n while (i < n.size() && j < str.size()) {\n if (n.get(i) <= str.get(j)) {\n s.add(n.get(i++));\n } else {\n s.add(str.get(j++));\n }\n }\n while (i < n.size()) {\n s.add(n.get(i++));\n }\n while (j < str.size()) {\n s.add(str.get(j++));\n }\n return s;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List n, List value) {\n if (n == null || value == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List n = new ArrayList<>(n.size() + value.size());\n int i = 0, j = 0;\n while (i < n.size() && j < value.size()) {\n if (n.get(i) <= value.get(j)) {\n n.add(n.get(i++));\n } else {\n n.add(value.get(j++));\n }\n }\n while (i < n.size()) {\n n.add(n.get(i++));\n }\n while (j < value.size()) {\n n.add(value.get(j++));\n }\n return n;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide(int input, int nums) {\n if (nums == 0) {\n throw new IllegalArgumentException(\"nums must not be zero\");\n }\n return (double) input / nums;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int n, int text) {\n if (text == 0) {\n throw new IllegalArgumentException(\"text must not be zero\");\n }\n return (double) n / text;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString(String nums) {\n if (nums == null) {\n return null;\n }\n return new StringBuilder(nums).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideEx(int list, int text) {\n if (text == 0) {\n throw new IllegalArgumentException(\"text must not be zero\");\n }\n return (double) list / text;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_alt(int s, int nums) {\n if (nums == 0) {\n throw new IllegalArgumentException(\"nums must not be zero\");\n }\n return (double) s / nums;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_new(String value) {\n if (value == null) {\n return 0;\n }\n int count = 0;\n for (char c : value.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide(int str, int arr) {\n if (arr == 0) {\n throw new IllegalArgumentException(\"arr must not be zero\");\n }\n return (double) str / arr;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List arr, List str) {\n if (arr == null || str == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List s = new ArrayList<>(arr.size() + str.size());\n int i = 0, j = 0;\n while (i < arr.size() && j < str.size()) {\n if (arr.get(i) <= str.get(j)) {\n s.add(arr.get(i++));\n } else {\n s.add(str.get(j++));\n }\n }\n while (i < arr.size()) {\n s.add(arr.get(i++));\n }\n while (j < str.size()) {\n s.add(str.get(j++));\n }\n return s;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_new(List text, List n) {\n if (text == null || n == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List str = new ArrayList<>(text.size() + n.size());\n int i = 0, j = 0;\n while (i < text.size() && j < n.size()) {\n if (text.get(i) <= n.get(j)) {\n str.add(text.get(i++));\n } else {\n str.add(n.get(j++));\n }\n }\n while (i < text.size()) {\n str.add(text.get(i++));\n }\n while (j < n.size()) {\n str.add(n.get(j++));\n }\n return str;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedHelper(List arr, List list) {\n if (arr == null || list == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List str = new ArrayList<>(arr.size() + list.size());\n int i = 0, j = 0;\n while (i < arr.size() && j < list.size()) {\n if (arr.get(i) <= list.get(j)) {\n str.add(arr.get(i++));\n } else {\n str.add(list.get(j++));\n }\n }\n while (i < arr.size()) {\n str.add(arr.get(i++));\n }\n while (j < list.size()) {\n str.add(list.get(j++));\n }\n return str;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Complete the following Java method so it returns the maximum value in an array.", "input": "", "output": "public class ArrayUtils {\n\n public static int max(int[] n) {\n if (n == null || n.length == 0) {\n throw new IllegalArgumentException(\"n must not be null or empty\");\n }\n int max = n[0];\n for (int v : n) {\n if (v > max) {\n max = v;\n }\n }\n return max;\n }\n}", "language": "java", "category": "completion", "difficulty": "easy"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_v2(String text) {\n if (text == null) {\n return null;\n }\n return new StringBuilder(text).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide(int value, int text) {\n if (text == 0) {\n throw new IllegalArgumentException(\"text must not be zero\");\n }\n return (double) value / text;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_new(int value) {\n if (value < 2) {\n return false;\n }\n for (int i = 2; i * i <= value; i++) {\n if (value % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide(int str, int str) {\n if (str == 0) {\n throw new IllegalArgumentException(\"str must not be zero\");\n }\n return (double) str / str;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that counts the number of vowels in a string.", "input": "", "output": "public class StringUtils {\n\n public static int countVowels_v2(String n) {\n if (n == null) {\n return 0;\n }\n int count = 0;\n for (char c : n.toLowerCase().toCharArray()) {\n if (\"aeiou\".indexOf(c) >= 0) {\n count++;\n }\n }\n return count;\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_new(int input, int n) {\n if (n == 0) {\n throw new IllegalArgumentException(\"n must not be zero\");\n }\n return (double) input / n;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List str, List arr) {\n if (str == null || arr == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List n = new ArrayList<>(str.size() + arr.size());\n int i = 0, j = 0;\n while (i < str.size() && j < arr.size()) {\n if (str.get(i) <= arr.get(j)) {\n n.add(str.get(i++));\n } else {\n n.add(arr.get(j++));\n }\n }\n while (i < str.size()) {\n n.add(str.get(i++));\n }\n while (j < arr.size()) {\n n.add(arr.get(j++));\n }\n return n;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List input, List text) {\n if (input == null || text == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List s = new ArrayList<>(input.size() + text.size());\n int i = 0, j = 0;\n while (i < input.size() && j < text.size()) {\n if (input.get(i) <= text.get(j)) {\n s.add(input.get(i++));\n } else {\n s.add(text.get(j++));\n }\n }\n while (i < input.size()) {\n s.add(input.get(i++));\n }\n while (j < text.size()) {\n s.add(text.get(j++));\n }\n return s;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_v2(List list, List arr) {\n if (list == null || arr == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List n = new ArrayList<>(list.size() + arr.size());\n int i = 0, j = 0;\n while (i < list.size() && j < arr.size()) {\n if (list.get(i) <= arr.get(j)) {\n n.add(list.get(i++));\n } else {\n n.add(arr.get(j++));\n }\n }\n while (i < list.size()) {\n n.add(list.get(i++));\n }\n while (j < arr.size()) {\n n.add(arr.get(j++));\n }\n return n;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int nums, int arr) {\n if (arr == 0) {\n throw new IllegalArgumentException(\"arr must not be zero\");\n }\n return (double) nums / arr;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrimeHelper(int str) {\n if (str < 2) {\n return false;\n }\n for (int i = 2; i * i <= str; i++) {\n if (str % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that checks whether a number is prime.", "input": "", "output": "public class MathUtils {\n\n public static boolean isPrime_alt(int list) {\n if (list < 2) {\n return false;\n }\n for (int i = 2; i * i <= list; i++) {\n if (list % i == 0) {\n return false;\n }\n }\n return true;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int str, int input) {\n if (input == 0) {\n throw new IllegalArgumentException(\"input must not be zero\");\n }\n return (double) str / input;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSortedEx(List value, List nums) {\n if (value == null || nums == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List list = new ArrayList<>(value.size() + nums.size());\n int i = 0, j = 0;\n while (i < value.size() && j < nums.size()) {\n if (value.get(i) <= nums.get(j)) {\n list.add(value.get(i++));\n } else {\n list.add(nums.get(j++));\n }\n }\n while (i < value.size()) {\n list.add(value.get(i++));\n }\n while (j < nums.size()) {\n list.add(nums.get(j++));\n }\n return list;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that reverses a string.", "input": "", "output": "public class StringUtils {\n\n public static String reverseString_v2(String n) {\n if (n == null) {\n return null;\n }\n return new StringBuilder(n).reverse().toString();\n }\n}", "language": "java", "category": "function", "difficulty": "easy"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide(int arr, int text) {\n if (text == 0) {\n throw new IllegalArgumentException(\"text must not be zero\");\n }\n return (double) arr / text;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List input, List nums) {\n if (input == null || nums == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List nums = new ArrayList<>(input.size() + nums.size());\n int i = 0, j = 0;\n while (i < input.size() && j < nums.size()) {\n if (input.get(i) <= nums.get(j)) {\n nums.add(input.get(i++));\n } else {\n nums.add(nums.get(j++));\n }\n }\n while (i < input.size()) {\n nums.add(input.get(i++));\n }\n while (j < nums.size()) {\n nums.add(nums.get(j++));\n }\n return nums;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted(List str, List str) {\n if (str == null || str == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List nums = new ArrayList<>(str.size() + str.size());\n int i = 0, j = 0;\n while (i < str.size() && j < str.size()) {\n if (str.get(i) <= str.get(j)) {\n nums.add(str.get(i++));\n } else {\n nums.add(str.get(j++));\n }\n }\n while (i < str.size()) {\n nums.add(str.get(i++));\n }\n while (j < str.size()) {\n nums.add(str.get(j++));\n }\n return nums;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divideHelper(int list, int arr) {\n if (arr == 0) {\n throw new IllegalArgumentException(\"arr must not be zero\");\n }\n return (double) list / arr;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_new(List str, List nums) {\n if (str == null || nums == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List str = new ArrayList<>(str.size() + nums.size());\n int i = 0, j = 0;\n while (i < str.size() && j < nums.size()) {\n if (str.get(i) <= nums.get(j)) {\n str.add(str.get(i++));\n } else {\n str.add(nums.get(j++));\n }\n }\n while (i < str.size()) {\n str.add(str.get(i++));\n }\n while (j < nums.size()) {\n str.add(nums.get(j++));\n }\n return str;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_new(List str, List arr) {\n if (str == null || arr == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List nums = new ArrayList<>(str.size() + arr.size());\n int i = 0, j = 0;\n while (i < str.size() && j < arr.size()) {\n if (str.get(i) <= arr.get(j)) {\n nums.add(str.get(i++));\n } else {\n nums.add(arr.get(j++));\n }\n }\n while (i < str.size()) {\n nums.add(str.get(i++));\n }\n while (j < arr.size()) {\n nums.add(arr.get(j++));\n }\n return nums;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"} {"instruction": "Fix the following Java method so it avoids division by zero.", "input": "", "output": "public class MathUtils {\n\n public static double divide_new(int input, int value) {\n if (value == 0) {\n throw new IllegalArgumentException(\"value must not be zero\");\n }\n return (double) input / value;\n }\n}", "language": "java", "category": "bug-fix", "difficulty": "easy"} {"instruction": "Write a Java method that merges two sorted lists of integers into a new sorted list.", "input": "", "output": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class CollectionUtils {\n\n public static List mergeSorted_alt(List text, List str) {\n if (text == null || str == null) {\n throw new IllegalArgumentException(\"lists must not be null\");\n }\n List nums = new ArrayList<>(text.size() + str.size());\n int i = 0, j = 0;\n while (i < text.size() && j < str.size()) {\n if (text.get(i) <= str.get(j)) {\n nums.add(text.get(i++));\n } else {\n nums.add(str.get(j++));\n }\n }\n while (i < text.size()) {\n nums.add(text.get(i++));\n }\n while (j < str.size()) {\n nums.add(str.get(j++));\n }\n return nums;\n }\n}", "language": "java", "category": "function", "difficulty": "medium"}