akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int dp[120][10200] = {};
int main() {
	int A, B;
	cin >> A >> B;
	if (A + B >= 10) {
		cout << "error";
	}
	else {
		cout << A + B;
	}
}

Measured memory_bytes: 256
N = int(input())
ans, B_, _A, B_A = 0, 0, 0, 0
for i in range(N):
  s = input()
  if s[0] == 'B' and s[-1] == 'A':
    B_ += 1
    _A += 1
    B_A += 1
  elif s[0] == 'B':
    B_ += 1
  elif s[-1] == 'A':
    _A += 1
  for j in range(len(s) - 1):
    if s[j:j + 2] == 'AB':
      ans += 1
if B_ == B_A and _A == B_A and B_ != 0:
  ans += B_ - 1
else:
  ans += min(B_, _A)
print(ans)

Measured memory_bytes: 3064
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
/*
template <typename T>  using ordered_set =
    tree<T, null_type, less<T>,   /// greater<T> for sorting decreasingly
    rb_tree_tag, tree_order_statistics_node_update>;
*/

#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         mod                         1000000007
#define         INF                         2e18
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;

#define lim 100005
ll a[lim],fr[lim],rev[lim];
int main(){
   ll n;
   sfl(n);
   FOR(i,n){
       sfl(a[i]);
   }
   FOR(i,n) fr[i]=__gcd(fr[i-1],a[i]);
   for(ll i=n;i>=1;i--){
       rev[i]=__gcd(rev[i+1],a[i]);
   }
   ll ans=1;
   for(ll i=1;i<=n;i++){
       ans = max(ans,__gcd(fr[i-1],rev[i+1]));
   }
   pfl(ans);
   return 0;
}

Measured memory_bytes: 2560
#include"bits/stdc++.h"
using namespace std;

int main() {
	string S;
	cin >> S;
	int count = 0;
	S[0] == '+' ? count += 1 : count -= 1;
	S[1] == '+' ? count += 1 : count -= 1;
	S[2] == '+' ? count += 1 : count -= 1;
	S[3] == '+' ? count += 1 : count -= 1;
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
	long long int h;
	int n;

	std::cin >> h >> n;

	int a[100010];
	long long int sum = 0;
	for (int i = 0; i < n; ++i)
		std::cin >> a[i], sum += a[i];

	if (sum >= h)
		std::cout << "Yes";
	else
		std::cout << "No";
}

Measured memory_bytes: 3972
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int h, w;
    cin >> h >> w;
    int pass_num = 0;
    rep(i, h) rep(j, w) {
        char tmp;
        cin >> tmp;
        if (tmp == '#') ++pass_num;
    }
    if (pass_num == h + w - 1) {
        cout << "Possible" << endl;
    }
    else {
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;

int main(void){
    
    int N;
    int ans = 0;

    cin >> N;
    int A[100];
    int B[100];
    int C[100];
    // 配列に値を格納
    for (int i = 0;i < N ;i++) {
        
        cin >> A[i];
        // 配列の連番として利用するためディクリメント
        --A[i];
    }     
    for (int i = 0;i < N ;i++) {
        
        cin >> B[i];        
    }    
    for (int i = 0;i < (N-1) ;i++) {
        
        cin >> C[i];        
    }
    // 配列Bの値はすべて合計
    for (int i = 0 ;i < N ;i++){
        
        ans += B[i];
    }

    for (int i= 0;i<N;++i){
        
        if (i > 0 && A[i-1] == (A[i]-1)) ans += C[A[i-1]];
    
    }

    cout << ans <<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    int p;
    int ans = 0;
    int max = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &p);
        ans += p;
        if (max < p)
            max = p;
    }
    printf("%d\n", ans - (max / 2));
    return 0;
}

Measured memory_bytes: 128
H,W,A,B = map(int, input().split())
N = H+W

MOD = 10**9 + 7

def mul(a, b):
    return ((a % MOD) * (b % MOD)) % MOD
  
def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % MOD
    elif y % 2 == 0 : return power(x, y//2)**2 % MOD
    else            : return power(x, y//2)**2 * x % MOD

def div(a, b):
    return mul(a, power(b, MOD-2))

# 階乗計算
fac = [1] * N
for i in range(1, N): 
    fac[i] = fac[i-1] * i % MOD
    
invfac = [0] * (N)
invfac[H+W-1] = power(fac[H+W-1], MOD-2)
for i in range(H+W-2, -1, -1):
    invfac[i] = invfac[i+1] * (i+1) % MOD
    
def nCr(n, r):
    return fac[n] * invfac[r] * invfac[n-r] % MOD



ans = 0
f = {}
for i in range(H-A):
    h1 = i
    w1 = B-1
    if (h1, w1) in f:
        zenhan = f[(h1, w1)]
    else:
        zenhan = nCr(h1+w1,h1)
        f[(h1, w1)] = zenhan
    
    h2 = (H-1) - i
    w2 = (W-1) - B
    if (h2, w2) in f:
        kouhan = f[(h2, w2)]
    else:
        kouhan = nCr(h2+w2,h2)
        f[(h2, w2)] = kouhan

    ans += zenhan * kouhan

print(ans % MOD)

Measured memory_bytes: 65004
H, W = map(int, input().split())
a = []
operation = []
for _ in range(H):
    a.append(list(map(int, input().split())))
root = []
for i in range(H):
    for j in range(W):
        if i % 2 == 0:
            root.append((i, j))
        else:
            root.append((i, W - j - 1))
for r in range(len(root) - 1):
    y, x = root[r]
    if a[y][x] % 2 == 1:
        a[y][x] -= 1
        a[root[r+1][0]][root[r+1][1]] += 1
        operation.append((y + 1, x + 1, root[r+1][0] + 1, root[r+1][1] + 1))
print(len(operation))
for o in operation:
    print(*o)


Measured memory_bytes: 48348
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e10;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int X;
    cin >> X;
    int ans = 1;
    for(int i = 2; i <= X; i++) {
        int res = i;
        while (res*i <= X) {
            ans = max(ans,res*i);
            res *= i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 605
#define mod 1000000007

int n, m;
vector<int> v[maxn];
double dp[maxn];

int main()
{
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        v[x].push_back(y);
    }
    double ans = INT_MAX;
    for (int i = 1; i <= n; i++)
    {
        for (int j = n - 1; j >= 1; j--)
        {
            double tot = 0;
            double _max = 0;
            for (int x : v[j])
            {
                _max = max(_max, dp[x] + 1);
                tot += dp[x] + 1;
            }
            if (j == i && v[j].size() > 1)
            {
                tot -= _max;
                dp[j] = tot / (v[j].size() - 1);
            }
            else
                dp[j] = tot / v[j].size();
        }
        ans = min(ans, dp[1]);
    }
    printf("%.9f\n", ans);

    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
#define X first
#define Y second
typedef long long ll; 
int x[105], y[105]; 
double seq[205]; 
int main()
{
	// freopen("AGC021-B.in", "r", stdin); 
	int n; 
	scanf("%d", &n); 
	for (int i = 0; i < n; i++)
		scanf("%d%d", x + i, y + i); 
	for (int i = 0; i < n; i++)
	{
		int cnt = 0; 
		for (int j = 0; j < n; j++)
		{
			if (i != j)
				seq[cnt++] = atan2(y[j] - y[i], x[j] - x[i]); 
		}
		std::sort(seq, seq + cnt); 
		for (int j = 0; j < cnt; j++)
			seq[j + cnt] = seq[j] + acos(-1) * 2; 
		double mx = 0; 
		for (int j = 1; j <= cnt; j++)
			mx = std::max(seq[j] - seq[j - 1] - acos(-1), mx); 
		printf("%.20lf\n", mx / acos(-1) / 2);
	}
	return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;



signed main()
{
    int a, b;

    cin >> a >> b;
    if (a <= 0 && 0 <= b) cout << "Zero" << endl;
    else if (1 <= a) cout << "Positive" << endl;
    else if ((b - a) % 2 == 0) cout << "Negative" << endl;
    else cout << "Positive" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long l[90];
    l[0]=2;
    l[1]=1;
    for(int i=2;i<87;i++){
		l[i]=l[i-1]+l[i-2];
	}
	int n;
	cin>>n;
	cout<<l[n]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i=0;i<N;i++) cin >> A[i];
    for (int i=K;i<N;i++){
        if (A[i] > A[i-K]) cout << "Yes" << "\n";
        else cout << "No" << "\n";
    }
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin>>n;
	vector<int> a;
	while(n){
		a.push_back(n%10);
		n/=10;
	}
	if(a[0] == a[1] && a[1] == a[2]) {
		cout<<"Yes";
	} else if(a[1] == a[2] && a[2] == a[3])
	{
		cout<<"Yes";
	} else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N,M=map(int,input().split())
L=[0]*N
R=[0]*N
right=0
pena=0
for _ in range(M):
    p,s=input().split()
    p=int(p)
    p-=1
    if R[p]==0:
        if s=='AC':
          right+=1
          R[p]=1
          pena+=L[p]
        else:
            L[p]+=1

print(right,pena)


Measured memory_bytes: 11304
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn argsort<T: std::cmp::Ord + std::marker::Copy>(v: &Vec<T>) -> Vec<usize> {
    let mut sort_v = Vec::new();
    for i in 0..v.len() {
        sort_v.push((v[i], i));
    }
    sort_v.sort();
    sort_v.iter().map(|x| x.1).collect::<Vec<usize>>()
}

fn main() {
    let n: usize = read();
    let mut a = read_vec::<u64>();
    let mut ans = 0u64;
    loop {
        let max_index = argsort(&a)[n - 1];
        if a[max_index] <= n as u64 - 1 {
            break;
        }
        let mut ope_count = a[max_index] / n as u64;
        for i in 0..n {
            if i == max_index {
                continue;
            }
            a[i] += ope_count;
        }
        a[max_index] -= ope_count * n as u64;
        ans += ope_count;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <typeinfo>
#include <list>
#include <queue>
#include <stack>
#include <limits.h>
#include <unordered_set>
#include <map>
#include <cstring>

using namespace std;

typedef long long ll;

int mod = 1e9 + 7;

int Solve(vector<int> C) {
    int n = C.size();
    vector<int> pre(n, -1);
    unordered_map<int, int> m;
    for (int i = 0; i < n; i++) {
        if (m.count(C[i])) {
            pre[i] = m[C[i]];
        }
        m[C[i]] = i;
    }
    vector<int> dp(n, 0);
    dp[0] = 1;
    for (int i = 1; i < n; i++) {
        dp[i] += dp[i - 1];
        if (pre[i] != -1) {
            dp[i] = (dp[i] + dp[pre[i]]) % mod;
        }
    }
    return dp[n - 1];
}


int main() {
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> C;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        if (C.empty() || C.back() != tmp) {
            C.push_back(tmp);
        }
    }
    cout << Solve(C);
    return 0;
}


Measured memory_bytes: 11672
#include <bits/stdc++.h>
using namespace std;
int p[100003];
int main()
{
    int N;
    cin >> N;
    while (N--)
    {
        int i;
        cin >>i;
        p[i]++;
        p[i + 1]++;
        p[i + 2]++;
    }
    cout << *max_element(p + 2, p + 100000) << endl;
    return 0;
}

Measured memory_bytes: 3892
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	ll X, Y;
	cin >> X >> Y;
	if (X % Y == 0) cout << "-1" << endl;
	else cout << X << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	r := make([]rune, 0)
	for _, v := range s {
		if v == 'B' && len(r) == 0 {
			continue
		} else if v == 'B' {
			r = r[:len(r)-1]
		} else {
			r = append(r, v)
		}
	}
	fmt.Println(string(r))
}


Measured memory_bytes: 512
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
typedef pair<int,int> P;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return 1;
    }
    return 0;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return 1;
    }
    return 0;
}

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;

int main(){
    ll N,M;
    cin >> N >> M;
    ll maximum=0;
    for(ll i=1; i<=sqrt(M); i++){
        if(M%i==0 && M/i>=N){
            maximum=max(maximum,i);
            if(i>=N){
                maximum=max(M/i,maximum);
            }
        }
    }
    cout << maximum <<endl;
    return 0;
}



Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)

fun main(args: Array<String>) {
    val n = sc.nextInt()
    val arr: Array<Int> = Array(n){sc.nextInt()}
    abc134c(n, arr)
}

fun abc134c(n: Int, arr: Array<Int>): Unit {
    val arrsorted = arr.sortedArray()
    val arrMax = arrsorted[arrsorted.size-1]
    val arrSec = arrsorted[arrsorted.size-2]
    for (i in 0 until n){
        if(arr[i] == arrMax){
            pw.println(arrSec)
        }else{
            pw.println(arrMax)
        }
    }
    pw.flush()
}


fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }



Measured memory_bytes: 80876
#include <bits/stdc++.h>
using namespace std;

int main() {
    int k;
    cin >> k;
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(i < k){
            cout << s[i];
        }else{
            cout << "..." << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3624
MOD = 10 ** 9 + 7
it = lambda: list(map(int, input().strip().split()))

def solve():
    N, K = it()
    A = it()
    
    zero = 0
    neg = []
    pos = []
    for i in range(N):
        if A[i] < 0:
            neg.append(A[i])
        elif A[i] > 0:
            pos.append(A[i])
        else:
            zero += 1
    
    if not neg and not pos:
        return 0
    
    pos.sort()
    neg.sort(reverse=True)

    if not pos and K % 2 == 1:
        if zero > 0:
            return 0

        ans = 1
        for i in range(K):
            ans = ans * neg[i] % MOD
        return ans

    ans = 1
    for _ in range(K >> 1):
        if len(pos) >= 2 and len(neg) >= 2:
            if neg[-1] * neg[-2] >= pos[-1] * pos[-2]:
                ans = ans * neg.pop() % MOD * neg.pop() % MOD
            else:
                ans = ans * pos.pop() % MOD * pos.pop() % MOD
        elif len(pos) >= 2:
            ans = ans * pos.pop() % MOD * pos.pop() % MOD
        elif len(neg) >= 2:
            ans = ans * neg.pop() % MOD * neg.pop() % MOD
        elif len(pos) == 1 and len(neg) == 1:
            ans = ans * pos.pop() % MOD * neg.pop() % MOD
        else:
            return 0
    
    if K % 2 == 1:
        if pos:
            ans = ans * pos.pop() % MOD
        elif neg:
            ans = ans * neg.pop() % MOD
        else:
            return 0
    if zero > 1 and ans < 0:
        return 0
    return ans


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

Measured memory_bytes: 31868
using System;

namespace AtCoder.ABC._122
{
    class a
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().Trim();
            switch (S)
            {
                case "A":
                    Console.WriteLine("T");
                    break;
                case "T":
                    Console.WriteLine("A");
                    break;
                case "C":
                    Console.WriteLine("G");
                    break;
                case "G":
                    Console.WriteLine("C");
                    break;
            }
        }
    }
}


Measured memory_bytes: 11092
while 1:
    s=map(int, raw_input().split())
    s.sort()
    if s==[0,0,0]: break
    n = input()
    cr = s[0]**2+s[1]**2
    for i in xrange(n):
        r = input()
        print "OK" if cr<4*r**2 else "NA"

Measured memory_bytes: 4208
#include <iostream>
using namespace std;


int main(){
	int q1,b,c1,c2,q2;
	while(cin>>q1,q1){
		cin>>b>>c1>>c2>>q2;
		int NA=1;
		for(int i=q2;i>0;i--){
			int j=c1*i;
			int k=(b-j)/c2;
			if(b>=j&&i+k>=q1){
				cout<<i<<" "<<k<<endl;
				NA=0;
				break;
			}
		}
		
		
		if(NA)cout<<"NA\n";
	}
	
	
	return 0;
}


Measured memory_bytes: 1160
import sys
import numpy as np


TEST_INPUT = [
    """
    4 3
    3 3 -4 -2
    """,
    """
    10 40
    5 4 3 2 -1 0 0 0 0 0
    """,
    """
    30 413
    -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0
    """
]
ANSWER = [
    "-6",
    "6",
    "448283280358331064"
]


class InputHandler:

    def __init__(self, text_lines="", is_test=False):
        self.data = list(text_lines.split("\n"))
        self.index = 0
        self.is_test = is_test

    def input(self):
        if self.is_test:
            self.index += 1
            return self.data[self.index].strip()
        else:
            return sys.stdin.readline().rstrip()


def query(a, n, a_arr_p, a_arr_n, n_zeros, k):

    # return (num of pairs <= a) < k

    if a >= 0:
        # negative
        res = len(a_arr_p) * len(a_arr_n)
        # zero
        res += n_zeros * (n - n_zeros) + n_zeros * (n_zeros - 1) // 2
        # p * p
        res_pp = np.searchsorted(a_arr_p, a // a_arr_p, side="right").sum()
        res_pp -= (a_arr_p * a_arr_p <= a).sum()
        res += res_pp // 2
        # n * n
        res_nn = np.searchsorted(a_arr_n, a // a_arr_n, side="right").sum()
        res_nn -= (a_arr_n * a_arr_n <= a).sum()
        res += res_nn // 2
    else:
        # p * n
        res = len(a_arr_p) * len(a_arr_n) - np.searchsorted(a_arr_n, (a_arr_p - a - 1) // a_arr_p, side="left").sum()
    # print(a, res)
    if res < k:
        return True
    else:
        return False


def solve(n, k, a_list):

    left = - 10 ** 18 - 1
    right = 10 ** 18 + 1
    center = 0

    a_arr = np.array(a_list)

    a_arr_p = a_arr[a_arr > 0]
    a_arr_n = - a_arr[a_arr < 0]
    n_zeros = (a_arr == 0).sum()
    a_arr_p.sort()
    a_arr_n.sort()

    while right > left + 1:
        if query(center, n, a_arr_p, a_arr_n, n_zeros, k):
            left, center = center, (center + right) // 2
        else:
            center, right = (left + center) // 2, center

    return right


def input_and_solve(ih):
    n, k = map(int, ih.input().split())
    a_list = list(map(int, ih.input().split()))
    res = solve(n, k, a_list)
    return res


def main():
    ih = InputHandler()
    res = input_and_solve(ih)
    print(res)


def test():
    for test_input, ans in zip(TEST_INPUT, ANSWER):
        ih = InputHandler(test_input, True)
        res = input_and_solve(ih)
        # print(res, ans)
        assert str(res) == str(ans)


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 32300
n = int(input())
ans = 0
for i in range(1, n+1):
        cnt = 0
        if i % 2 != 0:
                for j in range(1,i+1):
                        if i % j == 0:
                                cnt += 1
                        if cnt == 8:
                                ans += 1
print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define MOD 1000000007
typedef long long ll;
using namespace std;

int N, M, Q; 
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A)
{
	if (A.size() == N + 1) {
      	int now = 0;
      	for (int i = 0; i < Q; i++) {
        	if (A[b[i]] - A[a[i]] == c[i]) {
            	now += d[i];
            } 
        }
      	ans = max(ans, now);
    	return;
    }
  	A.push_back(A.back());
  	while (A.back() <= M) {
      	dfs(A);
    	A.back()++;
    }
}

int main()
{
	cin >> N >> M >> Q;
  	a = b = c = d = vector<int>(Q);
  	for (int i = 0; i < Q; i++) {
    	cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
  	dfs(vector<int>(1, 1));
  	cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 3600
X, K, D = list(map(int, input().split()))
X = abs(X)
syo, amari = divmod(X, D)
if amari > (D-amari):
    syo = syo +1
if syo >= K:
    print(X - K*D)
else: 
    remain_num = K - syo
    position = abs(X - syo*D)
    if remain_num%2 == 1:
        position = abs(position-D)
    print(position)

Measured memory_bytes: 9140
/* Murad Eynizade */

#include <bits/stdc++.h>
#define intt long long
#define FAST_READ ios_base::sync_with_stdio(0);cin.tie(0);
#define SIZE 100001
#define INF INT_MAX
#define F first
#define S second
#define in(a) scanf("%d",&a);
#define outn(a) printf("%d\n",&a);
#define outs(a) printf("%d ",&a);


using namespace std;



int main()
{
    FAST_READ;
    intt a,  b;
    cin>>a>>b;
    cout<<a - b + 1<<endl;
    return 0;
}


Measured memory_bytes: 768
#include<set>  
#include<map>  
#include<stack>  
#include<cmath>  
#include<cstdio>  
#include<queue>  
#include<vector>  
#include<cstring> 
#include<climits>  
#include<iostream> 
#include<algorithm> 
using namespace std; 
int read(){ 
    int f=1,x=0; 
    char c=getchar(); 
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();} 
    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();} 
    return f*x; 
}
#define MAXN 100000
#define INF 0x3f3f3f3f
char a[MAXN+5];
int num[MAXN+5][30];
int main(){
	scanf("%s",a+1);
	int len=strlen(a+1);
	for(int i=2;i<=len;i++)
		if(a[i]==a[i-1]){
			printf("%d %d\n",i-1,i);
			return 0;
		}
	for(int i=3;i<=len;i++)
		if(a[i]==a[i-2]){
			printf("%d %d\n",i-2,i);
			return 0;
		}
	printf("-1 -1\n");
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fr first
#define sc second
#define close(x){cout<<x<<endl;return 0;}
#define pb push_back
#define mp make_pair
#define forr(i,a,b) for(ll i=a;i<b;i++)
ll power(ll n,ll k)
{return k?n*power(n,k-1):1;}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);ll n,m,mod;
cin>>n>>m;
ll x;x=(ll)(n/m);
x=power(x,3);ll f=0;
if(!(m&1))
{mod=m/2;
f=(ll)(n/m);
if(n-m*f>=mod)f++;}
f=power(f,3);
cout<<f+x<<endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 1e11;
const ll bits = 62;
const ll mod = 1e9+7;
const ld pi = 3.14159265358979323846;


int main(){
    FASTIO;
    PRECISION;

    ll n,k;
    cin>>n>>k;

    vector<ll>arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }

    sort(arr.begin(),arr.end());

    ll ans = 0;

    for(int i=k;i<n;i++){
        ans+=arr[n-1-i];
    }

    cout<<ans<<"\n";

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

 
int main() {
   int n,k;
   string s;
   cin>>n>>k>>s;
   vector<char> S(n);
   rep(i,n)S[i]=s[i];

   k--;
   S[k]=S[k]+32;
   rep(i,n)cout<<S[i];

}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int cnt = 0;
            for(int i = 1; i <= N; i++)
            {
                if (i > 0 && i < 10)
                    cnt++;
                else if (i > 99 && i < 1000)
                    cnt++;
                else if (i > 9999 && i < 100000)
                    cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 11220
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli ans, n;
    cin >> n;
    ans = n / 2;
    n %= 2;
    ans += n;
    out(ans);
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int q[100005];
int main() {
	int n;
	cin>>n;
	int tmp,maxn=0;
	for(int j=0;j<n;j++){
		cin>>tmp;
		q[tmp-1]++;q[tmp]++;q[tmp+1]++;
		int mmmmm=max(q[tmp-1],max(q[tmp],q[tmp+1]));
		maxn=max(maxn,mmmmm);
	}
	cout<<maxn;
	return 0;
}


Measured memory_bytes: 640
x1,x2,x3,x4,x5 = list(map(int, input().split()))

if x1 == 0:
  print(1)
if x2 == 0:
  print(2)
if x3 == 0:
  print(3)
if x4 == 0:
  print(4)
if x5 == 0:
  print(5)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;

int main() {
int n;
cin >>n;
vector<double>a(n);
vector<string>b(n);
double ans =0;
for(int i=0;i<n;i++){
    cin >> a.at(i) >> b.at(i);
    if(b.at(i)=="JPY"){
        ans+=a.at(i);
    }
    else{
        ans+=a.at(i)*380000;
    }
}
cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())

pt = 0
px = 0
py = 0
ans = 'Yes'
for t in range(N):
    t, x, y = map(int, input().split())

    diff = abs(x - px) + abs(y - py)
    if diff > t - pt or ((t - pt) - diff) % 2 == 1:
        ans = 'No'

    pt, px, py = t, x, y

print(ans)


Measured memory_bytes: 3060
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE ViewPatterns          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Builder     as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Internal    as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import qualified System.IO                   as IO
import           Unsafe.Coerce

main :: IO ()
main = do
    n <- readLn
    xs <- map read.words <$> getLine :: IO [Int]
    case length . filter id $ zipWith (/=) [1..n] xs of
        0 -> putStrLn "YES"
        2 -> putStrLn "YES"
        _ -> putStrLn "NO"


-------------------------------------------------------------------------------
type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
    (,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt4 :: Parser (Int, Int, Int, Int)
parseInt4 = runStateT $
    (,,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }
  return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }
  return 0; }
vector<vector<int>> to(200005,vector<int>());
vector<int> ans;
void dfs(int v, int p = -1){
  for(int u : to[v]){
    if(u == p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
}
  

int main(void){
  int n,q; cin >> n >> q;
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(n);
  rep(i,q){
    int p,x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }
  dfs(0);
  rep(i,n){
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 23424
#include<bits/stdc++.h>

using namespace std;

long long n,k,he;

int a[10000];

int main()
{
cin>>n>>k;//读入
for(int i=1; i<=n; i++)
{
    cin>>a[i];//读入
    he+=a[i];//累加
}
sort(a+1,a+1+n);//从小到大排序
for(int i=1; i<=n-k; i++)
{
    he-=a[i];//从1到n-k的数都要减去
}
cout<<he<<endl;//输出结果并换行
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m;
    cin>>n>>m;
    std::deque<string> A;
    string a;
    for (int i=0;i<n;i++) {
        cin>>a;
        A.emplace_back(a);
    }
    string b;
    std::deque<string> B;
    for (int j=0;j<m;j++) {
        cin>>b;
        B.emplace_back(b);
    }
    int flag=0;
    for (int k=0;k<n;k++) {
        for (int l=0;l<=n-m;l++) {
            string tmp1=A[k].substr(l,m);
            if (tmp1==B[0]) {
                if (m>1) {
                    for (int hoge=1;hoge<m;hoge++) {
                        if (k+hoge<n) {
                            string tmp2=A[k+hoge].substr(l,m);
                            if (tmp2!=B[hoge]) {
                                break;
                            }
                            if (hoge==m-1) {
                                cout<<"Yes"<<endl;
                                flag=1;
                            }
                        } else {
                            break;
                        }
                    }
                } else {
                    cout<<"Yes"<<endl;
                    flag=1;
                }
            }
            if (flag==1) {
                break;
            }
        }
        if (flag==1) {
            break;
        }
    }
    if (flag==0) {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(){
  int num_member, points_start, num_quiz;
  scanf("%d %d %d", &num_member, &points_start, &num_quiz);
  
  int *points_member;
  points_member = (int *)malloc(num_member*sizeof(int));
  
  int i;
  for(i=0; i<num_member; i++){
    points_member[i] = points_start-num_quiz;
  }
  
  int num_answer;
  while(num_quiz > 0){
    scanf("%d", &num_answer);
    points_member[num_answer-1]++;
    num_quiz--;
  }
  
  for(i = 0; i<num_member; i++){
    if(points_member[i] > 0){
      puts("Yes");
    }else{
      puts("No");
    }
  }
  
  free(points_member);
}

Measured memory_bytes: 896
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Main{
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}                                              
		return ans;
	} 
	static long mod=1000000007;
	static long power(long x,long y) 
    { 
        long res = 1; 
        x = x % mod; 
        while (y > 0) { 
            if (y % 2 == 1) 
                res = (res * x) % mod; 
            y = y >> 1;
            x = (x * x) % mod; 
        } 
        return res%mod; 
    } 
    static long modInverse(long n) 
    { 
        return power(n, mod-2); 
    } 
    static int digits(int n)
    {
    	int ans=0;
    	while(n!=0)
    	{
    		ans++;
    		n=n/10;
    	}
    	return ans;
    }
    static long[][] dp;
    static long max(int[]wts,int[]val,int ind,int cap)
    {
    	if(cap<0)
    		return -1000000000;
    	if(ind==val.length)
    		return 0;
    	if(dp[ind][cap]!=-1)
    		return dp[ind][cap];
    	dp[ind][cap]=Math.max(max(wts,val,ind+1,cap),(long)val[ind]+max(wts,val,ind+1,cap-wts[ind]));
    	return dp[ind][cap];
    }
    public static void main(String[] args) throws Exception {
        br = new BufferedReader(new InputStreamReader(System.in));
        int[]ar=split();
        int n=ar[0];
        int w=ar[1];
        int[]wts=new int[n];
        int[]val=new int[n];
        for(int i=0;i<n;i++)
        {
        	ar=split();
        	wts[i]=ar[0];
        	val[i]=ar[1];
        }
        dp=new long[n+1][w+1];
        for(int i=0;i<=n;i++)
        {
        	Arrays.fill(dp[i],(long)-1);
        }
        System.out.println(max(wts,val,0,w));
    }
}

Measured memory_bytes: 138640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0019
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = 0;
            n = int.Parse(Console.ReadLine());
            long answer = 1;
           
            for (int i = 2; i <= n; i++)
            {
                answer = answer * i;
            }
            Console.WriteLine(answer);
        }
    }
}



Measured memory_bytes: 17960
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize, k: usize,
        a: [i32; n],
    }
    let ans = (n -1 + k -2) / (k-1);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef long long ll;
typedef double ld;
typedef pair<int,int> p2;
typedef pair<p2,int> p3;
typedef vector<ll> vi;
const ll Mod = 7 + 1e9;
const ll INF32 = 5 + 2e9;
const ll INF64 = 5 + 1e18;
const ll MAX = 5+ 1e5;

int n,a[MAX][3];
int dp[MAX][3];
int main()
{
    cin >> n;
    for(int i=1;i<=n;i++)
        for(int j=0;j<3;j++)
            cin >> a[i][j];
        for(int i=1;i<=n;i++){
            for(int j=0;j<3;j++)
            {
                int c1 = (j+1)%3;
                int c2 = (j+2)%3;
                dp[i][j] = max( dp[i-1][c1] ,dp[i-1][c2] ) + a[i][j];
            }
        }
    cout << max( dp[n][0] ,max( dp[n][1] ,dp[n][2] ) ) << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using ll=long long;


int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ans=-1e18;
  ans=max(ans,a*c);
  ans=max(ans,a*d);
  ans=max(ans,b*c);
  ans=max(ans,b*d);

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    string S;
    int K;
    cin >> K >> S;
    if (S.size() <= K)
    {
        cout << S << endl;
        return 0;
    }
    else
    {
        for (int i = 0; i < K; i++)
        {
            cout << S[i];
        }
        cout << "..." << endl;
        return 0;
    }
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cmath>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef pair<int,int> pii;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;

const ll MOD=1e9+7;

int main(){
  ios::sync_with_stdio(0);cin.tie(0);

  string s;
  cin>>s;
  int n = s.size();
  int k=0;
  for(char c:s) if(c=='p') k++;
  cout << n/2-k << endl;

  return 0;
}


Measured memory_bytes: 640
def test():

	n = int(input())
	A = list(map(int,input().split()))

	for k in range(n-1):
		print(f"{A[k]} ",end = '')
	print(f"{A[n-1]}")

	for i in range(1,n):
		
		key = A[i]
		j = i - 1
		while j >= 0 and A[j] > key:
			A[j+1] = A[j]
			j -= 1
		A[j+1] = key
		for k in range(n-1):
			print(f"{A[k]} ",end = '')
		print(f"{A[n-1]}")

if __name__ == "__main__":
	test()




Measured memory_bytes: 5992
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;




int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N;
    cin >> N;
    if (N % 1000) {
        cout << 1000 - N % 1000 <<endl;
    } else {
        cout << 0 <<endl;
    }

    return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    string S;
    int N;
    cin >> N >> S;

    string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
    
    for(int i = 0; i < S.size(); i++) {
        for(int j = 0; j < s.size(); j++) {
            if (S[i] == s[j]) {
                cout << s[j+N];
                break;
            }
        }
    }
    cout << endl;
    

    //cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    rep(n, 1, 3501){
        rep(h, 1, 3501){
            int a = 4 * h * n - N * (n + h);
            int b = N * h * n;
            if(a > 0 && b > 0 && b % a == 0){
                cout << h << " " << n << " " << b / a << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef tuple<string, int, int> shop;
int main() {
    int n;
    vector<shop> sp;
    string s;
    int p;

    cin >> n;
    for (int i = 0;i < n;i++) {
        cin >> s >> p;
        sp.push_back(make_tuple(s, p, i+1));
    }

    sort(sp.begin(), sp.end(), [](shop s, shop t){
        return get<0>(s) == get<0>(t) ? get<1>(s) > get<1>(t) : get<0>(s) < get<0>(t);
    });

    for (auto& s: sp) {
        cout << get<2>(s) << '\n';
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

const int max_n = 303, inf = 1000111222;

int n, m;
char a[max_n][max_n];
bitset<max_n> b[max_n][max_n];
long long ans;

void proc(int x1, int y1, int x2, int y2) {
    //cout << x1 << " " << y1 << " " << x2 << " " << y2 << " -> ";
    int x0 = 0, y0 = 0;
    if (min(y1, y2) < 0) {
        y0 = -min(y1, y2);
    }
    y1 += y0;
    y2 += y0;
    //cout << x0 << " " << y0 << " " << x1 << " " << y1 << " " << x2 << " " << y2 << ": ";
    for (int i = 0; i + x2 < n; ++i) {
        ans += ((b[i][y0]) & (b[i + x1][y1]) & (b[i + x2][y2])).count();
    }
    //cout << ans << endl;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) {
        scanf("%s", a[i]);
        for (int j = 0; j < m; ++j) {
            b[i][0][j] = (a[i][j] == '#');
        }
        for (int k = 1; k <= m; ++k) {
            b[i][k] = b[i][0] >> k;
        }
    }
    for (int x1 = 0; x1 < n; ++x1) {
        for (int y1 = -m + 1; y1 < m; ++y1) {
            if (x1 == 0 && y1 <= 0) {
                continue;
            }
            int l = x1 + abs(y1);
            for (int x2 = x1; x2 < n; ++x2) {
                for (int z = -1; z <= 1; z += 2) {
                    int y2 = (l - x2) * z;
                    if (abs(y1 - y2) >= m || x2 - x1 + abs(y1 - y2) != l || x2 + abs(y2) != l) {
                        continue;
                    }
                    if (x1 == x2 && y1 < y2) {
                        continue;
                    }
                    proc(x1, y1, x2, y2);
                    if (y2 == 0) {
                        break;
                    }
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3968
#include<iostream>
#include<algorithm>
using namespace std;

int main(){
	int mountain[10];
	for(int i=0; i<10; i++){
		cin >> mountain [i];
	}
	sort(mountain,mountain+10);
	cout << mountain [9] << endl << mountain[8] << endl << mountain[7] << endl;	
        return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define sz(c)       int(c.size())
#define rep(i,a,b)  for (int i=a; i<(b); ++i)
#define per(i,a,b)  for (int i=(b)-1; i>=(a); --i)
#define fore(c,...) for (auto &__VA_ARGS__:(c))
using namespace std;
using ll = long long;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int N;
	string S;
	cin>>N>>S;
	int res=0;
	rep(i,0,N-2) if (S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') res++;
	cout<<res<<'\n';
}


Measured memory_bytes: 256