zccneil/codelingua_dataset huggingface dataset:
assistant: s = list(input())
num_g, num_p = 0, 0
score = 0
for x in s:
    if x == 'g':
        if num_g - num_p > 0:
            score += 1
            num_p += 1
        else:
            score = score
            num_g += 1
    elif x == 'p':
        if num_g - num_p > 0:
            score = score
            num_p += 1
        else:
            score -= 1
            num_g += 1
print(score)


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

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

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String S = in.next();
            int score = 0;
            for (int i = 0; i < S.length(); i++) {
                char my = i % 2 == 0 ? 'g' : 'p';
                char his = S.charAt(i);
                if (my != his) {
                    score += my == 'p' ? 1 : -1;
                }
            }
            out.println(score);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
    }
}
assistant: import sys
import math
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)


def input():
    return sys.stdin.readline()[: - 1]


mod = 10 ** 9 + 7
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))


def Line(N, num):
    if N <= 0:
        return [[]] * num
    elif num == 1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(* read_all))


def my_sign(x):
    return (x > 0) - (x < 0)


N = I()
a = III()
max_val = 0
max_sign = 0
max_index = - 1
for i, a0 in enumerate(a):
    if abs(a0) > max_val:
        max_val = abs(a0)
        max_sign = my_sign(a0)
        max_index = i
if max_sign == 0:
    print(0)
elif max_sign == 1:
    print(2 * N - 1)
    for i in range(N):
        print(max_index + 1, i + 1)
    for i in range(N - 1):
        print(i + 1, i + 2)
else:
    print(2 * N - 1)
    for i in range(N):
        print(max_index + 1, i + 1)
    for i in range(1, N)[:: - 1]:
        print(i + 1, i)


user: import java.util.*;

public class atcoder_ARC086_B {
    public static void main(String[] $) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int[] a = new int[n];
        Arrays.setAll(a, i -> s.nextInt());
        ArrayList<String> r = new ArrayList<>();
        int m = 0;
        for (int i = 1; i < n; ++i) if (Math.abs(a[m]) < Math.abs(a[i])) m = i;
        for (int i = 0; i < n; ++i) if (a[m] >= 0 ^ a[i] >= 0) r.add(m + 1 + " " + (i + 1));
        if (a[m] >= 0) {
            for (int i = 1; i < n; ++i) r.add(i + " " + (i + 1));
        } else {
            for (int i = n; i > 1; --i) r.add(i + " " + (i - 1));
        }
        System.out.println(r.size());
        r.forEach(System.out::println);
    }
}
assistant: K, N = list(map(int, input().split()))
dprint = lambda * x: x


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


mod = 998244353
__N = 8000
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range(2, __N + 1):
    g1.append((g1[- 1] * i) % mod)
    inverse.append((- inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[- 1] * inverse[- 1]) % mod)


def kumiawase(p, q):
    return cmb(p + q - 1, q - 1, mod)


def solve(n):
    assert n <= K + 1
    ans = 0
    kumi = (n - 1) // 2
    for p in range(kumi + 1):
        if p > N:
            break
        ans += 2 ** p * cmb(kumi, p, mod) * kumiawase(N - p,
                                                      p + (K - kumi * 2 - int(n % 2 == 0)))
        if n % 2 == 0 and N - p - 1 >= 0:
            ans += 2 ** p * cmb(kumi, p, mod) * kumiawase(N -
                                                          p - 1, p + (K - kumi * 2 - int(n % 2 == 0)))
    return ans


ans = []
for i in range(2, 2 * K + 1):
    if i <= K + 1:
        tmp = solve(i) % 998244353
        ans.append(tmp)
        print(tmp)
    else:
        print(ans[- i + K])


user: import java.util.Scanner;

public class atcoder_ARC102_C {
    static int mod = 998244353;
    static long[][] nchoosek;

    public static void main(String[] args) {
        nchoosek = new long[4001][4001];
        for (int i = 0; i < nchoosek.length; i++) {
            nchoosek[i][0] = nchoosek[i][i] = 1;
        }
        for (int i = 2; i < nchoosek.length; i++) {
            for (int j = 1; j < i; j++) {
                nchoosek[i][j] = (nchoosek[i - 1][j] + nchoosek[i - 1][j - 1]) % mod;
            }
        }
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        for (int i = 2; i <= 2 * k; i++) {
            int pairs;
            if (i > k) {
                pairs = k - i / 2;
            } else {
                pairs = (i - 1) / 2;
            }
            int active = k - 2 * pairs;
            if (i % 2 == 0) active -= 1;
            long times2 = 1;
            long total = 0;
            for (int j = 0; j <= pairs; j++) {
                long choice = times2 * nchoosek[pairs][j] % mod;
                times2 = times2 * 2 % mod;
                if (active + j - 1 < 0) continue;
                total += choice * nchoosek[n + active - 1][active + j - 1];
                if (i % 2 == 0) {
                    total += choice * nchoosek[n + active - 2][active + j - 1];
                }
                total %= mod;
            }
            System.out.println(total);
        }
    }
}
assistant: n = int(input())
input_array = []
for i in range(n):
    S, R, H, C = map(int, input().split())
    input_array.append((S, R, H, C))
outdated = []
for i in range(n):
    for j in range(n):
        if (input_array[i][0] < input_array[j][0] and input_array[i][1] < input_array[j][1] and input_array[i][2] < input_array[j][2]):
            outdated.append(input_array[i])
outdated = set(outdated)
minimum_cost = 100000
input_number = 0
for i in range(n):
    current_item = input_array[i]
    cost = current_item[3]
    if (current_item not in outdated and cost < minimum_cost):
        minimum_cost = current_item[3]
        input_number = i + 1
print(input_number)


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

public class codeforces_106_B {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = input.nextInt();
        int[][] vec = new int[n][4];
        for (int i = 0; i < n; i++) {
            vec[i][0] = input.nextInt();
            vec[i][1] = input.nextInt();
            vec[i][2] = input.nextInt();
            vec[i][3] = input.nextInt();
        }
        int ans = 500;
        int ansprice = 20000;
        for (int i = 0; i < n; i++) {
            int fl = 1;
            for (int j = 0; j < n; j++) {
                if (vec[i][0] < vec[j][0] && vec[i][1] < vec[j][1] && vec[i][2] < vec[j][2]) {
                    fl = 0;
                }
            }
            if (fl == 1) {
                if (vec[i][3] < ansprice) {
                    ansprice = vec[i][3];
                    ans = i + 1;
                }
            }
        }
        System.out.println(ans);
        out.close();
    }
}
assistant: def s():
    input()
    a = list(map(int, input().split()))
    a.sort()
    for i in range(1, len(a)):
        if a[i] != a[i - 1] and a[i] < a[i - 1] * 2:
            return 'YES'
    return 'NO'


print(s())


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

public class codeforces_108_B {
    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);
        for (int i = 0; i < a.length - 1; i++) {
            if (a[i + 1] < a[i] * 2 && a[i] != a[i + 1]) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }
}
assistant: LUCKY = "abcd"
n = int(input())
s = ""
for i in range(n):
    s += LUCKY[i % 4]
print(s)


user: import java.util.*;

public class codeforces_110_B {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n, i, j, p = 97;
        n = sc.nextInt();
        char c[] = new char[n];
        for (i = 0; i < 4; i++) {
            for (j = i; j < n; j += 4) c[j] = (char) p;
            p++;
        }
        for (i = 0; i < n; i++) System.out.print(c[i]);
    }
}
assistant: n, d = map(int, input().split())
x = []
m = 0
q = 0
x = input().split()
for i in range(len(x)):
    x[i] = int(x[i])
for a in range(len(x) - 1):
    if x[a] >= x[a + 1]:
        q = int((x[a] - x[a + 1]) / d + 1)
        m = m + q
        x[a + 1] = x[a + 1] + q * d
print(m)


user: import java.util.Scanner;

public class codeforces_11_A {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int d = in.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = in.nextInt();
        }
        int result = 0;
        int a = 0;
        for (int i = 1; i < n; i++) {
            a = (nums[i - 1] - nums[i]);
            if (a >= 0) {
                result += a / d + 1;
                nums[i] += (a / d + 1) * d;
            }
        }
        System.out.println(result);
    }
}
assistant: from collections import Counter
import sys
input = sys.stdin.readline
n = int(input())
w = Counter(map(int, input().split()))
c = 0
for i in w:
    if i == 0:
        c += w[i] * (w[i] - 1)
    else:
        if - i in w:
            c += w[i] * w[- i]
print(c // 2)


user: import java.util.Scanner;

public class codeforces_131_B {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int N = (int) 1e5 + 5;
        long[] cnt = new long[21];
        for (int i = 0; i < n; i++) {
            cnt[scan.nextInt() + 10]++;
        }
        long res = 0;
        for (int i = 0; i < 10; i++) {
            res += cnt[i] * cnt[20 - i];
        }
        res += (cnt[10] * (cnt[10] - 1)) / 2;
        System.out.println(res);
    }
}
assistant: import sys
input = sys.stdin.readline
n = int(input())
w = list(map(int, input().split()))
x = sum(w)
d = []
for i in range(n):
    if (x - w[i]) / (n - 1) == w[i]:
        d.append(i + 1)
print(len(d))
print(' '.join(map(str, d)))


user: import java.util.*;

public class codeforces_134_A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
            sum += arr[i];
        }
        int c = 0;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            if ((sum - arr[i]) % (n - 1) == 0 && (sum - arr[i]) / (n - 1) == arr[i]) {
                c++;
                sb.append((i + 1) + " ");
            }
        }
        System.out.println(c);
        System.out.println(sb.toString());
    }
}
assistant: n = int(input())
number = list(map(int, list(input())))
h1 = 0
h2 = 0
x = 0
for i in range(n):
    if number[i] != 4 and number[i] != 7:
        print("NO")
        x += 1
        break
    if i < n // 2:
        h1 += number[i]
    else:
        h2 += number[i]
if not x:
    if h1 == h2:
        print("YES")
    else:
        print("NO")


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

import java.util.*;

public class codeforces_146_A {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int x = 0, y = 0;
        int t = 0;
        int n = in.nextInt();
        String str = in.next();
        char l[] = new char[str.length()];
        l = str.toCharArray();
        for (int i = 0; i < n; i++) {
            if (l[i] != '4' && l[i] != '7') {
                t = 1;
            }
        }
        if (t == 1) {
            System.out.println("NO");
        } else {
            for (int i = 0; i < n / 2; i++) {
                x = x + Character.getNumericValue(l[i]);
            }
            for (int i = n - 1; i > (n / 2) - 1; i--) {
                y = y + Character.getNumericValue(l[i]);
            }
            if (x == y) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
}
assistant: s = input()
res = []
punctuation = [',', '.', '!', '?']
for i in range(len(s)):
    if i >= 1:
        if s[i] == '':
            if res[- 1] != '':
                res.append(s[i])
            else:
                continue
        else:
            if s[i] in punctuation:
                if res[- 1] == '':
                    res.pop()
                res.append(s[i])
                res.append('')
            else:
                res.append(s[i])
    else:
        if s[i] == '':
            continue
        if s[i] in punctuation:
            continue
        else:
            res.append(s[i])
print(''.join(res))


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

public class codeforces_147_A {
    public static boolean isLatinLetter(char c) {
        return c >= 'a' && c <= 'z';
    }

    public static boolean isPunctuation(char c) {
        if (c == '.') return true;
        if (c == ',') return true;
        if (c == '!') return true;
        if (c == '?') return true;
        return false;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        String s = br.readLine();
        StringBuilder sb = new StringBuilder();
        int n = s.length();
        sb.append(s.charAt(0));
        for (int i = 1; i < n; i++) {
            char c = s.charAt(i);
            if (isLatinLetter(c)) {
                if (!isLatinLetter(s.charAt(i - 1))) {
                    sb.append(' ');
                }
                sb.append(c);
            } else if (isPunctuation(c)) {
                sb.append(c);
            }
        }
        pw.println(sb);
        pw.flush();
        pw.close();
    }
}
assistant: princess = int(input())
dragon = int(input())
t = int(input())
f = int(input())
c = int(input())
if dragon <= princess:
    print(0)
    exit(0)
result = 0
position = t * princess
position += princess * position / (dragon - princess)
while position < c:
    result += 1
    position += princess * position / dragon
    position += princess * f
    position += princess * position / (dragon - princess)
print(result)


user: import java.util.Scanner;

public class codeforces_148_B {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double VP = in.nextInt();
        double VD = in.nextInt();
        double T = in.nextInt();
        double F = in.nextInt();
        double C = in.nextInt();
        if (VD <= VP) {
            System.out.println("0");
            return;
        }
        int answer = 0;
        double start = T;
        while (true) {
            double x = start * VP / (VD - VP);
            if ((start + x) * VP >= C) {
                break;
            }
            start += 2 * x + F;
            answer++;
        }
        System.out.println(answer);
    }
}
assistant: s = input()
n = int(input())
ans = 0
for i in range(n):
    x = input()
    a, b = 0, 0
    for j in s:
        if j == x[0]:
            a += 1
        elif j == x[1]:
            b += 1
        else:
            ans = ans + min(a, b)
            a, b = 0, 0
    ans = ans + min(a, b)
print(ans)


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

public class codeforces_154_A {
    public static void main(String hi[]) throws Exception {
        BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
        char[] arr = infile.readLine().toCharArray();
        int N = arr.length;
        HashSet<String> set = new HashSet<String>();
        int K = Integer.parseInt(infile.readLine());
        int res = 0;
        for (int k = 0; k < K; k++) {
            String input = infile.readLine();
            int a = 0;
            int b = 0;
            for (int i = 0; i < N; i++) {
                if (arr[i] == input.charAt(0)) a++;
                else if (arr[i] == input.charAt(1)) b++;
                else {
                    res += Math.min(a, b);
                    a = b = 0;
                }
            }
            res += Math.min(a, b);
        }
        System.out.println(res);
    }
}
assistant: import sys
input = sys.stdin.readline
a, b = input()[: - 1].split()
x = max(len(a), len(b))
a = a.rjust(x, '0')
b = b.ljust(x, '0')
s = ''
c = 0
for i in range(x):
    d = int(b[i]) + int(a[x - i - 1]) + c
    if d > 9:
        s += str(d)[1]
        c = 1
    else:
        s += str(d)
        c = 0
if c == 1:
    s += '1'
print(int(s[:: - 1]))


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

public class codeforces_171_A {
    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;
        }
    }

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        int m = sc.nextInt();
        int t = reverse(m);
        System.out.println(t + n);
    }

    public static int reverse(int n) {
        if (n < 10) return n * 10;
        int t = n, r = 0;
        while (t > 0) {
            r = (r * 10) + t % 10;
            t = t / 10;
        }
        return r;
    }
}
assistant: def cutRibbon():
    arr = [int(i) for i in input().split()]
    length = arr[0]
    arr = sorted(arr[1: 4], reverse=False)
    if (length % arr[0] == 0):
        print(int(length / arr[0]))
        return
    ans = 0
    if (arr[0] == arr[1]):
        k = 0
        for i in range(int(length / arr[2]) + 1):
            check = length - i * arr[2]
            if (check >= 0 and check % arr[0] == 0):
                k = int(check / arr[0])
                ans = max(ans, k + i)
    else:
        k = 0
        for i in range(int(length / arr[2]) + 1):
            for j in range(int(length / arr[1]) + 1):
                check = length - i * arr[2] - j * arr[1]
                if (check >= 0 and check % arr[0] == 0):
                    k = int(check / arr[0])
                    ans = max(ans, k + i + j)
    print(ans)
    return


cutRibbon()


user: import java.util.*;

public class codeforces_189_A {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int maxn = 4010;
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int[] arr = {a, b, c};
        int[] dp = new int[maxn];
        for (int i = 0; i < n; i++) {
            dp[i] = Integer.MIN_VALUE;
        }
        dp[0] = 0;
        for (int i = 0; i < 3; i++) {
            for (int j = arr[i]; j < dp.length; j++) {
                dp[j] = Math.max(dp[j], dp[j - arr[i]] + 1);
            }
        }
        System.out.println(dp[n]);
    }
}
assistant: n, m = map(int, input().split())
if n < 1:
    if m < 1:
        print(n, m)
        quit()
    print("Impossible")
    quit()
if m > n:
    min = m
    max = n + m - 1
    print(min, max)
if m <= n:
    min = n
    max = n + m - 1
    if m == 0:
        max = n
    print(min, max)


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

public class codeforces_190_A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        if (n == 0) {
            if (m != 0) System.out.println("Impossible");
            else System.out.println(0 + " " + 0);
            return;
        }
        if (m <= n) {
            if (m == 0) {
                m = 1;
            }
            System.out.print(n + " " + (m + n - 1));
            return;
        }
        System.out.print(m + " " + (m + n - 1));
    }
}