iidai/codenet huggingface dataset:
Language: Java

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

public class s175590171 {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = fs.nextInt();
        }
        Arrays.sort(a);
        long sum = 0;
        int count = 0;
        for (int i = 0; i < n - 1; i++) {
            sum += a[i];
            if (a[i + 1] <= 2 * sum) {
                count++;
            } else {
                count = 0;
            }
        }
        System.out.println(count + 1);
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


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

output: 2
Language: Java

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

public class s500433274 {

    public static void main(String[] args) {
        BigInteger a, b, c;
        Scanner cin = new Scanner(System.in);
        while (cin.hasNext()) {
            a = cin.nextBigInteger();
            b = cin.nextBigInteger();
            c = a.max(b);
            if (a.equals(c) && !b.equals(c)) System.out.println("GREATER");
            else if (b.equals(c) && !a.equals(c)) System.out.println("LESS");
            else System.out.println("EQUAL");
        }
        cin.close();
    }
}


Example test case(s):
input: 36
24

output: GREATER
Language: Java

import java.util.*;

public class s314813282 {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int m = scan.nextInt();
        int n = scan.nextInt();
        int x = scan.nextInt();
        int y = scan.nextInt();
        int[] a = new int[m];
        for (int i = 0; i < a.length; i++) {
            a[i] = scan.nextInt();
        }
        int[] b = new int[n];
        for (int i = 0; i < b.length; i++) {
            b[i] = scan.nextInt();
        }
        int x_max = MaxInt(x, a);
        int y_min = MinInt(y, b);
        CheckWar(x_max, y_min);
    }

    static int MaxInt(int x, int[] a) {
        int bignum = x;
        for (int i = 0; i < a.length; i++) {
            bignum = Math.max(bignum, a[i]);
        }
        return bignum;
    }

    static int MinInt(int y, int[] b) {
        int smallnum = y;
        for (int i = 0; i < b.length; i++) {
            smallnum = Math.min(smallnum, b[i]);
        }
        return smallnum;
    }

    static void CheckWar(int a, int b) {
        if (a >= b) {
            System.out.println("War");
        } else {
            System.out.println("No War");
        }
    }
}


Example test case(s):
input: 3 2 10 20
8 15 13
16 22

output: No War
Language: Java

import java.util.Scanner;

public class s173032907 implements Runnable {

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

    public static void main(String[] args) {
        new Thread(null, new s173032907(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        long cost1 = 0;
        long cost2 = 0;
        int current1 = 0;
        int current2 = 0;
        long[] dp1 = new long[n];
        long[] dp2 = new long[n];
        for (int i = 0, j = n - 1; i < n; i++, j--) {
            cost1 += Math.abs(a[i] - current1);
            current1 = a[i];
            dp1[i] = cost1;
            cost2 += Math.abs(a[j] - current2);
            current2 = a[j];
            dp2[j] = cost2;
        }

        for (int i = 0; i < n; i++) {
            if (i == 0) {
                System.out.println(dp2[i + 1] + Math.abs(a[1]));
            } else if (i == n - 1) {
                System.out.println(dp1[i - 1] + Math.abs(a[i - 1]));
            } else {
                System.out.println(dp1[i - 1] + dp2[i + 1] + Math.abs(a[i - 1] - a[i + 1]));
            }
        }
    }
}


Example test case(s):
input: 3
3 5 -1

output: 12
8
10
Language: Java

import java.util.*;

public class s898738430 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int ans = 0;
        for (int i = 1; i < n - 1; i++) {
            if (a[i] != Math.min(a[i - 1], Math.min(a[i], a[i + 1]))
                    && a[i] != Math.max(a[i - 1], Math.max(a[i], a[i + 1]))) {
                ans++;
            }
        }
        System.out.println(ans);
        sc.close();
    }
}


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

output: 2
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class s527301188 {

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        String[] strs = reader.readLine().split(" ");
        int[] nums = new int[strs.length];
        int top = 0;
        for (int i = 0; i < strs.length; i++) {
            switch (strs[i].charAt(0)) {
                case '+':
                    top--;
                    nums[top - 1] = nums[top - 1] + nums[top];
                    break;
                case '-':
                    top--;
                    nums[top - 1] = nums[top - 1] - nums[top];
                    break;
                case '*':
                    top--;
                    nums[top - 1] = nums[top - 1] * nums[top];
                    break;
                default:
                    nums[top] = Integer.parseInt(strs[i]);
                    top++;
                    break;
            }
        }
        System.out.println(nums[0]);
    }
}


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

output: 3
Language: Java

import java.util.Scanner;

public class s356471394 {

    static Scanner sc = new Scanner(System.in);
    static String[] nums = sc.nextLine().split(" ");

    static int N = Integer.parseInt(nums[0]);
    static int M = Integer.parseInt(nums[1]);
    static char[][] room = new char[N][M];
    static int D = Integer.parseInt(nums[2]);
    static int num = 0;

    public static void main(String[] args) {
        inputRoom();

        if (M >= D) {
            setWE();
        }

        if (N >= D) {
            setNS();
        }

        System.out.println(num);
        sc.close();
    }

    private static void setWE() {
        boolean canPut = true;

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < M - D + 1; j++) {
                canPut = true;

                for (int k = 0; k < D; k++) {
                    if (s356471394.room[i][j + k] == '#') {
                        canPut = false;
                        break;
                    }
                }

                if (canPut == true) {
                    num++;
                }
            }
        }
    }

    private static void setNS() {
        boolean canPut = true;

        for (int i = 0; i < M; i++) {
            for (int j = 0; j < N - D + 1; j++) {
                canPut = true;

                for (int k = 0; k < D; k++) {
                    if (s356471394.room[j + k][i] == '#') {
                        canPut = false;
                        break;
                    }
                }

                if (canPut == true) {
                    num++;
                }
            }
        }
    }

    private static void inputRoom() {
        String str_room = "";

        for (int i = 0; i < N; i++) {
            str_room = sc.nextLine();
            s356471394.room[i] = str_room.toCharArray();
        }
    }
}


Example test case(s):
input: 3 5 2
...#.
#...#
....#

output: 12
Language: Java

import java.util.*;

public class s275359315 {
    public static void main(String... args) {
        Scanner scan = new Scanner(System.in);
        int r = scan.nextInt();
        int res = (int) Math.pow(r, 2);
        System.out.println(res);
    }
}


Example test case(s):
input: 2

output: 4
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class s640163137 {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] a = new int[n];
        String[] elements = br.readLine().split(" ");

        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(elements[i]);
        }

        int swapCount = 0;

        for (int i = 0; i < a.length; i++) {
            int mini = i;

            for (int j = i; j < a.length; j++) {
                if (a[j] < a[mini]) {
                    mini = j;
                }
            }

            if (mini != i) {
                int v = a[mini];
                a[mini] = a[i];
                a[i] = v;

                swapCount++;
            }
        }

        String ans = String.valueOf(a[0]);
        for (int i = 1; i < a.length; i++) {
            ans += " " + a[i];
        }

        System.out.println(ans);
        System.out.println(swapCount);
    }
}


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

output: 1 2 3 4 5 6
4
Language: Java

import java.util.Scanner;

public class s077706488 {

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
        int X = stdIn.nextInt();
        int[] m = new int[N];
        m[0] = stdIn.nextInt();
        X -= m[0];
        int min = m[0];
        for (int i = 1; i < N; i++) {
            m[i] = stdIn.nextInt();
            X -= m[i];
            if (m[i] < min) {
                min = m[i];
            }
        }
        System.out.println(N + X / min);
    }
}


Example test case(s):
input: 3 1000
120
100
140

output: 9
Language: Java

import java.util.Scanner;

public class s476581255 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int count = bubbleSort(a, n);
        for (int i = 0; i < n; i++) {
            if (i < n - 1) {
                System.out.print(a[i] + " ");
            } else {
                System.out.println(a[i]);
            }
        }
        System.out.println(count);
    }

    public static int bubbleSort(int[] a, int n) {
        boolean flag = true;
        int count = 0;
        while (flag == true) {
            flag = false;
            for (int j = n - 1; j > 0; j--) {
                if (a[j] < a[j - 1]) {
                    int free = a[j];
                    a[j] = a[j - 1];
                    a[j - 1] = free;
                    count++;
                    flag = true;
                }
            }
        }
        return count;
    }
}


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

output: 1 2 3 4 5
8
Language: Java

import java.util.*;

public class s490798303 {

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

        int n = scanner.nextInt();
        int k = scanner.nextInt();

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

        for (int i = 0; i < k; i++) {
            int d = scanner.nextInt();
            for (int j = 0; j < d; j++) {
                int person = scanner.nextInt();

                if (!map.containsKey(person)) {
                    map.put(person, new ArrayList<>());
                }
                map.get(person).add(d);
            }
        }

        int count = 0;
        for (int i = 1; i <= n; i++) {
            if (!map.containsKey(i)) {
                count++;
            }
        }

        System.out.println(count);
    }
}


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

output: 1
Language: Java

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

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

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


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

output: 1
Language: Java

import java.util.*;

class s399184958 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        if (A == B && B == C && C == A) System.out.println("Yes");
        else System.out.println("No");
    }
}


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

output: Yes
Language: Java

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

public class s888667117 {
    public static final Scanner in =
            new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    public static final PrintStream out = System.out;
    public static final PrintStream err = System.err;

    public static void main(String[] args) {
        String Si = in.next();
        char[] S = new StringBuilder(Si).reverse().toString().toCharArray();

        long[] dp = new long[13];
        dp[0] = 1;

        for (int i = 0, d = 1; i < S.length; i++, d = d * 10 % 13) {
            long[] nd = new long[13];

            err.println("d: " + d + ", i: " + i + ", S[i]: " + S[i]);
            char c = S[i];

            if (Character.isDigit(c)) {
                int x = (c - '0') * d;

                for (int j = 0; j < 13; j++) {
                    nd[(j + x) % 13] = dp[j];
                }
            } else {
                for (int xi = 0; xi < 10; xi++) {
                    int x = xi * d;

                    for (int j = 0; j < 13; j++) {
                        int ni = (j + x) % 13;
                        nd[ni] = (nd[ni] + dp[j]) % 1000000007;
                    }
                }
            }

            err.println(Arrays.toString(nd));
            dp = nd;
        }

        out.println(dp[5]);
    }
}


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

output: 768
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

public class s799002881 {
    public static void main(String[] args) throws IOException {
        InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
        BufferedReader in = new BufferedReader(reader);
        String[] str = in.readLine().split(" ");
        int n = Integer.parseInt(str[0]);
        double d = Integer.parseInt(str[1]);
        int cnt = 0;

        for (int i = 0; i < n; i++) {
            str = in.readLine().split(" ");
            double x = Integer.parseInt(str[0]);
            double y = Integer.parseInt(str[1]);
            if (Math.sqrt(x * x + y * y) <= d) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}


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

output: 3
Language: Java

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

public class s629237879 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String sc = br.readLine();
        int n = Integer.parseInt(sc);
        String[] str = new String[n];
        for (int i = 0; i < n; i++) {
            str[i] = br.readLine();
        }
        String[] mark = {"S", "H", "C", "D"};
        for (String ma : mark) {
            for (int i = 1; i <= 13; i++) {
                String s = Integer.toString(i);
                String st = ma + " " + s;
                if (Arrays.asList(str).contains(st)) {
                    continue;
                } else {
                    System.out.println(st);
                }
            }
        }
    }
}


Example test case(s):
input: 47
S 10
S 11
S 12
S 13
H 1
H 2
S 6
S 7
S 8
S 9
H 6
H 8
H 9
H 10
H 11
H 4
H 5
S 2
S 3
S 4
S 5
H 12
H 13
C 1
C 2
D 1
D 2
D 3
D 4
D 5
D 6
D 7
C 3
C 4
C 5
C 6
C 7
C 8
C 9
C 10
C 11
C 13
D 9
D 10
D 11
D 12
D 13

output: S 1
H 3
H 7
C 12
D 8
Language: Java

import java.util.Scanner;

public class s301480578 {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        int max = 0;
        for (int l = 0; l < n - 1; l++) {
            int count = 0;
            while (l < n - 1 && h[l] >= h[l + 1]) {
                l++;
                count++;
            }
            max = Math.max(max, count);
        }
        System.out.println(max);
    }
}


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

output: 2
Language: Java

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

public class s196249385 {

    private static Scanner sc;
    private static Printer pr;

    private static void solve() {
        int n = sc.nextInt();
        int k = sc.nextInt();

        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        long[] cumsum = new long[n + 1];
        for (int i = 0; i < n; i++) {
            cumsum[i + 1] = cumsum[i] + a[i];
        }

        List<Long> b = new ArrayList<>(n * (n + 1) / 2);
        long max = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                b.add(cumsum[j + 1] - cumsum[i]);
                max = Math.max(max, cumsum[j + 1] - cumsum[i]);
            }
        }

        long mask = Long.highestOneBit(max);
        while (mask > 0) {
            List<Long> tmp = new ArrayList<>();
            for (long e : b) {
                if ((e & mask) != 0) {
                    tmp.add(e);
                }
            }

            if (tmp.size() >= k) {
                b = tmp;
            }

            mask >>= 1;
        }

        if (b.size() < k) {
            pr.println(0);
        } else {
            long ans = -1L;
            for (long e : b) {
                ans &= e;
            }

            pr.println(ans);
        }
    }

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

        solve();

        pr.close();
        sc.close();
    }

    static class Printer extends PrintWriter {
        Printer(OutputStream out) {
            super(out);
        }
    }
}


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

output: 12
Language: Java

import java.util.Scanner;

public class s192812966 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int w = scanner.nextInt(), h = scanner.nextInt(), n = scanner.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        int[] a = new int[n];
        int xmax = w, xmin = 0;
        int ymax = h, ymin = 0;
        for (int i = 0; i < n; i++) {
            x[i] = scanner.nextInt();
            y[i] = scanner.nextInt();
            a[i] = scanner.nextInt();
            switch (a[i]) {
                case 1:
                    xmin = Math.max(xmin, x[i]);
                    break;
                case 2:
                    xmax = Math.min(xmax, x[i]);
                    break;
                case 3:
                    ymin = Math.max(ymin, y[i]);
                    break;
                case 4:
                    ymax = Math.min(ymax, y[i]);
                    break;
            }
        }
        w = Math.max(xmax - xmin, 0);
        h = Math.max(ymax - ymin, 0);

        System.out.println(w * h);
    }
}


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

output: 9
Language: Java

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class s561914763 {

    static Set<String> ODD = new HashSet<>();
    static Set<String> EVE = new HashSet<>();

    static {
        ODD.add("R");
        ODD.add("U");
        ODD.add("D");
        EVE.add("L");
        EVE.add("U");
        EVE.add("D");
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.nextLine();
        char[] tap = N.toCharArray();

        boolean isGood = true;
        for (int i = 0; i < N.length(); i++) {
            if ((i + 1) % 2 == 0) {
                if (!isMatch(EVE, tap[i])) {
                    isGood = false;
                    break;
                }
            } else {
                if (!isMatch(ODD, tap[i])) {
                    isGood = false;
                    break;
                }
            }
        }

        System.out.println(isGood ? "Yes" : "No");
    }

    private static boolean isMatch(Set<String> set, char c) {
        return set.contains(String.valueOf(c));
    }
}


Example test case(s):
input: RUDLUDR

output: Yes
Language: Java

import java.util.Scanner;

public class s442273167 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] l = new int[n];
        int[] r = new int[n];
        for (int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
        }
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += r[i] - l[i] + 1;
        }
        System.out.println(sum);
    }
}


Example test case(s):
input: 1
24 30

output: 7