akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <ctime>
#include <cstring>
#include <vector>
#define ll long long
#define INF 1000000000
#define For(i,a,b) for(int i=a;i<=b;++i)
#define Rev(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define pq priority_queue
#define PI acos(-1)

namespace IO
{
#define p(x) ('0'<=x&&x<='9')
	char cc; int C;
	template <class T>
	void read( T &x )
	{
		x=0; cc=getchar(); C=1;
		while(!p(cc)) { if(cc=='-') C=-1; cc=getchar(); }
		while(p(cc)) { x=x*10+cc-48; cc=getchar(); }
		x*=C;
	}
#undef p
}

using namespace IO;
using namespace std;

struct Pair
{
	Pair(int _=0,int CNT=0):id(_),cnt(CNT){}
	int cnt,id;
	bool operator < (const Pair &x) const
	{
		return cnt > x.cnt;
	}
};

vector<Pair> rec[2];
int n,a,cnt[2][100005];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	srand(time(0));
#ifdef LOCAL
	freopen("./tmp/input.txt", "r", stdin);
#endif

	read(n);
	For(i,0,n-1)
	{
		read(a);
		cnt[i&1][a]++;
	}
	For(i,1,100000)
	{
		rec[0].push_back(Pair(i,cnt[0][i]));
		rec[1].push_back(Pair(i,cnt[1][i]));
	}
	sort(rec[0].begin(),rec[0].end());
	sort(rec[1].begin(),rec[1].end());

	int id=rec[0][0].id;
	int ans=0;
	For(i,0,5)
		if(rec[1][i].id!=id)
		{
			ans=rec[0][0].cnt+rec[1][i].cnt;
			break;
		}


	id=rec[1][0].id;
	For(i,0,5)
		if(rec[0][i].id!=id)
		{
			ans=max(ans,rec[1][0].cnt+rec[0][i].cnt);
			break;
		}
	printf("%d",n-ans);
	return 0;
}


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

bool judge(int y, int x, int H, int W, vector<vector<char>> &grid){
    if(y-1>=0){
        if(grid.at(y-1).at(x) == '#')return true;
    }
    if(y+1<=H-1){
        if(grid.at(y+1).at(x) == '#')return true;
    }
    if(x-1>=0){
        if(grid.at(y).at(x-1) == '#')return true;
    }
    if(x+1<=W-1){
        if(grid.at(y).at(x+1) == '#')return true;
    }
    return false;
}

int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<char>> grid(H,vector<char>(W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> grid.at(i).at(j);
        }
    }

    vector<vector<char>> canvas(H,vector<char>(W));
    bool achive = true;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(grid.at(i).at(j) == '#'){
                if(!judge(i,j,H,W,grid))achive = false;
            }
        }
    }
    if(achive){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

template<int MOD> struct ModInt {
  using M = ModInt;
  using ll = long long;
  long long v;

  constexpr ModInt() : v(0) {}
  constexpr ModInt(ll r) : v(r % MOD) { if (v < 0) v += MOD; }
  explicit operator long() const { return v; }
  constexpr friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
  constexpr friend istream& operator>>(istream& is, M& r) { return is >> r.v; }

  constexpr bool operator == (const M& r) { return v == r.v; }
  constexpr bool operator != (const M& r) { return v != r.v; }

  constexpr M& operator += (const M& r) { v += r.v; if (v >= MOD) v -= MOD; return *this; }
  constexpr M& operator -= (const M& r) { v -= r.v; if (v < 0) v += MOD; return *this; }
  constexpr M& operator *= (const M& r) { v = v * r.v % MOD; return *this; }
  constexpr M operator - () { M res; if (v) res.v = MOD - v; return res; }
  constexpr M operator + (const M& r) const { return M(v) += r; }
  constexpr M operator - (const M& r) const { return M(v) -= r; }
  constexpr M operator * (const M& r) const { return M(v) *= r; }
};

using mint = ModInt<(int) 1e9+7>;
signed main() {
  int N; cin >> N;
  map<ll, int> factors;
  rep(i,N) {
    auto fs = prime_factor(i+1);
    for(pair<ll, int> p : fs) factors[p.first] += p.second;
  }
  mint ans(1);
  for(pair<ll, int> p : factors) {
    ans *= p.second + 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	private static long MOD = 1000000007;
	
	public static void main(String[] args) {
		long N = sc.nextLong();
		long M = sc.nextLong();
		
		if(Math.abs(N-M) > 1) {
			System.out.println(0);
			return;
		}
		
		if(N == M) {
			System.out.println(fact(N) * fact(M) * 2 % MOD);
		} else {
			System.out.println(fact(N) * fact(M) % MOD);
		}
	}
	
	public static long fact(long k) {
		long ans = 1;
		for(int i=2; i<=k; i++) {
			ans = ans * i % MOD;
		}
		
		return ans;
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 22996
a,b,c = list(map(int, input().split()))
if a == b == c:
    if a&1:
        print(0)
    else:
        print(-1)
else:
    ans = 0
    while True:
        if a&1 or b&1 or c&1:
            print(ans)
            break
        else:
            a,b,c = (b+c)//2,(c+a)//2,(a+b)//2
            ans += 1


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <string>
#include <numeric>


using namespace std;


void a(){

    int A,B,T; cin >> A >> B >> T;

    int c = T/A;

    cout << c*B;

}

void b(){

    int N; cin >> N;

    vector<int> V(N);
    vector<int> C(N);
    for(int i = 0; i < N; i++){
        cin >> V[i];
    }
    for(int i = 0; i < N; i++){
        cin >> C[i];
    }
    int profit = 0;
    for(int i = 0; i < N; i++){
        if (V[i] - C[i] > 0){
            profit += V[i] - C[i];
        }
    }

    cout << profit;

}

int gcd(int a, int b){

    if(a < b) gcd(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;

}

void c(){
    int N; cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    // left[i] == gcd of A[0,i]
    vector<int> left(N,A[0]);
    for (int i = 1; i < N; i++ ){
        left[i] = gcd(left[i - 1], A[i]);
    }

    vector<int> right(N, A[N-1]);
    for (int i = N -2; 0 <= i; i-- ){
        right[i] = gcd(A[i], right[i + 1]);
    }

    int max_gcd = 1;
    for(int i = 1; i < N - 1; i++){
        max_gcd = max( gcd(left[i -1], right[i+1]), max_gcd);
    }

    max_gcd = max( right[1], max_gcd);// i = 0
    max_gcd = max( left[N-2], max_gcd); // i = N -1

    cout << max_gcd;

}

void d(){

    int N; cin >> N;
    vector<long long>A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    // dp[0][i] == answer of A[i,N-1], dp[1][i] == answer of -A[i]::A[i+1; N-1]
    vector<vector<long long>> dp(2, vector<long long>(N));
    dp[0][N-1] = A[N-1];
    dp[1][N-1] = -A[N-1];
    for(int i = N -2; 0 <=i; i--){
        dp[0][i] = max( A[i] + dp[0][i+1],
                       -A[i] + dp[1][i+1]);
        dp[1][i] = max( -A[i] + dp[0][i+1],
                         A[i] + dp[1][i+1]);
    }

    cout << dp[0][0];
}

int main(){

    d();
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
pair<int, int> F[100005];
int main() {
    int N, X;
    cin >> N;
    for(int i = 1; i <= N; i++)
        cin >> X, F[i] = make_pair(X, i);
    sort(F + 1, F + N + 1);
    cout << F[1].second;
    for(int i = 2; i <= N; i++)
        cout << " " << F[i].second;
    cout << endl;
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,aa,bb,cc;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>a>>b>>c;
    while(1){
        if(a%2==1||b%2==1||c%2==1)break;
        aa=a;bb=b;cc=c;
        a=(bb+cc)/2;
        b=(aa+cc)/2;
        c=(aa+bb)/2;
        ans++;
        //cout<<a<<" "<<b<<" "<<c<<"\n";
        if(ans>=1000000)break;
    }
    if(ans==1000000)Cout(-1);
    else Cout(ans);
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;

int souwa(int x)
{
	int ret = 0;

	while (x != 0)
	{
		ret += x % 10;
		x /= 10;
	}

	return ret;
}

int main(void)
{
	int n, a, b;
	cin >> n >> a >> b;
	int sum = 0;
	int x;

	for(int i=0; i<=n; i++)
	{ 
		x = souwa(i);
		if (x >= a && x <= b) sum += i;
	}
	

	cout << sum << endl;
}

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

int main()
{
    int h, w, sum=0, min=1000000;
    double p = 3.1415;
    int max = 1-1000001;

    
    while (1){
        scanf("%d%d", &h, &w);
        if(h==0 && w==0){
            break;
        }
        else {
            for (int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                    printf("#");
                }
                printf("\n");
            }
            printf("\n");
        }
    }
        return 0;
}           


Measured memory_bytes: 2040
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  bool D[100];
  for(int i=0; i<100; i++)
    D[i] = false;
  for(int i=0; i<N; i++){
    int d;
    cin >> d;
    D[d-1] = true;
  }
  int ret = 0;
  for(int i=0; i<100; i++){
    if(D[i])
      ret++;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define debug(x) cerr<<#x<<" "<<x<<endl;
#define f(i,n) for(ll i=0; i<n; i++)
#define f1(i,n) for(ll i=1; i<=n; i++)
#define fr(i,n) for(ll i=n-1; i>=0; i--)
#define f1r(i,n) for(ll i=n; i>0; i--)
#define mst(arr,val) memset(arr,val,sizeof(arr))
#define all(x) x.begin(),x.end()

typedef long long int ll;
typedef pair<ll,ll> pii;
ll M=1e9+7;
ll M2=998244353;
ll M3 = 1e8;
ll MAX = 5001;
string s = "Everything correct till here!";

void show(vector<ll> v)
{
    for(ll i=0; i<v.size(); i++)
        cout<<v[i]<<" ";
    cout<<"\n";
}
void showrev(vector<ll> v)
{
    for(ll i=0; i<v.size(); i++)
        cout<<v[v.size()-i-1]<<" ";
    cout<<"\n";
}
void showarr(ll arr[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
}
void showpv(vector<pair<ll,ll> > v)
{
    f(i,v.size())
        cout<<v[i].ff<<" "<<v[i].ss<<"\n";
}
int main()
{
    IOS
    ll T = 1,Q=1;
    //cin>>T;
    while(T--)
    {
        ll n,w; cin>>n>>w;
        ll weights[n+1], values[n+1]; f1(i,n) cin>>weights[i]>>values[i];
        ll dp[n+1][w+1];
        mst(dp,0);
        f(i,n+1)
        {
            f(j,w+1)
            {
                if(i == 0 or j == 0)
                    dp[i][j] = 0;
                else if (weights[i] <= j)
                    dp[i][j] = max(dp[i-1][j],
                                   dp[i-1][j-weights[i]] + values[i]);
                else
                    dp[i][j] = dp[i-1][j];
            }
        }
        cout<<dp[n][w];

    }
    return 0;
}



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

using namespace std;

#define ll long long
#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())

char buff[(int) 2e7 + 17];
const ll inf = (ll) 1e9 + 7ll;

const int maxn = (int) 2e3 + 17;

int n;
string s;

bool read() {
    if (scanf("%s", buff) != 1)
        return false;

    return true;
}

void solve() {
    s = buff;
    n = sz(s);
    int ans = n;

    for (int i = 0; i < n - 1; ++i)
        if (s[i] != s[i + 1])
            ans = min(ans, max(i + 1, n - i - 1));

    printf("%d\n", ans);
}

int main() {
#if SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,m,n) for(int i=m;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};
int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=200020;

int main(){
	int n;
	cin>>n;
	vector<string> s(n);
	REP(i,n){
		cin>>s[i];
	}
	sort(s.begin(), s.end());
	int cnt=1;
	REP(i,n-1){
		if(s[i]==s[i+1])continue;
		else cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 9600
console.log((args=>{
  const [[N],a] = args.trim().split`\n`.map(r=>r.split` `.map(v=>v|0));
  let odd = 0, p4 = 0;
  for ( let i = 0; i < N; i++ ) {
    odd += a[i]&1;
    p4 += !(a[i]%4);
  }
  return (odd-(odd+p4===N)<=p4)?'Yes':'No';
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 39648
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
void trozen()
{
    string s;
    cin>>s;
    int summ=0;
    for(auto i:s) summ+=(i-'0');
    if(summ%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N,M;

int ans=INF;
map < P1,vector<P2> > E;
map < P1,int > dist;

void dijkstra(int s){

    priority_queue< P2,vector<P2>,greater<P2> > pq;

    dist[P1(s,0)] = 0;
    dist[P1(N-1,0)] = INF;
    pq.push(P2(0,P1(s,0)));
    while(!pq.empty()){
        P2 p = pq.top();
        pq.pop();
        int v = p.second.first;
        int c = p.second.second;
        if(dist[P1(v,c)]<p.first)continue;
        for(auto u : E[P1(v,c)]){
            P1 to = P1(u.first,u.second.first);
            int cost = u.second.second;
            if(dist[to]>dist[P1(v,c)]+cost){
                dist[to] = dist[P1(v,c)]+cost;
                pq.push(P2(dist[to],to));
            }
        }
    }

    ans = dist[P1(N-1,0)];
}

signed main(){
    cin>>N>>M;
    for(int i=0;i<M;++i){
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        E[P1(a,c)].PB(P2(b,P1(c,0)));
        E[P1(b,c)].PB(P2(a,P1(c,0)));

        E[P1(a,c)].PB(P2(a,P1(0,1)));
        E[P1(a,0)].PB(P2(a,P1(c,1)));
        E[P1(b,c)].PB(P2(b,P1(0,1)));
        E[P1(b,0)].PB(P2(b,P1(c,1)));

        /////////////////////////////
        dist[P1(a,c)] = INF;
        dist[P1(b,c)] = INF;

        dist[P1(a,c)] = INF;
        dist[P1(a,0)] = INF;
        dist[P1(b,c)] = INF;
        dist[P1(b,0)] = INF;

    }
    dijkstra(0);
    if(ans==INF)cout<<-1<<endl;
    else cout<<ans/2<<endl;
}


Measured memory_bytes: 113328
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<map>
using std::cin;using std::cerr;
using std::max;using std::min;
#define N 100005
#define ll long long
#define db double
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
int n,id[N],size[N],fa[N],ecnt,last[N];ll A[N],Sum; 
std::map<ll,int>mp;
struct road{int to,nex;}e[N];
void adde(int u,int v) {e[++ecnt]=(road){v,last[u]},last[u]=ecnt;}
void dfs(int x,int d=0)
{
	Sum+=d;
	for(int k=last[x];k;k=e[k].nex) dfs(e[k].to,d+1);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&A[i]),mp[A[i]]=id[i]=i;
	std::sort(id+1,id+1+n,[](int t1,int t2){return A[t1]<A[t2];});
	for(int i=n,x;i>1;i--)
	{
		x=id[i],size[x]++;
		if(!mp[A[x]-n+size[x]*2]) return puts("-1"),0;
		fa[x]=mp[A[x]-n+size[x]*2],size[fa[x]]+=size[x],adde(fa[x],x);
	}
	dfs(id[1]);
	if(Sum^A[id[1]]) return puts("-1"),0;
	for(int i=1;i<=n;i++) if(fa[i]) printf("%d %d\n",i,fa[i]);
	return 0;
}

Measured memory_bytes: 12288
S = input()

if int(S[:2]) == 0 and 0 < int(S[2:]) <= 12:
  print("YYMM")
elif int(S[2:]) == 0 and 0 < int(S[:2]) <= 12:
  print("MMYY")
elif int(S[:2]) == 0 or int(S[2:]) == 0 or (int(S[:2]) > 12 and int(S[2:]) > 12):
  print("NA")
elif int(S[:2]) > 12 and int(S[2:]) <= 12:
  print("YYMM")
elif int(S[:2]) <= 12 and int(S[2:]) > 12:
  print("MMYY")
else:
  print("AMBIGUOUS")

Measured memory_bytes: 8996
// #include <stdio.h>
// #include <string.h>
// #define INF 1001001000
// #define NO_PRINT 70
// int main() {
// 	int n, m, a[50], b[50], s[50], numCnt[50] = {0};
// 	for (int i = 0; i < 50; i++) {
// 		s[i] = INF;
// 	}
// 	char cmd[15];
// 	scanf("%d", &n);
// 	for (int i = 0; i < n; i++) {
// 		scanf("%d", &a[i]);
// 	}
// 	scanf("%d", &m);
// 	for (int i = 0; i < m; i++) {
// 		scanf("%d", &b[i]);
// 	}
// 	scanf("%s", cmd);
// 	if (strcmp(cmd, "intersection") == 0) {
// 	} else if (strcmp(cmd, "union_set") == 0) {
// 	} else if (strcmp(cmd, "symmetric_diff") == 0) {
// 	} else if (strcmp(cmd, "subtract") == 0) {
// 		int x;
// 		scanf("%d", &x);
// 		for (int i = 0; i < n; i++) {
// 			if (a[i] == x) {
// 				s[i] = NO_PRINT;
// 			} else {
// 				s[i] = a[i];
// 			}
// 		}
// 	} else if (strcmp(cmd, "increment") == 0) {
// 		for (int i = 0; i < n; i++) {
// 			s[i] = (a[i] + 1) % 50;
// 		}
// 	} else if (strcmp(cmd, "decrement") == 0) {
// 		for (int i = 0; i < n; i++) {
// 			s[i] = a[i] - 1;
// 			if (s[i] == -1)
// 				s[i] = 49;
// 		}
// 	}
// 	for (int i = 0; s[i] != INF; i++) {
// 		if (s[i] != NO_PRINT) {
// 			printf("%d ", s[i]);
// 		}
// 	}
// 	return 0;
// }

#include <stdbool.h>
#include <stdio.h>
int a[8], ans = 0;
bool G[8][8] = {0}, isUsed[8] = {0};
void perm(int n, int len) {
	if (len == n) {
		if (a[0] != 0) {
			return;
		}
		bool isOK = true;
		for (int i = 1; i < n; i++) {
			// printf("%d ", a[i]);
			if (!G[a[i]][a[i - 1]]) {
				isOK = false;
				break;
			}
		}
		// printf("\n");
		if (isOK)
			ans++;
		return;
	}
	for (int i = 0; i < n; i++) {
		if (!isUsed[i]) {
			a[len] = i;
			isUsed[i] = true;
			perm(n, len + 1);
			isUsed[i] = false;
		}
	}
}
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		G[a][b] = true;
		G[b][a] = true;
	}
	perm(n, 0);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  const double pi = acos(-1.0);
  double r; cin >> r;
  cout << fixed << setprecision(10) << 2.0 * pi * r << '\n';
}

Measured memory_bytes: 3796
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
	int a,b;
	char op;
	
	while(true){
		cin >> a >> op >> b;
		
		if(op == '?') break;
		else if(op == '+') cout << a + b << endl;
		else if(op == '-') cout << a - b << endl;
		else if(op == '*') cout << a * b << endl;
		else cout << a / b << endl;
	}
}

Measured memory_bytes: 3092
c_list = [list(map(int,input().split()))
     for _ in range(3)]

a_list = [0]
b_list = []

for c in c_list[0]:
    b = c - a_list[0]
    b_list.append(b)

for i in range(1,3):
    c = c_list[i][0]
    b = b_list[0]
    a = c - b
    a_list.append(a)

def check():
    for i in range(3):
        for j in range(3):
            a = a_list[i]
            b = b_list[j]
            c = c_list[i][j]
            if not c == a + b:
                return False
    return True

if check():
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin>>H>>W;
  vector<string>vec(H);
  for(int i=0;i<H;i++){
    cin>>vec.at(i);
    vec.at(i)='#'+vec.at(i)+'#';
  }
  for(int i=0;i<W+1;i++){
    cout<<'#';
  }
  cout<<'#'<<endl;
  for(int i=0;i<H;i++){
    cout<<vec.at(i)<<endl;
  }
  for(int i=0;i<W+1;i++){
    cout<<'#';
  }
  cout<<'#'<<endl;
}

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

int main(void) {
  string num;
  cin >> num;
  
  int n = stoi(num);
  
  int a, b, c, d;
  a = n / 1000;
  b = (n % 1000) / 100;
  c = (n % 100) / 10;
  d = n % 10;
  vector<int> v = {b, c, d};
  vector<char> op(3);

  for (int tmp = 0; tmp < (1 << 3); tmp++) {
    bitset<3> s(tmp);
    
    int sum = a;
    for (int i = 0; i < 3; i++) {
      if (s.test(i)) {
        sum += v.at(i);
        op.at(i) = '+';
      }
      else {
        sum -= v.at(i);
        op.at(i) = '-';
      }
    }
    
    if (sum == 7)
      break;
  }
 
  cout << a;
  for (int i = 0; i < 3; i++)
    cout << op.at(i) << v.at(i);
  cout << "=7" << endl;
  
  return 0;
}
  

Measured memory_bytes: 256
#include <cstdio>
#include <map>
using namespace std;

int main()
{
  char s[10];
  
  scanf("%s", s);
  map<char, char> m;
  m['A'] = 'T';
  m['T'] = 'A';
  m['G'] = 'C';
  m['C'] = 'G';
  printf("%c\n", m[s[0]]);
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

const int MAX = 100;

int SelectionSort(int *A, int n)
{
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        int min = i;
        for (int j = i; j < n; ++j) {
            if (A[j] < A[min]) {
                min = j;
            }
        }
        int save = A[i];
        A[i] = A[min];
        A[min] = save;
        if (i != min) ++cnt;
    }

    return cnt;
}

int main()
{
    int A[MAX];
    int N, cnt;
    std::cin >> N;
    for (int i = 0; i < N; ++i)
        std::cin >> A[i];
    cnt = SelectionSort(A, N);
    for (int i = 0; i < N; ++i) {
        std::cout << A[i];
        if (i != N-1) std::cout << " ";
        else std::cout << std::endl;
    }
    std::cout << cnt << std::endl;

    return 0;
}



Measured memory_bytes: 3088
/*** I came, I saw, I conquered. ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;typedef unsigned long long ull;
#define sc(a) cin >> a
#define pf(a) cout << a << endl
#define forIn(arr, num) for(ll i = 0; i < num; i++) cin >> arr[i];
#define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
#define mod 1000000007
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define GET_SET_BITS(a) (__builtin_popcount(a))
#define GET_SET_BITSLL(a) ( __builtin_popcountll(a))
#define GET_TRAIL_ZERO(a) (__builtin_ctz(a))
#define GET_LEAD_ZERO(a) (__builtin_clz(a))
#define GET_PARITY(a) (__builtin_parity(a))
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
void go() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
/*----------------------------------------------------------------*/
void solve() {
    ll n;
    sc(n);

    ll ans = 0;
    for(int i = 1;i < n;i++) {
        ans += (n - 1) / i;
    }

    pf(ans);
}

int main() {
    go();
    solve();
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;
class Main{
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
    
        int x = scanner.nextInt();
        int y = scanner.nextInt();

        if(x < y) {
            System.out.println("a < b");
        } else if( x == y) {
            System.out.println("a == b");
        } else if(x > y) {
            System.out.println("a > b");
        }
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int w, h, n;
P p1[100001];

signed main() {
  cin >> w >> h >> n;
  int mx = 0, my = 0;
  rep(i, 0, n) {
    cin >> p1[i].first >> p1[i].second;
    mx = max(mx, p1[i].first);
    my = max(my, p1[i].second);
  }
  sort(p1, p1 + n);
  int s, m = 0;
  int ans = min(mx, my);
  dep(i, n - 1, 0) {
    s = p1[i].first;
    ans = min(ans, s + m);
    m = max(m, p1[i].second);
  }
  cout << ans << endl;
}



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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A(N), B(N);
    REP(i,0,N) cin >> A[i];
    REP(i,0,N) cin >> B[i];

    ll S = 0, T = 0;
    REP(i,0,N) {
        if(A[i] >= B[i]) S += A[i] - B[i];
        else T += (B[i] - A[i]) / 2;
    }
    if(S <= T) PR("Yes");
    else PR("No");

    return 0;
}

/*



*/

Measured memory_bytes: 3740
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N,M = map(int,input().split())
ad = [[] for _ in range(N)]
for _ in range(M):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    ad[y].append(x)

dp = [0]*N

def rec(v):
    if dp[v] != 0:
        return dp[v]
    res = 0
    for nv in ad[v]:
        res = max(res, rec(nv) + 1)
    dp[v] = res
    return dp[v]

for v in range(N):
    rec(v)

ans = max(dp)
print(ans)

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;

    int ret = 0;
    for (int i=0; i<k; i++) {
        int rock = 0, paper = 0, scissors = 0;
        for (int j=i; j<n; j+=k) {
            int nr = (t[j] == 's' ? r : 0) + max(paper, scissors);
            int np = (t[j] == 'r' ? p : 0) + max(rock, scissors);
            int ns = (t[j] == 'p' ? s : 0) + max(rock, paper);
            rock = nr;
            paper = np;
            scissors = ns;
        }
        ret += max({rock, paper, scissors});
    }

    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 3760
n = int(input())
arr = list(map(int,input().split()))
res = 1
flag = 1
arr.sort()
inf = int(1e18)
for i in range(n):
  res = res*arr[i]
  if(res > inf):
    flag = 0
    break
 
if(flag == 0):
  print(-1)
else:
  print(res)

Measured memory_bytes: 21600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


int main() {
    int a,b; cin >> a >> b;
    if(abs(a-b) <= 1){
        cout << "Yay!";
    }else{
        cout << ":(";
    }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func chmin(a *int64, b int64) {
	if *a > b {
		*a = b
	}
}

var t [100001]int64
var w [100]int64
var v [100]int64

func main() {
	var n, maxW int64
	fmt.Scan(&n, &maxW)

	for i := int64(0); i < n; i++ {
		fmt.Scan(&w[i], &v[i])
	}

	for i := 0; i < len(t); i++ {
		t[i] = maxW + 1
	}

	maxV := int64(0)
	for i := int64(0); i < n; i++ {
		for j := maxV; j > 0; j-- {
			if t[j] > 0 {
				chmin(&t[j+v[i]], t[j]+w[i])
			}
		}

		chmin(&t[v[i]], w[i])

		maxV += v[i]
	}

	for i := maxV; i > 0; i-- {
		if t[i] <= maxW {
			fmt.Printf("%d\n", i)
			break
		}
	}
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Y = sc.nextInt();
		sc.close();
		for (int x = 0; x <= N; x++) {
			for (int y = 0; y <= N - x; y++) {
				if (10000 * x + 5000 * y + (N - x - y) * 1000 == Y) {
					System.out.println(x + " " + y + " " + (N - x - y));
					return;
				}
			}
		}
		System.out.println("-1 -1 -1");
	}
}


Measured memory_bytes: 22868
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e8
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;


int main() {
	
	int i, n, t; cin >> n >> t;
	vector<int> a(n);
	for (i = 0; i < n; i++)cin >> a[i];
	priority_queue<int> que;
	set<int> check;
	for (i = 0; i < n; i++)que.push(a[i]);

	int ans = 1, benefit=-INF;
	for (i = 0; i < n-1; i++) {
		check.insert(a[i]);
		while (check.count(que.top()) != 0)que.pop();
		int btown = que.top();
		if (btown - a[i] > benefit) {
			benefit = btown - a[i];
			ans = 1;
		}
		else if (btown - a[i] == benefit) ans++;
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> p(n, k-q);
    rep(i, q) {
        int a;
        cin >> a;
        p[a-1]++;
    }
    rep(i, n) {
        if (p[i] > 0) puts("Yes");
        else puts("No");
    }
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = Read();
            var k = N.Length-1;
            var f = true;
            for (int i = 0; i < N.Length; i++)
            {
                if (N[i] != N[k]) f = false;
                k--;
            }

            if (f) Println("Yes");
            else Println("No");
        }


        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11092
import static java.util.Comparator.reverseOrder;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		List<Integer> hillsHightList = new ArrayList<>();
		try {
			while (br.ready()) {
				hillsHightList.add(Integer.valueOf(br.readLine()));
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		Collections.sort(hillsHightList, reverseOrder());

		System.out.println(hillsHightList.get(0));
		System.out.println(hillsHightList.get(1));
		System.out.println(hillsHightList.get(2));

		System.exit(0);
	}
}

Measured memory_bytes: 24212
#include <cstdio>

int main() {
	auto ret = 0, s = 0;
	for(; ; ) {
		auto c = getchar();
		if(c == 'T') {
			if(s != 0) {
				s--;
			} else {
				ret++;
			}
		} else if(c == 'S') {
			s++;
		} else {
			break;
		}
	}
	printf("%d\n", ret + s);
	return 0;
}

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

int main() {
    string s,t; cin >> s >> t;
    vector<string> ans;
    int l = s.size()-t.size()+1;
    for(int inc = 0; inc < max(0, l); inc ++) {//sの可能性があるところまで
        string tmp = s;
        for(int j = 0; j < t.length(); j ++) {//tを一つずつ比べる
            if(inc+j>s.size()-1) break;//
            if(tmp[inc+j]=='?' || tmp[inc+j]==t[j]) tmp[inc+j] = t[j];
            else break;
            if(j==t.length()-1) {
                for(int k = 0; k < tmp.length(); k ++) {
                    if(tmp[k]=='?') tmp[k] = 'a';
                }
                ans.push_back(tmp);
            }
        }
    }
    sort(ans.begin(), ans.end());
    cout << (ans.size() > 0 ? ans[0] : "UNRESTORABLE") << endl;
    return 0;
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int N, M;
    cin >> N >> M;

    double ans = 0;
    double x = 100 * (N - M) + 1900 * M;
    double p = pow(0.5, M);
    for (int t = 1; t < 1000000; t++) {
        ans += x * t * p * pow(1.0 - p, t-1);
    }
    print(round(ans));
}

signed main() {
    solve();
}


Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;

public class Example3
{
	public static void Main ()
	{
		int count = int.Parse( Console.ReadLine ());
		List <string> triangleParameterList = new List<string> ();

		for (int i = 0; i < count; i++) {

			string tempStr = Console.ReadLine ();
			triangleParameterList.Add (tempStr);
		}

		foreach (var t in triangleParameterList) {

			string[] triangleParameterStr = t.Split (' ');
			int[] triangleParameter = new int[3];

			for (int j = 0; j < 3; j++){
				triangleParameter [j] = int.Parse( triangleParameterStr [j]);
			}

			if (isTriangle (triangleParameter)) {
				Console.WriteLine ("YES");
			} else {
				Console.WriteLine ("NO");
			}

		}

	}

	public static bool isTriangle(int[] triangleParameter){



		Array.Sort (triangleParameter);

		int result1 = triangleParameter[0]*triangleParameter[0] + triangleParameter[1]*triangleParameter[1];
		int result2 = triangleParameter [2] * triangleParameter [2];
		           
		if (result1 == result2) {
			return true;
		} else {
			return false;
		}

	}
}

Measured memory_bytes: 5744
//
//  main.cpp
//  B - Harshad Number
//
//  Created by wenhan on 2017/12/3.
//  Copyright © 2017年 wenhan. All rights reserved.
//

#include <iostream>
using namespace std;
int main() {
    int n;
    cin>>n;
    int m=0,t=n;
    while(n){
        m+=n%10;
        n=n/10;
    }
    cout<<((t%m==0)?"Yes":"No")<<endl;
    // insert code here...
    //td::cout << "Hello, World!\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string s;
    int r=0,p=0,ans=0;
    cin>>s;
    for(int i=0; i<s.length(); i++)
    {
        if(s[i]=='g' && p<r)
        {
            ans++;
            p++;
        }
        else if(s[i]=='g')
            r++;
        else
            p++;
        if(p>r)
        {
           // cout<<p<<" "<<i<<" "<<r<<endl;
            r++;
            p--;
            ans--;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    vector<ll> s(n+1);
    rep(i,n) s[i+1] = s[i]+a[i];
    ll ans = INF;
    rep(i,1,n){
        chmin(ans,abs(s[n]-2*s[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	int r;
	cin >> r;
	cout << r * r;
	return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;




int main(){
    int e;
    while(cin>>e){
        if(e==0)break;
        
        int mi=INF;
        rep(i,1001){
            rep(j,101){
                int a=(e-(i*i + j*j*j) );
//                cout<<i<<" "<<j<<" "<<a<<endl;
                if(a<0)break;
                mi=min(mi,a+i+j);

            }
        }
        cout<<mi<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(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 tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    ll T = 1, A = 1;
    rep(i,n) {
        ll t,a;
        cin >> t >> a;
        ll num = max((T+t-1)/t,(A+a-1)/a);
        T = num*t;
        A = num*a;
    }
    cout << T+A << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()

template<class T> using V = vector<T>;
template<class T> using V2 = V<V<T>>;



void solve(){
  vector<int> ten = {1,10,100,1000,10000,100000,1000000,10000000};
  int n; cin >> n; int ans = 0;
  FOR(j,0,6){
    if(n<ten[j+1] && n >=ten[j]) {
      if(j%2==0) {
        ans += 9*ten[j] - (ten[j+1]-n-1);
      }
      break;
    }
    if(j%2==0){
      ans += 9*ten[j];
    }
  }
  cout << ans << endl;
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll x;
    cin >> x;
    for (ll i = x; i > 0; i--) {
        for (ll b = 1; b < 40; b++) {
            for (int p = 2; p < 10; p++) {
                ll now = 1;
                rep(_, p) now *= b;
                if (now == i) {
                    cout << i << endl;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 256