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

int main() {
  string s;
  cin>>s;
  int n=s.size();
  vector<bool>check(26);
  for(int i=0;i<26;i++) check[i]=true;
  for(int i=0;i<n;i++) check[s[i]-'a']=false;
  for(int i=0;i<26;i++){
    if(check[i]){
      char ans='a'+i;
      cout<<ans<<endl;
      break;
    }
    else if(i==25) cout<<"None"<<endl;
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

template<class V> class MaxFlow_dinic {
public:
	struct edge { int to,reve;V cap;};
	static const int MV = 1100;
	vector<edge> E[MV];
	int itr[MV],lev[MV];
	void add_edge(int x,int y,V cap,bool undir=false) {
		E[x].push_back((edge){y,(int)E[y].size(),cap});
		E[y].push_back((edge){x,(int)E[x].size()-1,undir?cap:0});
	}
	void bfs(int cur) {
		MINUS(lev);
		queue<int> q;
		lev[cur]=0;
		q.push(cur);
		while(q.size()) {
			int v=q.front(); q.pop();
			ITR(e,E[v]) if(e->cap>0 && lev[e->to]<0) lev[e->to]=lev[v]+1, q.push(e->to);
		}
	}
	V dfs(int from,int to,V cf) {
		if(from==to) return cf;
		for(;itr[from]<E[from].size();itr[from]++) {
			edge* e=&E[from][itr[from]];
			if(e->cap>0 && lev[from]<lev[e->to]) {
				V f=dfs(e->to,to,min(cf,e->cap));
				if(f>0) {
					e->cap-=f;
					E[e->to][e->reve].cap += f;
					return f;
				}
			}
		}
		return 0;
	}
	V maxflow(int from, int to) {
		V fl=0,tf;
		while(1) {
			bfs(from);
			if(lev[to]<0) return fl;
			ZERO(itr);
			while((tf=dfs(from,to,numeric_limits<V>::max()))>0) fl+=tf;
		}
	}
};

int N;
int A[101],B[101];
int C[101],D[101];
MaxFlow_dinic<int> mf;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>A[i]>>B[i];
		mf.add_edge(2*N,i,1);
	}
	FOR(i,N) {
		cin>>C[i]>>D[i];
		mf.add_edge(N+i,2*N+1,1);
	}
	FOR(x,N) FOR(y,N) {
		if(A[x]<C[y] && B[x]<D[y]) mf.add_edge(x,N+y,1);
	}
	cout<<mf.maxflow(2*N,2*N+1)<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import sys
import numpy as np

N,S, *A = map(int, sys.stdin.buffer.read().split())
mod = 998244353
A = sorted(A)

answer = np.zeros(3002).astype(np.int64)
power2 = 1

total = 0
for a in A:
  total = min(3001,a+total)
  answer[a+1:total+1] = (2*answer[a+1:total+1]+answer[1:total-a+1])%mod
  answer[a] = (2*answer[a]+power2)%mod
  answer[1:a] = (2*answer[1:a])%mod
  power2 = (2*power2)%mod

print(answer[S])

Measured memory_bytes: 27556
#include <iostream>
#include <stdio.h>
#include <string.h>
int main() {
    int k;
    std::cin >> k;
    int a, b;
    std::cin >> a >> b;
    
    int min = a/k;
    int max = b/k;

    if(a <= max*k){
        std::cout << "OK" << std::endl;
    }
    else{std::cout << "NG" << std::endl;}

    return 0;
}

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

using namespace std;

int main()
{
    long long ai, ao, at, aj, al, as, az;

    cin >> ai >> ao >> at >> aj >> al >> as >> az;

    long long ans, ans1, ans2;

    ans1 = 2 * (ai / 2) + ao + 2 * (aj / 2) + 2 * (al / 2) + 3 * (ai % 2) * (aj % 2) * (al % 2);
    ans2 = 0;

    if (ai > 0 && aj > 0 && al > 0)
    {
        ans2 = 2 * ((ai-1) / 2) + ao + 2 * ((aj-1) / 2) + 2 * ((al-1) / 2) + 3;
    }

    if(ans1 < ans2)
    {
        ans = ans2;
    }
    else
    {
        ans = ans1;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	int x,a;
	cin >> x >> a;
	cout << (x<a ? 0 : 10) << endl;
//////////////////////////////////////////////
}


Measured memory_bytes: 256
//created by pyoxiao on 2020/04/19
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define CL(a, b) memset(a, b, sizeof(a))
using namespace std;
const int mod = 1e9 + 7;
LL fpow(LL a, LL b, LL p = mod){LL ans = 1; a %= p; while(b) {if(b & 1) ans = ans * a % p; b >>= 1; a = a * a % p;} return ans;}
LL gcd(LL a, LL b){return b == 0 ? a : gcd(b, a % b);}
const double PI = 3.1415926535898;
void solve() {
    double r;
    scanf("%lf", &r);
    printf("%.2f\n", 2 * PI * r);
}
int main() {
    int T = 1;
    // scanf("%d", &T);
    while(T --) 
        solve();
    return 0;
}

Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

template <class It>
auto RunLength(const It i0, const It i1) {
    using P = pair<decltype(*i0), int>;
    vector<P> v;
    P p = { *i0, 1 };
    for (It i = i0; ++i != i1;) {
        if (p.first == *i) {
            p.second++;
        } else {
            v.push_back(p);
            p = { *i, 1 };
        }
    }
    v.push_back(p);
    return v;
}

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

    int n;
    cin >> n;

    vector<array<char, 10>> s(n);
    for (int i = 0; i < n; i++) {
        char c[11];
        cin >> c;

        sort(c, c + 10);
        memcpy(s[i].data(), c, 10);
    }

    sort(s.begin(), s.end());
    auto v = RunLength(s.begin(), s.end());

    ll r = 0;
    for (const auto &p : v) {
        ll t = p.second;
        r += t * (t - 1) / 2;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3444
import numpy as np
import math
import collections
import bisect


X, N = map(int, input().split())

p = list(map(int, input().split()))


for i in range(200):
    ans = X - i
    if(ans not in p):
        print(ans)
        break

    ans = X + i
    if(ans not in p):
        print(ans)
        break


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

int main(){
  char moji[20];moji[0]='\0';
  char c[20];
  cin>>c;
  int cnt=0;
  for(int i=0;i<strlen(c);i++){
    if(c[i]=='0'){
      moji[cnt]='0';
      cnt++;
      moji[cnt]='\0';
    }
    if(c[i]=='1'){
      moji[cnt]='1';
      cnt++;
      moji[cnt]='\0';
    }
    if(c[i]=='B' && cnt>0){
      cnt--;
      moji[cnt]='\0';
    }
  }
  cout<<moji<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h,w,a,b;
const int N=1000010;
int fac[N],inv[N];
const int mod=1000000007;
int n,m,k;
int qp(int x,int k)
{
	int res=1;
	while(k)
	{
		if(k&1)res=1ll*res*x%mod;
		x=1ll*x*x%mod;
		k>>=1;
	}
	return res;
}
void init()
{
	fac[0]=inv[0]=1;
	for(int i=1;i<N;i++)
		fac[i]=1ll*fac[i-1]*i%mod;
	inv[N-1]=qp(fac[N-1],mod-2);
	for(int i=N-2;i>=1;i--)
		inv[i]=1ll*inv[i+1]*(i+1)%mod;
}
int C(int a,int b)
{
	if(a<b)return 0;
	return 1ll*fac[a]*inv[b]%mod*inv[a-b]%mod;
}
long long ans,sum;
int main()
{
	init();
	scanf("%d%d%d",&n,&m,&k);
	sum=1; ans=qp(3,m+k)%mod;
	for(int i=1;i<=m+k;i++)
	{
		sum=(sum*2%mod-(i-1>=k?C(i-1,k):0)+mod-(i-1>=m?C(i-1,i-m-1):0)+mod)%mod;
		//printf("%d\n",sum);
		ans=(ans+sum*qp(3,m+k-i)%mod*C(i+n-1,n-1)%mod)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 8064
n = int(input())
list1 = list(map(int, input().split()))
#print(n, list1)

m = int(input())
for i in range(m):
  p, x = map(int, input().split())
  #print(p,x)
  ans = 0
  for j in range(n):
    ans += x if j == p-1 else list1[j]
  print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  vector<int> h;
  cin>>n;
  h.resize(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  int sum=0;
  int max=0;
  for(int i=0;i<n;i++){
    if(max<=h[i])sum+=1;
    if(max<h[i])max=h[i];
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include <iomanip>
using namespace std;

int main(){
  long long n, k;
  cin >> n >> k;
  vector<long long> vec;
  for(long long i=0; i<n; i++){
    long long num;
    cin >> num;
    vec.push_back(num);
  }
  long long sum = 0;
  vector<long long> sumvec;
  for(long long i=0; i<k; i++){
    sum += vec[i];
  }
  sumvec.push_back(sum);
  for(long long i=k; i<n; i++){
    sum -= vec[i-k];
    sum += vec[i];
    sumvec.push_back(sum);
  }
  std::vector<long long>::iterator iter = std::max_element(sumvec.begin(), sumvec.end());
  size_t index = std::distance(sumvec.begin(), iter);
  double ressum = 0;
  for(long long i=(long long)index; i<(long long)index+k; i++){
    double tempsum = 0;
    long long num = vec[i];
    while(num != 0){
      tempsum += num;
      num--;
    }
    tempsum /= (double)vec[i];
    ressum += tempsum;
  }
  cout << std::setprecision(10) << ressum << endl;
  return 0;
}
    
  
  


Measured memory_bytes: 4848
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <math.h>

typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18+1;
const int N = 4e5+1;
const ll mod = 1e9+7;
const int bits = 19;


int main(){
    FASTIO;
    PRECISION;
    
    int n;
    ll k;
    cin>>n>>k;
    vector< vector<int> >dp(64, vector<int>(n+1));

    for(int i=1;i<=n;i++){
        cin>>dp[0][i];
    }

    int st = 1;

    for(int i=1;i<63;i++){
        for(int j=1;j<=n;j++){
            dp[i][j] = dp[i-1][dp[i-1][j]];
        }
    }

    for(int i=62;i>=0;i--){
        if(k-(1LL<<i)>=0){
            st = dp[i][st];
            k-=(1LL<<i);
        }
    }

    cout<<st<<"\n";


}

Measured memory_bytes: 54152
n,k = gets.chomp.split.map(&:to_i)
balls = {}
as = gets.chomp.split
as.each do |a|
    !balls[a] ? balls[a] = 1 : balls[a] += 1
end

c = balls.values.sort.reverse
p [(n - c[0..k-1].inject(:+)),0].max

Measured memory_bytes: 40688
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string raw;
    cin >> raw;
    int a = stoi(raw.substr(0, 2));
    int b = stoi(raw.substr(2, 2));
    bool ma = 0 < a && a < 13;
    bool mb = 0 < b && b < 13;
    if (ma && mb) {
        cout << "AMBIGUOUS" << endl;
    } else if (ma) {
        cout << "MMYY" << endl;
    } else if (mb) {
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
a=list(input())
c=0
def abcd(n,i,s):
    global c
    if i==3:
        if n==7 and c==0:
            print(s+"=7")
            c=1
    else:
        for j in range(2):
            if j==0:
                abcd(n+int(a[i+1]),i+1,s+"+"+a[i+1])
            else:
                abcd(n-int(a[i+1]),i+1,s+"-"+a[i+1])
abcd(int(a[0]),0,a[0])

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

int main(){
	int r,g,b;
	cin >> r >> g >> b ;
	int C = 100*r + 10*g + b;
	if(C % 4 ==0 ){
    cout <<"YES" << endl;
    }
    else cout <<"NO" <<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define siz 1005
ll INF = 1e18;
const ll mod = 1e9+7;
typedef pair<int,int> pii;
typedef pair< pair<int ,int> , pair<int ,int > > ppp;

int n,m,p;
char arr[siz][siz];
ll dp[siz][siz];

int main(){
   // ios_base::sync_with_stdio(0); cin.tie(0);
//
//       freopen("input.txt","r",stdin);
//       freopen("output.txt","w",stdout);
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            scanf(" %c",&arr[i][j]);
        }
    }

    dp[1][1]=1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(i==1&&j==1) continue;
            if(arr[i][j]=='.')
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
        }
    }
    printf("%lld",dp[n][m]);
    return 0;
}


Measured memory_bytes: 9088
//070 A - Palindromic Number 2017/08/12
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int n; cin >> n;
    cout << ((n%10==((n/10)/10)%10) ? "Yes" : "No" ) << endl; 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp make_pair
#define INF (1<<28)
typedef long long Int;

int N, B[64], C[64];
string A[64], D[64][64];
int g[64][64], vis[64];
int r[64], p[64];
Int f[64];

void collect(vector<int>& q, int at) {
    if (vis[at]) return ;
    vis[at] = 1;
    q.push_back(at);
    rep (i, N) if (g[at][i]) collect(q, i);
}

void prepare(vector<int>& q) {
    const int n = q.size();
    //vector<pair<int, int> > ps;
    //rep (i, n) ps.push_back(mp(C[q[i]], q[i]));
    //sort(ps.begin(), ps.end());
    //rep (i, n) r[i] = ps[n-1-i].second;
    rep (i, n) r[i] = q[i];
    rep (i, n) p[i] = B[r[i]];
    rep (i, n) {
        f[i] = 0;
        rep (j, n) if (g[r[i]][r[j]]) f[i] |= 1LL<<j;
    }
}

int rec(int n, int k, Int u) {
    if (k == n) return 0;
    rep (i, k) if (!(u&(1LL<<i)) && !(f[i]&u)) return -INF;
    int ans = -INF;
    const int mask = (1LL<<n) - 1;
    if (u&(1LL<<k)) ans = max(ans, rec(n, k+1, u&(mask-f[k])) + p[k]);
    if (r[k]) ans = max(ans, rec(n, k+1, u&(mask-(1LL<<k))));
    return ans;
}

int solve() {
    memset(vis, 0, sizeof(vis));
    int ans = 0;
    rep (i, N) if (!vis[i]) {
        vector<int> q;
        collect(q, i);
        prepare(q);
        ans += rec(q.size(), 0, (1LL<<q.size())-1);
    }
    return ans;
}

int main() {
    for (;;) {
        cin >> N;
        if (N == 0) return 0;
        map<string, int> of;
        rep (i, N) {
            cin >> A[i] >> B[i] >> C[i];
            of[A[i]] = i;
            rep (j, C[i]) cin >> D[i][j];
        }
        memset(g, 0, sizeof(g));
        rep (i, N) rep (j, C[i]) g[i][of[D[i][j]]] = 1;
        printf("%d\n", solve());
    }
}

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

int stones[11][5];
int main(void){
    int H;
    while(cin >> H && H) {
        rep(i, H) rep(j, 5) cin >> stones[H-i-1][j];
        bool isFinished = false;
        int score = 0;
        while(!isFinished) {
            isFinished = true;
            rep(i, H) {
                rep(j, 3) {
                    if(stones[i][j]!=-1 &&
                       stones[i][j]==stones[i][j+1] &&
                       stones[i][j]==stones[i][j+2]) {
                        isFinished = false;
                        int d = stones[i][j];
                        for(; stones[i][j]==d && j<5; ++j) {
                            stones[i][j] = -1;
                            score += d;
                        }
                    }
                }
            }
            rep(column, 5) {
                for(int row=1; row<H; ++row) {
                    if(stones[row-1][column]==-1 && stones[row][column]!=-1) {
                        for(int i=row; i>0&&stones[i-1][column]==-1; --i) {
                            swap(stones[i-1][column], stones[i][column]);
                        }
                    }
                }
            }
        }
        cout << score << endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int n; cin >> n;
	string S; cin >> S;

	int cnt = 0;

	for (int i = 0; i < n; ++i) {
		string si; cin >> si;
		int len = si.length();

		for (int j = 0; j < len; ++j) {
			if (si[j] == S[0]) {
				int f = 0;
				for (int k = 1; k < len; ++k) {
					for (int l = 1; l < len; ++l) {
						if (si[j + k*l] != S[l]) break;
						if (j + k*l >= len) break;
						if (l == S.length() - 1) {
							cnt++;
							f = 1;
						}
						if (f) break;
					}
					if (f) break;
				}
				if (f) break;
			}
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int h, w;
    cin >> h >> w;
    int cy, cx, ty, tx;
    cin >> cy >> cx >> ty >> tx;
    --cy, --cx, --ty, --tx;
    char s[h][w];
    rep(i, 0, h) rep(j, 0, w) cin >> s[i][j];
    int seen[h][w];
    rep(i, 0, h) rep(j, 0, w) seen[i][j] = -1;
    seen[cy][cx] = 0;
    deque<pint> q;
    q.push_front({cy, cx});
    while (!q.empty()) {
        int y = q.front().first, x = q.front().second;
        q.pop_front();
        rep(i, 0, 4) {
            int ny = y + dy[i], nx = x + dx[i];
            if (ny < 0 || nx < 0 || ny >= h || nx >= w || s[ny][nx] == '#') continue;
            if (seen[ny][nx] == -1) {
                seen[ny][nx] = seen[y][x];
                q.push_front({ny, nx});
            } else if (seen[ny][nx] > seen[y][x]) {
                seen[ny][nx] = seen[y][x];
                q.push_front({ny, nx});
            }
        }
        rep(i, -2, 3) {
            rep(j, -2, 3) {
                int ny = y + i, nx = x + j;
                if (ny < 0 || nx < 0 || ny >= h || nx >= w || s[ny][nx] == '#') continue;
                if (seen[ny][nx] == -1) {
                    seen[ny][nx] = seen[y][x] + 1;
                    q.push_back({ny, nx});
                } else if (seen[ny][nx] > seen[y][x] + 1) {
                    seen[ny][nx] = seen[y][x] + 1;
                    q.push_back({ny, nx});
                }
            }
        }
    }
    /*
    rep(i, 0, h) {
        rep(j, 0, w) cout << seen[i][j] << " ";
        cout << "\n";
    }
    */
    cout << seen[ty][tx] << "\n";
}

Measured memory_bytes: 12424
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := readInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = readInt()
	}

	result := 0
	a := make([]int, N)
	bs := make([]int, N)
	for b := 0; b < 60; b++ {
		a[N-1] = (A[N-1] >> uint(b)) & 1
		bs[N-1] = a[N-1]
		for i := N - 2; i > -1; i-- {
			a[i] = (A[i] >> uint(b)) & 1
			bs[i] = bs[i+1] + a[i]
		}

		t := 0
		for i := 0; i < N-1; i++ {
			if a[i] == 0 {
				t += bs[i+1]
			} else {
				t += (N - (i + 1)) - bs[i+1]
			}
			t %= 1000000007
		}
		B := (1 << uint(b)) % 1000000007
		result += (t * B) % 1000000007
		result %= 1000000007
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


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

int f(vector<int> v, int i, int a) {
    vector<int>::iterator maxIt = max_element(v.begin(), v.end());
    vector<int>::iterator minIt = min_element(v.begin(), v.end());
    if (v.size() == 0){
        return a;
    }
    if(*maxIt == *minIt) {
        return a + (*minIt) - i;
    }
    a+=*minIt-i;
    i = *minIt;
    size_t minIndex = distance(v.begin(), minIt);
    if (minIndex == 0) {
        vector<int> vec;
        copy(next(v.begin()), v.end(), back_inserter(vec));
        a = f(vec, i, a);
    } else if (minIndex == v.size()) {
        vector<int> vec;
        copy(v.begin(), prev(v.end()), back_inserter(vec));
        a = f(vec, i, a);
    } else {
        vector<int> vec1;
        copy(v.begin(), minIt, back_inserter(vec1));
        a = f(vec1, i, a);
        vector<int> vec2;
        copy(next(minIt), v.end(), back_inserter(vec2));
        a = f(vec2, i, a);
    }
    return a;
}


int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i=0; i<n; i++) {
        cin >> v[i];
    }
    int a = f(v, 0, 0);
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
  
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
#define L 2
#define U 3
#define R 0
#define D 1
  
int cost[30][30];
bool wall[4][30][30];
bool visited[30][30];
int w, h;
  
int bfs(int sx, int sy, int gx, int gy) {
  fill(cost[0], cost[32], 0);
  fill(visited[0], visited[32], false);
  cost[0][0] = 1;
    
  queue<pair<int, int> > Q;
  Q.push(make_pair(0, 0));
  visited[0][0] = true;
  while(!Q.empty()) {
    pair<int, int> st = Q.front(); Q.pop();
      
    if(st.first == gx && st.second == gy) {
      return cost[gy][gx];
    }
      
    for(int i=0; i<4; i++) {
      int nx = st.first + dx[i], ny = st.second + dy[i];
      if(0<= nx && nx < w && 0<= ny && ny < h) {
    if(!visited[ny][nx] && !wall[i][st.second][st.first]) {
      visited[ny][nx] = true;
      cost[ny][nx] = cost[st.second][st.first] + 1;
      Q.push(make_pair(nx, ny));
    }
      }
    }
  }
  return 0;
}
  
int main() {
  while(cin >> w >> h && w+h) {
    fill(wall[0][0], wall[4][30], 0);
      
    for(int i=0; i<h; i++) {
      wall[R][i][0] = wall[L][i][w-1] = 1;
    }
    for(int i=0; i<w; i++) {
      wall[D][0][i] = wall[U][h-1][i] = 1;
    }
      
    for(int i=0; i<h; i++) {
        
      for(int j=0; j<w-1; j++) {
    cin >> wall[L][i][j];
    wall[R][i][j+1] = wall[L][i][j];
      }
        
      if(i < h-1) {
    for(int j=0; j<w; j++) {
      cin >> wall[U][i][j];
      wall[D][i+1][j] = wall[U][i][j];
    }
      }
    }
  
    /*
    for(int i=0; i<h; i++) {
      for(int j=0; j<w; j++) {
    cout << "R: " << wall[R][i][j] << " L: " << wall[L][i][j] << " U: " << wall[U][i][j] << " D: " << wall[D][i][j] << endl;
      }
    }
    */
      
    cout << bfs(0, 0, w-1, h-1) << endl;
    /*
    for(int i=0; i<h; i++) {
      for(int j=0; j<w; j++) 
    cout << cost[i][j] << " "; 
      cout << endl; 
    }
    */
  }
    
  return 0;
}

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

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

  
  
  
  

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 10000
#define nil -1
#define vmax 10000
#define sentinel 2000000000
constexpr long long int inf = 1000000000000;
constexpr long long int rinf = -(INT64_MAX);
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main() {
    int n,k,ans=0;
    cin>>n>>k;
    vector<int> a(n,0);
    rep(i,n){
        cin>>a[i];
    }
    SORTR (a);
    for(int i=0;i<k;i++){
        ans+=a[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){
  ll n;
  cin >> n;
  ll a,b;
  for(ll i=1; i<=ceil(sqrt(n)); i++)if(n%i==0){
    a=i;
    b=n/i;
  }
  int ans = max(floor(log10(a))+1,floor(log10(b))+1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def check(p)
    c = 0
    for i in 1..p do
        if (p % 2) == 1 && (p % i) == 0
            c += 1
        end
    end
    c == 8
end

n = gets.to_i

cnt = 0
for i in 1..n do
    if check(i)
        cnt += 1
    end
end
puts cnt


Measured memory_bytes: 1788
import java.util.*;
class Main{
public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int size=Integer.parseInt(s.next());
		int k=Integer.parseInt(s.next());
		int[] h=new int[size];
		for(int i=0;i<size;i++)
		{
			h[i]=(s.nextInt());
		}
		System.out.println(new Main().frog2(h,k));
		s.close();
	}
	public int frog2(int[] heights,int k)
	{
		int[] dp=new int[heights.length];
		
		for(int i=0;i<dp.length;i++)
			dp[i]=Integer.MAX_VALUE;
		dp[0]=0;
		for(int i=0;i<dp.length;i++)
		{
			for(int j=i+1;j<=i+k && j<dp.length;j++)
			{
				dp[j]=Math.min(dp[j], dp[i]+Math.abs(heights[j]-heights[i]));
						
			}
		}
		return dp[dp.length-1];
	}
}


Measured memory_bytes: 49860
N=int(input())
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
a=0
for i in range(1,N+1):
    if a<sum(A1[:i])+sum(A2[i-1:]):
        a=sum(A1[:i])+sum(A2[i-1:])
print(a)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(c) (c).begin(), (c).end()
#define REVERSE(c) reverse(ALL(c))
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort(ALL(c))
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;


int main() {
	string S;
    cin >> S;
    LL x = toInt(S);
    LL f = x / 100, l = x % 100;
    LL flag = 0;
    if (1 <= f && f <= 12) {
        if (1 <= l && l <= 12) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }
    } else {
        if (1 <= l && l <= 12) {
            cout << "YYMM" << endl;
        } else {
            cout << "NA" << endl;
        }
    }
	
    return 0;
}


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

int main() {
	// your code goes here
	string s;
	cin>>s;
	if(s=="SUN")cout<<7-0;
	if(s=="MON")cout<<7-1;
	if(s=="TUE")cout<<7-2;
	if(s=="WED")cout<<7-3;
	if(s=="THU")cout<<7-4;
	if(s=="FRI")cout<<7-5;
	if(s=="SAT")cout<<7-6;
	
	// SUN, MON, TUE, WED, THU, FRI, or SAT, 
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	static final int MAX = 3000000;
	static boolean[] judge = new boolean[MAX];
	static int[] msprimes = new int[317247];

	static void fului_ver2(){
		int multiple;
		int i = 6, cnt = 0;
		msprimes[cnt++] = 1;
		while(i<MAX){
			if(judge[i]){
				msprimes[cnt++] = i;
				multiple = i + i;
				while(multiple<MAX){
					judge[multiple] = false;
					multiple += i;
				}
			}
			if(i%7==6){
				i += 2;
			}else{
				i += 5;
			}
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Arrays.fill(judge, true);
		fului_ver2();
		int msnum, i, flag;

		while(true){
			msnum = sc.nextInt();
			if(msnum==1) break;
			System.out.print(msnum + ":");
			i = 1;
			flag = 0;
			while(msprimes[i]<=msnum/6){
				if(msnum%msprimes[i]==0){
					flag = 1;
					System.out.print(" " + msprimes[i]);
				}
				i++;
			}
			if(flag==1){
				System.out.println();
			}else{
				System.out.println(" " + msnum);
			}
		}
	}
}

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

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

    string S;
    cin >> S;
    vector<vector<int>> dp(2, vector<int>(2019, 0));
    int pre = 0, cur = 1;
    uint64_t ans = 0;
    for (int i = 0; i < (int)S.length(); ++i) {
        fill(dp[cur].begin(), dp[cur].end(), 0);
        char ch = S[i] - '0';
        for(int j = 0; j < 2019; ++j) {
            if (dp[pre][j]) {
                dp[cur][(j * 10 + ch) % 2019] += dp[pre][j];
            }
        }
        ++dp[cur][ch];
        ans += dp[cur][0];
        swap(pre, cur);
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

int up(int A)
{
    if(A%10==0) return A;
    else return (A/10)*10 + 10;
}

int amari(int A)
{
    if(A%10==0) return 10;
    else return A%10;
}

int main()
{
    vector<int> Dish(5);
    for(int i=0;i<5;i++)
    {
        cin >> Dish.at(i);
    }

    vector<int> Amari = {amari(Dish.at(0)),amari(Dish.at(1)),amari(Dish.at(2)),amari(Dish.at(3)),amari(Dish.at(4))};
    vector<int> Up = {up(Dish.at(0)),up(Dish.at(1)),up(Dish.at(2)),up(Dish.at(3)),up(Dish.at(4))};

    int total = accumulate(ALL(Up),0) - (10 - *min_element(ALL(Amari)));

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll M; cin >> M;
  cout << 24 + (24 - M) << endl;

  return 0;
}



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

int main() {
  
int s;
    
    cin >> s;
    
    set<int> st;
    
    int x = s;
    
    
    while (st.count(x)==0) {
        
        st.insert(x);
        
        if (x%2==0) {
            x /= 2;
            
        }else{
            
            x = x*3+1;
        }
        
    }
    
    cout << (st.size()+1) << endl;
  
 
  return  0;
}

Measured memory_bytes: 256
//Patwari26
//#include template<t> as mine
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n,x,y;
    cin>>n;
    ll cc=0;
    rep(i,0,n-1){
        cin>>x>>y;
        if(x==y){
            cc++;
            if(cc==3){
                cout<<"Yes"<<endl;
                return;
            }
        }
        else{
            cc=0;
        }
    }
    cout<<"No"<<endl;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    // time
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int n,a[20];

int solve(int i,int m){
    if(m==0) return 1;
    if(i>=n) return 0;
    int res = solve(i+1,m) || solve(i+1,m-a[i]);
    return res;
}

int main(){
    int q,m;
    cin >> n;
    for(int i=0;i<n;i++)cin >> a[i];
    cin >> q;
    for(int i=0;i<q;i++){
        cin >> m;
        if(solve(0,m))cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}






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

typedef long long ll;

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

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

int main() {
  int a, b;
  cin >> a;
  cin >> b;

  int ans = a + b;

  if(ans >= 10) {
    cout << "error" << endl;
  }else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  
  int i,j,k,v,A[100],N;
  
  scanf("%d",&N);
  
  for(i = 0; i < N; i++){
    scanf("%d",&A[i]);
  }
  
  for(i = 1; i < N+1; i++){
    for(k = 0; k < N; k++){
      printf("%d",A[k]);
      if(k == N-1) break;
      printf(" ");
    }
    
    printf("\n");
    
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
  }
  return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<string>

using namespace std;

int main(){
    string str;
    cin >> str;

    if(str[2]==str[3]){
        if(str[4]==str[5]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>){
  var (a,b) = readLine()!!.split(" ").map(String::toInt)
  if(a<b){
    if(a<b-1){
      println(b+b-1)
    }
    else{
      println(b+a)
    }
  }
  else{
    if(a-1>b){
      println(a+a-1)
    }
    else{
      println(a+b)
    }
  }
}

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int plan1 = a * n;

  if (plan1 < b) {
    cout << plan1 << endl;
  } 
  else {
    cout << b << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    try {
      int n = sc.nextInt();
      int m = sc.nextInt();
      int[] cnt = new int[n];
      for (int i = 0; i < m; i++) {
        int a = sc.nextInt() - 1;
        int b = sc.nextInt() - 1;
        cnt[a]++;
        cnt[b]++;
      }
      for (int i = 0; i < n; i++) System.out.println(cnt[i]);
    } finally {
      sc.close();
    }
  }
}

Measured memory_bytes: 35856
import           Data.Sequence (Seq ((:<|)), index, (|>))
import qualified Data.Sequence as S


main :: IO ()
main = do
  k <- readLn
  print $ solve k

solve :: Int -> Int
solve k = index (xs !! (k - 1)) 0
  where xs = iterate f $ S.fromList [1 .. 9]

f :: Seq Int -> Seq Int
f (x :<| xs) = xs'''
  where y = x `mod` 10
        z = 10 * x + y
        xs' = if y /= 0 then xs |> z - 1 else xs
        xs'' = xs' |> z
        xs''' = if y /= 9 then xs'' |> z + 1 else xs''


Measured memory_bytes: 24020
#include<stdio.h>
int main(void)
{
   int a,b,c,i,n=0;
   scanf("%d %d %d",&a,&b,&c);
   for(i=a;i<=b;i++){
      if((c%i)==0){
         n++;
      }
   }
   printf("%d\n",n);
   return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
const int maxn = 21, mod = 1e9 + 7;
int dp[maxn][1<<maxn];
int a[maxn][maxn];
vector<int> status[maxn];
int bitcnt(int n){
    int res = 0;
    while(n){
        if(n&1)res++;
        n >>= 1;
    }
    return res;
}
int main()
{
//    freopen("in", "r", stdin);
    int n;
    cin>>n;
    for(int s = 0; s < (1<<n); s++)
        status[bitcnt(s)].push_back(s);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++)
            cin>>a[i][j];
    }
    dp[n-1][(1<<n)-1] = 1;
    for(int i = n-2; i >= 0; i--){
        for(auto s:status[i+1]){
            for(int j = 0; j < n; j++){
                if(a[i+1][j] == 0 || (s&(1<<j)))continue;
                dp[i][s] = (dp[i][s] + dp[i+1][s|(1<<j)]) % mod;
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++)
        if(a[0][i] == 1)
            ans = (ans + dp[0][1<<i]) % mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 169404
#include <stdio.h>
int main(void) {
	int n, a, v, number = 21, value = -1;

	scanf("%d", &n);
	while (n--) {
		scanf("%d %d", &a, &v);
		if (v > value || (v == value && a < number)) {
			number = a;
			value = v;
		}
	}
	printf("%d %d\n", number, value);
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>

using namespace std;

int main(void) {
	int n,k,a[200000],s[200000],x;
    cin >> n;
    cin >> k;
    int i;
    for (i=0;i<n;i++) cin >> a[i];
    for (i=0;i<n;i++) s[i]=0;
    for (i=0;i<n;i++) s[a[i]]++;
    sort(s, &s[n-1], greater<int>());
    x=n;
    for (i=0;i<k;i++) x-=s[i];
    //printf("%d, %d\n", s[0], s[1]);
    cout << x << endl;
	return 0;
}


Measured memory_bytes: 1792
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
score = sum(b)
for i in range(len(a) - 1):
    if a[i] + 1 == a[i + 1]:
        score += c[a[i] - 1]
print(score)

Measured memory_bytes: 3064
//2018.9.24 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
inline int read(){
    res s=0;
    bool w=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline void _swap(res &x,res &y){
    x^=y^=x^=y;
}
inline int _abs(const res &x){
    return x>0?x:-x;
}
inline int _max(const res &x,const res &y){
    return x>y?x:y;
}
inline int _min(const res &x,const res &y){
    return x<y?x:y;
}
const int N=1e5+10;
namespace MAIN{
    inline bool cmp(const res &x,const res &y){
        return x>y;
    }
    int n,a[N];
    inline void MAIN(){
        n=read();
        for(res i=1;i<=n;i++)a[i]=read();
        sort(a+1,a+n+1,cmp);
        for(res i=1;i<=n;i++)
            if(i+1>a[i+1]){
                res j=i+1,ans=0;
                while(a[j]==i)ans^=1,j++;
                if((ans||((a[i]-i)&1)))puts("First");
                else puts("Second");
                return;
            }
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	bool debug = false;
	string exa[4] = { "dream",  "erase", "eraser","dreamer" };

	for (int i = 0; i < 4; i++)
	{
		reverse(exa[i].begin(), exa[i].end() );
	}

	reverse(s.begin(), s.end());


	int count = 0;
	bool result = true;
	string comp = "";

	if (debug) cout << s.size() << endl;

	for (int i = 0; i < s.size(); i++)
	{
		count++;
		comp += s[i];

		if(debug) cout << comp << endl;

		if (count >= 5)
		{
			for (int j = 0; j < 4; j++)
			{
				if (comp == exa[j])
				{
					count = 0;
					comp = "";
					break;
				}
			}
			
		}
		if (count > 7)
		{
			result = false;
			break;
		}
		if (i ==( s.size() - 1) && count > 0)
		{
			result = false;
		}
	}

	if (result)
	{
		cout << "YES";
	}
	else
	{
		cout << "NO";
	}

}

Measured memory_bytes: 3656
/*
Miles Morales : When will I know I'm ready?
Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith.
*/
//KEEP IT SIMPLE STUPID
/*#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define print(o) for(auto it=(o).begin();it!=(o).end();it++) cout<<*it<<" ";
#define vll vector<ll>
#define pb push_back
#define FOR(n) for(ll i=0;i<=n;i++)
#define FORd(n) for(ll i=n;i>=0;i--)
#define FORrd(a,b) for(ll i=a;i>=b;i--)
#define FORr(a,b) for(ll i=a;i<=b;i++)
#define all(x) (x).begin(),(x).end()
#define FIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define ff first
#define ss second
#define w(t) ll t;cin>>t;while(t--)

int main()
{
    ll n;
    cin>>n;
    vll a(n);
    for(ll i=0;i<n-1;i++)
    {
        ll x;
        cin>>x;
        x--;
        a[x]++;
    }
    for(ll i=0;i<n;i++)
    {
        cout<<a[i]<<'\n';
    }
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 4844
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  int i,j,n,w,x;
  double ans,v[11],max,m2;
  while(1){
    cin >> n >> w;
    if(n == 0 && w == 0) break;

    for(i=0;i<11;i++) v[i] = 0.0;

    m2 = 0.0;

    for(i=0;i<n;i++){
      cin >> x;
      for(j=0;j<11;j++){
	if(x < (j+1) * w){
	  v[j]++;
	  if((int)m2 < j) m2 = (double)j;
	  break;
	}
      }
    }

    max = v[0];
    for(i=0;i<11;i++){
      if(max < v[i]) max = v[i];
    }

    ans = v[0] / max;
    for(i=1;i<11;i++){
      if(i == (int)m2) break;
      ans += v[i] / max * (double)(m2 - i) / m2;
    }

    ans += 0.01;
    
    printf("%f\n",ans);
    
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  int g = 0; 
  int m = 0;
  for (int i = 0; i < a; i++) {
    int x;
    cin >> x;
    g = __gcd(g, x);
    m = max(m, x);
  }
  if (m >= b && b % g == 0) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()
r = s.count('R')
g = s.count('G')
b = n - r - g

ans = r * g * b
for i in range(1, (n // 2) + 1):
    for j in range(0, n - (2 * i) + 1):
        if j + (2 * i) >= n:
            break
        if ((s[j] != s[j + i]) & (s[j] != s[j + (2 * i)]) & (s[i + j] != s[j + (2 * i)])):
            ans -= 1
        
print(ans)

Measured memory_bytes: 68340
/*
ID: seekho
PROG: friday
LANG: C++14                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
// const int N = 100005;



int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);

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

    int tk = n/2 + (n%2);
    if(k > tk) {
    	cout << "NO\n";
    }
    else cout << "YES\n";
}

Measured memory_bytes: 256
s = input()
t = ''
n = len(s)
while n > len(t):
    if s[-5:] == 'dream' or s[-5:] == 'erase':
        t += 'dream'
        s = s[:-5]
    elif s[-7:] == 'dreamer':
        t += 'dreamer'
        s = s[:-7]
    elif s[-6:] == 'eraser':
        t += 'eraser'
        s = s[:-6]
    else:
        break
if len(s) == 0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3324
#include <stdio.h>
int main()
{
int A,B,C,D;
scanf("%d%d", &A,&B);
if(2*B>0)
	D = A+B;
else
	D = A-B;
if(D>A*B)
	printf("%d",D);
else
	printf("%d",A*B);
}

Measured memory_bytes: 128
// C - Scc Puzzle
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	ll s,c; cin>>s>>c;
	ll ans = 0;

	ll c2 = c/2;
	if(s<=c2){
		ans += s;
		c -= s*2;
		s = 0;
	}
	else{
		ans += c2;
		s -= c2;
		c -= c2*2;
	}

	ans += c/4;

	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void main()
{
  int in_ch;
  int out_ch;
  
  in_ch = getchar();
  
  switch( in_ch ){
    case 'A':
      out_ch = 'T';
      break;
    case 'T':
      out_ch = 'A';
      break;
    case 'C':
      out_ch = 'G';
      break;
    case 'G':
      out_ch = 'C';
      break;
  }
  printf("%c\n", out_ch );
  exit(0);
}


Measured memory_bytes: 128
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

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

ans = 1
mm = 0
i = 0
flg = 0
while(i<N-1):
    if A[i]>A[i+1]:
        if mm>0:
            ans += 1
            flg = 1
            
            # print(i,A[i])
        mm = -1
        if flg:
            flg = 0
            mm = 0

    elif A[i]<A[i+1]:
        if mm<0:
            ans += 1
            flg = 1
            
            # print(i,A[i])

        mm = 1
        if flg:
            flg = 0
            mm = 0
    i+=1
    
print(ans)




Measured memory_bytes: 14252
X, K, D = list(map(int,input().rstrip().split()))
X = abs(X)
a = X//D
if K <= a:
    print(abs(X-(D*K)))
elif (K-a)%2 == 0:
    print(abs(X-(D*a)))
else:
    print(abs(D*(a+1)-X))

Measured memory_bytes: 9180