zccneil/codelingua_dataset huggingface dataset:
assistant: xxs = input().split(" ")
x, t, a, b, da, db = int(xxs[0]), int(xxs[1]), int(
    xxs[2]), int(xxs[3]), int(xxs[4]), int(xxs[5])


def main():
    if x == 0:
        print("YES")
        return "Result Found"
    a_time = min([a // da, t - 1])
    b_time = min([b // db, t - 1])
    for i in range(a_time + 1):
        for j in range(b_time + 1):
            if a - da * i == x or b - db * j == x:
                print("YES")
                return "Result Found"
            if (a - da * i) + (b - db * j) == x:
                print("YES")
                return "Result Found"
    return "Result Not Found"


ff = main()
if ff == "Result Not Found":
    print("NO")


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

public class codeforces_203_A {
    private void solve() {
        int x = nextInt();
        int t = nextInt();
        int a = nextInt();
        int b = nextInt();
        int da = nextInt();
        int db = nextInt();
        int first;
        int second;
        boolean ok = false;
        for (int i = 0; i < t; i++) {
            first = a - (da * i);
            for (int j = 0; j < t; j++) {
                second = b - (db * j);
                if (second + first == x || second == x || first == x || x == 0) {
                    ok = true;
                    break;
                }
            }
        }
        if (ok) out.print("YES");
        else out.print("NO");
    }

    public static void main(String[] args) {
        new codeforces_203_A().run();
    }

    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;

    private void run() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            br.close();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

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

    private String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
                return "END_OF_FILE";
            }
        }
        return st.nextToken();
    }
}
assistant: def solve_case():
    n, m = map(int, input().split())
    count = [None] * n
    for i in range(n):
        count[i] = [0] * n
    ans = - 1
    for k in range(m):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        found = False
        for i in range(x - 2, x + 1):
            for j in range(y - 2, y + 1):
                if i >= 0 and i < n and j >= 0 and j < n:
                    count[i][j] += 1
                    if count[i][j] == 9:
                        found = True
        if found:
            ans = k + 1
            break
    print(ans)


solve_case()


user: import java.util.Scanner;

public class codeforces_203_B {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int M = in.nextInt();
        int[][] black = new int[N + 2][N + 2];
        for (int m = 1; m <= M; m++) {
            int x = in.nextInt();
            int y = in.nextInt();
            for (int xx = x - 1; xx <= x + 1; xx++) {
                for (int yy = y - 1; yy <= y + 1; yy++) {
                    if (++black[xx][yy] == 9) {
                        System.out.println(m);
                        return;
                    }
                }
            }
        }
        System.out.println("-1");
    }
}
assistant: def readInts(): return map(int, input().split())


def dfs(g, seen, i):
    if i in seen:
        return 0, 0
    seen.add(i)
    nodes = 1
    edges = len(g[i])
    for j in g[i]:
        x, y = dfs(g, seen, j)
        nodes += x
        edges += y
    return nodes, edges


def solve():
    line0 = []
    try:
        line0 = readInts()
    except EOFError:
        return False
    n, m = line0
    g = {}
    seen = set()
    for i in range(1, n + 1):
        g[i] = set()
    for _ in range(m):
        a, b = readInts()
        g[a].add(b)
        g[b].add(a)
    ans = 0
    for i in range(1, n + 1):
        if i not in seen:
            nodes, edges = dfs(g, seen, i)
            if nodes > 1 and nodes % 2 == 1 and 2 * nodes == edges:
                ans += 1
    if (n - ans) % 2 == 1:
        ans += 1
    print(ans)
    return True


while solve():
    pass


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

public class codeforces_216_B {
    int count;
    boolean[] seen;
    int path = 0, cycle = 1;
    LinkedList<LinkedList<Integer>> graph;

    public int dfs(int child, int par) {
        if (seen[child] == true) return cycle;
        seen[child] = true;
        for (Integer i : graph.get(child)) {
            if (i != par) {
                this.count++;
                if (dfs(i, child) == cycle) return cycle;
            }
        }
        return path;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        codeforces_216_B ft = new codeforces_216_B();
        ft.graph = new LinkedList<>();
        for (int i = 0; i <= m; i++) {
            ft.graph.add(new LinkedList<Integer>());
        }
        ft.seen = new boolean[m + 1];
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            ft.graph.get(x).add(y);
            ft.graph.get(y).add(x);
        }
        int toremove = 0;
        for (int i = 1; i <= m; i++) {
            if (!ft.seen[i]) {
                ft.count = 0;
                if (ft.dfs(i, 0) == ft.cycle) {
                    if (ft.count % 2 == 1) toremove++;
                }
            }
        }
        if ((m - toremove) % 2 == 1) toremove++;
        System.out.println(toremove);
    }
}
assistant: def main():
    n, k = list(map(int, input().split(' ')))
    elems = list(map(int, input().split(' ')))
    def all_same(arr): return all([x == arr[0] for x in arr])
    if all_same(elems):
        print(0)
        return
    if k == 1:
        print(- 1)
        return
    if not all_same(elems[k - 1:]):
        print(- 1)
        return
    target = elems[- 1]
    to_delete = elems[0: k - 1]
    while to_delete and to_delete[- 1] == target:
        to_delete.pop()
    print(len(to_delete))


if __name__ == "__main__":
    main()


user: import java.util.*;

public class codeforces_222_A {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), k = in.nextInt(), l = 0, c = 1;
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            if (a == l) c += 1;
            else c = 1;
            l = a;
        }
        if (c + k > n) System.out.println(n - c);
        else System.out.println(-1);
    }
}
assistant: n = int(input())
c = 0
for i in range(n):
    l1 = list(map(int, input().split()))
    if sum(l1) > 1:
        c = c + 1
print(c)


user: import java.util.Scanner;

public class codeforces_231_A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int count = 0;
        while (t-- > 0) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            if ((a == 1 && b == 1)
                    || (a == 1 && c == 1)
                    || (b == 1 && c == 1)
                    || (a == 1 && b == 1 && c == 1)) {
                count++;
            }
        }
        System.out.println(count);
    }
}
assistant: n = int(input())
for i in range(n):
    a = int(input())
    if a < 2:
        print(0)
    if a >= 2:
        print(a - 2)


user: import java.util.Scanner;

public class codeforces_23_B {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int t = scan.nextInt();
        for (int i = 0; i < t; i++) {
            int n = scan.nextInt();
            System.out.println(maxLeft(n));
        }
    }

    public static int maxLeft(int n) {
        return n > 2 ? n - 2 : 0;
    }
}
assistant: x, y, a, b = map(int, input().split())
games = []
for i in range(a, x + 1):
    if (i <= b):
        continue
    else:
        for j in range(b, y + 1):
            if i > j:
                games.append((i, j))
print(len(games))
for i in games:
    print(f"{i[0]} {i[1]}")


user: import java.util.Scanner;

public class codeforces_242_A {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x, y, a, b;
        x = in.nextInt();
        y = in.nextInt();
        a = in.nextInt();
        b = in.nextInt();
        int count = 0;
        for (int i = a; i <= x; i++) {
            for (int j = b; j <= y; ++j) {
                if (i <= j) continue;
                count++;
            }
        }
        System.out.println(count);
        for (int i = a; i <= x; i++) {
            for (int j = b; j <= y; ++j) {
                if (i <= j) continue;
                System.out.println(i + " " + j);
            }
        }
        in.close();
    }
}
assistant: import os
import sys
import io
import math
from tokenize import Triple
from math import *
def I(): return [* map(int, sys.stdin.readline().split())]
def IS(): return input()


def IN(): return int(input())
def IF(): return float(input())


n = IN()
id = 0
l, r = map(int, input().split())
for i in range(1, n):
    li, ri = map(int, input().split())
    if li <= l and r <= ri:
        id = i
    elif li < l or r < ri:
        id = n
    l = min(l, li)
    r = max(r, ri)
print(- 1 if id == n else id + 1)


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

public class codeforces_242_B {
    static final int INF = (int) 1e9 + 5;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n;
        n = sc.nextInt();
        ArrayList<Integer> a = new ArrayList<>();
        ArrayList<Integer> b = new ArrayList<>();
        int left = INF, right = 0;
        for (int i = 0; i < n; i++) {
            a.add(sc.nextInt());
            b.add(sc.nextInt());
            left = Math.min(left, a.get(i));
            right = Math.max(right, b.get(i));
        }
        for (int i = 0; i < n; i++) {
            if (left == a.get(i) && right == b.get(i)) {
                System.out.println(++i);
                return;
            }
        }
        System.out.println(-1);
    }
}
assistant: n = int(input())
list = [int(x) % 2 for x in input().split()]
if sum(list) == 1:
    print(list.index(1) + 1)
else:
    print(list.index(0) + 1)


user: import java.util.Scanner;

public class codeforces_25_A {
    public static void main(String[] args) {
        Scanner ob = new Scanner(System.in);
        int n = ob.nextInt();
        int array[] = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            array[i] = ob.nextInt();
        }
        int odd = 0, even = 0, odd_ind = 0, even_ind = 0;
        for (int i = 1; i <= n; i++) {
            if (array[i] % 2 == 0) {
                even++;
                even_ind = i;
            } else {
                odd++;
                odd_ind = i;
            }
        }
        if (odd > even) System.out.println(even_ind);
        else System.out.println(odd_ind);
    }
}
assistant: n = int(input())
l = []
for i in range(n):
    l.append(int(input()))
ans = n - 1
last = 0
for i in l:
    ans += abs(last - i) + 1
    last = i
print(ans)


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

public class codeforces_265_B {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = scn.nextInt();
        }
        int ans = arr[0] + 1;
        for (int i = 1; i < arr.length; i++) {
            ans += Math.abs(arr[i] - arr[i - 1]) + 2;
        }
        System.out.println(ans);
    }
}
assistant: def substract(a, b):
    if a > b:
        total = 0
        while a > 0 and b > 0:
            total += int(a / b)
            a = a % b
            if a > 0:
                total += int(b / a)
                b = b % a
        return total
    if a < b:
        total = 0
        while a > 0 and b > 0:
            total += int(b / a)
            b = b % a
            if b > 0:
                total += int(a / b)
                a = a % b
        return total
    if a == b:
        return 1


n = int(input())
lst = []
for i in range(0, n):
    a, b = map(int, input().split())
    lst.append(substract(a, b))
for i in lst:
    print(i)


user: import java.util.Scanner;

public class codeforces_267_A {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        for (int i = 0; i < n; i++) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            System.out.println(sub(a, b));
        }
    }

    public static int sub(int a, int b) {
        int min = Math.min(a, b);
        int max = Math.max(a, b);
        int result = 0;
        while (min > 0) {
            result += max / min;
            max = max % min;
            int curr_min = Math.min(min, max);
            int curr_max = Math.max(min, max);
            min = curr_min;
            max = curr_max;
        }
        return result;
    }
}
assistant: n = int(input())
q = []
count = 0
for i in range(n):
    a = input().split()
    q.append(a)
for j in q:
    for k in q:
        if k == j:
            continue
        elif j[0] == k[len(k) - 1]:
            count += 1
        else:
            continue
print(count)


user: import java.util.*;

public class codeforces_268_A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        int result = 0;
        int[] h = new int[n];
        int[] g = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
            g[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (h[i] == g[j]) result++;
        System.out.println(result);
    }
}
assistant: def main():
    input()
    return nPairsWithCommonFX(map(int, input().split()))


def nPairsWithCommonFX(sequence):
    storage = {}
    FXs = []
    for value in sequence:
        y = f(value)
        if y not in storage:
            storage[y] = [value]
            FXs.append(y)
        else:
            storage[y].append(value)
    return (sum(len(storage[y]) * len(storage[y]) for y in FXs) - sum(len(storage[y]) for y in FXs)) // 2


def f(n):
    y = 1
    while n != 1:
        if n % 2:
            y += 1
        n //= 2
    return y


if __name__ == '__main__':
    print(main())


user: import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class codeforces_272_B {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        int a[] = new int[33];
        for (int i = 0; i < n; i++) {
            a[rec(sc.nextInt())]++;
        }
        double answer = 0;
        for (int i = 0; i < a.length; i++) {
            double summ = (1 + a[i] - 1) / 2.0 * (a[i] - 1);
            answer += summ;
        }
        out.println((long) answer);
        out.close();
    }

    static int rec(long x) {
        int answer = 0;
        for (int k = 31; k >= 0; k--) {
            if ((x & (1 << k)) != 0) answer++;
        }
        return answer;
    }

    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: num, k = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
different = set()
temp = 0
arr.sort()
for x in arr:
    if (x % k != 0 or not x // k in different):
        different.add(x)
    temp = max(len(different), temp)
print(temp)


user: import java.util.*;

public class codeforces_274_A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        long[] arr = new long[n];
        HashSet<Long> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextLong();
        }
        Arrays.sort(arr);
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (arr[i] % k != 0) {
                count++;
                set.add(arr[i]);
            } else if (!set.contains(arr[i] / k)) {
                count++;
                set.add(arr[i]);
            }
        }
        System.out.println(count);
    }
}
assistant: s = list(input())
x = True
dt = {}
for i in s:
    if i in dt:
        dt[i] += 1
    else:
        dt[i] = 1
cnt = 0
x = True
for key, value in dt.items():
    if value % 2 != 0 and cnt < 1:
        cnt += 1
    elif value % 2 != 0 and cnt >= 1:
        x = False
        break
if x:
    print("First")
elif not x and len(s) % 2 == 0:
    print("Second")
elif not x and len(s) % 2 != 0:
    print("First")


user: import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class codeforces_276_B {
    public static void main(String[] args) throws NumberFormatException, IOException {
        InputStreamReader inputStreamReader = new InputStreamReader(System.in);
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
        PrintWriter writer = new PrintWriter(System.out);
        String str = bufferedReader.readLine();
        Map<Character, Integer> map = new HashMap<>();
        int oddCount = 0;
        for (int i = 0; i < str.length(); i++) {
            char ch = str.charAt(i);
            if (map.containsKey(ch)) {
                map.put(ch, map.get(ch) + 1);
            } else {
                map.put(ch, 1);
            }
        }
        for (Map.Entry<Character, Integer> entry : map.entrySet()) {
            if (entry.getValue() % 2 != 0) {
                oddCount++;
            }
        }
        if (oddCount <= 1 || oddCount % 2 != 0) {
            writer.println("First");
        } else {
            writer.println("Second");
        }
        writer.flush();
    }
}
assistant: firstline = int(input())
total = 0
memory = []
for x in range(firstline):
    A, G = list(map(int, input().split()))
    if total + A <= 500:
        total += A
        memory.append("A")
    else:
        total -= G
        memory.append("G")
print("".join(memory))


user: import java.util.*;

public class codeforces_282_B {
    public static void main(String arg[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char ch[] = new char[n];
        int s1 = 0, s2 = 0;
        int i, j = 0, flag = 0, dif = 0;
        for (i = 0; i < n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int temp1 = s1 + x;
            int temp2 = s2 + y;
            if (Math.abs(temp1 - s2) <= 500) {
                s1 += x;
                ch[j++] = 'A';
                continue;
            }
            if (Math.abs(temp2 - s1) <= 500) {
                s2 += y;
                ch[j++] = 'G';
                continue;
            }
            flag = 1;
            break;
        }
        if (flag == 1) System.out.println(-1);
        else {
            String ans = "";
            ans = ans.valueOf(ch);
            System.out.println(ans);
        }
    }
}
assistant: t = []
for i in range(4):
    l = list(map(str, input()))
    t.append(l)
black = 0
white = 0
correct = 0
for i in range(3):
    for j in range(3):
        if t[i][j] == '#':
            black += 1
        else:
            white += 1
        if t[i][j + 1] == '#':
            black += 1
        else:
            white += 1
        if t[i + 1][j] == '#':
            black += 1
        else:
            white += 1
        if t[i + 1][j + 1] == '#':
            black += 1
        else:
            white += 1
        if (black == 0 or black == 3 or white == 0 or white == 3 or white == 4 or black == 4):
            correct = 1
            break
        black = 0
        white = 0
if correct == 1:
    print('YES')
else:
    print('NO')


user: import java.util.*;

public class codeforces_287_A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] str = new String[4];
        int i = -1;
        while (i != 3) {
            i = i + 1;
            str[i] = sc.next();
        }
        int u = -1;
        i = -1;
        int yes = 0;
        while (u != 2) {
            u = u + 1;
            i = -1;
            while (i != 2) {
                i = i + 1;
                if ((str[u].charAt(i) == str[u].charAt(i + 1)
                                && (str[u + 1].charAt(i) == str[u].charAt(i)
                                        || str[u + 1].charAt(i + 1) == str[u].charAt(i)))
                        || (str[u + 1].charAt(i) == str[u + 1].charAt(i + 1)
                                && (str[u].charAt(i) == str[u + 1].charAt(i)
                                        || str[u].charAt(i + 1) == str[u + 1].charAt(i)))) {
                    yes = 1;
                    System.out.println("YES");
                    break;
                }
            }
            if (yes == 1) {
                break;
            }
        }
        if (yes == 0) {
            System.out.println("NO");
        }
    }
}