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

int main()
{
  string S;
  cin >> S;
  
  while(S.length() >= 0)
  {
    if(S.length() == 0)
    {
      cout << "YES" << endl;
      return 0;
    }
      
    if(S.substr(S.length() - 5, 5) == "dream" || S.substr(S.length() - 5, 5) == "erase")
    {
      S = S.substr(0, S.length() - 5);
    }
    else if(S.substr(S.length() - 6, 6) == "eraser")
    {
      S = S.substr(0, S.length() - 6);
    }
    else if(S.substr(S.length() - 7, 7) == "dreamer")
    {
      S = S.substr(0, S.length() - 7);
    }
    else
    {
      cout << "NO" << endl;
      return 0;
    }    
  }
  
  return 0;
}    

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	double N;
	cin >> N;
	vector<double> x(N);
	vector<double> y(N);
	rep(i, N) {
		cin >> x[i] >> y[i];
	}
	double ans = 0.0;
	rep(i, N) {
		rep(j, N) {
			if (i >= j)
				continue;
			double len = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
			ans += len;
		}
	}
	ans /= N;
	ans *= 2;
	printf("%.12f\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

int main(){

  long long int s[32] = {1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};

  long long int K;
  std::cin >> K;

  std::cout << s[K-1] << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

struct segtree{
    int size;
    vector<ll> dat;
    ll init = 0;

    segtree (int N) {
        size = 1;
        while (size < N) size *= 2;
        dat = vector<ll>(2*size-1, init);
    }

    ll op(ll a, ll b) {
        return max(a, b);
    }

    void update(int i, ll x) { 
        i += size-1;
        dat[i] = x;
        while (i > 0) {
            i = (i-1)/2;
            dat[i] = op(dat[2*i+1], dat[2*i+2]);
        }
        return;
    }

    ll get(int i) {
        return dat[i+size-1];
    }

    ll query(int a, int b) {
        return query(a, b, 0, 0, size);
    }
    

    ll query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return init;
        if (a <= l && r <= b) return dat[k];
        ll lv, rv;
        lv = query(a, b, 2*k+1, l, (l+r)/2);
        rv = query(a, b, 2*k+2, (l+r)/2, r);
        return op(lv, rv);
    }
};

int main() {
    int N;
    cin >> N;
    vector<ll> H(N), A(N);
    for (int i = 0; i < N; i++) cin >> H[i];
    for (int i = 0; i < N; i++) cin >> A[i];
    
    segtree sgt(N+1);
    for (int i = 0; i < N; i++) {
        sgt.update(H[i], sgt.query(0, H[i])+A[i]);
    }
    cout << sgt.query(0, N+1) << endl;
    return 0;
}

Measured memory_bytes: 10376
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int T = sc.nextInt();
        int[] t = new int[N];
        for (int i = 0; i < t.length; ++i) {
            t[i] = sc.nextInt();
        }

        System.out.println(solve(t, T));

        sc.close();
    }

    static long solve(int[] t, int T) {
        long result = 0;
        int prev = 0;
        for (int ti : t) {
            result += Math.min(T, ti + T - prev);
            prev = ti + T;
        }

        return result;
    }
}

Measured memory_bytes: 64928
# ref https://atcoder.jp/contests/practice2/submissions/16604990
# ref https://aotamasaki.hatenablog.com/entry/2020/09/09/Cython_in_AtCoder

mycode = r"""
# distutils: language=c++
# distutils: include_dirs=/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include
# cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "/opt/atcoder-stl/atcoder/dsu.hpp" namespace "atcoder":
    cdef cppclass dsu:
        dsu(int n)
        int merge(int a, int b)
        bool same(int a, int b)
        int leader(int a)
        int size(int a)
        vector[vector[int]] groups()

from libc.stdio cimport scanf, printf
cdef int i
cdef int N, Q
cdef int t, u, v
scanf("%d%d", &N, &Q)
cdef dsu *d = new dsu(N)
for i in range(Q):
    scanf("%d%d%d", &t, &u, &v)
    if t == 0:
        d.merge(u, v)
    else:
        printf("%d\n", d.same(u, v))
"""
import os
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    with open('solve.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 solve.pyx')
import solve


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

int main() {
  int A,B;
  cin>>A>>B;
  if(A<10&&B<10){cout<<A*B<<endl;}else{cout<<-1<<endl;}
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define BLN 65536

static char *p;
static char *query;
static char buffer[ BLN ];

struct line
{
  int ind;
  char *a;
  char *b;
};
typedef struct line line;
static line lp[ BLN ];
static int ln = 0;

int
main (
  int   argc,
  char *argv[ ]
  )
{
  char *q, *nq;
  int b, lv;

  for ( p = buffer; ; )
  {
    q = fgets ( p, BLN - ( p - buffer ), stdin );
    if ( q == NULL ) break ;
    p = q + strlen ( q );
  }

  query = buffer;
  p = strchr ( buffer, '\n' );
  *( p++ ) = '\0';

  for ( ; *p != '\0' ; ++ln )
  {
    for ( lp[ ln ].ind = 0; *p == ' '; ++lp[ ln ].ind, ++p ) ;
    lp[ ln ].a = p;
    p = strchr ( p, ':' );
    *( p++ ) = '\0';
    if ( *p == '\n' )
    {
      lp[ ln ].b = NULL;
      ++p;
    }
    else
    {
      lp[ ln ].b = ++p;
      p = strchr ( p, '\n' );
      *( p++ ) = '\0';
    }
  }

  lv = 0; ++query;
  nq = strchr ( query, '.' );
  if ( nq != NULL )
    *( nq++ ) = '\0';
  for ( b = 0; b < ln; ++b )
  {
    if ( lp[ b ].ind < lv )
    {
      b = ln;
      continue ;
    }
    else if ( lp[ b ].ind > lv )
      continue ;

    if ( !strcmp ( lp[ b ].a, query ) )
    {
      if ( nq == NULL )
      {
        if ( lp[ b ].b == NULL )
          puts ( "object" );
        else
          printf ( "string \"%s\"\n", lp[ b ].b );
        break ;
      }
      else if ( lp[ b ].b != NULL )
      {
        b = ln;
        continue ;
      }

      query = nq;

      nq = strchr ( query, '.' );
      if ( nq != NULL )
        *( nq++ ) = '\0';

      lv = lp[ b + 1 ].ind;
    }
  }
  if ( b >= ln )
    puts ( "no such property" );

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 596
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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 ll INF = 1LL << 60;

int main() {
    int n, m; cin >> n >> m;
    int a[n];
    rep(i, n) cin >> a[i];
    double sum = 0;
    rep(i, n) sum += a[i];
    int res = 0;
    rep(i, n) {
        if((double)a[i] >= sum / (double)4 / (double)m) res++;
    }
    if(res < m) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int antenna[100];
	for (int i = 0; i < 5; i++) cin >> antenna[i];
	int k; cin >> k;

	int distance = 0;
	bool flag = 0;
	for (int i = 0; i < 5; i++) {
		for (int j = i+1; j < 5; j++) {
			distance = max(distance, abs(antenna[i]-antenna[j]));
			if (distance > k) {
				flag = 1;
				break;
			}
		}
	}
	if (flag == 0) cout << "Yay!" << endl;
	else cout << ":(" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod=1e9+7 ;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define input_from_file  freopen("input.txt", "r", stdin);
using namespace std::chrono; 

int main()
{
  // input_from_file 
  ll q;q=1;while(q--){
    ll n;cin>>n;vector<ll> vec(n,0);
    for(int i=0;i<n;i++)  cin>>vec[i];
    ll ans=1000,val=1000,stocks=0;
    if(vec[0]<vec[1]){
      stocks=val/vec[0];
      val-=stocks*vec[0];
    }
    // cout<<"i="<<"0"<<" ,val="<<val<<" ,ans="<<ans<<" ,stocks="<<stocks<<" "<<endl;
    for(int i=1;i<n-1;i++){
      if(vec[i-1]<=vec[i] && vec[i]>=vec[i+1]){
        val+=stocks*vec[i];
        stocks=0;
        ans=max(ans,val);
      }
      if(vec[i-1]>=vec[i] && vec[i]<=vec[i+1]){
        stocks+=val/vec[i];
        val-=(val/vec[i])*vec[i];
        // if(i==5)cout<<vec[i-1]<<" "<<vec[i]<<" "<< vec[i+1]<<endl;
        // if(i==5)break;
      }
      // cout<<"i="<<i<<" ,val="<<val<<" ,ans="<<ans<<" ,stocks="<<stocks<<" "<<endl;
      
    }
    if(vec[n-1]>=vec[n-2]){
      val+=stocks*vec[n-1];
      stocks=0;
      ans=max(ans,val);
      // cout<<"i="<<n-1<<" ,val="<<val<<" ,ans="<<ans<<" ,stocks="<<stocks<<" "<<endl;
    }
    cout<<ans;
  }
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=2e5+500;
char st[10];
int w[N],fh[N],n,lst[N];long long s[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",w+i);
		if(i!=n)
		{
			scanf("%s",st+1);
			if(st[1]=='-')fh[i]=-1;else fh[i]=1;
		}
	}
	long long ans=w[1];for(int i=2;i<=n;i++)ans+=fh[i-1]*w[i];
	for(int i=1;i<=n;i++)s[i]=s[i-1]+w[i];
	lst[n]=n;long long pres=0;
	for(int i=n-1;i>=1;i--)if(fh[i]==1)lst[i]=lst[i+1];else lst[i]=i;
	fh[0]=1;
	for(int i=1;i<n;i++)
	{
		pres+=fh[i-1]*w[i];
		if(fh[i]==-1)ans=max(ans,s[n]-s[lst[i+1]]-(s[lst[i+1]]-s[i])+pres);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
int main(){
    int N;
    cin >> N;
    vector<P> a(N);
    for(int i = 0 ; i < N; i++) {
        long long b;
        cin >> b;
        a[i] = P(b, i);
    }
    sort(a.begin(), a.end());
    long long dp[N + 1][N + 1];
    long long ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++) dp[i][j] = 0;
    }
    dp[0][0] = 0;
    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= i; j++){
            int k = i - j;
            if(j == 0) dp[j][k] = dp[j][k - 1] + abs(N - k - a[N - i].second) * a[N - i].first;
            else if(k == 0) dp[j][k] = dp[j - 1][k] + abs(j - 1 - a[N - i].second) * a[N - i].first;
            else {
                long long m1 = dp[j][k - 1] + abs(N - k - a[N - i].second) * a[N - i].first;
                long long m2 = dp[j - 1][k] + abs(j - 1 - a[N - i].second) * a[N - i].first;
                dp[j][k] = max(m1, m2);
            }
        }
    }
    for(int i = 0; i <= N; i++) ans = max(ans, dp[i][N - i]);
    cout << ans << endl;
}

Measured memory_bytes: 34908
#include <iostream>

using namespace std;

int main()
{
	char sr[20];
	cin >> sr;
	for (int i = 20; i >0; i--)
	{
		if (sr[i - 1] != '\0') {
			cout << sr[i - 1];
		}
	}cout << endl;
	return 0;
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
#define LL long long
#define db double

using namespace std;
const int N=1e5+10;
LL rd()
{
	LL x=0,w=1;char ch=0;
	while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return x*w;
}
int n,m,v,p,a[N];
bool ck(int md)
{
	LL rs=1ll*(v-1)*m;
	int j=p-1;
	for(int i=n;i;--i)
	{
		if(i==md) continue;
		if(j>0)
		{
			rs-=m;
			j-=a[i]>a[md];
		}
		else
		{
			int dt=min(m,a[md]+m-a[i]);
			if(dt<0) return 0;
			rs-=dt;
		}
	}
	return rs<=0;
}

int main()
{
	n=rd(),m=rd(),v=rd(),p=rd();
	for(int i=1;i<=n;++i) a[i]=rd();
	sort(a+1,a+n+1);
	int l=1,r=n;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(ck(mid)) r=mid-1;
		else l=mid+1;
	}
	printf("%d\n",n-r);
	return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
   	int n=read(),m=read();
   	if((n+m)&1)puts("IMPOSSIBLE");
   	else pr2((n+m)/2);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;

int main(){

    ll H, W, A, B;
    cin >> H >> W >> A >> B;

    ll n_rows = H;
    ll n_cols = W;
    ll value = 0;
    vector<vector<ll > > vec(H, vector<ll >(W, 0));;

    for(ll i = 0; i < H; i++){
        for(ll j = 0; j < W; j++){
            if(i < B && j < A){
                vec[i][j] = 0;
            }else if(i >= B && j < A){
                vec[i][j] = 1;
            }else if(i < B && j >= A){
                vec[i][j] = 1;
            }else if(i >= B && j >= A){
                vec[i][j] = 0;
            }
        }  


    }

    for(ll i = 0; i < H; i++){
        for(ll j = 0; j < W; j++){
            cout << vec[i][j];
        }  
        cout << endl;
    }

} 

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x, n; cin >> x >> n;
    set<int> st;
    for (int i = 0; i <= 101; i++)
        st.insert(i);
    for (int i = 0; i < n; i++) {
        int t; cin >> t;
        st.erase(t);
    }
    int ans = 0;
    int mi = INT_MAX;
    for (auto i : st)
    	if (abs(i - x) < mi)
    		mi = abs(i - x), ans = i;
    cout << ans << "\n";
}

Measured memory_bytes: 3636
#include <iostream>

int classify(int x)
{
    switch (x)
    {
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:    return 1;
        case 4:
        case 6:
        case 9:
        case 11:    return 2;
        default:    return 3;
    }
}

int main(void)
{
    int x, y;
    std::cin >> x >> y;
    x = classify(x);
    y = classify(y);
    bool flag = (x == y);
    std::cout << (flag ? "Yes" : "No") << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;

template <typename T>
class UnionFind {
 private:
  vector<T> parent;
  vector<T> group_size;

 public:
  UnionFind(T size_) : parent(size_), group_size(size_, 1) {
    iota(parent.begin(), parent.end(), 0);
  }

  void reset() {
    iota(parent.begin(), parent.end(), 0);
    fill(group_size.begin(), group_size.end(), 1);
  }
  
  T root(T x) { return parent[x] == x ? x : parent[x] = root(parent[x]); }

  void merge(T x, T y) {
    x = root(x);
    y = root(y);
    if (x == y) return;

    if (group_size[x] < group_size[y]) swap(x, y);
    group_size[x] += group_size[y];
    parent[y] = x;
  }

  bool same(T x, T y) { return root(x) == root(y); }
  T size(T x) { return group_size[root(x)]; }
};


int main() {
  int N, M, A, B, ans{};
  cin >> N >> M;
  UnionFind<int> u(N);
  while (cin >> A >> B) {
    u.merge(--A,--B);
  }
  for (int i = 0; i !=N; ++i) {
    ans = max(ans, u.size(i));
  }
  cout << ans << endl;
}


Measured memory_bytes: 4752
#include<iostream>
#include<string>
#include <vector>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
#define PI 3.141592653589793
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 1e9 + 7;

int main() {
	ll n, k;
	cin >> n >> k;
	vi p(n);
	rep(i, n) cin >> p[i];
	vector<double> e(n);
	rep(i, n) {
		double q = p[i];
		double ex = q * (q + 1.0) / (2.0 * q);
		e[i] = ex;
	}
	for (ll i = 1; i < n; i++) {
		e[i] = e[i] + e[i - 1];
	}
	double ans = e[k - 1];
	for (int i = 0; i < n - k; i++) {
		double t = e[i + k] - e[i];
		if (t > ans) ans = t;
	}
	cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 2560
using System;


public class B{
	
	public static void Main(){
	
		string[] args = Console.ReadLine().Split(' ');
		int x1, y1, x2, y2, x3, y3, x4, y4;
		x1 = Int32.Parse(args[0]);
		y1 = Int32.Parse(args[1]);
		x2 = Int32.Parse(args[2]);
		y2 = Int32.Parse(args[3]);
		
		int dx = x2 - x1;
		int dy = y2 - y1;
		x3 = -dy + x2;
		y3 = dx + y2;
		x4 = -dx + x3;
		y4 = -dy + y3;
		Console.WriteLine("{0} {1} {2} {3}", x3, y3, x4, y4);
		
	}

}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string s;
  cin >> s;
  bool ans = true;
  for(int i = 1; i < 4 ;i++){
    if(s.at(i) == s.at(i-1)) ans = false;
  }
  puts(ans ? "Good" : "Bad");
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll N;
    cin >> N;
    ll m, j, len;
    for(int i = 1; i <= sqrt(N); i++) {
        if(N % i == 0) {
            j = N / i;
            len = i + j - 2;
            m = min(m, len);
        }
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

int st[51];
int n,p;

bool isended(int arg){
    bool ret = true;
    for(int i=0;i<n;i++){
        if(i == arg) continue;
        if(st[i] != 0){
            ret = false;
            break;
        }
    }
    return ret;
}

int main(){
    while(cin >> n >> p){
        if((n|p) == 0) break;
        int turn = 0;

        memset(st, 0, sizeof(st));
        
        while(1){
            if(p > 0){
                p--;
                st[turn]++;
                if(p == 0 &&
                   isended(turn)){
                    break;
                }
            }else{
                p += st[turn];
                st[turn] = 0;
            }
            turn++;
            turn %= n;
        }
        cout << turn << endl;
    }
}

Measured memory_bytes: 864
#include <iostream>
#include <math.h>
using namespace std;
int main(){
    int A,B;
    cin>>A>>B;
    float noPowerStrips = (B-A) / (A-1.0);
    int ans = (int)(ceil(noPowerStrips));
    cout<<ans + 1<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int a, b, c;
  char ch;
  int p = 0, q = 0;
  while (cin >> a >> ch >> b >> ch >> c) {
    p += (a * a + b * b == c * c);
    q += (a == b);
  }
  cout << p << endl;
  cout << q << endl;

  return 0;
}


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

int main(){
  string a, b;
  cin >> a >> b;
  if(a.length() > b.length()) cout << "GREATER" << endl;
  else if(b.length() > a.length()) cout << "LESS" << endl;
  else {
    int f = 0;
    rep(i,a.length()) {
      if(a[i] != b[i]) {
        if(a[i] > b[i]) f = 1;
        else if(a[i] < b[i]) f = -1;
        break;
      }
    }
    if(f == 1) cout << "GREATER" << endl;
    else if(f == -1) cout << "LESS" << endl;
    else cout << "EQUAL" << endl;
  }
  return 0;
}


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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 2e5 + 5;
ll mod = 1e9 + 7;
ll fact[N];
ll inv(ll u, ll p){
        if (p == 0) return 1;
        if (p == 1) return u;
        ll t = inv(u, p/2) % mod;
        if (p & 1) return t * t % mod * u % mod;
        return t * t % mod;
}
ll nck(ll n, ll k){
        return fact[n] * inv(fact[k], mod - 2) % mod * inv(fact[n - k], mod - 2) % mod;
}
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (fopen(".INP", "r")){
                freopen(".INP", "r", stdin);
                freopen(".OUT", "w", stdout);
        }
        ll n, k;
        cin >> n >> k;
        fact[0] = 1;
        for (int i = 1; i <= n; i++){
                fact[i] = fact[i - 1] * i % mod;
        }
        ll ans = 0;
        for (int i = 0; i <= min(k, n - 1); i++) {
                ans += nck(n, i) * nck(n - 1, i) % mod;
                ans %= mod;
        }
        cout << ans;
}


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

int main() {
 
 

  string s;
  cin >> s;
  
  while (s != "-") {
  
  int m;
  cin >> m;
  
    for (int i=0; i<m; i++ ) {
      int h;
      cin >> h;
      string x;
      x = s.substr(0, h);
      s.erase(0, h);
      s.append(x);
    }
  
    cout << s << endl;
    
    cin >> s;
  }
  
return 0;
}




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

int main(){
#ifdef _DEBUG
	freopen("in" , "r", stdin );
	freopen("out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int a, b, c; cin >> a >> b >> c;
	if(a + b == c || a + c == b || b + c == a) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;


int main(){
  string s;
  cin >> s;
  rep(i,3){
    if(s[i]=='1')s[i]='9';
    else if(s[i]=='9')s[i]='1';
  }
  cout << s <<endl;
}

Measured memory_bytes: 3596
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Clue = Tuple!(long, "x", long, "y", long, "h");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

long cnt;

void main()
{
    auto ary = new long[](MAX);
    auto is_prime = new bool[](MAX);
    is_prime[] = true;
    is_prime[0] = is_prime[1] = false;
    foreach (i; iota(MAX))
    {
        if (!is_prime[i])
            continue;

        foreach (j; iota(0, MAX, i))
        {
            is_prime[j] = false;
        }
        is_prime[i] = true;
    }
    foreach (i; iota(1, MAX))
        ary[i] = ary[i - 1] + (is_prime[i] && is_prime[(i + 1) / 2] ? 1 : 0);
    auto q = lread();
    foreach (i; iota(q))
    {
        long l, r;
        scan(l, r);
        writeln(ary[r] - ary[l - 1]);
    }
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 11772
$memo = Array.new(10000)
def f n
  x = $memo[n]
  return x if x
  return 0 if n==6174
  return "NA" if n%1111==0
  str = "%04d" % n
  l = str.chars.sort.reverse.join.to_i
  s = str.chars.sort.join.to_i
  m = l - s
  r = f m
  $memo[n] = r + 1
end

loop do
  s = gets.chomp
  break if s=="0000"
  puts f s.to_i
end


Measured memory_bytes: 7004
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<bitset>
#include<tuple>
#include<time.h>
#include<list>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

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; }




void solve(){
	int a,b;
	while(cin >> a >> b){
		cout << __gcd(a,b) << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

int main(){
  int A, B, C, K;
  cin >> A >> B >> C >> K;

  int D[3] = {A, B, C};
  sort(D, D + 3);
  for(int i = 0; i < K; i++){
     D[2] *= 2;
  }
  cout << D[0] + D[1] + D[2] << endl;
}


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

using namespace std;

inline void Boost() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}
typedef long long int ll;
typedef long double ld;

int main() {
	Boost();

	int n, k; cin >> n >> k;

	ll ans = 0;
	for (int b = k + 1; b <= n; ++b) {
		ans += (n / b) * (b - k);
		int now = n;
		int prev = (n / b) * b;
		// cout << (n / b) * (b - k) << " " << max(0, now - prev - k + 1) << " " << now << " " << prev << endl;
		ans += max(0, now - prev - k + 1);
	}

	if (k == 0) ans -= n;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int N, T, A;
  cin >> N >> T >> A;
  
  vector<double> h(N);
  for(int i=0; i<N; i++){
    cin >> h.at(i);
  }
  vector<double> temp(N);
  for(int i=0; i<N; i++){
	temp.at(i) = T-h.at(i)*0.006;
  }
  vector<double> gap(N);
  for(int i=0; i<N; i++){
    if(temp.at(i) >= A){
      gap.at(i) = temp.at(i)-A;
    }
    else{
      gap.at(i) = A-temp.at(i);
    }
  }
    int ans = 1;
  double d = gap.at(0);
   for(int i=0; i<N-1; i++){
    if(d > gap.at(i+1)){
      d = gap.at(i+1);
      ans = i+2;
      
    }
   }
    cout << ans << endl;
  } 

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N;
  cin >> N;
  string S;
  cin >> S;
  bool done = false;
  int hidari = 0;
  int migi = 0;
  while (!done) {
    hidari = 0;
    migi = 0;
    for (int i = 0; i < S.size(); i++) {
      if (S[i] == '(') {
        hidari++;
      } else {
        migi++;
      }
      if (migi > hidari) {
        S.insert(S.begin(), '(');
        break;
      }
      if (i == S.size() - 1) {
        done = true;
      }
    }
  }
  for (int i = 0; i < hidari - migi; i++) {
    S.insert(S.end(), ')');
  }
  cout << S << endl;
}

Measured memory_bytes: 3640
#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;

#define endl '\n'

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

const int maxn = 1e5 + 5;

int n;
ll m;

vector<int> g[maxn];
vector<ll> pref[maxn], suff[maxn];

ll down[maxn], up[maxn];

int idx[maxn];

void get_down(int u, int p){
	down[u] = 1;
	
	for(int i = 0; i < (int)g[u].size(); i++){
		int v = g[u][i];
		if(v != p){
			get_down(v, u);
			ll x = (down[v] + 1) % m;
			down[u] = (down[u] * x) % m;
			idx[v] = i;
		}
	}
	
	for(int i = 0; i < (int)g[u].size(); i++){
		int v = g[u][i];
		if(v == p)
			pref[u][i] = 1;
		else
			pref[u][i] = (down[v] + 1) % m;
		if(i)
			pref[u][i] = (pref[u][i] * pref[u][i - 1]) % m;
	}
	
	for(int i = (int)g[u].size() - 1; i >= 0; i--){
		int v = g[u][i];
		if(v == p)
			suff[u][i] = 1;
		else
			suff[u][i] = (down[v] + 1) % m;
		if(i + 1 != (int)g[u].size())
			suff[u][i] = (suff[u][i] * suff[u][i + 1]) % m;
	}
}

void get_up(int u, int p){

	if(u == 1)
		up[u] = 1;
	else{
		up[u] = up[p];
		int l = idx[u] - 1;
		int r = idx[u] + 1;
		if(l >= 0)
			up[u] = (up[u] * pref[p][l]) % m;
		if(r < (int)g[p].size())
			up[u] = (up[u] * suff[p][r]) % m;
		up[u] = (up[u] + 1) % m;
	}

	for(int i = 0; i < (int)g[u].size(); i++){
		int v = g[u][i];
		if(v != p)
			get_up(v, u);
	}
}

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	cin >> n >> m;
	for(int i = 1, a, b; i < n; i++){
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	for(int i = 1; i <= n; i++){
		pref[i].resize((int)g[i].size());
		suff[i].resize((int)g[i].size());
	}
	
	get_down(1, 0);
	get_up(1, 0);

	for(int i = 1; i <= n; i++){
		ll ans = down[i] * up[i] % m;
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 25088
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <complex>

using namespace std;

#define all(c) ((c).begin()),((c).end())
#define debug(c) cerr<<"> "<<#c<<" = "<<(c)<<endl;
#define iter(c) __typeof((c).begin())
#define tr(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)

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

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

#define EPS 1.0e-6

//ツ点
typedef complex<double> P;

struct C{
	P p;
	double r;
};

vector<P> isCC(const C &c1, const C &c2) {
	double d = abs(c1.p - c2.p);
	if (c1.r + c2.r - d < -EPS || fabs(c1.r - c2.r) - d > EPS) return vector<P>();
	double x = (d*d + c1.r * c1.r - c2.r * c2.r) / 2 / d;
	double y = sqrt(c1.r * c1.r - x * x);
	P diff = (c2.p - c1.p) / d;
	vector<P> res;
	res.pb(c1.p + diff * P(x, y));
	if (y != 0) res.pb(c1.p + diff * P(x, -y));
	return res;
}


int main() {
	for (int N; cin >> N, N != 0; ) {
		vector<P> ps;
		rep (i, N) {
			double x, y; cin >> x >> y;
			ps.pb(P(x, y));
		}
		int res = 0;
		rep (i, N) REP (j, i + 1, N-1) {
			vector<P> isp = isCC((C){ps[i],1},(C){ps[j],1});
			rep (k, isp.size()) {
				int cnt = 0;
				rep (l, N) if (abs(isp[k] - ps[l]) <= 1 + EPS) cnt++;
				res = max(res, cnt);
			}
		}
		if (res == 0) res++;
		cout << res <<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Dice dice = new Dice(new int[]{sc.nextInt(), sc.nextInt(), sc.nextInt(),
                                       sc.nextInt(), sc.nextInt(), sc.nextInt()});

        int count = sc.nextInt();
        for (int i = 0; i < count; i++) {
            int[] a = new int[]{sc.nextInt(), sc.nextInt()};
            while (dice.eyes[dice.now[0]] != a[0]) {
                int idx = dice.find(a[0]);
                if (idx == 2 || idx == 4) {
                    dice.move('E');
                } else {
                    dice.move('N');
                }
            }
            while (dice.eyes[dice.now[3]] != a[1]) {
                dice.spin('R');
            }
            System.out.println(dice.eyes[dice.now[2]]);
        }
    }

    static class Dice {

        int[] eyes;
        int[/*TOP N E S W BOT*/] now;

        public Dice(int[] eyes) {
            this.eyes = eyes;
            this.now = new int[]{0, 4, 2, 1, 3, 5};
        }

        int find(int eye) {
            for (int i = 0; i < now.length; i++) {
                if (eyes[now[i]] == eye) {
                    return i;
                }
            }
            return -1; // never comes
        }

        void move(char way) {
            int tmp;
            switch (way) {
                case 'N':
                    tmp = now[0];
                    now[0] = now[3];
                    now[3] = now[5];
                    now[5] = now[1];
                    now[1] = tmp;
                    break;
                case 'E':
                    tmp = now[0];
                    now[0] = now[4];
                    now[4] = now[5];
                    now[5] = now[2];
                    now[2] = tmp;
                    break;
                case 'S':
                    tmp = now[0];
                    now[0] = now[1];
                    now[1] = now[5];
                    now[5] = now[3];
                    now[3] = tmp;
                    break;
                case 'W':
                    tmp = now[0];
                    now[0] = now[2];
                    now[2] = now[5];
                    now[5] = now[4];
                    now[4] = tmp;
                    break;
            }
        }

        void spin(char way) {
            int tmp;
            switch (way) {
                case 'R':
                    tmp = now[1];
                    now[1] = now[4];
                    now[4] = now[3];
                    now[3] = now[2];
                    now[2] = tmp;
                    break;
                case 'L':
                    tmp = now[1];
                    now[1] = now[2];
                    now[2] = now[3];
                    now[3] = now[4];
                    now[4] = tmp;
                    break;
            }
        }
    }
}

Measured memory_bytes: 26180
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
int expo(int x,int y, int MOD){
    int ans = 1;
    while(y){
        if(y&1) ans = ans * x % MOD;
        x = x*x % MOD, y >>= 1;
    }
    return ans;
}
int fun(vector<int> A, int n) 
{ 
    int fun2 = 0; 
    for (int i = 0; i < n; i++) 
        fun2 = (fun2 + A[i])%mod; 
  
    int fun2_square = (fun2 * fun2)%mod; 
  
    int fun1 = 0; 
    for (int i = 0; i < n; i++) 
        fun1 =( fun1 + (A[i]*A[i])%mod)%mod; 
  
    
    int ans = (fun2_square - fun1) % mod;
    ans = (ans + mod)%mod;
    int mul = expo(2,mod-2,mod);
    ans = (ans*mul)%mod;
    return ans;
} 
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        int n; cin  >> n;
        vector<int> a(n);
        FOR(i,0,n) cin >> a[i];
        cout << fun(a,n);
    }    
}


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

ll v = coin * 50;
vector<vector<pair<ll,ll>>> graph(v,vector<pair<ll,ll>>());
vector<ll> shortest(v);
vector<bool> visited(v,false);

void dijkstra(ll start){
    priority_queue<pair<ll,ll>,vector<pair<ll ,ll>>,greater<pair<ll,ll>>> pq;
    pq.push(make_pair(0,start));
    while (!pq.empty()){
        pair<ll,ll> now = pq.top();
        pq.pop();
        ll cost,node;
        tie(cost,node) = now;
        if(visited[node]){
            continue;
        }else{
            shortest[node] = cost;
            visited[node] = true;
            for(pair<ll,ll> next:graph[node]){
                ll next_cost,next_node;
                tie(next_cost,next_node) = next;
                pq.push(make_pair(cost+next_cost,next_node));
            }
        }
    }
}


int main(){
    ll n,m,s;
    cin >> n >> m >> s;
    rep(ii,m){
        ll p,q,a,b;
        cin >> p >> q >> a >> b;
        --p;--q;
        p *= coin,q *= coin;
        for(int i=0;i<coin-a;i++){
            graph[p+a+i].push_back(P(b,q+i));
            graph[q+a+i].push_back(P(b,p+i));
        }
    }
    rep(i,n){
        ll c,d;
        cin >> c >> d;
        rep(x,coin){
            if(x+c >= coin) break;
            graph[i*coin+x].push_back(P(d,i*coin+x+c));
        }
    }

    s = min(s,2500LL);
    dijkstra(0 + s);
    ll ans = INF;
    for(int i=2501;i<n*2501;i++){
        ans = min(ans,shortest[i]);
        if(i%coin == 2500){
            cout << ans << endl;
            ans = INF;
        }
    }

    /*
    rep(i,n*6000){
        for(P j:graph[i]){
            cout << j.first << " "<< j.second << "  ";
        }
        if(graph[i].size() != 0) cout << endl;
        if(i%6000 == 5999) cout << endl;
    }*/
    return 0;
}


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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  

bool is(string s, int a, int b)
{
    for(int i=a;i<=b;i++)
    {
        if(s[i] != s[b-(i-a)])
            return false;
    }
    return true;
}

int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    string s;
    cin >> s;
    int n = s.length();
    if(n%2 == 0) cout << "No\n";
    else
    {
        bool a = is(s, 0, n-1);
        bool b = is(s, 0, (n-1)/2 - 1);
        bool c = is(s, (n+3)/2 - 1, n-1);
        if(a and b and c) cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

void trace(int A[], int N) {
     
    int i;
 
    for (i = 0; i < N; i++) {
       if (i > 0) 
          printf(" ");
          printf("%d", A[i]);
    }
    printf("\n");
}


void insertionSort(int A[], int N) {

    int j, i, v;

    for (i = 1; i < N; i++) {
       v = A[i];
       j = i - 1;
       while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
       }
       
       A[j + 1] = v;
       trace(A, N);
    }
}


int main() {

    int N, i, j;
    int A[100];

    scanf("%d", &N);

    for (i = 0; i < N; i++)
       scanf("%d", &A[i]);

    trace(A, N);
    insertionSort(A, N);
 
    return 0;
}

Measured memory_bytes: 1804
import collections
n = int(input())
v = list(map(int,input().split()))
a = v[0::2]
b = v[1::2]
a = collections.Counter(a)
a = a.most_common()
b = collections.Counter(b)
b = b.most_common()
c = n//2
if a[0][0] != b[0][0]:
    ans = c-a[0][1] + c-b[0][1]
    print(ans)
else: 
    if len(a) == 1:
        tmpa = 0
    else:
        tmpa = a[1][1]
    if len(b) == 1:
        tmpb = 0
    else:
        tmpb = b[1][1]
    ans1 = c-tmpa + c-b[0][1]
    ans2 = c-a[0][1] + c-tmpb
    print(min(ans1,ans2))

Measured memory_bytes: 20700
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define INF 1000000000000000000LL

int main() {
	string s;
	cin>>s;
	ll ans = 0;
	rep(i,0,s.sz){
		if(i%2==0){
			if(s[i]=='p')ans--;
		}
		else{
			if(s[i]=='g')ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll h,w,a,b;

int main(){
  ll ans=0;
  cin >> h >> w >>a >>b;
  vvi data(w, vi(h,0));  // N * M の2次元配列

  REP(i,a){
    REP(j,h){
      data[i][j]=1;
    }
  }

  REP(i,b){
    REP(j,w){
      data[j][i]=1-data[j][i];
    }
  }


  REP(i,h){
    REP(j,w){
      cout<<data[j][i];
    } 
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 9088
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int k = sc.nextInt();
    int count = 0;
    for(int i = 101;i>0;i--){
      if(a%i==0&&b%i==0)count++;
      if(count==k){
        System.out.println(i);
        return;
      }
    }
  }
}


Measured memory_bytes: 35832
#!user/bin/bash

read d n
ans=$((($n-1)/99 * 100 + $n - ($n-1)/99 * 99))
if [ $d -eq 0 ]; then
    echo $((($n-1)/99 * 100 + $n - ($n-1)/99 * 99))
elif [ $d -eq 1 ]; then
    echo $(($ans * 100))
else
    echo $(($ans * 10000))
fi



Measured memory_bytes: 376
#B
n = int(input())
s = input()
alphabet = [chr(i) for i in range(65,65+26)]
s_list = []
for i in s:
    s_list.append(i)

for j in range(len(s_list)):
    s_list[j] = alphabet[(alphabet.index(s_list[j])+ n) % 26]
print("".join(s_list))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
signed main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	//MessageBox(GetForegroundWindow(),"标题","内容",MB_YESNO);
	int x;
	cin>>x;
	if(x==0){
		cout<<"1"<<endl;
	}else{
		cout<<"0"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
#define pint pair<int,int>
#define pdouble pair<double,double>
using namespace std;
typedef long long ll;

int main(){
    int n;
    string s;
    cin >> n >> s;
    //printf("%d\n", s[0]);
    rep(i,sz(s)){
        if(s[i]+n > 90) printf("%c", s[i]+n-26);
        else printf("%c", s[i]+n);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
error_reporting(0);
//$A = explode(" ",trim(fgets(STDIN)));
list($N,$K) = explode(" ",trim(fgets(STDIN)));
$A = explode(" ",trim(fgets(STDIN)));
$X = array_count_values($A);
arsort($X);
$cnt=0;
$ret=0;
foreach($X as $k=>$v) {
  if ($cnt >= $K) {
    $ret+=$v;
  }
  $cnt++;
}
printf("%d\n",$ret);


Measured memory_bytes: 68628
unittest
{
	assert( [ "3", "1 2 3" ].solve == 11 );
	assert( [ "4", "141421356 17320508 22360679 244949" ].solve == 437235829 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	
	const M = 10L ^^ 9 + 7;
	auto ans = ModWorld!M( 0L );
	auto t = ModWorld!M( as.sum );
	foreach( a; as )
	{
		t -= a;
		ans += t * a;
	}
	return ans;
}

// モジュラ整数型（n mod M）
struct ModWorld( long M )
{
	long n;
	
	this( long n ){ this.n = n % M; }
	void opUnary( string OP )() if( OP == "++" ){ this.n = ( this.n + 1 ) % M; }
	void opUnary( string OP )() if( OP == "--" ){ this.n = ( this.n + M - 1 ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "+"  ){ this.n = ( this.n + r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "-"  ){ this.n = ( this.n + M - r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "*"  ){ this.n = ( this.n * r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "/"  ){ this *= r ^^ ModWorld( M - 2 ); }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "^^" )
	{
		auto a = this.n;
		this.n = 1L;
		for( auto i = r.n; 0 < i; i >>= 1 )
		{
			if( i & 1 ) this.n = ( this.n * a ) % M;
			a = ( a * a ) % M;
		}
	}
	auto opBinary( string OP )( ModWorld r ){ auto l = this; l.opOpAssign!OP( r ); return l; }
	auto opEquals( ModWorld r ){ return this.n == r.n; }
	
	void opAssign( long r ){ this.n = r % M; }
	void opOpAssign( string OP )( long r ){ this.opOpAssign!OP( ModWorld( r ) ); }
	auto opBinary( string OP )( long r ){ return this.opBinary!OP( ModWorld( r ) ); }
	auto opBinaryRight( string OP )( long l ){ return ModWorld( l ).opBinary!OP( this ); }
	auto opEquals( long r ){ return this.n == r; }
	
	auto toString(){ return this.n.to!string; }
}


Measured memory_bytes: 12364
import java.util.*;

public class Main{
    public static void main(String[] args){
        int m;
        int f;
        int r;
        String n = System.getProperty("line.separator");
        Scanner scanner = new Scanner(System.in);
        while(true){
            m = scanner.nextInt();
            f = scanner.nextInt();
            r = scanner.nextInt();
            if(m == -1 && f == -1 && r == -1) break;
            else{
                if(m == -1 || f == -1) System.out.println("F");
                else{
                    if((m + f) >= 80) System.out.println("A");
                    else if((m + f) >= 65) System.out.println("B");
                    else if((m + f) >= 50) System.out.println("C");
                    else if((m + f) >= 30){
                        if(r >= 50) System.out.println("C");
                        else System.out.println("D");
                    }
                    else System.out.println("F");
                }
            }
        }
        scanner.close();
    }
}


Measured memory_bytes: 26220
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
//typedef complex<double> P;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
const int MAX_V = 1005;
const int MAX_E = 2005;

struct edge { int from, to, cost; };
edge es[MAX_E];
int d[MAX_V], V, E;

bool bellman_ford(int s){
  REP(i, V) d[i] = INF;
  d[s] = 0;
  REP(i, V + 1){
    bool update = false;
    REP(j, E){
      edge e = es[j];
      if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from] + e.cost;
        if(i == V) return false;
        update = true;
      }
    }
  }
  return true;
}

int main() {
  int r;
  cin >>V >>E >>r;
  REP(i, E) cin >>es[i].from >>es[i].to >>es[i].cost;
  bool is_end = bellman_ford(r);
  if(!is_end) cout <<"NEGATIVE CYCLE" <<endl;
  else{
    REP(i, V){
      if(d[i] == INF) cout <<"INF" <<endl;
      else cout <<d[i] <<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1188
N = int(input())
lst = [int(n) for n in input().split(" ")]
val_max = lst[0]
val_min = lst[0]
for i in lst:
  if val_max < i:
    val_max = i
  elif val_min > i:
    val_min = i
  
print(val_max-val_min)

Measured memory_bytes: 2940