akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cctype>

#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

int main()
{
    constexpr int N = 'z' - 'a' + 1;

    bool table[N];

    fill(table, table + N, true);

    while(true)
    {
        char c = getchar();
        if( isspace(c) || c == EOF  ) break;

        table[c - 'a'] = false;
    }

    REP(i, N)
    {
        if( table[i] )
        {
            cout << (char)('a' + i) << endl;
            return 0;
        }
    }

    cout << "None" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
   string s;
   cin>>s;
   if (s=="AAA"||s=="BBB")
   {cout<<"No"<<endl;
   	/* code */
   }
   else{cout<<"Yes"<<endl;}
}

Measured memory_bytes: 256
//
//  abc057B.cpp
//  
//
//  Created by 楊承昊 on 2017/3/26.
//
//

#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int N,M;
    cin>>N>>M;
    long long int sx[50],sy[50],x[50],y[50];
    for(int i=0;i<N;i++)
    {
        cin>>sx[i]>>sy[i];
    }
    for(int i=0;i<M;i++)
    {
        cin>>x[i]>>y[i];
    }
    for(int i=0;i<N;i++)
    {
        long long int ind=0,minn=999999999999999;
        for(int j=0;j<M;j++)
        {
            long long int dis=abs(x[j]-sx[i])+abs(y[j]-sy[i]);
            if(minn>dis)
            {
                minn=dis;
                ind=j;
            }
        }
        cout<<ind+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> C(H);
    REP(i, 0, H){
        cin >> C[i];
    }
    int upper_cnt = 0;
    REP(i, 0, H){
        REP(j, 0, W){
            if (C[i][j] == '#') ++upper_cnt;
        }
    }

    if (upper_cnt < K){
        cout << 0 << endl;
        return 0;
    }

    int case_cnt = 0;
    REP(Hbit, 0, (1 << H)){
        REP(Wbit, 0, (1 << W)){
            int black_cnt = 0;
            REP(i, 0, H){
                if (!(Hbit & (1 << i))){
                    REP(j, 0, W){
                        if (!(Wbit & (1 << j))){
                            if (C[i][j] == '#')
                                ++black_cnt;
                        }
                    }
                }
            }
            
            if (black_cnt == K){
                ++case_cnt;
            }
        }
    }
    cout << case_cnt << endl;
    return 0;
}


Measured memory_bytes: 3620
# coding: utf-8

from collections import deque


s = input().strip()
answer = deque()

for c in s:
    if c == '0':
        answer.append('0')
    elif c == '1':
        answer.append('1')
    elif c == 'B':
        try:
            answer.pop()
        except IndexError:
            answer = deque()

for c in answer:
    print(c, end='')
print('')

Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  bitset<100001>l;cin>>l;
  ll sz=0;
  rrep(k,100001){
    if(l[k]==0)continue;
    else {
      sz=k+1;
      break;
    }
  }
  ll mod=1e9+7;
  vector<ll> dp(2);
  dp[0]=1;
  rrep(k,sz){
    auto tdp=dp;
    tdp[1]=dp[1]*3;
    if(l[k]){
      tdp[1]+=dp[0];
      tdp[0]=dp[0]*2;
    }
    tdp[0]%=mod;
    tdp[1]%=mod;
    dp=tdp;
  //  cout<<dp[0]<<" "<<dp[1]<<endl;
  }
  cout<<(dp[0]+dp[1])%mod<<endl;

  return 0;

}


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

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

    int ans = 0;
    for (int i = 105; i <= N; i += 2)
    {
        int count = 0;
        for (int j = 1; j <= i; ++j)
        {
            if (i % j == 0)
                count++;
        }
        if (count == 8)
            ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 998244353
#define MAX 100009
#define endl '\n'
#define mp make_pair
#define INF 1000000000
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main() {
	fast
	ll a,b,c,d,n,k,p;
	ll t;
	ll r;
	cin>>r;
	ld x=22.0/7.0;
	ld y=2*x*r;
	cout<<fixed<<setprecision(8)<<y;
}
//cout<<"Case #"<<x<<": "<<ans<<endl;
//x++;

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

struct edge{
    ll u, v, w;
};

struct xzkaknazvat{
    ll cost, black;
};

bool operator < (edge a, edge b){
    return a.w < b.w;
}

ll n,m;
vector<ll> a;
vector<edge> g;
vector<ll> p;
vector<ll> sz;
vector<xzkaknazvat> d;

ll get_sqrt(ll v){
    if(p[v] == v){
        return v;
    }
    ll x = get_sqrt(p[v]);
    p[v] = x;
    return x;
}


bool check(int u, int v){
    return get_sqrt(u) == get_sqrt(v);
}

void unio(int u, int v, int typreb){
    if(sz[v] > sz[u]){
        swap(sz[v],sz[u]);
    }
    if(sz[v] == sz[u]){
        sz[u]++;
    }
    d[u].cost += d[v].cost;
    d[u].black += d[v].black;
    d[u].black*=typreb;
    d[u].black+=typreb;
    p[v] = u;
}


main(){
    cin >> n >> m;

    p.resize(n+1);
    for(int i=0;i<=n;++i){
        p[i] = i;
    }
    sz.assign(n+1, 1);
    a.resize(n+1);
    for(int i=1;i<=n;++i){
        cin >> a[i];
    }

    d.resize(n+1);
    for(int i=1;i<=n;++i){
        d[i] = {a[i], 0};
    }

    g.resize(m);
    ll f1,f2,f3;
    for(int i=0;i<m;++i){
        cin >> f1 >> f2 >> f3;
        g[i] = {f1,f2,f3};
    }
    sort(g.begin(),g.end());


    for(int i=0;i<m;++i){
        int u = get_sqrt(g[i].u);
        int v = get_sqrt(g[i].v);
        //cout << u << ' ' << v << ' ' << d[u].cost << ' ' << d[v].cost << ' ' << d[u].black << ' ' << d[v].black <<  "\n";
        if(u == v){
            if(d[u].cost >= g[i].w){
                d[u].black = 0;
            }
            else{
                d[u].black++;
            }
            continue;
        }
        if(d[u].cost + d[v].cost >= g[i].w){
            unio(u,v,0);
        }
        else{
            unio(u,v,1);
        }
    }

    cout << d[get_sqrt(1)].black;

}


Measured memory_bytes: 6784
//Twitter@KonoLv1 2020年春卒で現在就職活動中！
 
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
 
int main(void){
    int i,j;            //  ループ文に使用
    int x,y,z;
    int count1,count2,count;   //  カウント用に使用
    double box[10000] = {};
    double box2[10000] = {};
    char s[200001] = {};        //  文字列
    char s2[200001] = {};        //  文字列
    int a,b,c;
    a = b = c = i = 0;
    int mode = 0;
    int max = 0;
    double ans = 0;
    count = count1 = count2 = 0;
    int sum = 0;
    int emp = 0;
    double sum2 = 0;
 
    //  入力処理
    
    scanf("%d",&a);

    for(i = 0; i < a; i++){
        scanf("%lf",&box[i]);
    }
    
    for (i = a - 1; i > 0; i--){
        for (j = i - 1; j >= 0; j--){
            if (box[i] > box[j]){
                emp = box[i];
                box[i] = box[j];
                box[j] = emp;
            }
        }
    }
    

    for (i = a - 1; i > 0; i--){
        box[i - 1] = (box [i - 1] + box[i]) / 2; 
    }
    
/*
    for(i = 0; i < a; i++){
      //  printf("%lf",box[i]);
    }
 */
    printf("%lf",box[0]);

    //  計算処理


    //  出力処理

 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N, C;
    cin >> N >> C;
    VVL d(C+1, VL(C+1));
    rep(i, 1, C+1){
        rep(j, 1, C+1){
            cin >> d[i][j];
        }
    }
    /*
    rep(i, 1, C+1) d[i][i] = 0;
    rep(i, 1, C+1){
        rep(j, 1, C+1){
            rep(k, 1, C+1){
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
    */
    
    VVL c(N+1, VL(N+1));
    VVL cnt(3, VL(C+1,0));
    rep(i, 1, N+1){
        rep(j, 1, N+1){
            cin >> c[i][j];
            cnt[(i+j)%3][c[i][j]]++;
        }
    }

    ll ans = 1e18;
    rep(z, 1, C+1){
        rep(o, 1, C+1){
            if(z == o) continue;
            rep(t, 1, C+1){
                if(z == t || o == t) continue;
                ll tmp = 0;
                rep(cc, 1, C+1){
                    tmp += cnt[0][cc] * d[cc][z] + cnt[1][cc] * d[cc][o] + cnt[2][cc] * d[cc][t];
                }
                ans = min(tmp, ans);
            }
        }
    }

    cout << ans << endl;
    return 0;
}

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

int main(){
  int a = 100,b=10, c,d,e,f,g;
  cin >>c;
  d=c/a;
  e=c%a;
  f=e/b;
  g=e%b;
  cout << d+f+g <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
	int A,B,C;
	char e, f;
	cin >> A>>e>>B>>f>>C;
	if (B <= 4)cout << "Heisei" << endl;
	else cout << "TBD" << endl;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#define N 52
using namespace std;
struct edge{
	int u,v;
}e[N];
int head[N],ver[N*N],nxt[N*N],l;
int head1[N],ver1[N*2],nxt1[N*2],l1;
int t,n,i,j,k,fa[N],fb[N],d[N],d1[N],cnt;
bool vis[N];
int read()
{
	char c=getchar();
	int w=0;
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0'){
		w=w*10+c-'0';
		c=getchar();
	}
	return w;
}
void insert(int x,int y)
{
	l++;
	ver[l]=y;
	nxt[l]=head[x];
	head[x]=l;
}
void insert1(int x,int y)
{
	l1++;
	ver1[l1]=y;
	nxt1[l1]=head1[x];
	head1[x]=l1;
}
void dfsa(int x,int pre)
{
	fa[x]=pre;
	for(int i=head[x];i;i=nxt[i]){
		int y=ver[i];
		if(y!=pre) dfsa(y,x);
	}
}
void dfsb(int x,int pre)
{
	fb[x]=pre;
	vis[x]=vis[pre]&(fa[x]==fb[x]);
	for(int i=head1[x];i;i=nxt1[i]){
		int y=ver1[i];
		if(y!=pre) dfsb(y,x);
	}
}
bool toposort()
{
	queue<int> q;
	for(int i=1;i<=n;i++){
		if(d1[i]==0){
			q.push(i);
		}
	}
	int cnt=0;
	while(!q.empty()){
		int x=q.front();
		q.pop();
		cnt++;
		for(int i=head[x];i;i=nxt[i]){
			int y=ver[i];
			d1[y]--;
			if(d1[y]==0) q.push(y);
		}
	}
	return (cnt==n);
}
bool check1()
{
	for(int i=1;i<=n;i++){
		if(fa[i]!=fb[i]) return 0;
	}
	return 1;
}
int check(int root)
{
	memset(vis,0,sizeof(vis));vis[0]=1;
	for(int i=1;i<n;i++){
		if(e[i].u!=root&&e[i].v!=root) insert(e[i].u,e[i].v),insert(e[i].v,e[i].u);
	}
	dfsa(root,0);dfsb(root,0);
	memset(head,0,sizeof(head));l=0;
	memset(d1,0,sizeof(d1));
	int ans=0;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			if(!vis[fa[i]]) insert(i,fa[i]),d1[fa[i]]++;
			if(!vis[fb[i]]) insert(fb[i],i),d1[i]++;
			ans++;
		}
	}
	if(toposort()) return ans;
	else return 1<<30;
}
int main()
{
	t=read();
	while(t--){
		cnt++;
		int ans=1<<30;
		memset(d,0,sizeof(d));
		memset(head1,0,sizeof(head1));l1=0;
		memset(head,0,sizeof(head));l=0;
		n=read();
		for(i=1;i<n;i++){
			e[i].u=read();e[i].v=read();
			d[e[i].u]++;d[e[i].v]++;
			insert(e[i].u,e[i].v);insert(e[i].v,e[i].u);
		}
		for(i=1;i<n;i++){
			int u=read(),v=read();
			insert1(u,v);insert1(v,u);
		}
		dfsa(1,0);dfsb(1,0);
		if(check1()){
			puts("0");
			continue;
		}
		for(i=1;i<=n;i++){
			if(d[i]==1){
				for(j=1;j<=n;j++){
					if(i==j) continue;
					memset(head,0,sizeof(head));l=0;
					insert(i,j);insert(j,i);
					ans=min(ans,check(i));
				}
			}
		}
		if(ans!=1<<30) printf("%d\n",ans+1);
		else puts("-1");
	}
	return 0;
}


Measured memory_bytes: 3708
#include <iostream>

using namespace std;

int c[3][3];
int a[3];
int b[3];

int main(){
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }
    
    bool judge;
    for(int i = 0; i <= 100; i++){
        a[0] = i;
        for(int j = 0; j <= 100; j++){
            a[1] = j;
            for(int k = 0; k <= 100; k++){
                judge = true;
                a[2] = k;
                b[0] = c[0][0] - a[0];
                b[1] = c[0][1] - a[0];
                b[2] = c[0][2] - a[0];
                
                for(int x = 1; x < 3; x++){
                    for(int y = 0; y < 3; y++){
                        if(a[x] + b[y] != c[x][y]){
                            judge = false;
                            break;
                        }
                    }
                }
                
                if(judge)      break;
            }
            
            if(judge)   break;
        }
        
        if(judge)       break;
    }
    
    if(judge){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm> // sort
#include <utility> // pair
#include <cfloat> // DBL_MAX

typedef long long ll;
using namespace std;

int main(){
  ll X;
  cin >> X;

  ll ans = (X/11) * 2;
  ll tmp = X%11;
  if(tmp == 0){
    ans += 0;
  } else if(tmp <= 6){
    ans += 1;
  } else {
    ans += 2;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}

signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    string s;
    cin>>s;
    int ans =0;
    for(auto x : s)
        ans+=(x-'0');

    ans%=3;

    cout<<(ans ? "No" : "Yes");

    printclock;
    return 0;
}


Measured memory_bytes: 3892
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N, M, A, B, C;
    string s1, s2;
    cin >> s1;
    map<char, int> m;
    rep(i, s1.length()){
        m[s1[i]]++;
    }
    bool flag = true;
    if(m['N'] == 0 && m['S'] != 0) flag = false;
    if(m['N'] != 0 && m['S'] == 0) flag = false;
    if(m['W'] == 0 && m['E'] != 0) flag = false;
    if(m['E'] == 0 && m['W'] != 0) flag = false;
    if(flag == true) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
a,b,c = gets.split(" ").map(&:to_i)
k = gets.to_i
i = 0
while b <= a
		b = b*2
		i += 1
end
while c <= b
	c = c*2
	i += 1
end
if i <= k
	puts 'Yes'
else
	puts'No'
end

Measured memory_bytes: 14372
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> d = divisor(m);
  ll ans = 1;
  for (auto x : d) {
    if (x*n <= m) ans = x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3496
#include<iostream>
#include<string>
int main() {
	int gCount = 0, pCount = 0, winCount = 0,loseCount=0;
	std::string gp;
	std::cin >> gp;
	for (int i = 0; i < gp.size(); ++i) {
		if (gp[i] == 'g') {
			if (pCount + 1 <= gCount) {
				pCount += 1;
				winCount += 1;
			}
			else {
				gCount += 1;
			}
		}
		else {
			if (pCount + 1 <= gCount) {
				pCount += 1;
			}
			else {
				gCount += 1;
				loseCount += 1;
			}
		}
	}
	std::cout << winCount - loseCount << std::endl;
	return 0;
}

Measured memory_bytes: 512
N,K=map(int,input().split())
S=list(map(int,input().split()))
ans=float("inf")
if N==1:
	ans=abs(S[0])
for i in range(N-K+1):
	L=S[i]
	R=S[i+K-1]
	ans=min(abs(L)+abs(R-L),abs(R)+abs(L-R),ans)
print(ans)

Measured memory_bytes: 14392
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <deque>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	bool isEven = true;
	if (n % 2 == 1)
	{
		isEven = false;
	}
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	deque<int> Deq;
	for (int i = 0; i < n; ++i)
	{
		if (i % 2 == 1)
		{
			Deq.push_back(a[i]);
		}
		else
		{
			Deq.push_front(a[i]);
		}
	}
	if (isEven)
	{
		for (int i = n - 1; i >= 1; --i)
		{
			cout << Deq[i] << " ";
		}
		cout << Deq[0] << endl;
	}
	else
	{
		for (int i = 0; i < n - 1; ++i)
		{
			cout << Deq[i] << " ";
		}
		cout << Deq[n - 1] << endl;
	}
}

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

Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	while(true){
		
vector<int> order;
vector<int> store;
	int r=0;
	int d,n,m;
	cin >> d;
	if(d==0)
	break;
	cin >> n >> m;
	store.push_back(0);
	for(int i=1;i<n;i++){
	cin >> r;
	store.push_back(r);
	}
	store.push_back(d);
	for(int i=0;i<m;i++){
	cin >> r;
	order.push_back(r);
	}
	sort(store.begin(),store.end());
	sort(order.begin(),order.end());
	int now=0,sum=0;
	for(int i=0;i<m;i++){
		int p=order[i];
		while(!( p >= store[now] && p <= store[now+1]))
		now++;
		sum+=min(p-store[now],store[now+1]-p);
	}
	
	cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end());
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
string s;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  s[3] = '8';
  cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int T;
  T = 1;
  while (T--) solve();
}

// https://twitter.com/totori_kpr/status/1256941746866368513?s=20
void solve() {
  int n;
  cin >> n;
  vector<int> a(3);
  cin >> a;
  vector<string> s(n);
  cin >> s;
  vector<vector<int> > v(3);
  rep(i, sz(s)) rep(j, 2) v[s[i][j] - 'A'].eb(i);

  string ans;
  rep(i, n) {
    int x = s[i][0] - 'A', y = s[i][1] - 'A';
    if(a[x] > a[y]) swap(x, y);
    // cout << x << " " << y << endl;
    if (a[x] < a[y]) {
      ans += 'A' + x;
      a[x]++;
      a[y]--;
    } else {
      if (a[x] == 0) {
        cout << "No" << endl;
        return;
      }
      int z = (x + 1) ^ (y + 1);
      --z;
      int it = ub(v[z], i);
      // cout << it << endl;
      if (it == sz(v[z])) {
        a[x]++;
        a[y]--;
        ans += 'A' + x;
      } else {
        // 次, x, y 以外が出る
        it = v[z][it];
        if (s[it][0] - 'A' == x || s[it][1] - 'A' == x) {
          a[x]++;
          a[y]--;
          ans += 'A' + x;
        } else { // y
          a[y]++;
          a[x]--;
          ans += 'A' + y;
        }
      }
    }
    // cout << a << endl;
  }
  cout << "Yes" << endl;
  rep(i, n) cout << ans[i] << endl;
}


Measured memory_bytes: 7756
#include<cstdio>
using namespace std;
typedef long long ll;
const int N=100100;
int i,j,k,n,m,ch,ff,x,y,En;
int h[N],sg[N];
struct edge { int s,n;} E[N<<1];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void W(int x) {
	if (x<0) putchar('-'),x=-x;
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
void R(ll &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void W(ll x) {
	if (x<0) putchar('-'),x=-x;
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
void E_add(int x,int y) {
	E[++En].s=y;E[En].n=h[x];h[x]=En;
	E[++En].s=x;E[En].n=h[y];h[y]=En;
}
void dfs(int x,int F) {
	for (int k=h[x];k;k=E[k].n) if (E[k].s!=F) {
		dfs(E[k].s,x);
		sg[x]^=sg[E[k].s]+1;
	}
}
int main() {
	R(n);
	for (i=1;i<n;i++) {
		R(x);R(y);
		E_add(x,y);
	}
	dfs(1,0);
	if (sg[1]) puts("Alice");
	else puts("Bob");
}

Measured memory_bytes: 7168
#include <iostream>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

int const nmax = 200000;
ll const inf = 1000000000000000000;

ll v[5 + nmax], sum[5 + nmax], sum2[5 + nmax];

ll solve(int n, int k) {
  ll result = 0;
  int start = n, coef = 1;
  while(1 <= start) {
    int nxt = std::max(0, start - k);
    ll coef2 = (1LL * (coef + 1) * (coef + 1) - 1LL * coef * coef);
    if(coef == 1)
      coef2 = 5;
    result += (sum[start] - sum[nxt]) * coef2;
    if(inf < result)
      return inf;
    start = nxt;
    coef++;
  }
  return result;
}

int main() {
  int n, x;
  std::cin >> n >> x;
  for(int i = 1;i <= n; i++) 
    std::cin >> v[i];
  for(int i = 1;i <= n; i++)
    sum[i] = sum[i - 1] + v[i];
  sum2[1] = v[1];
  for(int i = 2;i <= n; i++) 
    sum2[i] = sum2[i - 2] + v[i];
  ll result = inf;
  for(int i = 1;i <= n; i++)
    result = std::min(result, solve(n, i) + 1LL * x * (n + i));
  std::cout << result;
}


Measured memory_bytes: 8280
#include <stdio.h>
int main(void){
    int i, n, x, y, a, b, k;
    int p[10000], ans;
    int f = 0;
    scanf("%d%d", &n,&k);
    for (i = 0; i < n; i++)
    {
        scanf("%d", p + i);
    }
    while (f == 0)
    {
        f = 1;
        for (i = 0; i < n - 1; i++)
        {
            if (p[i] > p[i + 1])
            {
                f = 0;
                p[i] ^= p[i + 1];
                p[i + 1] ^= p[i];
                p[i] ^= p[i + 1];
            }
        }
    }
    ans = 0;
    for (i = 0; i < k; i++)
    {
        ans += p[i];
    }
    printf("%d", ans);
    return (0);
}


Measured memory_bytes: 1716
#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))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>x;
	if(x==3 || x==5 || x==7) cout<<"YES"<<endl;
	else cout<<"NO"<<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: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

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

    if (a != 0) {
        cout << max(0ll, b / x - (a - 1) / x) << endl;
    } else {
        cout << b / x + 1 << endl;
    }
}


Measured memory_bytes: 256
/*
    quid-pro-quo: LOGIC for AC
    written by: codercell07
    LANG: C++ 11
    Problem: random
*/
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL)
#define testcases freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
#define ui unsigned int
#define ll long long
#define pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define sz(x) (int)x.size()
#define pq priority_queue /*maxim at top(max-heap)*/
#define pqmax priority_queue<int, vector<int>, greater<int>> /*minim at top(min-heap)*/
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define asc(x) sort(all(x))
#define desc(x) sort(all(x), greater<int>())
#define time_el (double)time/CLOCKS_PER_SEC
using namespace std;
const int MAX=2e6; //dummy, make sure change as per constraints
const ll M=1e9+7, inf=1e18;
const char nl='\n';
 
ll apbmc(ll a, ll b, ll c){ a%=c; ll res=1; while(b){ if(b&1) res=res*a%c; a=a*a%c; b>>=1; } return res;}
ll apb(ll x, ll y){ ll temp; if(y==0) return 1;  temp=apb(x, y/2); if(y%2==0) return temp*temp;  else return temp*temp*x;}
 

void dfs(vi &dist, int i, vvi &adj){
    if(dist[i]!=-1) return;
    dist[i]=0;
    for(int u: adj[i]){
        dfs(dist, u, adj);
        dist[i]=max(dist[i], dist[u]+1);
    }
}

void solve(){   
    //clock_t time;
    int n, m; cin>>n>>m;
    vvi adj(n, vi());
    for(int i=0; i<m; i++){
        int x, y; cin>>x>>y;
        --x, --y;
        adj[x].pb(y);
    }
    vi dist(n, -1);
    for(int i=0; i<n; i++){
        dfs(dist, i, adj);
    }
    cout<<*max_element(all(dist));
}
int main(){
    fastio;
    // #ifndef ONLINE_JUDGE
    //     testcases;
    // #endif // !DEBUG
    cout<<fixed<<setprecision(10);
    
    //int t; cin>>t; while(t--) solve();    
    solve();

    return 0;
}
//points to check:
//  * check for constraints, mainly array!
//  * EDGE CASES
//  * check for integer overflow, use long long!
//  * learn, do, solve, share something, NOW!

Measured memory_bytes: 11896
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
public class Main {

	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		while (read())
			solve();
	}
	
	static int n;
	static int[] s;
	static boolean read() {
		
		n = sc.nextInt();
		if (n == 0) return false;
		
		s = new int[n];
		for (int i = 0; i < n; i++)
			s[i] = sc.nextInt();
		
		return true;
	}

	static void solve() {
		sort(s);
		int res = 0;

		for (int i = 1; i < n - 1; i++) {
			//System.out.println(s[i]);
			res += s[i];
		}
		
		System.out.println(res / (n - 2));
	}	
}

Measured memory_bytes: 12000
/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1102

??????
?¨???????????????°????????????????????????????????????????????¨??????
?¨????????????§??????10000????¶??????????overflow??¨??¨??????

?§£???
?§?????§£???
pair???first????????°???second????????°?????????????????????

??¨??????
???????????±??????????????§is_over????????????????????????
overflow????????????????????´???????°?????????????????¶?????????????WA?????????
?????°??¨???????¬??????¨???????°????????????????????????¨?????????10+-10i???
??????i??¨?????§????????????1i
 */
#include <bits/stdc++.h>
  
using namespace std;
  
typedef string::const_iterator State;
typedef pair<int, int> Pii; //first:?????°???second:?????°
  
#define fr first
#define sc second

bool is_over = false;
  
struct Parser {
  Pii expression(State &idx) {
    Pii ret = term(idx);
    while ( 1 ) {
      if ( *idx == '+' ) {
	idx++;
	Pii tmp = term(idx);
	ret.fr = ret.fr + tmp.fr;
	ret.sc = ret.sc + tmp.sc;
      } else if ( *idx == '-' ) {
	idx++;
	Pii tmp = term(idx);
	ret.fr = ret.fr - tmp.fr;
	ret.sc = ret.sc - tmp.sc;
      } else {
	break;
      }
      if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    }
    return ret;
  }
    
  Pii term(State &idx) {
    Pii ret = factor(idx);
    while ( 1 ) {
      if ( *idx == '*' ) {
	idx++;
	Pii tmp = factor(idx), tmp2 = ret;
	ret.fr = tmp2.fr * tmp.fr - tmp2.sc * tmp.sc;
	ret.sc = tmp2.fr * tmp.sc + tmp2.sc * tmp.fr;
      } else {
	break;
      }
      if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    }
    return ret;
  }
  
  Pii factor(State &idx) {
    Pii ret;
    if ( *idx == '(' ) {
      idx++;
      ret = expression(idx);
      idx++;
    } else {
      ret = number(idx);
    }
    return ret;
  }
  
  Pii number(State &idx) {
    int tmp = 0;
    while ( '0' <= *idx && *idx <= '9' ) {
      tmp *= 10;
      tmp += *idx - '0';
      if ( abs(tmp) > 10000 ) is_over = true;
      idx++;
    }
    if ( *idx == 'i' ) {
      idx++;
      return Pii(0, 1); //i???0+1i??¨??????????????????
    }
   
    else return Pii(tmp, 0);
  }
};
  
int main()
{
  string s;
  while ( cin >> s ) {
    is_over = false;
    Parser ps;
    string tmp = s.substr(0, s.size() - 1);
    State idx = s.begin();
  
    Pii ret = ps.expression(idx);
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    if ( is_over ) cout << "overflow" << endl;
    else if ( ret.fr == 0 && ret.sc == 0 ) cout << 0 << endl;
    else if ( ret.fr == 0 ) printf("%di\n", ret.sc);
    else if ( ret.sc == 0 ) printf("%d\n", ret.fr);
    else printf("%d%+di\n", ret.fr, ret.sc); //?????°??¨????¬????????°?????????????
  }
  
  return 0;
}

Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

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

	rep(i, 0, n)
	{
		rep(j, 0, m)
		{
			if (i * (m - j) + j * (n - i) == k)
			{
				cout << "Yes" << en;
				return 0;
			}
		}
	}
	cout << "No" << en;
	return 0;


	return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld double
#define mp make_pair
#define vl vector<ll> 
#define ll long long int
#define pl pair<ll, ll>
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
ll fact[(ll)(1e6+100)];
ll a, b, n;
ll power(ll a, ll b)
{
    if(b==0)
    return 1%MOD;
    if(b%2==1)
    return a*(power(a, b-1))%MOD;
    ll pow2=power(a, b/2);
    return pow2*pow2%MOD;
}
void solve()
{
    ll n;
    cin>>n;
    vl a(n), b(n), c(n);
    forr(i, n)
    cin>>a[i]>>b[i]>>c[i];
    vector<vl> dp(n, vl(3, 0));
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];          
    for(ll i=1; i<n; i++)
    {
        dp[i][0]=max(dp[i-1][1], dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0], dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][1], dp[i-1][0])+c[i];
    }
    cout<<max({dp[n-1][0], dp[n-1][1], dp[n-1][2]});
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 8064
#include <iostream>

using namespace std;

int main(void){

  double l[10];
  double v1,v2;
  char ten;

  while( cin >> l[0] ){

    for( int i = 1 ; i < 10 ; i++ ){
      cin >> ten >> l[i];
    }
    cin >> ten >> v1 >> ten >> v2;

    double way = 0;
    for( int i = 0 ; i < 10 ; i++ ){
      way += l[i];
    } 

    way = way * ( v1 / ( v1 + v2 ) );

    double way2 = 0;
    int ans;
    for( int i = 0 ; i < 10 ; i++ ){
      way2 += l[i];
      if( way <= way2 ){
	ans = i + 1;
	break;
      }
    }
    cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 1224
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64_t n, sum;
  cin >> n;
  vector<int> a(n);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    while (a[i] % 2 == 0) { a[i] /= 2; sum++; }
  }
  cout << sum << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
// file name: 求两个集合的并集
// Written by: by_sknight
// Date: 2019/6/12

#include <bits/stdc++.h>
using namespace std;

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

	set<int> A, B, result;
	set<int>::iterator it;
	int n, m, x;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x;
		A.insert(x);
	}

	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> x;
		B.insert(x);
	}

	for (it = A.begin(); it != A.end(); it++) {
		result.insert(*it);
	}
	for (it = B.begin(); it != B.end(); it++) {
		result.insert(*it);
	}

	for (it = result.begin(); it != result.end(); it++) {
		cout << *it << endl;
	}
	
	return 0;
}


Measured memory_bytes: 40660
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Main{
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine().replaceAll("\\s", ""));
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}                                              
		return ans;
	} 
	static long mod=1000000007;
	static long power(long x,long y) 
    { 
        long res = 1; 
        x = x % mod; 
        while (y > 0) { 
            if (y % 2 == 1) 
                res = (res * x) % mod; 
            y = y >> 1;
            x = (x * x) % mod; 
        } 
        return res%mod; 
    } 
    static long modInverse(long n) 
    { 
        return power(n, mod-2); 
    } 
    public static void main(String[] args) throws Exception {
        br = new BufferedReader(new InputStreamReader(System.in));
        int n=cin();
        int[]arr=split();
        int ans=0;
        Arrays.sort(arr);
        for(int i=0;i<n;i++)
        {
        	for(int j=i+1;j<n;j++)
        	{
        		for(int k=j+1;k<n;k++)
        		{
        			if(arr[i]!=arr[j] && arr[j]!=arr[k] && arr[i]!=arr[k] && arr[i]+arr[j]>arr[k])
        				ans++;
        		}
        	}
        }
        System.out.println(ans);
    }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
    string s; cin >> s;
    int size = s.size();
    cout << s[0] << (int)size-2 << s[size-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring> 
using namespace std;
int n, m, k;
int cnt[15][1005];
char mp[15][1005];
bool vis[1005];
int cut[20], top;
int ans = 0x7f7f7f7f;
int cal(int x1, int x2, int y1, int y2) {
	return cnt[x2][y2] - cnt[x2][y1 - 1] - cnt[x1 - 1][y2] + cnt[x1 - 1][y1 - 1];
}
void dfs(int pos) {
	cut[++top] = pos;
	if (pos == n) {
		memset(vis, 0, sizeof(vis)); 
		int sx, sy, lst = 0, tmp = 0;
		for (int j = 1; j <= m; j++) {
			for (int i = 1; i <= top; i++) {
				sx = cut[i - 1] + 1;
				sy = lst + 1;
				if (cal(sx, cut[i], sy, j) > k) {
					if (lst == j - 1) {
						top--;
						return;
					} else {
						sy = j;
						if (!vis[j - 1]) {
							tmp++;
							vis[j - 1] = 1;
						}
					}
				}
			}
			if (vis[j - 1]) lst = j - 1;
		}
		ans = min(ans, tmp + top - 1);
		top--;
		return;
	}
	for (int i = pos + 1; i <= n; i++) {
		dfs(i);
	}
	top--;
}
int main() {
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%s", mp[i] + 1); 
		for (int j = 1; j <= m; j++) {
			cnt[i][j] = cnt[i - 1][j] + cnt[i][j - 1] - cnt[i - 1][j - 1] + mp[i][j] - '0';
		}
	}
	for (int i = 1; i <= n; i++) {
		dfs(i);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

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

int ceil(int x, int y)
{
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y)
{
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y)
{
  return x / gcd(x, y) * y;
}

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

  int a, b;
  cin >> a >> b;

  if (abs(a - b) % 2 == 0)
  {
    cout << ((a + b) / 2) << endl;
  }
  else
  {
    cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end());
#define ll long long 
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi <vector<vector<vector<int>>> 
#define vc vector<char> 
#define vvc vector<vector<char>>
#define vvvc vector<vector<vector<char>>> 
#define INF 2000000000

using namespace std;

int main() {
	
	int n;
	bool start = true;
	cin >> n;
	rep(i, 1, n+1) {
		if (i % 3 == 0 ) {
			cout << " " << i;
		}
		else {
			int ii = i;
			while (ii > 0) {
				if (ii % 10 == 3) {
					cout << " " << i;
					break;
				}
				else ii /= 10;
			}
		}
	}

	cout << endl;

	

	


	return 0;
}

Measured memory_bytes: 3084