zccneil/codelingua_dataset huggingface dataset:
assistant: n = int(input())
m = input().split()
possible = True
for i in set(m):
    if m.count(i) >= n / 2 + 1:
        possible = False
        break
print('YES' if possible else 'NO')


user: import java.io.*;
import java.util.StringTokenizer;

public class codeforces_296_A {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] array = new int[1001];
            for (int i = 0; i < n; i++) {
                int index = in.nextInt();
                array[index]++;
            }
            int countMax = -1;
            for (int i = 1; i < array.length; i++) {
                if (countMax < array[i]) countMax = array[i];
            }
            if (n % 2 == 0) {
                if (countMax <= n / 2) {
                    out.println("YES");
                } else {
                    out.println("NO");
                }
            } else {
                if (countMax <= n / 2 + 1) {
                    out.println("YES");
                } else {
                    out.println("NO");
                }
            }
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreElements()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}
assistant: def num_inp(): return int(input())


def arr_inp(): return list(map(int, input().split()))
def sp_inp(): return map(int, input().split())


a = sorted(map(int, [* open(0)][1].split()))
print([a[0], - 1][any(x % a[0] for x in a)])


user: import java.util.Arrays;
import java.util.Scanner;

public class codeforces_299_A {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        Arrays.sort(a);
        int min = a[0];
        for (int value : a) {
            if (value % min != 0) {
                System.out.println(-1);
                return;
            }
        }
        System.out.println(min);
    }
}
assistant: n, m = map(int, input().split())
sa = input().count("-")
sa = min([n - sa, sa])
ss = []
for _ in range(m):
    a, b = map(int, input().split())
    b -= a
    ss.append((b % 2 and b <= sa << 1) and "1\n" or "0\n")
print("".join(ss))


user: import java.io.IOException;
import java.util.Scanner;

public class codeforces_302_A {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int arr[] = new int[n];
        for (int i = 0; i < n; i++) arr[i] = sc.nextInt();
        StringBuffer res = new StringBuffer();
        int o = 0, e = 0;
        for (int i = 0; i < n; i++)
            if (arr[i] == 1) ++o;
            else ++e;
        for (int i = 0; i < k; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            if ((r - l + 1) % 2 == 1) res.append("0\n");
            else {
                if ((r - l + 1) / 2 <= o && (r - l + 1) / 2 <= e) res.append("1\n");
                else res.append("0\n");
            }
        }
        System.out.print(res);
        sc.close();
    }
}
assistant: n, m = map(int, input().split())
q = n // m
r = n % m
a = [q] * m
for i in range(r):
    a[i] += 1
for i in range(m):
    print(a[i], end=' ')


user: import java.util.Scanner;

public class codeforces_306_A {
    public static Scanner input = new Scanner(System.in);

    public static void main(String[] args) {
        int n = input.nextInt();
        int m = input.nextInt();
        int a[] = new int[m];
        if (n % m == 0) {
            for (int i = 0; i < a.length; i++) {
                a[i] = n / m;
            }
        } else {
            int sub = n / m;
            for (int i = 0; i < a.length; i++) {
                a[i] = sub;
            }
            int test = n - (sub * m);
            int count = 0;
            for (int i = 0; i < test; i++) {
                a[count] = a[count] + 1;
                count++;
                if (count > +a.length) count = 0;
            }
        }
        for (int i = (a.length - 1); i >= 0; i--) {
            System.out.print(a[i] + " ");
        }
    }
}
assistant: def task4(A, B, n):
    for X in range(- 1000, 1001):
        if A * (X ** n) == B:
            return X
    return "No solution"


[A, B, n] = input().split()
print(task4(int(A), int(B), int(n)))


user: import java.util.*;

public class codeforces_30_A {
    public static void main(String[] args) {
        new codeforces_30_A().solve(new Scanner(System.in));
    }

    private void solve(Scanner sc) {
        int A = sc.nextInt(), B = sc.nextInt(), n = sc.nextInt();
        if (A == 0) {
            if (B == 0) System.out.println(1);
            else System.out.println("No solution");
            return;
        }
        if (B % A != 0) {
            System.out.println("No solution");
            return;
        }
        B /= A;
        boolean neg = B < 0;
        if (neg && n % 2 == 0) {
            System.out.println("No solution");
            return;
        }
        if (neg) B = -B;
        for (int x = 0; x <= B; x++) {
            if (Math.pow(x, n) == B) {
                System.out.println(neg ? -x : x);
                return;
            }
        }
        System.out.println("No solution");
    }
}
assistant: soz = input()
a = [0] * (len(soz) + 1)
for i in range(1, len(soz)):
    a[i] = a[i - 1]
    if soz[i - 1] == soz[i]:
        a[i] += 1
n = int(input())
arr = []
for i in range(n):
    m, l = input().split()
    arr.append(a[int(l) - 1] - a[int(m) - 1])
for i in arr:
    print(i)


user: import java.io.*;
import java.util.StringTokenizer;

public class codeforces_313_B {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
        Fast f = new Fast();
        f.sol(br, pw);
        pw.close();
    }
}

class Fast {
    public void sol(BufferedReader br, PrintWriter pw) throws IOException {
        StringTokenizer st = new StringTokenizer(br.readLine());
        String s = st.nextToken();
        Integer cum[] = new Integer[s.length() + 1];
        cum[0] = cum[s.length()] = 0;
        for (int i = 1; i < s.length(); i++) {
            if (s.charAt(i) == s.charAt(i - 1)) cum[i] = cum[i - 1] + 1;
            else cum[i] = cum[i - 1];
        }
        st = new StringTokenizer(br.readLine());
        Integer q = Integer.parseInt(st.nextToken());
        while (q-- != 0) {
            st = new StringTokenizer(br.readLine());
            Integer l = Integer.parseInt(st.nextToken()), r = Integer.parseInt(st.nextToken()) - 1;
            pw.println(cum[r] - cum[l - 1]);
        }
    }
}
assistant: y = int(input())
arr = [int(i) for i in input().split()]
for i in range(len(arr)):
    for j in range(len(arr)):
        if i == j:
            continue
        for k in range(len(arr)):
            if arr[k] != arr[j] and arr[k] != arr[i] and arr[k] == arr[i] + arr[j]:
                print(k + 1, j + 1, i + 1)
                exit()
print(- 1)


user: import java.util.*;

public class codeforces_31_A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int f = 0;
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int k = 0, j = 0, i = 0;
        for (k = 0; k < n; k++) {
            int t = a[k];
            for (i = 0; i < n; i++) {
                for (j = 0; j < n - 1; j++) {
                    if (i != j && t == (a[i] + a[j])) {
                        f = 1;
                        break;
                    }
                }
                if (f == 1) break;
            }
            if (f == 1) break;
        }
        if (f == 1) System.out.println(k + 1 + " " + (j + 1) + " " + (i + 1));
        else System.out.println("-1");
    }
}
assistant: import itertools


def find(s, ch):
    return [i for i, ltr in enumerate(s) if ltr == ch]


if __name__ == '__main__':
    n = int(input())
    s = input().replace("", "")
    if '0' not in s:
        print(n - 1)
    else:
        indices = find(s, '0')
        if len(indices) == 1:
            print(n)
        else:
            maximum = 0
            combs = itertools.combinations(indices, 2)
            for x in combs:
                maximum = max(
                    maximum, 2 + 2 * (abs(indices.index(x[0]) - indices.index(x[1])) - 1) - (abs(x[0] - x[1]) - 1))
            print(s.count('1') + maximum)


user: import java.util.Scanner;

public class codeforces_327_A {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        if (scanner.hasNext()) {
            int n = scanner.nextInt();
            int arr[] = new int[n];
            for (int i = 0; i < n; i++) arr[i] = scanner.nextInt();
            int max = Integer.MIN_VALUE;
            for (int i = 0; i < n; i++) {
                for (int j = i; j < n; j++) {
                    int x = 0;
                    int brr[] = new int[n];
                    for (int k : arr) brr[x++] = k;
                    for (int k = i; k <= j; k++) {
                        if (brr[k] == 0) brr[k] = 1;
                        else brr[k] = 0;
                    }
                    int count = checKNo(brr);
                    if (count > max) max = count;
                }
            }
            if (n == 1) {
                if (arr[0] == 1) System.out.println(0);
                else System.out.println(1);
            } else {
                System.out.println(max);
            }
        }
    }

    private static int checKNo(int[] brr) {
        int val = 0;
        for (int i : brr) if (i == 1) ++val;
        return val;
    }
}
assistant: s = input()
result = ""
i = 0
while i < len(s):
    if s[i] == ".":
        result += '0'
    else:
        i += 1
        if s[i] == ".":
            result += '1'
        else:
            result += '2'
    i += 1
print(result)


user: import java.util.Scanner;

public class codeforces_32_B {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] n = in.next().toCharArray();
        boolean s = false;
        for (int i = 0; i < n.length; i++) {
            if (n[i] == '.') {
                if (s) {
                    System.out.print(1);
                    s = false;
                } else {
                    System.out.print(0);
                }
            } else {
                if (s) {
                    System.out.print(2);
                    s = false;
                } else {
                    s = true;
                }
            }
        }
        in.close();
    }
}
assistant: I = input
n, m = map(int, I().split())
b = [1] * n * 2
b[0] = b[n - 1] = b[n] = b[2 * n - 1] = 0
for i in range(m):
    r, c = map(int, I().split())
    b[r - 1] = b[n + c - 1] = 0
if n % 2 and b[n // 2] and b[n + n // 2]:
    b[n // 2] = 0
print(sum(b))


user: import static java.lang.Math.*;

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

public class codeforces_333_B {
    public static FastReader in = new FastReader();
    public static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt(), m = in.nextInt();
        Set<Integer> bannedRows, bannedCols;
        bannedRows = new HashSet<>();
        bannedCols = new HashSet<>();
        for (int i = 0; i < m; i++) {
            int r = in.nextInt();
            if (r > 1 && r < n) bannedRows.add(r);
            int c = in.nextInt();
            if (c > 1 && c < n) bannedCols.add(c);
        }
        int answer = (n - 2) * 2;
        answer -= bannedRows.size();
        answer -= bannedCols.size();
        if (n % 2 != 0) {
            int mid = (n + 1) / 2;
            if (!bannedRows.contains(mid) && !bannedCols.contains(mid)) {
                answer--;
            }
        }
        out.println(answer);
        out.close();
    }

    public static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}
assistant: n = int(input())
i, j = 1, n * n
while i < j:
    print(i, j)
    i += 1
    j -= 1


user: import java.io.*;
import java.util.*;

public class codeforces_334_A {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = in.nextInt();
        int square = n * n;
        ArrayList<Integer> odd = new ArrayList<>();
        ArrayList<Integer> even = new ArrayList<>();
        for (int i = 1; i <= square; i++) {
            if (i % 2 == 0) {
                even.add(i);
            } else {
                odd.add(i);
            }
        }
        int loop = square / n;
        int div = loop / 2;
        debug(div);
        for (int i = 1; i <= loop; i++) {
            for (int j = 0; j < div; j++) {
                if (i % 2 == 1) {
                    pw.print(odd.remove(0) + " " + (even.remove(even.size() - 1)) + " ");
                } else {
                    pw.print(even.remove(0) + " " + (odd.remove(odd.size() - 1)) + " ");
                }
            }
            pw.println();
        }
        pw.close();
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}
assistant: def G(a, b):
    while a % b != 0:
        a, b = b, a % b
    return b


def L(a, b):
    return a * b // G(a, b)


l = input().split(' ')
x, y, a, b = int(l[0]), int(l[1]), int(l[2]), int(l[3])
lcm = L(x, y)
print(b // lcm - (a - 1) // lcm)


user: import java.util.Scanner;

public class codeforces_340_A {
    public static void main(String[] sh) {
        Scanner s = new Scanner(System.in);
        long x = s.nextInt();
        long y = s.nextInt();
        long a = s.nextInt();
        long b = s.nextInt();
        long j = 2, i, x1 = 0, y1 = 0, c = 0;
        boolean ans = true;
        c = Math.max(x, y);
        if (c > b) {
            System.out.println("0");
            ans = false;
        }
        while (c % Math.min(x, y) != 0 && ans) {
            if (x > y) {
                c = x * j;
                j++;
            } else {
                c = y * j;
                j++;
            }
            if (c > b) {
                System.out.println("0");
                ans = false;
                break;
            }
        }
        if (ans) {
            long count = 0;
            i = a;
            for (i = a; i <= b; i++) {
                if (i % c == 0) break;
            }
            if (i != b + 1) System.out.println(((b - i) / c) + 1);
            else System.out.println("0");
        }
    }
}
assistant: def R(): return map(int, input().split())


n, m, s, f = R()
if s < f:
    d = 1
    c = 'R'
else:
    d = - 1
    c = 'L'
res = ""
i = 1
j = s
t, l, r = R()
k = 1
while j != f:
    if i > t and k < m:
        t, l, r = R()
        k += 1
    if i == t and (l <= j <= r or l <= j + d <= r):
        res += 'X'
    else:
        res += c
        j += d
    i += 1
print(res)


user: import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;

public class codeforces_342_B {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String input[] = reader.readLine().split(" ");
        int m = Integer.parseInt(input[1]);
        int s = Integer.parseInt(input[2]);
        int f = Integer.parseInt(input[3]);
        int maxT = -1;
        HashMap<Integer, ArrayList<Integer>> map = new HashMap<>();
        while (m > 0) {
            String mth[] = reader.readLine().split(" ");
            int k = Integer.parseInt(mth[0]);
            map.put(k, new ArrayList<>());
            map.get(k).add(Integer.parseInt(mth[1]));
            map.get(k).add(Integer.parseInt(mth[2]));
            maxT = Math.max(maxT, k);
            m--;
        }
        StringBuilder actions = new StringBuilder();
        final char M = (s < f) ? 'R' : 'L';
        int d = (s < f) ? +1 : -1;
        int cur = s;
        int a = -1;
        int b = -1;
        for (int t = 1; t <= maxT; t++) {
            if (map.containsKey(t)) {
                a = map.get(t).get(0).intValue();
                b = map.get(t).get(1).intValue();
            }
            if (map.containsKey(t) && ((cur >= a && cur <= b) || (cur + d >= a && cur + d <= b))) {
                actions.append('X');
            } else {
                actions.append(M);
                cur += d;
            }
            if (cur == f) break;
        }
        while (cur != f) {
            actions.append(M);
            cur += d;
        }
        System.out.println(actions);
    }
}
assistant: n = int(input())
t = [0] + list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
ans, cnt = [], [0 for i in range(n + 1)]
for i in a:
    cnt[i] += 1
for i in range(1, n + 1):
    if t[i] == 1:
        crt = [i]
        x = a[i]
        while cnt[x] == 1:
            crt.append(x)
            x = a[x]
        if len(crt) > len(ans):
            ans = crt[:]
ans.reverse()
print(len(ans))
print(' '.join(map(str, ans)))


user: import java.io.*;
import java.util.*;

public class codeforces_350_B {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int a[] = new int[n + 1];
        int b[] = new int[n + 1];
        int num[] = new int[n + 1];
        for (int i = 1; i <= n; i++) a[i] = scanner.nextInt();
        for (int i = 1; i <= n; i++) b[i] = scanner.nextInt();
        for (int i = 1; i <= n; i++) num[b[i]]++;
        String ss = "";
        int ans = 0;
        boolean st[] = new boolean[n + 1];
        for (int i = 1; i <= n; i++) {
            if (a[i] == 1) {
                st[i] = true;
                StringBuilder sb = new StringBuilder();
                int x = b[i];
                StringBuilder sss = new StringBuilder();
                sss.append(i);
                sb.append(" " + sss.reverse());
                int s = 1;
                while (!st[x] && num[x] == 1 && x != 0 && a[x] != 1) {
                    sss = new StringBuilder();
                    sss.append(x);
                    sb.append(" " + sss.reverse());
                    st[x] = true;
                    x = b[x];
                    s++;
                }
                if (s > ans) {
                    ans = s;
                    ss = sb.reverse().toString();
                }
            }
        }
        System.out.println(ans);
        System.out.println(ss);
    }
}
assistant: n = int(input())
arr = list(map(float, input().split()))
arr = sorted([x - int(x) for x in arr if x - int(x) != 0])
o = 2 * n - len(arr)
arr_sum = sum(arr)
res = int(2e9)
for i in range(n + 1):
    if i + o >= n:
        res = min(res, abs(i - arr_sum))
print("%.3f" % res)


user: import java.io.*;
import java.util.*;

public final class codeforces_351_A {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        int n = Integer.parseInt(br.readLine());
        StringTokenizer st = new StringTokenizer(br.readLine());
        Double[] arr = new Double[2 * n];
        int non_int = 0;
        double sum_before = 0, sum = 0;
        for (int i = 0; i < 2 * n; i++) {
            double num = Double.parseDouble(st.nextToken());
            sum_before += num;
            if (num != Math.floor(num)) non_int++;
            sum += Math.floor(num);
            arr[i] = num;
        }
        double max_sum = Math.min(n, non_int) + sum;
        double min_sum = Math.max(0, non_int - n) + sum;
        double ans;
        if (min_sum > sum_before) ans = (min_sum - sum_before);
        else if (max_sum < sum_before) ans = (sum_before - max_sum);
        else {
            double x = sum_before - Math.floor(sum_before);
            ans = Math.min(1 - x, x);
        }
        System.out.printf("%.3f", ans);
    }
}
assistant: n, L, R, QL, QR = map(int, input().split())
W = list(map(int, input().split()))
sum_el = [0]
for i in range(1, n + 1):
    sum_el.append(W[i - 1] + sum_el[i - 1])
answer = QR * (n - 1) + sum_el[n] * R
for i in range(1, n + 1):
    energy = L * sum_el[i] + R * (sum_el[n] - sum_el[i])
    if i > (n - i):
        energy = energy + (i - (n - i) - 1) * QL
    elif (n - i) > i:
        energy = energy + ((n - i) - i - 1) * QR
    if energy < answer:
        answer = energy
print(answer)


user: import java.util.Scanner;

public class codeforces_354_A {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int L = in.nextInt();
        int R = in.nextInt();
        int QL = in.nextInt();
        int QR = in.nextInt();
        int[] W = new int[N];
        int[] sum = new int[N + 1];
        for (int n = 0; n < N; n++) {
            W[n] = in.nextInt();
            sum[n + 1] = sum[n] + W[n];
        }
        long min = Long.MAX_VALUE;
        for (int firstR = 0; firstR <= N; firstR++) {
            int lCount = firstR;
            int rCount = N - lCount;
            long cand = sum[lCount] * L + (sum[N] - sum[lCount]) * R;
            int llCount = Math.max(0, lCount - rCount - 1);
            int rrCount = Math.max(0, rCount - lCount - 1);
            cand += llCount * QL;
            cand += rrCount * QR;
            min = Math.min(cand, min);
        }
        System.out.println(min);
    }
}