iidai/codenet huggingface dataset:
Language: Java

import java.util.*;

class s440824480 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c = 0;
        int flg = 0;
        while (n-- > 0) {
            int x = sc.nextInt();
            int y = sc.nextInt();

            if (x == y) {
                c++;
                if (c >= 3) {
                    flg = 1;
                }
            } else {
                c = 0;
            }
        }
        if (flg == 0) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}


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

output: Yes
Language: Java

import java.util.Scanner;

public class s481865042 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        long k = sc.nextLong();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < s.length(); i++) {
            if ((26 - (s.charAt(i) - 'a')) <= k && s.charAt(i) != 'a') {
                k -= 26 - (s.charAt(i) - 'a');
                sb.append('a');
            } else {
                sb.append(s.charAt(i));
            }
        }
        if (k > 0) {
            char t = sb.charAt(s.length() - 1);
            sb.delete(s.length() - 1, s.length());
            sb.append((char) ('a' + (t - 'a' + k) % 26));
        }
        System.out.println(sb);
    }
}


Example test case(s):
input: xyz
4

output: aya
Language: Java

import java.io.*;
import java.math.*;
import java.util.*;
import java.util.concurrent.*;

class s443066739 {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static FastScanner sc = new FastScanner(br);
    static PrintWriter out = new PrintWriter(System.out);
    static Random rnd = new Random();

    public static void main(String args[]) throws Exception {
        int n = sc.nextInt();
        long[] pre = new long[n + 1];

        for (int i = 1; i <= n; i++) {
            pre[i] = pre[i - 1] + sc.nextLong();
        }

        long min = Long.MAX_VALUE;

        for (int i = 1; i < n; i++) {
            long val1 = pre[i], val2 = pre[n] - pre[i];

            min = Math.min(min, Math.abs(val1 - val2));
        }

        out.println(min);
        out.close();
    }
}

class FastScanner {
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }

    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    public String next() throws Exception {
        return nextToken().toString();
    }

    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}


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

output: 1
Language: Java

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

public class s960387817 {

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int n = scanner.nextInt();
            Set<Integer> set = new HashSet<>();
            IntStream.range(0, n).forEach(i -> set.add(scanner.nextInt()));
            System.out.println(set.size());
        }
    }
}


Example test case(s):
input: 4
10
8
8
6

output: 3
Language: Java

import java.util.Scanner;

public class s832608243 {
    public static void main(final String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt(), b = scanner.nextInt();
        boolean flag = false;
        for (int i = 1; i <= 100000; i++) {
            if (Math.floor(1. * i * .08) == a && b == Math.floor(.1 * i)) {
                System.out.println(i);
                flag = true;
                break;
            }
        }
        if (!flag) {
            System.out.println(-1);
        }
    }
}


Example test case(s):
input: 2 2

output: 25
Language: Java

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

        int[][][] info = new int[4][3][10];
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 10; k++) {
                    info[i][j][k] = 0;
                }
            }
        }

        java.util.Scanner sc = new java.util.Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            int built = sc.nextInt();
            int floor = sc.nextInt();
            int room = sc.nextInt();
            int num = sc.nextInt();
            info[built - 1][floor - 1][room - 1] += num;
        }

        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 10; k++) {
                    System.out.print(" " + info[i][j][k]);
                }
                System.out.print("\n");
            }
            if (i != 4 - 1) {
                System.out.print("####################\n");
            }
        }
    }
}


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

output:  0 0 8 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
####################
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
####################
 0 0 0 0 0 0 0 0 0 0
 0 7 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
####################
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 1 0 0
Language: Java

import java.util.*;

public class s416486483 {
    private static long split(long n, long k) {
        long sum = 0;
        while (n > 0) {
            sum += n % k;
            n /= k;
        }
        return sum;
    }

    private static long solve(long n, long s) {
        long k;
        for (k = 2; k * k <= n || k < 100; k++) {
            if (split(n, k) == s) {
                return k;
            }
        }
        while (k <= n) {
            long a = n / k;
            long b = n % k;
            if ((a + b - s) % a == 0) {
                long dk = (a + b - s) / a;
                if (dk >= 0 && b - dk * a >= 0) {
                    return k + dk;
                }
            }
            k = n / a + 1;
        }
        if (n == s) {
            return n + 1;
        }
        return -1;
    }

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long nl = s.nextLong();
        long sl = s.nextLong();
        System.out.println(solve(nl, sl));
    }
}


Example test case(s):
input: 87654
30

output: 10
Language: Java

import java.util.Scanner;

class s821112618 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] s = ".,!? :abc:def:ghi:jkl:mno:pqrs:tuv:wxyz".split(":");
        char[][] k = new char[9][];
        for (int i = 0; i < 9; i++) {
            k[i] = s[i].toCharArray();
        }
        while (n-- > 0) {
            char[] c = sc.next().toCharArray();
            int l = -1, a = 0;
            for (int i = 0; i < c.length; i++) {
                if (c[i] != '0') {
                    a = c[i] - '1';
                    l = (l + 1) % k[a].length;
                } else if (l >= 0) {
                    System.out.print(k[a][l]);
                    l = -1;
                }
            }
            System.out.println();
        }
    }
}


Example test case(s):
input: 5
20
220
222220
44033055505550666011011111090666077705550301110
000555555550000330000444000080000200004440000

output: a
b
b
hello, world!
keitai
Language: Java

import java.io.PrintWriter;
import java.util.Scanner;

public class s452855095 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        int arr[] = new int[n];
        for (int i = 0; i < n; i++) arr[i] = sc.nextInt();
        int cnt = 0;
        boolean flag = true;
        while (true) {
            for (int i = 0; i < n; i++) {
                if (arr[i] % 2 != 0) {
                    flag = false;
                    break;
                } else arr[i] = arr[i] / 2;
            }
            if (flag == true) cnt++;
            else break;
        }
        out.println(cnt);
        out.flush();
    }
}


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

output: 2
Language: Java

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

public class s916993080 {
    public static void main(String[] args) throws IOException {
        int n = sc.nextInt();
        int[][] arr = new int[n][3];
        for (int i = 0; i < n; ++i) for (int j = 0; j <= 2; ++j) arr[i][j] = sc.nextInt();
        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 j = 0; j < 3; ++j) {
                if (j == 0) dp[i][j] = Math.max(arr[i][0] + dp[i - 1][1], arr[i][0] + dp[i - 1][2]);
                if (j == 1) dp[i][j] = Math.max(arr[i][1] + dp[i - 1][0], arr[i][1] + dp[i - 1][2]);
                if (j == 2) dp[i][j] = Math.max(arr[i][2] + dp[i - 1][1], arr[i][2] + dp[i - 1][0]);
            }
        }
        int max = -1;
        for (int i = 0; i < 3; ++i) if (dp[n - 1][i] > max) max = dp[n - 1][i];
        System.out.println(max);
    }
}

class sc {
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer tokenizer = new StringTokenizer("");

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) tokenizer = new StringTokenizer(reader.readLine());
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    static float nextFloat() throws IOException {
        return Float.parseFloat(next());
    }
}


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

output: 210
Language: Java

import java.util.Scanner;

public class s577060895 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.nextLine());

        double sqrt = Math.sqrt(n);
        double nearNum = Math.floor(sqrt);

        long ans = (long) Math.pow(nearNum, 2);

        System.out.println(ans);

        sc.close();
    }
}


Example test case(s):
input: 10

output: 9
Language: Java

import java.util.Scanner;

public class s681118763 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String c = in.next();
        Character letter = c.charAt(0);
        letter++;

        System.out.println(letter);
    }
}


Example test case(s):
input: a

output: b
Language: Java

import java.util.*;

public class s321983475 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int answer = Math.max(a, b) - Math.min(a, b) - w;
        if (answer < 0) {
            System.out.println(0);
        } else {
            System.out.println(answer);
        }
    }
}


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

output: 1
Language: Java

import java.util.Scanner;

public class s933313035 {

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

        int m = sc.nextInt();

        Node tree = null;
        for (int i = 0; i < m; i++) {
            String command = sc.next();

            if (command.equals("insert")) {
                long key = sc.nextLong();
                if (tree == null) {
                    tree = new Node();
                    tree.value = key;
                } else {
                    tree.insert(key);
                }
            } else {
                if (tree != null) {
                    tree.printInOrder();
                    System.out.println();
                    tree.printPreOrder();
                    System.out.println();
                }
            }
        }
    }

    static class Node {
        long value;
        Node left;
        Node right;

        void insert(long newValue) {
            if (newValue < this.value) {
                if (left == null) {
                    left = new Node();
                    left.value = newValue;
                } else {
                    left.insert(newValue);
                }
            } else {
                if (right == null) {
                    right = new Node();
                    right.value = newValue;
                } else {
                    right.insert(newValue);
                }
            }
        }

        void printInOrder() {
            if (left != null) {
                left.printInOrder();
            }
            System.out.print(" " + value);
            if (right != null) {
                right.printInOrder();
            }
        }

        void printPreOrder() {
            System.out.print(" " + value);
            if (left != null) {
                left.printPreOrder();
            }
            if (right != null) {
                right.printPreOrder();
            }
        }
    }
}


Example test case(s):
input: 8
insert 30
insert 88
insert 12
insert 1
insert 20
insert 17
insert 25
print

output:  1 12 17 20 25 30 88
 30 12 1 20 17 25 88
Language: Java

import java.util.Scanner;

public class s257593977 {

    private static final int BASE = 3;

    public static void main(String[] args) {
        System.out.println((int) Math.pow(new Scanner(System.in).nextInt(), BASE));
    }
}


Example test case(s):
input: 2

output: 8
Language: Java

import java.util.*;

public class s063482767 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        PriorityQueue<Integer> queue = new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            queue.add(sc.nextInt());
        }
        int sum = 0;
        for (int i = 0; i < n - 1; i++) {
            sum += queue.poll();
        }

        System.out.println(queue.poll() < sum ? "Yes" : "No");
    }
}


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

output: Yes
Language: Java

import java.util.*;

public class s321216487 {
    public static void main(String[] args) throws Exception {

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

        String begin;
        String end;
        String answer;

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

            for (int j = 0; j < S.length(); j++) {

                begin = S.substring(0, i);
                end = S.substring(j, S.length());
                answer = begin + end;

                if (answer.equals("keyence")) {
                    System.out.println("YES");
                    return;

                } else if (begin.equals("keyence")) {
                    System.out.println("YES");
                    return;

                } else if (end.equals("keyence")) {
                    System.out.println("YES");
                    return;
                }
            }
        }
        System.out.println("NO");
    }
}


Example test case(s):
input: keyofscience

output: YES
Language: Java

import java.util.Scanner;

public class s125837071 {

    @SuppressWarnings("resource")
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long ans = 1;
        int mod = (int) Math.pow(10, 9) + 7;
        for (int i = 2; i <= n; i++) {
            for (int j = 2; (i % j != 0 && j < i) || j == i; j++) {
                if (j == i) {
                    int s = 0;
                    for (int k = 1; k <= n; k++) {
                        s += findS(k, i);
                    }

                    ans = (ans * (s + 1)) % mod;
                }
            }
        }
        System.out.println(ans);
    }

    private static int findS(int k, int i) {
        int s = 0;
        for (int j = k; j % i == 0; j /= i) {

            s++;
        }
        return s;
    }
}


Example test case(s):
input: 3

output: 4
Language: Java

import java.util.Scanner;

public class s937747608 {

    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 d = sc.nextInt();
        if (a * b >= c * d) {
            System.out.println(a * b);
        } else if (a * b <= c * d) {
            System.out.println(c * d);
        }
    }
}


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

output: 15
Language: Java

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

public class s221078931 {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        IntegralRect rects[] = new IntegralRect[40000];
        for (int i = 0; i < 200; i++) {
            for (int j = 0; j < 200; j++) {
                rects[i * 200 + j] = new IntegralRect(i + 1, j + 1);
            }
        }
        Arrays.sort(rects);

        while (true) {
            String[] tmpArray = br.readLine().split(" ");

            int h = Integer.parseInt(tmpArray[0]);
            int w = Integer.parseInt(tmpArray[1]);

            if (h == 0 && w == 0) {
                break;
            }

            IntegralRect tmpRect = new IntegralRect(h, w);
            int diag = tmpRect.diagonal();

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

                if (rects[i].compareTo(tmpRect) > 0) {
                    System.out.println(rects[i].height + " " + rects[i].width);
                    break;
                }
            }
        }
    }
}

class IntegralRect implements Comparable<IntegralRect> {
    int height;
    int width;

    public IntegralRect(int h, int w) {
        this.height = h;
        this.width = w;
    }

    public int diagonal() {
        if (height >= width) {
            return Integer.MAX_VALUE;
        }
        return this.height * this.height + this.width * this.width;
    }

    @Override
    public int compareTo(IntegralRect o) {

        int d1 = this.diagonal();
        int d2 = o.diagonal();

        return d1 == d2 ? this.height - o.height : d1 - d2;
    }
}


Example test case(s):
input: 1 2
1 3
2 3
1 4
2 4
5 6
1 8
4 7
98 100
99 100
0 0

output: 1 3
2 3
1 4
2 4
3 4
1 8
4 7
2 8
3 140
89 109
Language: Java

import java.util.Scanner;

public class s962361667 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] values = new int[w];
        for (int i = 0; i < values.length; i++) {
            values[i] = i + 1;
        }
        for (int i = 0; i < n; i++) {
            int x = 0;
            String str = sc.next();
            String[] ab = str.split(",");
            int a = Integer.parseInt(ab[0]) - 1;
            int b = Integer.parseInt(ab[1]) - 1;
            x = values[a];
            values[a] = values[b];
            values[b] = x;
        }
        for (int i = 0; i < w; i++) {
            System.out.println(values[i]);
        }
    }
}


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

output: 4
1
2
5
3
Language: Java

import java.util.Scanner;

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

        int n = stdIn.nextInt();
        int m = stdIn.nextInt();
        int dp[] = new int[n + 2];
        dp[n + 1] = 0;
        dp[n] = 1;
        for (int i = 0; i < m; i++) dp[stdIn.nextInt()] = -1;
        for (int i = n - 1; i >= 0; i--) {
            if (dp[i] == -1) dp[i] = 0;
            else dp[i] = (dp[i + 1] + dp[i + 2]) % 1000000007;
        }
        System.out.println(dp[0]);
    }
}


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

output: 4
Language: Java

import java.util.Scanner;

public class s505375619 {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = Integer.parseInt(s.next());
        int[] v = new int[n];
        int[] c = new int[n];
        int[] dp = new int[n];

        for (int i = 0; i < n; i++) {
            dp[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            v[i] = Integer.parseInt(s.next());
        }
        for (int i = 0; i < n; i++) {
            c[i] = Integer.parseInt(s.next());
        }

        dp[0] = 0;

        for (int i = 1; i < n; i++) {
            int tmp = dp[i - 1] + (v[i - 1] - c[i - 1]);
            dp[i] = tmp > dp[i - 1] ? tmp : dp[i - 1];
        }

        int tmp = dp[n - 1] + (v[n - 1] - c[n - 1]);
        dp[n - 1] = tmp > dp[n - 1] ? tmp : dp[n - 1];

        System.out.println(dp[n - 1]);
    }
}


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

output: 5
Language: Java

import java.util.ArrayList;
import java.util.Scanner;

public class s000087391 {
    public static void main(String[] args) {
        ArrayList<Integer> result = new ArrayList<Integer>();
        Scanner insert = new Scanner(System.in);
        int n = -1;
        while (true) {
            String line = insert.nextLine();
            n = Integer.parseInt(line);
            if (n == 0) {
                break;
            }
            for (int i = 0; i < n; i++) {}

            line = insert.nextLine();
            String array2[] = line.split(" ");
            int[] input = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                input[i] = (Integer.parseInt(array2[i]));
                sum += input[i];
            }
            double avg = (double) sum / (double) n;
            int num = 0;
            for (int i = 0; i < n; i++) {
                if (input[i] <= avg) {
                    num++;
                }
            }
            result.add(num);
        }
        for (int i = 0; i < (result.size()); i++) {
            if (result.get(i) == -1) {
                System.out.println("NONE");
            } else {
                System.out.println(result.get(i));
            }
        }
    }
}


Example test case(s):
input: 7
15 15 15 15 15 15 15
4
10 20 30 60
10
1 1 1 1 1 1 1 1 1 100
7
90 90 90 90 90 90 10
7
2 7 1 8 2 8 4
0

output: 7
3
9
1
4
Language: Java

import java.util.Scanner;

public class s682242794 {
    int high;
    int low;
    int sa;

    public void solve() {
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 7; i++) {
            high = sc.nextInt();
            low = sc.nextInt();
            sa = high - low;
            System.out.println(sa);
        }
    }

    public static void main(String[] args) {
        s682242794 obj = new s682242794();
        obj.solve();
    }
}


Example test case(s):
input: 30 19
39 20
19 18
25 20
22 21
23 10
10 -10

output: 11
19
1
5
1
13
20
Language: Java

import java.util.*;

public class s936984238 {
    static Scanner sc = new Scanner(System.in);

    static int[] score;

    static int number;

    public static void main(String[] args) {

        while (read()) {
            slove();
        }
    }

    static boolean read() {
        number = sc.nextInt();
        if (number == 0) return false;

        score = new int[number];
        for (int i = 0; i < number; i++) {
            score[i] = sc.nextInt();
        }
        return true;
    }

    static void slove() {
        java.util.Arrays.sort(score);
        int sum = 0;
        for (int i = 1; i < number - 1; i++) {
            sum = sum + score[i];
        }
        System.out.println(sum / (number - 2));
    }
}


Example test case(s):
input: 3
1000
342
0
5
2
2
9
11
932
5
300
1000
0
200
400
8
353
242
402
274
283
132
402
523
0

output: 342
7
300
326