iidai/codenet huggingface dataset:
Language: Java

import java.util.Scanner;

public class s584135649 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int i = 0;

        for (i = 1; i <= 5; i++) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
        }

        System.out.println(i);
    }
}


Example test case(s):
input: 0 2 3 4 5

output: 1
Language: Java

import java.util.*;

class s379215956 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String s1 = s.substring(0, 1);
        String s2 = s.substring(1, 2);
        String s3 = s.substring(2, 3);
        String s4 = s.substring(3, 4);
        int a = 0;

        if (s1.equals(s2)) a = 1;
        if (s2.equals(s3)) a = 1;
        if (s3.equals(s4)) a = 1;

        if (a == 1) {
            System.out.println("Bad");
        } else {
            System.out.println("Good");
        }
    }
}


Example test case(s):
input: 3776

output: Bad
Language: Java

import java.io.*;
import java.util.*;

public class s580342216 {
    public static void main(String[] args) throws java.lang.Exception {
        new Solution();
    }
}

class Solution {
    Scanner scanner;

    public Solution() {
        scanner = new Scanner(System.in);

        while (scanner.hasNext()) {
            run_case();
        }
    }

    private void run_case() {

        String line = scanner.nextLine();
        int N = Integer.parseInt(line.split("\\s+")[0]);
        int K = Integer.parseInt(line.split("\\s+")[1]);

        int len = 0;
        while (N > 0) {
            N /= K;
            len++;
        }

        System.out.println(len);
        return;
    }

    private int[] strToIntArray(String str) {
        String[] vals = str.split("\\s+");
        int sz = vals.length;
        int[] res = new int[sz];
        for (int i = 0; i < sz; i++) {
            res[i] = Integer.parseInt(vals[i]);
        }
        return res;
    }
}

class LCS {
    int[][] dp;

    public int lcs(String A, String B) {
        int sz_a = A.length(), sz_b = B.length();
        dp = new int[sz_a + 1][sz_b + 1];

        for (int i = 0; i <= sz_a; i++) dp[i][0] = 0;
        for (int j = 0; j <= sz_b; j++) dp[0][j] = 0;

        for (int i = 1; i <= sz_a; i++) {
            for (int j = 1; j <= sz_b; j++) {
                if (A.charAt(i - 1) == B.charAt(j - 1)) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                } else {
                    dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
                }
            }
        }

        return dp[sz_a][sz_b];
    }

    public String getLCS(String X, String Y) {
        int m = X.length();
        int n = Y.length();

        int index = dp[m][n];
        int temp = index;

        char[] lcs = new char[index + 1];
        lcs[index] = '\0';

        int i = m;
        int j = n;
        while (i > 0 && j > 0) {

            if (X.charAt(i - 1) == Y.charAt(j - 1)) {

                lcs[index - 1] = X.charAt(i - 1);

                i--;
                j--;
                index--;
            } else if (dp[i - 1][j] > dp[i][j - 1]) i--;
            else j--;
        }

        return String.valueOf(lcs).substring(0, temp + 2);
    }
}


Example test case(s):
input: 11 2

output: 4
Language: Java

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class s126744620 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = sc.nextInt();
        Integer[] x = new Integer[200010];
        Arrays.fill(x, 0);
        for (int i = 0; i < n; i++) {
            x[a[i] - 1]++;
        }
        Arrays.sort(
                x,
                new Comparator<Integer>() {
                    public int compare(Integer p1, Integer p2) {
                        return p1 - p2;
                    }
                });
        int ans = 0;
        for (int i = 0; i <= 200010 - k - 1; i++) {
            ans += x[i];
        }
        System.out.println(ans);
    }
}


Example test case(s):
input: 5 2
1 1 2 2 5

output: 1
Language: Java

import java.util.Scanner;

class s450226252 {
    public static void main(String[] args) {

        Scanner stdIn = new Scanner(System.in);

        short r = stdIn.nextShort();

        if (r < 1200) {
            System.out.println("ABC");
            return;
        }

        if (r < 2800) {
            System.out.println("ARC");
            return;
        }

        System.out.println("AGC");
    }
}


Example test case(s):
input: 1199

output: ABC
Language: Java

import static java.lang.System.*;

import java.util.*;

public class s125881159 {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        int d = 0;
        for (int i = 0; i < n; i++) {
            d += sc.nextInt() % 2;
        }
        out.println(d % 2 == 0 ? "YES" : "NO");
    }
}


Example test case(s):
input: 3
1 2 3

output: YES
Language: Java

import java.util.Scanner;

class s725559666 {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        scan.close();
        if (a < b && b < c && a < c) {
            System.out.println("Yes");

        } else {
            System.out.println("No");
        }
    }
}


Example test case(s):
input: 1 3 8

output: Yes
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.StringTokenizer;

public class s733150445 {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(in.readLine());
        BigDecimal a = new BigDecimal(st.nextToken());
        BigDecimal b = new BigDecimal(st.nextToken());
        BigDecimal mul = a.multiply(b);
        st = new StringTokenizer(mul.toString(), ".");
        System.out.println(st.nextElement());
    }
}


Example test case(s):
input: 198 1.10

output: 217
Language: Java

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.stream.Collectors;

public class s387083574 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        for (int i = 1; i < N + 1; i++) map.put(i, sc.nextInt());
        System.out.println(
                String.join(
                        " ",
                        map.entrySet().stream()
                                .sorted(Entry.<Integer, Integer>comparingByValue())
                                .map(Map.Entry::getKey)
                                .map(String::valueOf)
                                .collect(Collectors.toList())));
    }
}


Example test case(s):
input: 3
2 3 1

output: 3 1 2
Language: Java

import java.util.Scanner;

class s601569023 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        if (num < 1200) System.out.println("ABC");
        else System.out.println("ARC");
    }
}


Example test case(s):
input: 1000

output: ABC
Language: Java

import static java.lang.System.*;

import java.math.*;
import java.util.*;

public class s449886393 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] youbi = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
        String s = sc.next();
        int ans = 0;
        for (int i = 0; i < youbi.length; i++) {
            if (youbi[i].equals(s)) {
                ans = 7 - i;
            }
        }
        out.println(ans);
    }
}


Example test case(s):
input: SAT

output: 1
Language: Java

import java.util.Scanner;

public class s513933260 {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);

        long n = stdIn.nextLong();

        System.out.println(n * (n + 1) / 2 - n);
    }
}


Example test case(s):
input: 2

output: 1
Language: Java

import java.util.Scanner;

class s325080396 {
    static final int MAX = 200000;

    public static void main(String[] args) {
        int[] R = new int[MAX];
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for (int i = 0; i < n; i++) R[i] = in.nextInt();
        int maxv = R[1] - R[0];
        int minv = R[0];
        for (int i = 1; i < n; i++) {
            maxv = Math.max(maxv, R[i] - minv);
            minv = Math.min(minv, R[i]);
        }
        System.out.println(maxv);
    }
}


Example test case(s):
input: 6
5
3
1
3
4
3

output: 3
Language: Java

import java.util.Scanner;

public class s902370101 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        int max = 0;
        int min = 10000;
        for (int i = 0; i < array.length; i++) {
            array[i] = sc.nextInt();
            if (max < array[i]) {
                max = array[i];
            }

            if (min > array[i]) {
                min = array[i];
            }
        }
        System.out.println(max - min);
        sc.close();
    }
}


Example test case(s):
input: 4
2 3 7 9

output: 7
Language: Java

import java.io.*;
import java.util.*;

public class s511234019 {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner in = new Scanner(System.in);
        int a, b;
        a = in.nextInt();
        b = in.nextInt();
        if (a % 2 == 0 || b % 2 == 0) System.out.println("No");
        else System.out.println("Yes");
    }
}


Example test case(s):
input: 3 1

output: Yes
Language: Java

import java.util.*;

public class s494783955 {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String C = sc.next();

        System.out.println((char) (C.charAt(0) + 1));
    }
}


Example test case(s):
input: a

output: b
Language: Java

import java.util.Scanner;

public class s059916837 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.nextLine();
        String T = scanner.nextLine();
        int min = Integer.MAX_VALUE;
        for (int i = 0; i <= S.length() - T.length(); i++) {
            min = Math.min(min, find(S.substring(i, i + T.length()), T));
        }
        if (min != Integer.MAX_VALUE) {
            System.out.println(min);
        } else {
            System.out.println(T.length());
        }
    }

    public static int find(String a, String b) {
        int calc = 0;
        for (int x = 0; x < a.length(); x++) {
            if (a.charAt(x) != b.charAt(x)) {
                calc++;
            }
        }
        return calc;
    }
}


Example test case(s):
input: cabacc
abc

output: 1
Language: Java

import java.util.Scanner;

public class s458826999 {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        long MOD = 1000000007;
        long dp[][] = new long[S.length() + 1][13];
        dp[0][0] = 1;
        for (int i = 0; i < S.length(); i++) {
            if (S.substring(i, i + 1).equals("?")) {
                for (int j = 0; j < 10; j++) {
                    for (int k = 0; k < 13; k++) {
                        dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
                        dp[i + 1][(k * 10 + j) % 13] %= MOD;
                    }
                }
            } else {
                for (int k = 0; k < 13; k++) {
                    int x = Integer.parseInt(S.substring(i, i + 1));
                    dp[i + 1][(k * 10 + x) % 13] += dp[i][k];
                    dp[i + 1][(k * 10 + x) % 13] %= MOD;
                }
            }
        }
        System.out.println(dp[S.length()][5]);
    }
}


Example test case(s):
input: ??2??5

output: 768
Language: Java

import java.util.*;

public class s780604068 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int[] map = new int[N * 2];
        for (int i = 0; i < N * 2; i++) {
            map[i] = sc.nextInt();
        }

        Arrays.sort(map);

        int max = 0;
        for (int i = 0; i < N * 2; i += 2) {
            max += Math.min(map[i], map[i + 1]);
        }

        System.out.println(max);
    }
}


Example test case(s):
input: 2
1 3 1 2

output: 3
Language: Java

import java.util.Scanner;

public class s685537842 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int t = sc.nextInt();
        double time = 0;
        int count = 0;
        while (time < t + 0.5) {
            count += b;
            time += a;
            if (time > t + 0.5) {
                count -= b;
                break;
            }
        }
        System.out.println(count);
    }
}


Example test case(s):
input: 3 5 7

output: 10
Language: Java

import java.util.*;

class s319823779 {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();

        int res = 0;

        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b; j++) {
                for (int k = 0; k <= c; k++) {
                    int total = 500 * i + 100 * j + 50 * k;

                    if (total == x) {
                        res++;
                    }
                }
            }
        }
        System.out.println(res);
    }
}


Example test case(s):
input: 2
2
2
100

output: 2
Language: Java

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class s320655609 {
    List<Long> constraints = new ArrayList<>();
    long N;
    long result;

    s320655609() throws IOException {
        InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
        BufferedReader in = new BufferedReader(reader);
        this.N = Long.parseLong(in.readLine());
        for (int i = 0; i < 5; ++i) {
            this.constraints.add(Long.parseLong(in.readLine()));
        }
        in.close();

        this.calc();
    }

    void calc() {
        long min = Long.MAX_VALUE;
        for (Long c : this.constraints) {
            min = Math.min(min, c);
        }
        long time = this.N / min;
        if (this.N % min != 0) {
            ++time;
        }
        time += 4;
        this.result = time;
    }

    public static void main(String[] args) throws IOException {
        s320655609 ins = new s320655609();
        System.out.println(ins.result);
    }
}


Example test case(s):
input: 5
3
2
4
3
5

output: 7
Language: Java

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class s047401835 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        List<Integer> numbers = new ArrayList();

        for (int i = 0; i < N; i++) {
            numbers.add(Integer.parseInt(scanner.next()));
        }

        int count = 0;

        do {
            numbers =
                    numbers.stream()
                            .filter(i -> (i % 2) == 0)
                            .map(i -> i / 2)
                            .collect(Collectors.toList());
            if (numbers.size() == N) count++;
        } while (numbers.size() == N);

        System.out.println(count);
    }
}


Example test case(s):
input: 3
8 12 40

output: 2
Language: Java

import java.io.PrintStream;
import java.util.Scanner;

public class s831281137 {
    static final Scanner sc = new Scanner(System.in);
    static final PrintStream so = System.out;

    public static void main(String[] args) {
        int N = nint();
        int W = nint();

        int[] v = new int[N + 1];
        int[] w = new int[N + 1];

        for (int i = 1; i <= N; i++) {
            v[i] = nint();
            w[i] = nint();
        }

        int[][] sumV = new int[N + 1][W + 1];

        for (int i = 1; i <= N; i++) {
            for (int i_sum = 0; i_sum < w[i]; i_sum++) {
                sumV[i][i_sum] = sumV[i - 1][i_sum];
            }

            for (int i_sum = w[i]; i_sum <= W; i_sum++) {
                sumV[i][i_sum] = Math.max(sumV[i - 1][i_sum], sumV[i - 1][i_sum - w[i]] + v[i]);
            }
        }

        so.println(sumV[N][W]);
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++) a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++) a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++) a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++) System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


Example test case(s):
input: 4 5
4 2
5 2
2 1
8 3

output: 13
Language: Java

import java.io.*;
import java.util.*;

public class s745776078 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt(), m = in.nextInt(), A[][] = new int[n][m], b[] = new int[m];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) A[i][j] = in.nextInt();
        }

        for (int i = 0; i < m; i++) b[i] = in.nextInt();

        for (int i = 0; i < n; i++) {
            int c = 0;
            for (int j = 0; j < m; j++) {
                c += A[i][j] * b[j];
            }
            out.println(c);
        }

        out.flush();
    }
}


Example test case(s):
input: 3 4
1 2 0 1
0 3 0 1
4 1 1 0
1
2
3
0

output: 5
6
9
Language: Java

import java.util.*;

public class s826491904 {

    public static final void main(String[] args) {
        new s826491904().solve();
    }

    private final Scanner sc = new Scanner(System.in);

    void solve() {
        int N = sc.nextInt();
        int max, min;
        max = min = sc.nextInt();
        for (int i = 1; i < N; i++) {
            int in = sc.nextInt();
            max = Math.max(max, in);
            min = Math.min(min, in);
        }
        System.out.println(max - min);
    }
}


Example test case(s):
input: 4
2 3 7 9

output: 7
Language: Java

import java.math.*;
import java.util.*;

class s739337307 {
    public static void main(String[] args) {

        try (Scanner sc = new Scanner(System.in)) {

            int n = Integer.parseInt(sc.next());
            int m = Integer.parseInt(sc.next());

            HashMap<Integer, Integer> map = new HashMap<>();

            int countAc = 0;
            int countWaAll = 0;

            for (int i = 0; i < m; i++) {
                int question = Integer.parseInt(sc.next());
                String waOrAc = sc.next();

                if (!map.containsKey(question)) {
                    if (waOrAc.equals("WA")) map.put(question, 1);
                    else {
                        map.put(question, -1);
                        countAc++;
                    }
                } else {
                    int countWa = map.get(question);
                    if (countWa < 0)
                        ;
                    else {
                        if (waOrAc.equals("WA")) map.replace(question, countWa, countWa + 1);
                        else {
                            map.replace(question, countWa, -countWa);
                            countAc++;
                            countWaAll += countWa;
                        }
                    }
                }
            }

            System.out.println(countAc + " " + countWaAll);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


Example test case(s):
input: 2 5
1 WA
1 AC
2 WA
2 AC
2 WA

output: 2 2
Language: Java

import java.util.*;

public class s596918302 {
    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] arr = new int[n][3];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) arr[i][j] = sc.nextInt();
        }

        int ans = 0;

        ans = dpx(arr, n);
        System.out.println(ans);
    }

    static int min(int[] arr, int n) {
        if (n == 1) return 0;
        if (n == 2) return Math.abs(arr[n - 1] - arr[n - 2]);
        int op1 = Math.abs(arr[n - 1] - arr[n - 2]) + min(arr, n - 1);
        int op2 = Math.abs(arr[n - 1] - arr[n - 3]) + min(arr, n - 2);
        int res = Math.min(op1, op2);

        return res;
    }

    static int dpc(int[][] arr, int i, int n, int row) {
        if (row == n) return 0;
        int j = 0;
        int k = 0;
        if (i == 1) {
            j = 0;
            k = 2;
        } else if (i == 0) {
            j = 1;
            k = 2;
        } else {
            j = 0;
            k = 1;
        }

        return arr[row][i] + Math.max(dpc(arr, j, n, row + 1), dpc(arr, k, n, row + 1));
    }

    static int dpx(int[][] arr, int n) {
        int[][] dp = new int[n][3];

        dp[0][0] = arr[0][0];
        dp[0][1] = arr[0][1];
        dp[0][2] = arr[0][2];

        for (int i = 1; i < n; i++) {
            for (int in = 0; in < 3; in++) {
                int j = 0, k = 0;
                if (in == 1) {
                    j = 0;
                    k = 2;
                } else if (in == 0) {
                    j = 1;
                    k = 2;
                } else {
                    j = 0;
                    k = 1;
                }
                dp[i][in] = Math.max(dp[i - 1][k], dp[i - 1][j]) + arr[i][in];
            }
        }

        return Math.max(dp[n - 1][0], Math.max(dp[n - 1][1], dp[n - 1][2]));
    }
}


Example test case(s):
input: 3
10 40 70
20 50 80
30 60 90

output: 210
Language: Java

import java.util.*;

public class s701317277 {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N];
        int min = Integer.MAX_VALUE;
        int count = 0;
        long sum = 0;
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            if (A[i] < 0) count++;
            min = Math.min(min, Math.abs(A[i]));
            sum += Math.abs(A[i]);
        }
        sc.close();

        if (count % 2 == 0) System.out.println(sum);
        else {
            System.out.println(sum - min * 2);
        }
    }
}


Example test case(s):
input: 3
-10 5 -4

output: 19