akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
  int N;
  cin>>N;
  vector<int>p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  int cnt=0;
  for(int i=0;i<N;i++){
    if(i<N-1&&p[i]==i+1){cnt++;swap(p[i],p[i+1]);}
    if(i==N-1&&p[i]==i+1){cnt++;swap(p[N-1],p[N-2]);}
  }

  //for(int i=0;i<N;i++){
    //cout<<p[i]<<" ";
  //}
  cout<<cnt<<endl;
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    map<string, int> m;
    string str;
    for(int i=0; i<N; i++){
        cin >> str;
        m[str] += 1;
    }
    int mx = -1;
    for(pair<string, int> p: m){
        mx = max(p.second, mx);
    }
    for(pair<string, int> p: m){
        if(mx==p.second){
            cout << p.first << endl;
        }
    }
}

Measured memory_bytes: 25216
#include <stdio.h>
int main(){
	char s[200001];
    char t[200001];
  	int count=0;
  	scanf("%s",s);
  	scanf("%s",t);
  	for(int i=0;s[i];i++){
    	if(s[i]!=t[i]) count++;
    }
  	printf("%d\n",count);
}


Measured memory_bytes: 2548
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const int MOD = 998244353;
const int MX = 5000;

int powmod(int n, int k) {
	int res = 1;
	while(k > 0) {
		if(k & 1) res = (res * n) % MOD;
		n = (n * n) % MOD;
		k /= 2;
	}
	return res;
}
int invmod(int n) {
	return powmod(n, MOD - 2);
}

int fact[MX], invfact[MX];

int comb(int n, int m) {
	return (fact[n] * invfact[m] % MOD) * invfact[n - m] % MOD;
}

int N, K;

int calc(int i) {
	int res = 0;
	int g = max(K - i + 1, 0LL);
	int num = (i - 1) / 2;

	// don't user <i vals
	if (g > 0) {
		res += comb(N + g - 1, g - 1);
		res %= MOD;
	}

	if (i % 2 == 0) {
		res += comb(N - 1 + g - 1, g - 1);
		res %= MOD;
	}

	for(int j = 1; j <= num && j <= N; ++j) {
		int tmp = powmod(2, j) * comb(num, j) % MOD;

		res += (tmp * comb((N - j) + (j + g - 1), j + g - 1)) % MOD;
		res %= MOD;

		if(i % 2 == 0 && N - j - 1 >= 0) {
			res += (tmp * comb((N - j - 1) + (j + g - 1), j + g - 1)) % MOD;
			res %= MOD;
		}
	}
	cout << res << endl;
}

signed main(){
	fact[0] = invfact[0] = 1;
	for(int i = 1; i < MX; ++i) {
		fact[i] = (fact[i-1] * i) % MOD;
		invfact[i] = invmod(fact[i]);
	}

	cin >> K >> N;
	for(int i = 2; i <= K + 1; ++i) {
		calc(i);
	}
	for(int i = K + 2; i <= 2 * K; ++i) {
		calc(2 * K - i + 2);
	}
	return 0;
}



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

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

int main() {
    ll N, D; cin >> N >> D;
    int cnt = 0;
    rep(i, N) {
        ll x, y; cin >> x >> y;
        if (x * x + y * y <= D * D) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

a=input()
b=a.upper()
if a==b:
    print('A')
else:
    print('a')

Measured memory_bytes: 61680
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	int a, b; cin >> a >> b;
	string n; cin >> n; int s = 0, t = 0; bool flag = false;
	Rep(i, n.length()){
		if(n[i] != '-' && !flag){
			s++;
		}
		if(n[i] == '-'){
			flag = true;
		}
		if(n[i] != '-' && flag){
			t++;
		}
	}
	if(a == s && b == t){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  int h,a;
  cin >> h >> a;
  if(h%a ==  0) cout << h/a << endl;
  else cout << h/a + 1 << endl;
}

Measured memory_bytes: 256
def length(x1,y1,x2,y2):
  dx = x2 - x1
  dy = y2 - y1
  if dx >= 0 and dy >= 0:
    return max(dx, dy)
  elif dx >= 0 and dy < 0:
    return dx - dy
  elif dx < 0 and dy >= 0:
    return dy - dx
  elif dx < 0 and dy < 0:
    return -min(dx,dy)

def main():
  w, h, n = map(int,input().split())
  x, y = map(int,input().split())
  ans = 0
  
  for i in range(n - 1):
    x2,y2 = map(int,input().split())
    ans += length(x,y,x2,y2)
    x, y = x2, y2
  
  print(ans)
main()


Measured memory_bytes: 5604
#include <cstdio>
using namespace std;
int main ()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    int x,y,z;
    if(a>b && a>c)
    {
        if(b>c)
        {
            x=a;
            y=b;
            z=c;
        }
        else
        {
            x=a;
            y=c;
            z=b;
        }
    }
    else if(b>a && b>c)
    {
        if(a>c)
        {
            x=b;
            y=a;
            z=c;
        }
        else
        {
            x=b;
            y=c;
            z=a;
        }
    }
    else if(c>a && c>b)
    {
        if(a>b)
        {
            x=c;
            y=a;
            z=b;
        }
        else
        {
            x=c;
            y=b;
            z=a;
        }
    }
    int sum1;
    sum1=y+z;
    if(x==sum1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>

typedef long long ll;
const int N=201000,MOD=998244353;
ll qpow(ll a,ll b){ll c=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)c=c*a%MOD;return c;}
void inc(int a,int &b){b=(a+b)%MOD;}

int s[N];
int n;

namespace bf
{
	bool vis[N];
	int ans;
	void dfs(int state)
	{
		if(vis[state])return;
		vis[state]=1,ans++;

		int t[4],dt[4];
		for(int i=n;i;i--)t[i]=state%3,state/=3;

		for(int i=1;i<n;i++)
			if(t[i]!=t[i+1])
			{
				for(int j=1;j<=n;j++)dt[j]=t[j];
				int tmp=((t[i]+1)^(t[i+1]+1))-1,dk=0;
				dt[i]=dt[i+1]=tmp;
				for(int i=1;i<=n;i++)
					dk=dk*3+dt[i];
				dfs(dk);
			}
	}
	void solve()
	{
		int k=0;
		for(int i=1;i<=n;i++)k=k*3+s[i];
		ans=0,dfs(k);
		printf("%d\n",ans);
	}
}
namespace qwq
{
	int f[N][3][3];

	bool spj()
	{
		for(int i=1;i<n;i++)
			if(s[i]==s[i+1])return 0;
		return 1;
	}
	bool equal()
	{
		for(int i=1;i<n;i++)
			if(s[i]!=s[i+1])return 0;
		return 1;
	}

	void solve()
	{
		if(equal()){printf("1\n");return;}

		int tmp=0;
		for(int i=1;i<=n;i++)tmp=(tmp+s[i])%3;

		for(int i=0;i<3;i++)f[1][i][i]=1;
		for(int i=1;i<n;i++)
			for(int j=0;j<3;j++)
				for(int k=0;k<3;k++)
					for(int l=0;l<3;l++)
						if(l!=j)inc(f[i][j][k],f[i+1][l][(k+l)%3]);

		int ans=qpow(3,n-1);

		for(int i=0;i<3;i++)
			ans=(ans-f[n][i][tmp])%MOD;
		ans=(ans+spj()+MOD)%MOD;

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

char tmp[N];
int main()
{
	scanf("%s",tmp+1);
	n=strlen(tmp+1);
	for(int i=1;i<=n;i++)
		s[i]=tmp[i]-'a';
	if(n<=3)bf::solve();
	else qwq::solve();

	return 0;
}


Measured memory_bytes: 8448
# coding: utf-8

x, y = map(int,input().split())

l1 = [1,2,3]
l2 = [300000,200000,100000]

ans = 0
if x in l1:
    ans += l2[l1.index(x)]
    
if y in l1:
    ans += l2[l1.index(y)]

if x == 1 and y == 1:
    ans += 400000

print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

ll N;

ll f(ll n) {
  ll cnt = 0;
  for (ll i = 1; i * i <= n; ++i) {
    for (ll j = i; j * j <= n - i * i; ++j) {
      for (ll k = j; k * k <= n - i * i - j * j; ++k) {
        if (i * i + j * j + k * k + i * j + j * k + k * i == n) {
          if (i == j && j == k) {
            ++cnt;
          } else if (i == j && j != k) {
            cnt += 3;
          } else if (i != j && j == k) {
            cnt += 3;
          } else {
            cnt += 6;
          }
        }
      }
    }
  }
  return cnt;
}

int main() {
  //
  cin >> N;

  repe(i, 1, N) { cout << f(i) << "\n"; }
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;cin>>n;
    vector<ll> v(n);rep(i,0,n)cin>>v[i];
    ll l;cin>>l;
    ll d[n+1][20];
    rep(i,0,n){
        ll y=upper_bound(v.begin(),v.end(),v[i]+l)-v.begin();
        y--;
        d[i][0]=y;
    }
    d[n][0]=n;
    rep(j,1,20){
        rep(i,0,n+1){
            d[i][j]=d[d[i][j-1]][j-1];
            //cout<<d[i][j]<<" ";
        }
        //cout<<endl;
    }
    ll q;cin>>q;
    rep(i,0,q){
        ll a,b;cin>>a>>b;
        if(a>b)swap(a,b);
        a--;
        b--;
        ll u=n,dd=0;
        while(u-dd>1){
            ll mid=(u+dd)/2;
            ll y=mid;
            ll now=a;
            ll cn=0;
            while(y>0){
                if(y%2){
                    now=d[now][cn];
                }
                y/=2;
                cn++;
            }
            if(now>=b){
                u=mid;
            }
            else dd=mid;
        }
        cout<<u<<endl;
    }
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define dbg(S) { int f=1; for(auto x:S) cerr<<(f?"[":", ")<<x, f=0; cerr<<"]\n"; }

using namespace std;
using lint=long long;

int main(){
	lint k; cin>>k;

	int n=50;
	lint a[50];
	rep(i,n) a[i]=n-1+k/n;

	k%=n;

	rep(i,k) rep(j,n) {
		if(j==i) a[j]+=n;
		else     a[j]--;
	}

	cout<<n<<endl;
	rep(i,n) cout<<a[i]<<' ';

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int c=0;
int c1=0;
int n;
scanf("%d",&n);
if (n>=1&&n<=100){
	char s[n];
	for (int i=0;i<n;i++){
		cin>>s[i];
		if(s[i]=='I'){
		c++;
		if(c>c1)
		c1=c;}
		else
		c--;
	}
	n=0;
}

if(c1>0)
cout<<c1;
else
cout<<"0";
}

Measured memory_bytes: 256
D = int(input())
C = list(map(int, input().split()))
S = [[] for _ in range(D)]
for i in range(D):
    S[i] = list(map(int, input().split()))

def based_b():
    last = [0 for _ in range(26)]
    for i in range(D):
        d = i + 1
        max_score = 0
        t = 0
        for contest in range(26):
            last_tmp = last[:]
            score = S[i][contest]
            last_tmp[contest] = d
            for x in range(26):
                score -= C[x] * (d - last_tmp[x])
            if max_score < score:
                t = contest
                max_score = score
        last[t] = d
        print(t+1)

based_b()

Measured memory_bytes: 68932
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct LowLink{
    const vector<vector<int>> &g;
    vector<int> used,ord,low;
    vector<int> articulation;// 関節点
    vector<pair<int,int>> bridge;// 橋
    LowLink(const vector<vector<int>> &g):g(g){}
    int dfs(int pre,int now,int k){
        used[now]=1;
        ord[now]=k++;
        low[now]=ord[now];
        bool is_articulation=false;
        int cnt=0;
        for(auto &to:g[now])if(to!=pre){
            if(!used[to]){
                cnt++;
                k=dfs(now,to,k);
                low[now]=min(low[now],low[to]);
                is_articulation|=(pre>=0 and low[to]>=ord[now]);
                if(ord[now]<low[to]) bridge.push_back(minmax(now,to));
            }else{
                // 後退辺
                low[now]=min(low[now],ord[to]);
            }
        }
        // 根の場合子が2個以上いれば関節点
        is_articulation|=(pre==-1 and cnt>1);
        if(is_articulation) articulation.push_back(now);
        return k;
    }
    void build(){
        used.assign(g.size(),0);
        ord.assign(g.size(),0);
        low.assign(g.size(),0);
        int k=0;
        for(int i=0;i<(int)g.size();i++)if(!used[i]) k=dfs(-1,i,k);
    }
    bool isBridge(int u,int v){
        if(ord[u]>ord[v]) swap(u,v);
        return ord[u]<low[v];
    }
};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n,m;cin>>n>>m;
    vector<vector<int>> g(n);
    rep(i,m){
        int u,v;cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    LowLink L(g);
    L.build();

    sort(ALL(L.bridge));
    for(auto &p:L.bridge)cout<<p.first<<" "<<p.second<<endl;

    return 0;
}



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

int main(){
    int N,H,W;
    cin >> N >> H >> W;
    int ans = 0;
    rep(i,N){
        int A,B;
        cin >> A >> B;
        if (H <= A && W <= B) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3524
//Sameer's Code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define MOD 1000000007
#define pb push_back
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s;
	cin >> s;
	if (s[s.length() - 1] != 's')
	{
		cout << s << "s" << endl;
	}
	else {
		cout << s << "es" << endl;
	}
	return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 998244353;
const int inf = 1e18;
const int Maxn = 20010;
int cal(string s){
  int cnt = 0;
  for(int i = 0; i + 1 < sz(s);i++){
    if(s[i] == 'A' && s[i + 1] == 'B') cnt++;
  }
  return cnt;
}
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;
  int ans = 0 , c1 = 0 , c2 = 0 , c3 = 0;
  for(int i = 0;i < N; i++) {
    string s;
    cin >> s;
    if(s.front() == 'B' && s.back() == 'A'){
      c1++;
    }
    else if(s.front() == 'B') c2++;
    else if(s.back() == 'A') c3++;
    ans += cal(s);
  }
  if(c1 == 0){
    ans += min(c2 , c3);
  }
  else if(c1 > 0 && c2 + c3 > 0){
    ans += c1 + min(c2 , c3);
  }
  else if(c1 > 0 && c2 + c3 == 0) {
    ans += c1 - 1;
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3148
// Last Change: 04/06/2019 21:22:42.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  vector<ll> food(5);
  for (int i = 0; i < 5; ++i) {
    cin >> food[i];
  }

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

  ll ans = INT16_MAX;
  ll tmpAns;
  do {
    tmpAns = 0;
    for (int i = 0; i < 5; ++i) {
      int tmp = food[i];
      if (i != 4 and tmp % 10 > 0) {
        tmp /= 10;
        ++tmp;
        tmp *= 10;
      }
      tmpAns += tmp;
    }
    ans = min(ans, tmpAns);
  } while (next_permutation(food.begin(), food.end()));

  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}


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

int main(){
  ll n,m,p;
  cin >> n >> m >> p;
  vector<ll> s;
  for(int i=0;i<m;i++){
    ll a; cin >> a;
    s.push_back(a);
    if(a<p)s.push_back(a+n);
    else s.push_back(a-n);
  }
  sort(s.begin(),s.end());

  ll ans = min(p-s[0], s[2*m-1]-p);
  for(int i=1;i<m;i++){
    ll l = s[i], r = s[i+m-1];
    ans = min(ans, min(p-l,r-p)*2 + max(p-l,r-p));
  }
  cout << ans * 100 << endl;
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C; cin >> A >> B >> C;
  int a, b, c; a = max(A, max(B, C)); c = min(A, min(B, C)); b = A + B + C - a - c;
  if(a % 2 + b % 2 + c % 2 == 0 || a % 2 + b % 2 + c % 2 == 3) {
    cout << (a - b + a - c) / 2 << endl;
  } else if(a % 2 != b % 2 && a % 2 != c % 2) {
    cout << (a - (b + 1) + a - (c + 1)) / 2 + 1 << endl;
  } else if(a % 2 != b % 2 && a % 2 == c % 2) {
    cout << ((a + 1) - b + (a + 1) - (c + 1)) / 2 + 1 << endl;
  } else {
    cout << ((a + 1) - (b + 1) + (a + 1) - c) / 2 + 1 << endl;
  }
}

Measured memory_bytes: 256
N, M = map(int, input().split())
if M == 1:
  print(1)
  exit(0)
  
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a
  
fct = factorize(M)
#print(fct, num(fct))

ans = 1
for div in divisorize(fct):
    #print(div, num(div))
    temp = num(div)
    if N * temp <= M:
      ans = max(ans, temp)
      
print(ans)

Measured memory_bytes: 3064
N, M = map(int, input().split())

l = 1
r = N

for i in range(M):
    L, R = map(int, input().split())
    if L > l:
        l = L
    if R < r:
        r = R

ans = r - l + 1
if ans >= 0:
    print(ans)
else:
    print(0)

Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int [] in = new int [a];
        for(int i=0;i<a;i++){
                             in[i] = sc.nextInt();
                            }
		String s = "APPROVED";
        for(int i=0;i<a;i++){if(in[i]%2==0){if(in[i]%3!=0 && in[i]%5!=0){s="DENIED";break;
                                                                        }
                                                 
                                           }
                            }
       
		System.out.println(s);
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<stdio.h>
using namespace std;

int n;
int data[35];

void solve( int rest, int befhigh, int dep=0 ){
	int i;
	if( rest==0 ){
		for( i = 0; i < dep-1; i++ )
			printf("%d ",data[i]);
		printf("%d\n",data[i]);
		return;
	}
	for( i = min( befhigh, min(rest,befhigh) ); i >= 1; i-- ){
		data[dep] = i;
		solve(rest-i, i, dep+1);
	}
}
int main(){
	while(1){
		cin >> n;
		if(!n)break;
		
		solve(n,114514194);
	}
	return 0;
}

Measured memory_bytes: 1144
#include<stdio.h>

int F[45];

void fib(int n){

  int i;

  F[0] = 1;
  F[1] = 1;

  for(i=2;i<=n;i++){

    F[i] = F[i - 2] + F[i - 1];

  }


}


int main(){

  int n;

  scanf("%d",&n);

  fib(n);

  printf("%d\n",F[n]);

  return 0;
}


Measured memory_bytes: 2060
def f(n, s, min)
    if n == 1
        min <= s && s <= 100 ? 1 : 0
    else
        d = n * (n-1) / 2
        ([min, s-100*(n-1)+(n-1)*(n-2)/2].max..[100, (s-d)/n].min)
            .map{|x| f(n-1, s-x, x+1)}
            .inject(0, :+)
    end
end

module Memoizable
    def memoize(name)
        original = "__original_#{name}__"
        ([Class, Module].include?(self.class) ? self : self.class).class_eval {
            alias_method(original, name)
            private(original)
            cache = {}
            define_method(name){|*args|
                cache[args] ||= send(original, *args)
            }
        }
    end
end

include Memoizable
memoize :f

loop {
    n, s = gets.split.map(&:to_i)
    break if n == 0
    p f(n, s, 0)
}

Measured memory_bytes: 13300
#include<stdio.h>

int main(){
    int h,w,l,i,j,min;
    for (;scanf("%d %d",&h,&w),(h||w);) {
        l=h*h+w*w;
        int a=0,b=0,min=100000;
        for(i=1;i<150;i++)for(j=i+1;j<150;j++){
            if(l>i*i+j*j)continue;
           // printf("%d %d\n",l,i*i+j*j);
            
            if(l==i*i+j*j&&!(i==h&&j==w)&&i>h){
                //printf("%d",i-h);
                min=l;
                a=i;b=j;goto ok;
            }
            
            if(l!=i*i+j*j&&i*i+j*j<min&&!(i==h&&j==w)){
                min=i*i+j*j;
                a=i;b=j;
            }
        }
    ok:;
        printf("%d %d\n",a,b);
    }
    
    return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N;
int A[100010];
map<int, int> mp;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    mp[A[i]]++;
  }
  vector<int> v;
  for (auto p : mp) {
    if (p.second < 2) continue;
    v.emplace_back(p.first);
    p.second -= 2;
    if (p.second < 2) continue;
    v.emplace_back(p.first);
  }
  sort(v.rbegin(), v.rend());
  if (v.size() < 2) cout << 0 << endl;
  else cout << (ll)v[0] * v[1] << endl;

  return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, c = 0; cin >> n;
	ll d; cin >> d;
	for(int i = 0; i < n; i++)
	{
		ll x, y; cin >> x >> y;
		if(x * x + y * y <= d * d) c++;
	}
	cout << c;

	return 0;
}

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

#define INF 1e9
using namespace std;

int main() {

    int D, N; cin >> D >> N;

    if (D == 0) {
        if (N == 100) {
            puts("101");
        } else {
            cout << N << endl;
        }
    }

    if (D == 1) {
        if (N == 100) {
            puts("10100");
        } else {
            cout << N * 100 << endl;
        }
    }

    if (D == 2) {
        if (N == 100) {
            puts("1010000");
        } else {
            cout << N * 10000 << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
using namespace std;
    
int main()
{
    long long int a,b,n;
    cin >> a >> b >> n;
    
    long long int x = 0;
    long long int tmpx = n%b;
    if(n <= b-1){
        x = n;
    }else{
        x = (n/b) * b - 1;
    }
    
    long long int tmp1,tmp2;
    long long int ax = a*x;
    tmp1 = floor(ax/b);
    tmp2 = a*floor(x/b);
    cout << tmp1 - tmp2 << endl;
}


Measured memory_bytes: 3636
import math
x = []
sum = 0
max = 9
memo_m1 = 0
for i in range(5):
    x.append(int(input()))
for i in range(5):
    temp = x[i] % 10
    if temp != 0 and temp < max:
        max = temp
        memo_m1 = i
        
for i in range(5):
    if i == memo_m1 :
        continue
    sum += math.ceil(x[i]/10)*10

print(sum + x[memo_m1])

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  bool approved = true;
  for (int a : A) {
    if (a % 2 == 0 && (a % 3 != 0 && a % 5 != 0)) {
      approved = false;
    }
  }

  if (approved) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ld a, b, x;
    cin >> a >> b >> x;
    ld cur_h = x / (a * a);
    ld delta = b - cur_h;
    if (delta == cur_h)
        cout << "45.0000000000\n";
    else if (delta > cur_h) {
        ld c = 2 * x / (a * b);
        ld x = sqrt(b*b*c*c/(b*b+c*c));
        ld theta = asin(sqrt(b*b-x*x)/b);
        cout << fixed << setprecision(10) << 180*theta/acos(-1) << '\n';
    }
    else {
        ld x = sqrt(a*a/((4*(b-cur_h)*(b-cur_h)+a*a)/((2 * cur_h-b)*(2 * cur_h-b))));
        ld theta = acos(x / (2*cur_h-b));
        cout << fixed << setprecision(10) << 180*theta/acos(-1) << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	cout<<fixed<<setprecision(6)<<(w*h)/2<<" ";
	if (x==w/2 && y==h/2) cout<<1;
	else cout<<0;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};
const int mod = 1000000007;

void Main(){
  string s;
  cin>>s;
  list<char> a;
  rep(i,s.length()){
    a.push_back(s[i]);
  } 
  int q;
  cin>>q;
  int fb = 1;
  rep(i,q){
    int t;
    cin>>t;
    if(t==1){
      fb*=-1;
    }else{
      int f;char c;
      cin>>f>>c;
      if(f==1){
        if(fb==1){
          a.push_front(c);
        }else{
          a.push_back(c);
        }
      }else{
        if(fb==1){
          a.push_back(c);
        }else{
          a.push_front(c);
        }
      }
    } 
  }
  if(fb==1){
    for(auto c:a){
      cout<<c;
    }
  }else{
    a.reverse();    
    for(auto c:a){
      cout<<c;
    }
  }
  cout<<endl;
} signed main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 10064
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


int main(){
    set<int> S;
    int q; cin >> q;
    REP(i, q){
        int op, x; cin >> op >> x;
        switch(op){
            case 0:
                S.insert(x);
                cout << S.size() << endl;
                break;
            case 1:
                cout << noboolalpha << (S.find(x) != S.end()) << "\n";
                break;
            case 2:
                S.erase(x);
                break;
        }
    }
    return 0;
}



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

int main() {
  int A;
  int B;
  int C;
  int D;
  
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> D;
  
  if((A+B) == (C+D)){
  cout << "Balanced" << endl;
  }else if((A+B) < (C+D)){
    cout << "Right" << endl;
  }else{
    cout << "Left" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repp(i, n) for(int i = 1; i <= (int)(n); i++)
#define co(x) cout<<x<<endl
typedef long long int lint;

int main(){
  int N;
  cin >> N;
  vector<int> A(N-1),X(N,0);

  rep(i,N-1){
    cin >> A.at(i);
    X.at(A.at(i)-1)++;
  }

  rep(i,N){co(X.at(i));}

}     

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

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

    if (s[0] == 'S')
        cout << "Cloudy" << endl;
    else if (s[0] == 'C')
        cout << "Rainy" << endl;
    else
        cout << "Sunny" << endl;
    return 0;
}


Measured memory_bytes: 256
brave = int(input())
a_monster = list(map(int,input().split()))
b_monster = list(map(int,input().split()))
rem_power = 0
count = 0

for i in range(0, brave):
    rem_monster = a_monster[i] - rem_power
    if rem_monster <= 0:
        count += a_monster[i]
        rem_power = b_monster[i]
        continue
    rem_power += b_monster[i]
    if rem_power > a_monster[i]:
        count += a_monster[i]
        rem_power -= a_monster[i]
    else:
        count += rem_power
        rem_power = 0

last = a_monster[-1] - rem_power

if last > 0:
    print(count + rem_power)
else:
    print(count + a_monster[-1])


Measured memory_bytes: 18624
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<int> P(N);
    for (int& x : P) cin >> x, --x;
    int res = 0;
    int mn = N + 1;
    for (int x : P) {
      if (x <= mn) {
        ++res;
      }
      chmin(mn, x);
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
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);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  ll N,A,B;
  string S;
  cin >> N >>A >> B  >> S;
  ll K=0,T=0;
  rep(i,S.size()){
    if(S[i]=='a'){
      if(K<A+B){
        cYes;
        K++;
      }
      else{
        cNo;
      }
    }
    else if(S[i]=='b'){
      if(K<A+B && T<B){
        cYes;
        T++;
        K++;
      }
      else{
        cNo;
      }
    }
    else{
      cNo;
    }
  }
}


Measured memory_bytes: 896
#include<stdio.h>
#include <iostream>
int main()
{
    int Anum,FirstNo;
    std::cin >>
        Anum;
    //桁数チェック
    FirstNo = Anum%10;

switch(FirstNo){
    case 3:
        puts("bon");
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        puts("pon");
        break;
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        puts("hon");
        break;
}
return 0;
}


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

const ll MOD = 1e9 + 7;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i, m) cin >> a[i];

  vector<int> d(n+2, 0);
  rep(i, m) d[a[i]] = 1;
  d[n+1] = 1;

  vector<int> dp(n+1, 0);
  dp[0] = 1;

  rep(i, n) {
    if (d[i+1] == 0) dp[i+1] = (dp[i+1] + dp[i]) % MOD;
    if (d[i+2] == 0) dp[i+2] = (dp[i+2] + dp[i]) % MOD;
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 4316
#include <iostream>

using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    int ret=0;
    for (int i=A;i<=B;i++){
	int x=i;
	int d[5];
	for (int j=0;j<5;j++){
	    d[j]=x%10;
	    x/=10;
	}
	if ((d[0] == d[4]) && (d[1] == d[3])) ret++;
    }

    cout << ret << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

ll power_mod(ll x, ll y, ll m){
  ll res = 1;
  if(y>0){
    res = power_mod(x,y/2,m);
    if(y%2==0) res = (res*res)%m;
    else res = (((res*res)%m)*x)%m;
  }
  return res;
}

ll trans(char c){
  return (ll)(c) + 1;
}

// len文字のハッシュ値を返す
vvll rolling_hash1D(string str, ll len){
  ll n = str.size();
  if(n < len) return {}; // 空の配列を返す

  vll mod = {1000000000 + 7, 1000000000 + 9, 1000000000 + 21};
  ll base = 257;

  ll mods = mod.size();

  vvll res(n,vll(mods));

  for(ll m=0;m<mods;m++){
    ll k = power_mod(base,len,mod[m]);

    ll hog = 0;
    for(ll i=0;i<len;i++) hog = ( hog * base % mod[m] + trans(str[i])) % mod[m];

    for(ll i=0;i+len<=n;i++){
      res[i][m] = hog;
      if(i+len < n) hog = (hog * base % mod[m] + trans(str[i+len]) - trans(str[i]) * k + mod[m] * mod[m]) % mod[m];
    }
    
  }

  return res;
}
int main(){
  string s, t;
  cin >> s >> t;

  ll m = t.size();
  vvll hs = rolling_hash1D(s,m);
  vvll ht = rolling_hash1D(t,m);

  if(hs.size() == 0 || ht.size() == 0) return 0;

  for(ll i=0;i<=s.size()-m;i++){
    if(hs[i] == ht[0]) cout << i <<endl;
  }
  return 0;
}


Measured memory_bytes: 59660
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
n,m,l = ma()
INF=10**15
cost = [[INF]*n for i in range(n)]
for i in range(m):
    a,b,c = ma();a-=1;b-=1
    cost[a][b]=c
    cost[b][a]=c

def wf(cost):
    l = len(cost[0])
    for k in range(l):
        for i in range(l):
            for j in range(l):
                cost[i][j] =  min(cost[i][j],cost[i][k] + cost[k][j])
wf(cost)
rest = [[INF]*n for i in range(n)]
for i in range(n):
    for j in range(n):
        if cost[i][j]<=l:
            rest[i][j]=1
wf(rest)
q = ni()
for i in range(q):
    s,t = ma();s-=1;t-=1
    print(rest[s][t] -1) if rest[s][t] !=INF else print(-1)


Measured memory_bytes: 73748
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<62;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

int main(){

    int D, T, S; cin >> D >> T >> S;

    int time = (D+(S-1))/S;

    if (time > T){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }

}

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


int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    for( int i = 0; i < M; ++i ) cin >> a[i] >> b[i];


    vector<int> firstBoat, secondBoat;
    for( int i = 0; i < M; ++i ){
        if( a[i] == 1 ) firstBoat.push_back( b[i] );
        else if( b[i] == N ) secondBoat.push_back( a[i] );
    }

    sort( secondBoat.begin(), secondBoat.end() );
    bool ans = false;
    for( auto f: firstBoat ){
        ans = binary_search( secondBoat.begin(), secondBoat.end(), f );
        if( ans ) break;
    }
    if( ans ) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;

    return 0;
}

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

const int N = 100000;

int p[N], parent[N], mark[N];
std::vector<int> buckets[N];

int find(int u)
{
    if (parent[u] != u) {
        parent[u] = find(parent[u]);
    }
    return parent[u];
}

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++ i) {
        scanf("%d", p + i);
        p[i] --;
        parent[i] = i;
    }
    for (int i = 0; i < m; ++ i) {
        int x, y;
        scanf("%d%d", &x, &y);
        x --;
        y --;
        if (find(x) != find(y)) {
            parent[find(x)] = find(y);
        }
    }
    for (int i = 0; i < n; ++ i) {
        buckets[find(i)].push_back(i);
    }
    int idx = 0;
    int result = 0;
    for (auto&& b : buckets) {
        idx ++;
        for (int i : b) {
            mark[i] = idx;
        }
        for (int i : b) {
            result += mark[p[i]] == idx;
        }
    }
    printf("%d\n", result);
}

Measured memory_bytes: 6912
import java.util.*;
import java.io.*;

class Cake implements Comparable<Cake>{
        long but,yum,pop;
        
        public Cake(long b, long y, long p){
        	but = b;
        	yum = y;
        	pop = p;
        }
        
        public long value(){
        	return but + yum + pop;
        }
        
        public int compareTo(Cake another){
            long v1 = this.value();
            long v2 = another.value();
            if(v1==v2) return 0;
            if(v1>v2) return 1;
            return -1;
        }
}

public class Main {
    
    public static long chooseCake(Cake[] cakes, int eat){
    	Arrays.sort(cakes);
    	long ans = 0;
    	for(int i=0;i<eat;i++){
    	    ans += cakes[(cakes.length)-1-i].value();
    	}
    	return ans;
    }
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        Cake[] ppp = new Cake[N];
        Cake[] ppn = new Cake[N];
        Cake[] pnp = new Cake[N];
        Cake[] pnn = new Cake[N];
        Cake[] npp = new Cake[N];
        Cake[] npn = new Cake[N];
        Cake[] nnp = new Cake[N];
        Cake[] nnn = new Cake[N];
        for(int n=0;n<N;n++){
        	long b = sc.nextLong();
        	long y = sc.nextLong();
        	long p = sc.nextLong();
        	ppp[n] = new Cake( b, y,-p);
        	ppn[n] = new Cake( b, y, p);
        	pnp[n] = new Cake( b,-y,-p);
        	pnn[n] = new Cake( b,-y, p);
        	npp[n] = new Cake(-b, y,-p);
        	npn[n] = new Cake(-b, y, p);
        	nnp[n] = new Cake(-b,-y,-p);
        	nnn[n] = new Cake(-b,-y, p);
        }
        

        long ans = chooseCake(ppp,M);
        if (chooseCake(ppn,M) > ans) ans = chooseCake(ppn,M);
        if (chooseCake(pnp,M) > ans) ans = chooseCake(pnp,M);
        if (chooseCake(pnn,M) > ans) ans = chooseCake(pnn,M);
        if (chooseCake(npp,M) > ans) ans = chooseCake(npp,M);
        if (chooseCake(npn,M) > ans) ans = chooseCake(npn,M);
        if (chooseCake(nnp,M) > ans) ans = chooseCake(nnp,M);
        if (chooseCake(nnn,M) > ans) ans = chooseCake(nnn,M);
        
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 26240