akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=2000100,mod=1e9+7;
inline int read(){
    int x=0,c=getchar(),f=0;
    for(;c>'9'||c<'0';f=c=='-',c=getchar());
    for(;c>='0'&&c<='9';c=getchar())
    x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
void write(ll x){
    if(x>9)write(x/10);
    putchar(x%10+'0');
}char s[N];ll ans;
int m,i,a,b,n,x,sm[N],pri[N],j,k,v[N];
int main(){
	n=read();a=read();b=read();
	x=read();for(i=2;i<=n;i++){
		k=read();
		ans+=min(1ll*b,1ll*a*(k-x));
		x=k;
	}write(ans);putchar('\n');
	return 0;
}

Measured memory_bytes: 128
N=int(input())
A=list(map(int,input().split()))
B=[]
C=[]
for i in A:
    if i%2==0:
        B.append(i)
for i in B:
    if i%3==0 or i%5==0:
        C.append(i)
if len(B)==len(C):
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    long long a,b,c;
    cin>>a>>b>>c;
    if(a==b && b==c && a==c){
    	cout<<"Yes"<<endl;
    }
    else{
    	cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int s, a;
    int sa_sum = 0, num_sum = 0, n = 0;
    while( scanf( "%d,%d", &s, &a ) != -1 ) {
        sa_sum += s * a;
        num_sum += a;
        ++n;
    }

    cout << sa_sum << endl;
    cout << round( static_cast<double>(num_sum) / n ) << endl;
}

Measured memory_bytes: 1268
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

int main() {
    int N, A[100000];
    cin >> N;
    REP(i, N) cin >> A[i];
    int ans = A[0];
    FOR(i, 1, N) ans = gcd(ans, A[i]);
    cout << ans << endl;
    return 0;
}

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

#define endl "\n"
#define ll long long int
#define f(i,st,ed) for(ll i=st;i<ed;i++)
#define fr(i,ed,st) for(ll i=ed;i>=st;i--)
#define vv vector<ll>
#define all(v) v.begin(),v.end() 
#define pb push_back
#define pp pair<ll,ll>
#define gv(v,s,e) f(i,s,e){ ll x,y; cin >> x >> y; v.pb({x,y});}
#define pv(v,s,e) f(i,s,e){cout << v[i] << " ";}
#define MOD 1000000007
#define debug(x) cout << x << endl;


void yes(){
    cout << "YES" << endl;
}

void no(){
    cout << "NO" << endl;
}

ll powmod(ll x, ll y, ll mod)
{
    ll ans=1;

    while(y)
    {
        if(y%2==1)
        {
            ans = (ans*x)%mod;
        }

        x = (x*x)%mod;
        y/=2;
    }

    return ans;
}

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

    ll n,w;
    cin >> n >> w;

    vector<pp> v;
    gv(v,0,n);

    ll dp[n+5][w+5];

    f(i,0,w+5)
    {
        dp[0][i]=0;
    }
    f(i,0,n+5)
    {
        dp[i][0]=0;
    }

    f(i,1,n+1)
    {
        f(j,0,w+1)
        {
            if(v[i-1].first>j)
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = max(dp[i-1][j-v[i-1].first] + v[i-1].second, dp[i-1][j]); 
        }
    }

    cout << dp[n][w] << endl;
    return 0;
}



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

int main(){
    int a,b;
    cin>>a>>b;
    
    if(a==2||b==2){
        cout<<"No"<<endl;
    }else if(a==4||a==6||a==9||a==11){
        if(b==4||b==6||b==9||b==11)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }else{
        if(b==4||b==6||b==9||b==11)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()



int main(void){
	int n;
    cin >> n;
    int p[n];
    rep(i,n){
        cin >> p[i];
    }
    int ans = 0;

    for(int i = 1;i<n-1;i++){
        if((p[i-1]-p[i])*(p[i+1]-p[i])<0){
            ans = ans + 1;
        }
    }

    cout << ans << endl; 

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
int main(){
  int H,W,N;cin>>H>>W>>N;
  vector<pair<int,int>>XY(N);
  for(pair<int,int> &xy:XY)cin>>xy.first>>xy.second;
  sort(XY.begin(),XY.end());
  int ans=H;
  int h=0;
  for(pair<int,int> xy:XY){
    if(xy.first==xy.second+h)h++;
    else if(xy.first>=xy.second+h+1){ans=xy.first-1;break;}
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
N = int(input())
A = list(map(int,input().split()))

for i in range(N):
  if A[i] % 2 == 0:
    if A[i] % 3 == 0 or A[i] % 5 == 0:
      continue
    else:
      print("DENIED")
      break
else:
  print("APPROVED")

Measured memory_bytes: 3060
a,b,k = map(int, input().split())
c = b - a + 1
if c % 2 == 0:
  if k >= c / 2:
    for i in range(a, b + 1):
      print(i)
  else:
    for j in range(a, a + k):
      print(j)
    for k in range(b - k + 1, b + 1):
      print(k)
if c % 2 != 0:
  if k >= (c + 1)/ 2:
    for i in range(a, b + 1):
      print(i)
  else:
    for j in range(a, a + k):
      print(j)
    for k in range(b - k + 1, b + 1):
      print(k)
    

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)

int m;

#define MOD 10000

int dp[505][505][15][2][2]; //keta,amari,sento,zanonaoke,sameok,muki
//p0 .. sameok,p1 .. sameng

bool isgz(string s){
	int r = 0;
	rep(i,s.size()){
		r = (r*10+s[i]-'0')%m;
	}
	if(r%m!=0)return false;
	
	if(s.size()<=1)return true;

	if(s[0]==s[1])return false;
	int d = (s[0]>s[1]?1:0);
	rep(i,s.size()){
		if(!i)continue;
		if(d^(s[i]>s[i-1]?1:0)^(i%2))return false;
	}
	return true;
}

int gzn(string s){
	{
		string ts = "";
		irep(i,s.size()){
			ts += s[i];
		}
		swap(s,ts);
	}
	
	memset(dp,0,sizeof(dp));
	int res=0;
	
	int ls=s.size();
	
	rep(j,10){
		int i = j%m;
		if(i==0)res++;
		rep(k,2){
			if((s[0]-'0')>=j)dp[1][i][j][0][k]=1;
			else dp[1][i][j][1][k]=1;
		}
	}
	
	//printf("i.1 . %d\n",res);
	
	int bm=10%m;
	reg(i,2,ls){
		rep(j,m){
			rep(k,10){
				rep(p,2){
					rep(q,2){
						int& d = dp[i][j][k][p][q]; //sameok
						int c = s[i-1]-'0';
						
						int am = (bm*k)%m;
						//?????????j-am????????????
						int bj = (j-am+m)%m;
						rep(bk,10){
							rep(bp,2){
								if(p==0){
									if(c<k)continue;
									if(c==k && bp==1)continue;
								}
								else{
									if(c>k)continue;
									if(c==k && bp==0)continue;
								}
								
								if(bk==k)continue;
								if(q^(i%2)^(bk<k?1:0))continue;
								
								d = (d+dp[i-1][bj][bk][bp][q])%MOD;
							}
						}
						
						if(i<ls && j==0 && k!=0)res = (res+d)%MOD; //0pad
					}
				}
			}
		}
		bm = (bm*10)%m;
		//printf("i.%d .. %d\n",i,res);
	}
	
	/*
	reg(i,1,ls){
		rep(k,10){
			printf("%d %d : ",i,k);
			rep(j,m){
				printf("(%d %d,%d %d) ",dp[i][j][k][0][0],dp[i][j][k][0][1],dp[i][j][k][1][0],dp[i][j][k][1][1]);
			}
			printf("\n");
		}
	}
	*/
	
	if(ls>1){
		reg(i,1,9){
			rep(k,2){
				res = (res+dp[ls][0][i][0][k])%MOD;
			}
		}
	}
	else{
		res=(s[0]-'0')/m+1;
	}
	
	//printf("%s .. %d\n",s.c_str(),res);
	return res;
}

int main(void){
	string a,b;
	cin >> a >> b >> m;
	int ma = gzn(a);
	int mb = gzn(b);
	if(isgz(a))mb++;
	printf("%d\n",(MOD+mb-ma)%MOD);
	return 0;
}

Measured memory_bytes: 61000
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int a[maxn];
int main()
{
	int n;
	bool t=true;
	scanf("%d",&n);
	scanf("%d",&a[0]);
	int maxx=a[0];
	for(int i=1;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(t)
		{
		if(maxx-a[i]>1)t=false;
		maxx=max(maxx,a[i]);}
	}
	if(!t)printf("No\n");
	else printf("Yes\n");
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin>>n;
  ll h;
  cin>>h;
  vector<ll> v1,v2;
  for(int i=0;i<n;i++){
    ll a,b;
    cin>>a>>b;
    v1.push_back(a);
    v2.push_back(b);
  }
  sort(v1.begin(),v1.end());
  sort(v2.begin(),v2.end());
  ll l=upper_bound(v2.begin(),v2.end(),v1[n-1])-v2.begin();
  ll ans=0;
  if(l<n){
    for(ll i=n-1;i>=l;i--){
      h-=v2[i];
      ans++;
      if(h<=0) break;
    }
  }
  if(h>0) ans+=h/v1[n-1]+(h%v1[n-1]==0?0:1);
  cout<<ans<<endl;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

bool visited[200010];
vector<vector<int>> G;

void dfs(int v, int count) {
    if (visited[v]) return;
    visited[v] = true;
    if (count == 0) return;

    for (auto nv: G[v]) {
        dfs(nv, count - 1);
    }
}

int main() {
    int N, M;
    cin >> N >> M;
    G.resize(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    dfs(0, 2);
    if (visited[N - 1]) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 12144
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 200000;

ll power_(ll a, ll power){
    ll value = 1;
    
    while(power != 0){
        if(power & 1) value = value * a;
        a = a * a;
        power = power >> 1;
     
    }
 
    return value;
}

int main(void){
    ll N, K;
    ll answer;

    cin >> N >> K;

    if (K % 2 == 1) answer = power_(N / K , 3);
    else{
        answer = power_(N / (K / 2) - N / K, 3);
        answer += power_(N / K, 3);
    } 

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
	par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
bool fe(int a,int b){
  a%=10;
  b%=10;
  if(a==0)
    a=10;
  if(b==0)
    b=10;
  if(a>b)
    return true;
  else
    return false;
}
signed main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max(a*b,c*d)<<endl;
}

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

const int MAX_N = 200010;
long long mod = 1e9 + 7;

vector<int> G[MAX_N];
vector<int> sz(MAX_N);
vector<long long> inv(MAX_N);
long long res1 = 1;
int n;

long long mod_inv(long long a, long long p){
    long long res = 1;
    while (p){
        if (p & 1LL)
            res = (res * a) % mod;
        a = ((a % mod) * (a % mod)) % mod;
        p >>= 1;
    }

    return res;
}

void dfs(int u, int p){
    sz[u] = 1;
    for (auto v: G[u]){
        if (v != p){
            dfs(v, u);
            sz[u] += sz[v];
        }
    }

    res1 = res1 * sz[u] % mod;
}

void dfs1(int u, int p){
    if (p != -1){
        inv[u] = ((inv[p] * mod_inv(sz[u], mod - 2)) % mod) * (n - sz[u]) % mod;
    }

    for (auto v: G[u]){
        if (v != p){
            dfs1(v, u);
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n;
    
    for (int i = 0; i < n - 1; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;

        G[u].push_back(v);
        G[v].push_back(u);
    }

    dfs(0, -1);
    inv[0] = res1;
    dfs1(0, -1);
    
    long long fac = 1;
    for (long long i = 1; i <= n; i++)
        fac = ((fac % mod) * (i % mod)) % mod;

    for (int i = 0; i < n; i++)
        cout << fac * mod_inv(inv[i], mod - 2) % mod << '\n';

    return 0;
}


Measured memory_bytes: 16244
#include<iostream>
#include<algorithm>
using namespace std;
string s[100];int n,l;
main(){
  cin>>n>>l;
  for(int i=0;i<n;i++)cin>>s[i];
  sort(s,s+n);
  for(int i=0;i<n;i++)cout<<s[i];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int Q; string s, t;
int main() {
	cin >> Q >> s;
	int n = s.size(), ret = 0;
	while(Q--) {
		cin >> t;
		bool flag = false;
		for(int i = 0; i < t.size(); i++) {
			for(int j = n - 1; j + i < t.size(); j += n - 1) {
				bool ok = true;
				for(int k = 0; k < n; k++) {
					if(s[k] != t[i + k * (j / (n - 1))]) ok = false;
				}
				if(ok) flag = true;
			}
		}
		if(flag) ret++;
	}
	cout << ret << endl;
	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.length() / 2; i++)
    {
        if (s[i] != s[s.length() - i - 1])
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int n,a,i,max=0,min=1000;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(max<a){max=a;}
		if(min>a){min=a;}
	}
	printf("%d",max-min);
	return 0;
}

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

int main(){
  int W,H,x,y,r;
  cin>>W>>H>>x>>y>>r;

  if( x-r >= 0 &&
      x+r <= W &&
      y-r >= 0 &&
      y+r <= H )
      {
        cout << "Yes" << endl;
      }
      else{
        cout << "No" << endl;
      }

  return 0;
}

void swap(int &a, int &b){
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

Measured memory_bytes: 3064
import collections


N = int(input().strip())
V = [int(str) for str in input().strip().split()]

V1 = V[::2]
V2 = V[1::2]

V1_mosts = collections.Counter(V1).most_common()
V2_mosts = collections.Counter(V2).most_common()

if V1_mosts[0][0] != V2_mosts[0][0]:
    print(N - V1_mosts[0][1] - V2_mosts[0][1])

else:
    costs = []

    costs.append(N - V1_mosts[0][1] - V2_mosts[1][1] if len(V2_mosts) >= 2 else N // 2)
    costs.append(N - V2_mosts[0][1] - V1_mosts[1][1] if len(V1_mosts) >= 2 else N // 2)

    print(min(costs))

Measured memory_bytes: 21084
n = int(input())
a = list(map(int, input().split()))
alice_sum = 0
bob_sum = 0
turn = 1
a.sort(reverse=True)
for i in range(n):
    if turn == 1:
        alice_sum += a.pop(0)
    else:
        bob_sum += a.pop(0)
    turn *= (-1)
print(alice_sum-bob_sum)

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

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string str[4] = {"dream", "dreamer", "erase", "eraser"};
    string s;
    cin >> s;
    bool f = true;
    repb(i, s.size() - 1, 0){
        bool g = false;
        rep(j, 0, 4){
            int sz = str[j].size();
            if(i < sz - 1) continue;
            string t = s.substr(i - sz + 1, sz);
            // cout << t << endl;
            if(t == str[j]){
                g = true;
                i -= sz - 1;
                break;
            }
        }
        if(g == false) f = false;
    }
    if(f) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)


int main()
{
  string s;
  int k;
  cin>>s>>k;

  vector<string> sub;
  rep(i,s.size())
  {
    rep(j,k)
    {
      if(i+j>=s.size()) break;
      sub.push_back(s.substr(i,j+1));
    }
  }
  sort(sub.begin(),sub.end());
  unique(sub.begin(),sub.end());

  cout<<sub[k-1]<<endl;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    int n,k,q;
    cin >> n >> k >> q;
    int arr[n];
    for (int i=0;i<=n-1;i++)
    {
        arr[i]=0;
    }

    for (int i=0;i<=q-1;i++)
    {
        int a;
        cin >> a;
        arr[a-1]++;
    }

    for (int i=0;i<=n-1;i++)
    {
        arr[i]=k+arr[i]-q;
        if (arr[i]>=1)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4016
import sys
l = []
for line in sys.stdin:
    l.append(line)

for i in range(len(l)):
    numl = l[i].split(' ')
    a = int(numl[0])
    b = int(numl[1])
    sum = a + b
    digitstr = "{0}".format(sum)
    print(len(digitstr))

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

int main() {
	while(1) {
		int w, h;
		cin >> w >> h;
		if (w == 0 && h == 0) break;
		for(int j = 0; j < w; j++) {
			for(int i = 0; i < h; i++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		int maxNum = Integer.parseInt(br.readLine());

		boolean beforeIsOdd = false;
		int currentNum = 0;
		long pairCount = 0;

		for (int i = 1; i <= maxNum; i++) {
			currentNum = Integer.parseInt(br.readLine());
			pairCount += currentNum / 2;

			// 奇数のケース
			if (currentNum % 2 == 1) {
				if (beforeIsOdd) {
					pairCount++;
					beforeIsOdd = false;
				} else {
					beforeIsOdd = true;
				}
			} else {
				if (beforeIsOdd && currentNum != 0) {
					beforeIsOdd = true;
				} else {
					beforeIsOdd = false;
				}
			}
		}
		System.out.println(pairCount);
	}
}


Measured memory_bytes: 17776
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
cnt1=0
cnt2=0
cnt3=0
for i in range(n):
    if p[i]<=a:
        cnt1+=1
    elif p[i]<=b:
        cnt2+=1
    else:cnt3+=1
print(min(cnt1,cnt2,cnt3))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M =1000000007;
//MOD??
long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}
ll mpow(ll x, ll n){ //x^n(mod M) ????pow(x,n)?????????????mod??
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
int main (){
  ll i,m=100,x,c=0;
  cin>>x;
  while(m<x){
    m = (ll)(m*1.01);
    c++;
  }
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const int t9 = 1000000000;

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

	ll x, y, z;
	ll S; cin >> S;
	y = S / t9;
	S = S % t9;
	z = S;
	x = 1 + y;
	if (z==0) {
		x = y;
	}
	cout << 0 << " " << y << " " << z << " " << 0 << " " << t9 << " " << x;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            long a = in.nextInt();
            long b = in.nextInt();
            if (a == b || a % b == 0) {
                out.println(-1);
            } else {
                out.println(a);
            }
        }

    }

    static class FastReader {
        BufferedReader reader;
        StringTokenizer st;

        public FastReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String line = reader.readLine();
                    if (line == null) {
                        return null;
                    }
                    st = new StringTokenizer(line);
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 22996
from itertools import accumulate
n,W,*L=map(int,open(0).read().split())
l=[[] for _ in range(4)]
lim=[1]*4
m=min(L[::2])
for w,v in zip(*[iter(L)]*2):
	l[w-m].append(v)
	lim[w-m]+=1
ll=[]
for x in l:
	ll.append([0]+list(accumulate(sorted(x)[::-1])))
ans=0
for i in range(lim[0]):
	for j in range(lim[1]):
		for k in range(lim[2]):
			for l in range(lim[3]):
				if m*i+(m+1)*j+(m+2)*k+(m+3)*l>W:
					continue
				ans=max(ans,ll[0][i]+ll[1][j]+ll[2][k]+ll[3][l])
print(ans)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
//-----------------------------------------

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

  ld a, b, c;
  cin >> a >> b >> c;
  c = (c / 180.0) * PI;
  ld S = a * b * sin(c) / 2;
  ld l = a + b + sqrt(a*a + b*b - 2 * a * b * cos(c));
  ld h = b * sin(c);
  cout << S <<" " << l <<" " << h <<endl;

  return 0;
}



Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i;
	string s;
	cin >> s;
	if (s == "RRR")
		printf("3\n");
	else if (s == "SSS")
		printf("0\n");
	else if (0 <= s.find("RR") && s.find("RR") < 3)
		printf("2\n");
	else
		printf("1\n");
	return 0;
}

Measured memory_bytes: 3620
using AtCoderBeginnerContest157.Questions;
using AtCoderBeginnerContest157.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest157.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            yield return (n + 1) / 2;
        }
    }
}


namespace AtCoderBeginnerContest157
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest157.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest157.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int n;
long long l;
long long a[N];
int main()
{
	scanf("%d%lld",&n,&l);
	long long maxn=0;
	int mid;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		if(i>1&&a[i-1]+a[i]>maxn)
		{
			maxn=a[i-1]+a[i];
			mid=i-1;
		}
	}
	if(maxn>=l)
	{
		printf("Possible\n");
		for(int i=1;i<mid;i++)
		printf("%d\n",i);
		for(int j=n-1;j>mid;j--)
		printf("%d\n",j);
		printf("%d",mid);
	}
	else
	{
		printf("Impossible");	
	}
	return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

i32 popcnt (i32 bit) {
  i32 cnt = 0;
  while (bit > 0) {
    cnt += bit & 1;
    bit >>= 1;
  }
  return cnt;
}

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  i32 *bit = ALLOC (n, i32);
  for (i32 i = 0; i < n; ++i) {
    for (i32 j = 0; j < n; ++j) {
      i32 b;
      scanf ("%" SCNi32, &b);
      bit[i] |= b << j;
    }
  }
  i32 *dp = ALLOC (1 << n, i32);
  const i32 mod = 1000000007;
  dp[0] = 1;
  for (i32 i = 1; i < (1 << n); ++i) {
    i32 v = popcnt (i) - 1;
    i32 b = bit[v] & i;
    i64 sum = 0;
    for (i32 j = 0; j < n; ++j) {
      if ((b >> j) & 1) {
        sum += dp[i ^ (1 << j)];
      }
    }
    dp[i] = sum % mod;
  }
  printf ("%" PRIi32 "\n", dp[(1 << n) - 1]);
}

int main (void) {
  run();
  return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<long long>a(n);
  for(int i=0;i<n;i++) a[i]=i+1;
  long long ans=0;
  for(int i=0;i<n;i++){
    if(a[i]%5==0) a[i]=0;
    else if(a[i]%3==0) a[i]=0;
    ans+=a[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 11108
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>

typedef unsigned long long ULONG;
typedef long long LONG;
using namespace std;

#define PI 3.1415926535897932384626433
#define _DBG_

#define BIG 10000000000 //10

#define LAST 10000000 //10^7

#define MOD (LONG)(10e8 + 7)




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

	int kaisuB = 0;
	if (A >= B) {
		while (A >= B) {
			kaisuB++;
			B *= 2;
		}
	}
	int kaisuC = 0;
	if (B >= C) {
		while (B >= C) {
			kaisuC++;
			C *= 2;
		}
	}
	if (kaisuB + kaisuC <= K) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



	return 0;
}

Measured memory_bytes: 3592
/*
Rathin Bhargava
IIIT Bangalore

*/
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(n*a,b)<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

ll gcd(ll a, ll b)
{
	return (b == 0) ? a : gcd(b, a % b);
}


int main()
{

	ll A, B;
	cin >> A >> B;
	
	set<ll> divs;

	ll d = gcd(A, B);
	
	while (d % 2 == 0)
	{
		divs.insert(2);
		d /= 2;
	}

	ll root = sqrt(d);
	for (ll i = 3; i <= root; i += 2)
	{
		while (d % i == 0)
		{
			divs.insert(i);
			d /= i;
		}
	}

	if (d > 2)
	{
		divs.insert(d);
	}

	cout << divs.size() + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long A,B;
    cin >> A >> B;
    long long i = B*10;
    while(1){
        if(int(i*0.08) == A && int(i*0.1) == B){
            cout << i << endl;
            break;
        }
        i ++;
        if(i >= B*100){
            cout << -1 <<endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define INF 1e18
int main(){
  ll N;
  cin>>N;
  vector<ll> A(N+2);
  A[0]=0,A[N+1]=INF;
  rep(i,N){
    cin>>A[i+1];
    if(i) A[i+1]+=A[i];
  }
  sort(all(A));
  ll ans=0,c=1;
  rep(i,N+1){
    if(A[i]!=A[i+1]){
      ans+=c*(c-1)/2;
      c=1;
    }else c++;
  }
  cout<<ans<<endl;
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  int nokori = a - b;
  cout << max(0, c - nokori) << endl;
}


Measured memory_bytes: 256
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#pragma GCC      optimize ("Ofast")
#include         <bits/stdc++.h>
#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
using namespace std;

const int N = (int)1e5 + 4;
int n, k;
int memo[N], h[N];
int dp (int i) {
	if (i >= n) return 0;
	else if (memo[i] != -1) return memo[i];
	else {
		int val = INT_MAX;
		for (int j = 1; i + j <= min (i + k, n); ++j) {
			val = min (val, dp (i + j) + abs(h[i] - h[i + j]));
		}
		return memo[i] = val;
	}
}

int main() {
	IOS; PREC;

	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> h[i], memo[i] = -1;
	cout << dp (1) << endl;

	return EXIT_SUCCESS;
}




Measured memory_bytes: 3840
#include<bits/stdc++.h>
using   namespace      std;
typedef long long      LL;
typedef vector<int>    VI;
typedef pair<int,int>  PII;

int main(){

	LL a, b, c, d, lcm, l1, l2, l3, u1, u2, u3, n1, n2, n3;
	cin>> a>> b>> c>> d;

	lcm = (c * d) / __gcd(c, d);
	
	l1 = a / c;
	if(l1 * c != a)		l1++;
	u1 = b / c;
	
	l2 = a / d;
	if(l2 * d != a)		l2++;
	u2 = b / d;
	
	l3 = a / lcm;
	if(l3 * lcm != a)		l3++;
	u3 = b / lcm;

	l1 <= u1 ? n1 = u1 - l1 + 1 : n1 = 0;
	l2 <= u2 ? n2 = u2 - l2 + 1 : n2 = 0;
	l3 <= u3 ? n3 = u3 - l3 + 1 : n3 = 0;

	cout<< (b - a + 1) - (n1 + n2 - n3)<< endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,m,s,c,i;
    scanf("%d%d",&n,&m);
    int a[m];
    for(i=0;i<n;i++) a[i]=-1;
    for(i=0;i<m;i++){
        scanf("%d%d",&s,&c);
        if(a[s-1]!=-1 && a[s-1]!=c){
            printf("-1");
            return 0;
        }
        a[s-1]=c;
    }
    if(n!=1 && a[0]==0){
        printf("-1");
        return 0;
    }
    if(n==1 && a[0]==-1) a[0]=0;
    if(n!=1 && a[0]==-1) a[0]=1;
    for(i=0;i<n;i++){
        if(a[i]==-1) printf("0");
        else printf("%d",a[i]);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int A1,A2,A3;
	cin>>A1>>A2>>A3;
	if (A1+A2+A3>=22){
		cout<<"bust"<<endl;
	}else{
		cout<<"win"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;

int main() {
	string s;
	cin >> s;
	
	bool flag = true;

	int index = s.size();
	while(index > 0){
		if(index >= 7 && s.substr(index - 7, 7) == "dreamer") index -= 7;
		else if(index >= 6 && s.substr(index - 6, 6) == "eraser") index -= 6;
		else if (index >= 5 && (s.substr(index - 5, 5) == "dream" || s.substr(index - 5, 5) == "erase")) index -= 5;
		else{
			flag = false;
			break;
		}
		
	}
	
	cout << (flag ? "YES" : "NO") << endl;
	
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

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

            int count = 0;
            for (int i = 0; i < S.length(); i++) {
                if (S.charAt(i) == 'o') {
                    count++;
                }
            }
            System.out.println(700 + count * 100);
        }
    }
}


Measured memory_bytes: 26948
#include <climits>
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <iomanip>


#define rep(i,i0,n) for (int (i) = (i0); (i) < (n); ++(i))

using namespace std;
using ll = long long;

const ll INF = 4e9;
const int N_LIMIT = 1002;

double g[N_LIMIT * N_LIMIT];
double dist[N_LIMIT];

double solve(int n, vector< tuple<ll, ll, ll> > &b) {

    ll x0, x1, y0, y1, r0, r1;
    int v;
    double d, nd;
    priority_queue< pair<double, int> > que;

    fill(g, g + N_LIMIT * N_LIMIT, 0);

    rep (v, 0, n + 2) {
        tie(x0, y0, r0) = b[v];
        rep (w, v + 1, n + 2) {
            tie(x1, y1, r1) = b[w];
            d = sqrt((double)(x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)) - r0 - r1;
            if (d < 0) {
                d = 0;
            }
            g[N_LIMIT * v + w] = d;
            g[N_LIMIT * w + v] = d;
        }
    }

    fill(dist, dist + N_LIMIT, INF);
    v = 0;
    dist[v] = 0;
    que.push(make_pair(0, v));
    while (!que.empty()) {
        tie(d, v) = que.top();
        que.pop();
        d = -d;
        rep (w, 0, n + 2) {
            nd = d + g[N_LIMIT * v + w];
            if (nd < dist[w]) {
                dist[w] = nd;
                que.push(make_pair(-nd, w));
            }
        }
    }
    

    return dist[n + 1];
}



int main(int argc, const char * argv[]) {
    ll xs, ys, xt, yt;
    int n;
    ll x, y, r;
    vector< tuple<ll, ll, ll> > b;

    cin >> xs >> ys >> xt >> yt;
    cin >> n;
    b.push_back(make_tuple(xs, ys, 0));
    rep (i, 0, n) {
        cin >> x >> y >> r;
        b.push_back(make_tuple(x, y, r));
    }
    b.push_back(make_tuple(xt, yt, 0));
    
    cout << fixed << setprecision(11) << solve(n, b) << endl;

    return 0;
}


Measured memory_bytes: 14212
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repll(i,n) for(long long i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
typedef long long ll;
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; }
using namespace std;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};

int main(){

  ll N,M;
  cin >> N >> M;
  vector<ll> A(M),B(M);
  rep(i,M){
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }
  UnionFind U(N);
  
  vector<ll> answers(M);
  ll ans = N*(N-1)/2;
  answers[M-1] = ans;
  for(ll i=M-1;i>0;--i){
    ll a = A[i];
    ll b = B[i];
    answers[i-1] = answers[i];
    if(U.root(a)!=U.root(b)){
      answers[i-1] -= U.size(a)*U.size(b);
      U.connect(a,b);
    }
  }
  
  rep(i,M)cout << answers[i] << endl;


  return 0;
}


Measured memory_bytes: 4096
#include <stdio.h>

int main(){
	int height[10], rank[3] = {0};
	int i;
	
	for(i = 0; i < 10; i++){
    	scanf("%d\n", &height[i]);

        if (rank[0] < height[i]){
        	rank[2] = rank[1];
        	rank[1] = rank[0];
        	rank[0] = height[i];
        }else if (rank[1] < height[i]){
        	rank[2] = rank[1];
        	rank[1] = height[i];
        }else if (rank[2] < height[i]){
        	rank[2] = height[i];
        }
    }

    for(i = 0; i < 3; i++){
    	printf("%d\n", rank[i]);
    }

	return 0;
}

Measured memory_bytes: 1032
#include<stdio.h>
#include<string.h>
typedef long long int ll;
int main()
{

    ll a,b,c,d,e,f,g,h,s;ll hh[100000]={0};
    while(~scanf("%lld",&a))
    {
        ll cnt=0;
        memset(hh,0,sizeof(hh));
        while(1)
        {
         //   printf(" %lld ",a);
            if(hh[a]==1)
            {
                printf("%lld\n",cnt+1);
                break;
            }
            if(a%2==0)
            {
                hh[a]=1;
                a=a/2;
                cnt++;
            }
            else
            {
                hh[a]=1;
                a=a*3+1;
                cnt++;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 896
from collections import defaultdict
def inpl(): return [int(i) for i in input().split()]

HW = defaultdict(lambda: 0)
direction = [(0,0),(1,1),(1,0),(1,-1),(0,-1),(-1,-1),(-1,0),(-1,1),(0,1)]

H, W, N = inpl()
for _ in range(N):
    a, b = inpl()
    for dh, dw in direction:
        if 2 <= a+dh <= H-1 and 2 <= b+dw <= W-1: 
            HW[(a+dh, b+dw)] += 1

ans = [0 for i in range(10)]
print((H-2)*(W-2) - len(HW))
for j in HW.values():
    ans[j] += 1
for i in ans[1:]:
    print(i)

Measured memory_bytes: 166876
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  cin >> N;
  vector<int> L(N);
  for(int a = 0;a < N;a++)cin >> L.at(a);
  int result = 0;
  sort(L.begin(), L.end() );
  for(int a = 0;a < N;a++){
    for(int b = 0;b < a;b++){
      for(int c = 0;c < b;c++){
        if(L.at(a)<L.at(b)+L.at(c))result++;
        
      }
    }
  }
    cout <<result<< endl;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v,n) reverse(v,v+n)
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix[i]<<(i!=N-1?' ':'\n');
	return;
}


const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+17; //(+1までok)
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

inline int in(){int x; cin>>x; return x;}

int main(void){
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	
	ll N,A,B,V[50],result=0;

	cin>>N>>A>>B;
	REP(i,N) cin>>V[i];
	
	SORT(V,N);
	REV(V,N);
	REP(i,A) result+=V[i];
	printf("%.6f\n",(double)result/A);

	ll C[51][51];
	REP(i,N+1){
		REP(j,i+1){
			if(j==0||j==i) C[i][j]=1LL;
			else C[i][j]=(C[i-1][j-1]+C[i-1][j]);
		}
	}
	
	int cn1=0,cn2=0;
	REP(i,N) if(V[i]==V[A-1]) cn1++;
	REP(i,A) if(V[i]==V[A-1]) cn2++;
	if(V[0]==V[A-1]){
		ll tem=0;
		FOR(i,A,B+1) tem+=C[cn1][i];
		printf("%lld\n",tem);
	}else{
			printf("%lld\n",C[cn1][cn2]);
	}
	return 0;
}




Measured memory_bytes: 256