akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    ll k;
    cin >> k;


    rep(i, 0, s.size() - 1){
        if(s[i] == 'a')continue;
        if(k >= 26 - s[i] + 'a'){
            k -= 26 - s[i] + 'a';
            s[i] = 'a';
        }
    }

    s[s.size() - 1] = (k + s[s.size() - 1] - 'a') % 26 + 'a';
    cout << s << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll h1,m1,h2,m2,k,mini=0;
    cin>>h1>>m1>>h2>>m2>>k;
    if(m1<=m2){
        while(h1!=h2){
            mini+=60;
            h1++;
        }
        mini+=(m2-m1);
    }else{
        mini+=(60-m1);
        h1++;
        while(h1!=h2){
            mini+=60;
            h1++;
        }
        mini+=m2;
    }
    cout<<(mini-k);
    return 0;
}

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

int abc[26];

int main() {
	// your code goes here
	string str;
	cin >> str;
	for(int i=0; i<str.size(); i++){
		if(abc[str[i]-'a']){
			cout << "no" << endl;
			return 0;
		}
		abc[str[i]-'a']++;
	}
	cout << "yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
using ll = long long;
int main(){
  ll n,d;
  cin >> n >> d;
  vector<ll> x(n),y(n);
  for(int i=0;i<n;i++) cin >> x[i] >> y[i];

  int cnt = 0;
  for(int i=0;i<n;i++){
    if(x[i]*x[i]+y[i]*y[i] <= d*d) cnt++;
  }

  cout << cnt << endl;
}

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

Measured memory_bytes: 1012
#include<stdio.h>
int main(void)
{
	int n;
	scanf("%d",&n);
	if(n==1 || n==2 || n==3 || n==5 || n==6 || n==9 || n==10 || n==13 || n==17){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
}

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

using namespace std;

int main()
{
   int k;cin>>k;
   int res=0;
   for(int i=1;i<=k;i++)
   {
       for(int j=1;j<=k;j++)
       {
           for(int l=1;l<=k;l++)
           {
               res+=__gcd(__gcd(i,j),l);
           }
       }
   }
   cout<<res;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds; 
using ll = long long int;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order() - 0 indexing
// order_of_key() - number of elements strictly smaller
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
//---------------------------------------GL HF------------------------------------------------------
// -------------------------------------ManavJ07----------------------------------------------------
bool check(ll C,ll Z){
	ll low=0;
	ll high=C;
	while(low<=high){
		ll mid=(low+high)/2;
		if(mid*mid+mid*Z==C)
			return true;
		if(mid*mid+mid*Z<C)
			low=mid+1;
		else
			high=mid-1;
	}
	return false;
}
ll calculate(int N){
	ll lim=sqrtl(N)+2;
	ll ans=0;
	for(ll x=1;x<=lim;x++){
		for(ll y=1;y<=lim;y++){
			ll c=N-x*x-y*y-x*y;
			if(c<=0)
				break;
			if(check(c,x+y)){
				//cout<<x<<" "<<y<<endl;
				ans++;
			}
		}
	}
	return ans;
}
signed main()
{
	fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
	int t=1;
	//cin>>t;
	while(t--)
	{
		ll N;
		cin>>N;
		for(ll i=1;i<=N;i++){
			cout<<calculate(i)<<endl;
		}
	}
}

Measured memory_bytes: 3688
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;

int main()
{
	int n, a[3];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 3; j++)cin >> a[j];
		sort(a, a + 3);
		if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2])cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
char s[100010][11];
map<string, int> mp;
int mem[100010][4][4][4], mem1[100010][4][4][4], n;
int dp(int x, int a, int b, int c){
	if(a<0 || b<0 || c<0){
		return 0;
	}
  if(a>3)a=3;if(b>3)b=3;if(c>3)c=3;
	if(x==n){
		return 1;
	}
	if(mem[x][a][b][c]!=-1){
		return mem[x][a][b][c];
	}
	int res=0, sm[333];
	sm['A']=a;
	sm['B']=b;
	sm['C']=c;
	sm[s[x][0]]++;
	sm[s[x][1]]--;
	res|=dp(x+1, sm['A'], sm['B'], sm['C']);
	if(res){
		mem1[x][a][b][c]=0;
		return res;
	}
	sm['A']=a;
	sm['B']=b;
	sm['C']=c;
	sm[s[x][0]]--;
	sm[s[x][1]]++;
	res|=dp(x+1, sm['A'], sm['B'], sm['C']);
	if(res){
		mem1[x][a][b][c]=1;
		return res;
	}
	mem[x][a][b][c]=res;
	return res;
}
int sm[333];
int main(){
    int a, b, c;
    while(cin>>n>>a>>b>>c){
        ll ans=0;
        for(int i=0; i<n; ++i){
            scanf("%s",s[i]);
        }
        memset(mem, -1, sizeof mem);
        a=min(a, 3);
        b=min(b, 3);
        c=min(c, 3);
        ans=dp(0, a, b, c);
        if(ans){
        	cout<<"Yes"<<endl;
			sm['A']=a;
			sm['B']=b;
			sm['C']=c;
        	for(int x=0; x<n; ++x){
              sm['A']=min(sm['A'], 3);
              sm['B']=min(sm['B'], 3);
              sm['C']=min(sm['C'], 3);
	        	if(mem1[x][sm['A']][sm['B']][sm['C']]==0){
	        		printf("%c\n",s[x][0]);
	        		++sm[s[x][0]];
	        		--sm[s[x][1]];
	        	}
	        	else{
	        		printf("%c\n",s[x][1]);
	        		--sm[s[x][0]];
	        		++sm[s[x][1]];
	        	}
        	}
        }
        else{
        	cout<<"No"<<endl;
        }
    }
  return 0;
}




Measured memory_bytes: 193988
/*
    Ankit Singhal
 */
#define ll long long int
#include <bits/stdc++.h>
//#include <fstream>
using namespace std;
 
#define         ff               first
#define         ss               second
#define         mp               make_pair
#define         pb               push_back
#define         pf               push_front
#define         vi               vector<ll>
#define         pii              pair<ll,ll>
#define         qi               queue<ll>
#define         mem(a,b)         memset(a,b,sizeof(a))
#define         print(a)         cout<<a<<'\n'
#define         sorted(arr)      sort(arr.begin(),arr.end())
#define         gcd(a,b)         gcd((a),(b))
#define         lcm(a,b)         ((a)*(b))/gcd((a),(b))
#define         all(v)           v.begin(),v.end()
#define         read(a)          scanf("%d", &a)
#define         f(a,n)           for(ll i=a;i<n;i++)
#define         in2(n,m,arr)     for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cin>>arr[i][j];}
#define         debug(a)         cerr<<a<<" ";
#define         debug1(a)        cerr<<a<<'\n'
 
/*typedef tree<int, null_type, less<int>, rb_tree_tag , tree_order_statistics_node_update> Set;*/


const unsigned ll mod= (ll)1e9 ;
const ll inf = (ll)1e15 + 42;
const ll N = (ll)1e6 + 2;
 
ll power ( ll x , unsigned ll y)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x);
        y = y >> 1;
        x = (x * x);
    }
    return res;
}
 
/*struct node{
    ll x , y , z;
};
vector<set<ll>> tree;
vector<ll> ar , ans;
set<ll> s;
ll get(ll x)
{
    if(x == ar[x])
        return x;
    return ar[x] = get(ar[x]);
}
void merge(ll a ,ll b)
{
    a = get(a);
    b = get(b);
    if(a == b)
        return;
    ar[b] = ar[a];
    //ans[a] += ans[b];
 }

ll sev[1000001];


void seive()
{
    for(ll i = 2 ; i <= 1000000 ; i ++)
    {
        if(!sev[i])
        {
            for(ll j = i ; j <= 1000000 ; j += i)
            {
                if(!sev[j])
                    sev[j] = i;
            }
        }
    }
}
*/

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t ;
    t = 1;
    //cin >> t;
    while(t --)
    {
        ll m1 , m2 , d1 , d2;
        cin >> m1 >> d1;
        cin >> m2 >> d2;
        if(d1 + 1 == d2 && m1 == m2)
            print(0);
        else
            print(1);
        
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
    
}
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n;cin>>n;
	string s,t;cin>>s>>t;
	string ans;
	for(int i=0;s[i];i++)
	{
		ans +=s[i];
		ans +=t[i];
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
/*
      author : nishi5451
      created: 11.08.2020 22:15:30
*/

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


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << max(c-(a-b),0) << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iostream>
#include <list>
#include <functional>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
typedef long long ll;
using namespace std;
const ll MAX = 9223372036854775807;
vector<ll> v;
int main()
{
	ll n;
	scanf("%lld", &n);
	ll sum = 0;
	for (int i = 0; i < n; i++)
	{
		ll t;
		scanf("%lld", &t);
		v.push_back(t - i - 1);
		sum += t - i - 1;
	}
	sort(v.begin(), v.end());

	ll ssss = MAX , sss2;
	ll s2 = 0;
	
	if (v.size() == 1)ssss = 0;
	for (ll i = 1; i < v.size(); i++)
	{
		sum -= v[i - 1];
		s2 += v[i - 1];
		for (ll j = v[i - 1]; j <= v[i]; j++)
		{
			sss2 = sum - j * (n - i) + j * i - s2;
			ssss = min(ssss, sss2);
		}
	}

	printf("%lld\n", ssss);
}

Measured memory_bytes: 2420
import sys
sys.setrecursionlimit(10**6)
N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
    A, B = map(int, input().split())
    G[A-1].append(B-1)
    G[B-1].append(A-1)
M = {}
K = int(input())
for i in range(K):
    V, P = map(int, input().split())
    M[V-1] = P
memo = [0]*N
def dfs(v, p, x, y):
    if v in M:
        x = y = M[v]
    x0 = x; y0 = y
    for w in G[v]:
        if p == w:
            continue
        s, t = dfs(w, v, x-1, y+1)
        x0 = max(x0, s-1); y0 = min(y0, t+1)
    memo[v] = x0, y0
    return x0, y0
def dfs1(v, p, x, y, c):
    if v in M:
        x = y = M[v]
        if c != (M[v] % 2):
            return 0
    x0, y0 = memo[v]
    x = max(x, x0); y = min(y, y0)
    for w in G[v]:
        if p == w:
            continue
        if not dfs1(w, v, x-1, y+1, c^1):
            return 0
    memo[v] = x, y
    return 1

INF = 10**18
f = list(M.keys())[0]
dfs(f, -1, -INF, INF)
ok = dfs1(f, -1, -INF, INF, M[f]%2)
for i in range(N):
    x, y = memo[i]
    if not x <= y:
        ok = 0
if ok:
    print('Yes')
    print(*map(lambda x: x[1], memo), sep='\n')
else:
    print('No')


Measured memory_bytes: 131472
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

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

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


int main(void) {
	int n, l;

	cin >> n >> l;
	vector<string>s(n);
	FOR(i, 0, n - 1) {
		cin >> s[i];
	}

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

	FOR(i, 0, n - 1) {
		cout << s[i];
	}
	cout << endl;


	return 0;
}

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

const int mx = 1<<28;

int cost[101][101];
int tIme[101][101];


int main(){
	int n , m;
	while(cin>>n>>m , n||m){
		for(int i=0;i<m;++i){
			for(int j=0;j<m;++j){
				cost[i][j]=mx;
				tIme[i][j]=mx;
			}
		}
		for(int i=0,a,b,c,t; i<n ; ++i){
			cin >> a >> b >> c >> t;
			a--; b--;
			cost[a][b]=c;
			cost[b][a]=c;
			tIme[a][b]=t;
			tIme[b][a]=t;
		}
		for(int i=0 ; i<m ; ++i ){
			for(int j=0 ; j<m ; ++j){
				for(int k=0 ; k<m ; ++k){
					cost[j][k]=min(cost[j][k] , cost[j][i]+cost[i][k]);
					tIme[j][k]=min(tIme[j][k] , tIme[j][i]+tIme[i][k]);
				}
			}
		}
		int k;
		cin >> k;
		for(int i=0 , p , q , r ; i<k ; ++i){
			cin >> p >> q >> r;
			p--; q--;
			cout << (r ? tIme[p][q] : cost[p][q] ) << endl;
		}
	}
	return 0; 
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

lli mod;
const int N = 1e5 + 5;
vector<int> g[N];

map<pair<int, int>, lli> memo;
lli rec1(int curr, int prev)
{
  const pair<int, int> key = make_pair(prev, curr);
  if (memo.count(key)) return memo[key];
  lli x = 1;
  each (next, g[curr]) {
    if (next == prev) continue;
    (x *= rec1(next, curr) + 1) %= mod;
  }
  return memo[key] = x;
}

void rec2(int curr, int prev, lli p)
{
  memo[make_pair(curr, prev)] = p;

  vector<lli> pref = {1};
  each (next, g[curr]) {
    lli x = pref.empty() ? 1 : pref.back();
    x *= memo[make_pair(curr, next)] + 1;
    pref.push_back(x % mod);
  }
  reverse(g[curr].begin(), g[curr].end());

  vector<lli> suff = {1};
  each (next, g[curr]) {
    lli x = suff.empty() ? 1 : suff.back();
    x *= memo[make_pair(curr, next)] + 1;
    suff.push_back(x % mod);
  }
  reverse(g[curr].begin(), g[curr].end());
  reverse(suff.begin(), suff.end());

  for (int i = 0; i < g[curr].size(); ++i) {
    int next = g[curr][i];
    if (next == prev) continue;
    rec2(next, curr, (pref[i] * suff[i + 1]) % mod);
  }

  return ;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n >> mod) {
    memo.clear();
    fill(g, g + N, vector<int>());
    for (int i = 0; i < n - 1; ++i) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      g[a].push_back(b);
      g[b].push_back(a);
    }

    rec1(0, 0);
    rec2(0, 0, 0);
    for (int i = 0; i < n; ++i) {
      lli x = 1;
      each (j, g[i]) (x *= memo[make_pair(i, j)] + 1) %= mod;
      cout << x << endl;
    }
    // break;
  }

  return 0;
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) ;
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

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



int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll N; cin >> N;
	
	string res = ":(";
	REP(i, 1000000)
	{
		if (floor(i * 1.08) == N)
		{
			res = to_string(i);
			break;
		}
	}

	std::cout << res << std::endl;
	
	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define INF 1100000000
using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> h(N), dp(N, INF);
  REP(i, N) cin >> h[i];

  dp[0] = 0;
  REP(i, N) {
    for (int j = 1; j <= K; j++) {
      if (i + j < N)
        dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
    }
  }
  cout << dp[N - 1] << endl;

  return 0;
}

Measured memory_bytes: 1024
/*Code by Codercjh*/
#include<bits/stdc++.h>
#define fr(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,a,b) for(int i=(a);i>=(b);--i)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
template<typename T>
inline void read(T &x){
	char c=getchar();T fh=0;bool f=false;
	while(!isdigit(c))f|=(c=='-'),c=getchar();
	while(isdigit(c))fh=(fh<<1)+(fh<<3)+(c^48),c=getchar();
	x=f?-fh:fh;
	return;
}

int main(){
    double a;
    cin>>a;
    double b=a/3.0;
    printf("%lf",b*(a*1.0-b)/2.0*(a*1.0-b)/2.0);
	return 0;
}


Measured memory_bytes: 256
#include <string>
    #include <iostream>
    using namespace std;
     
    int main() {
     
    	string a, b;
    	cin >> a >> b;
    	int con = stoi(a + b);
     
    	for (int i = 1; i <= 1000; i++) {
    		if (con == i*i) {
    			cout << "Yes" << endl;
    			return 0;
    		}
    	}
    	cout << "No" << endl;
     
    	return 0;
    }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n= sc.nextInt();
		sc.close();
		
		int i=0;
		int max;
		while (true){
			if(i*(i+1)/2 >= n){
				max = i;
				break;
			}
			i++;
		}
		
		for(int j=max; j>0; j--){
			if(n >= j){
				System.out.println(j);
				n -= j;
			}
		}

	}

}


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

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)



signed main(){

	int N, K;
	cin >> N >> K;
	int bit[42] = { 0 };
	int A[123456];
	for (int i = 0; i < N; i++) cin >> A[i];

	for (int b = 0; b < 42; b++){
		for (int i = 0; i < N; i++)
			if (A[i] & (1LL << b)) bit[b]++;
	}

	int ans = -INF;
	// greedyにとるのは間違い
	// 1を立てるべきでも、hanten_bitでは0にして、以降はgreedyにするという場合
	for (int hanten_bit = 41; hanten_bit >= -1; hanten_bit--){
		int X = 0;
		for (int b = 41; b >= 0; b--){
			if (bit[b] < N / 2.0){
				// 1を立てるべきでもしない
				if (b == hanten_bit) continue;
				else{
					// Xのbit目は1にすべき
					if ((X | (1LL << b)) <= K){
						X = X | (1LL << b);
					}
				}
			}
		}

		int tmp = 0;
		for (int i = 0; i < N; i++){
			tmp += X^A[i];
		}
		ans = max(ans, tmp);
	}

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

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

int n, dp[100002][3];

void max_self(int &a, int b){
	a=max(a,b);
}

int main(){
	cin >> n;
	dp[0][0]=dp[0][1]=dp[0][2]=0;
	for (int i=1;i<=n;i++){
		int a[3];
		for (int j=0;j<3;j++) cin >> a[j];
		for (int j=0;j<3;j++){
			dp[i][j]=0;
			for (int k=0;k<3;k++){
				if (j==k) continue;
				max_self(dp[i][j],dp[i-1][k]+a[j]);
			}
		}
	}
	cout << max(max(dp[n][0],dp[n][1]),dp[n][2]) << "\n";
}

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

#define FOR(i,a,b) for(size_t i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

typedef pair<ll, ll> pll;
// const ll INF = (ll)1e18;

signed main() {
	string str;
	stack<int>st;
	while (cin >> str) {
		if (str == "+") {
			int a = st.top();
			st.pop();
			int b = st.top();
			st.pop();
			st.push(a + b);
		} else if (str == "-") {
			int a = st.top();
			st.pop();
			int b = st.top();
			st.pop();
			st.push(b - a);
		} else if (str == "*") {
			int a = st.top();
			st.pop();
			int b = st.top();
			st.pop();
			st.push(a * b);
		} else {
			st.push(atoi(str.c_str()));
		}
	}
	cout << st.top() << endl;
}

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

using namespace std;

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

  for (int i = 0; i < s.size();)
  {
    cout << s[i] ;
    i+=2 ;
  } 

  cout << endl ;

 return 0 ;

}

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

int main() {
    string S;
    cin >> S;
    if(S=="RRR") cout << 3 <<endl;
    else if(S=="RRS"||S=="SRR") cout << 2 << endl;
    else if(S=="RSR"||S=="RSS"||S=="SRS"||S=="SSR") cout << 1 << endl;
    else cout << 0 << endl;
    }



Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int s[15][15];
int p[15];
int ans;
int main()
{
    int n,m,k;
    cin>>n>>m;
    for(int i=1; i<=m; i++)
    {
        cin>>k;
        for(int j=1; j<=k; j++)
        {
            cin>>s[i][j];
        }
    }
    for(int i=1; i<=m; i++)
    {
        cin>>p[i];
    }
    for(int s0=0; s0<(1<<n); s0++)
    {
        int a=0;
        for(int i=1; i<=m; i++)
        {
            int num=0;
            for(int j=1; j<=m; j++)
            {
                if(s0&(1<<(s[i][j]-1)))
                    num++;
            }
            if(num%2==p[i])
                a++;
            else
                break;
        }
        if(a==m)
            ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	fmt.Scanf("%d\n%s", &n, &s)
	answer := rgb(n, s)
	fmt.Println(answer)
}

func rgb(n int, s string) int {
	var r, g, b int
	for i := 0; i < n; i++ {
		switch s[i] {
		case 'R':
			r++
		case 'G':
			g++
		case 'B':
			b++
		}
	}
	maxSkip := (n - 1) / 2
	cntToExclude := 0
	for i := 1; i <= maxSkip; i++ {
		for j := 0; j+2*i < n; j++ {
			if s[j] != s[j+i] && s[j] != s[j+2*i] && s[j+i] != s[j+2*i] {
				cntToExclude++
			}
		}
	}
	return r*g*b - cntToExclude
}


Measured memory_bytes: 1892
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cstdio>
#include <queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();
constexpr ll I_MAX = numeric_limits<int>::max();
constexpr ull UI_MAX = numeric_limits<unsigned int>::max();

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)

auto sumdig(ll num) {
	ll dig, sum;
	sum = 0;
	while (num) {
		dig = num % 10;
		sum = sum + dig;
		num = num / 10;
	}
	return sum;
}



struct edge {
	int from;
	int to;
	int cost=1;
};


auto dijkstra(vector<vector<edge>> &g, int start = 0) {
	vector<int> d(g.size(), I_MAX);
	vector<bool> flag(g.size(), false);
	d[start] = 0;
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int,int>>> nodes;//first dist, second edgenum
	nodes.push(pair<int, int>(0, start));


	while (!nodes.empty()) {
		pair<int, int> n = nodes.top();
		int s_node = n.second;
		nodes.pop();
		if (n.first > d[n.second])continue;
		rep(i, 0, g[s_node].size()) {
			int new_dist = d[s_node] + g[s_node][i].cost;
			int n_num = g[s_node][i].to;
			if (new_dist < d[n_num]) {
				nodes.push(make_pair(new_dist, n_num));
				d[n_num] = new_dist;
			}
		}
	}
	return d;
}

int main() {
	int n;
	cin >> n;
	vector<edge> empty;
	vector<vector<edge>> g(n, empty);
	vector<int> ans;
	
	rep(i, 0, n) {
		int temp;
		cin >> temp;//頂点番号はいらん
		cin >> temp;

		rep(j, 0, temp) {
			int tc, tt;
			cin >> tt >> tc;
			edge tn = { i,tt,tc };
			g[i].push_back(tn);
		}
	}

	ans = dijkstra(g, 0);
	
	rep(i, 0, ans.size()) {
		cout << i << " " << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3172
#!/usr/bin/env python
"""AtCoder Grand Contest 046: A - Takahashikun, The Strider
https://atcoder.jp/contests/agc046/tasks/agc046_a
"""


def calc(x):
    mod = 360 % x
    ans = 360 // x
    if mod == 0:
        return ans
    angle = 360 - mod
    while True:
        angle += x
        ans += 1
        if angle % 360 == 0:
            return ans


def main():
    X = int(input())
    print(calc(X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 8984
#include<iostream>
using namespace std;
 
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    
   if ((a<=b)&&(b<=c)){
       cout << a << " "<< b << " "<< c << endl;
   }else if ((a<=b)&&(b>=c)){
       if (a <= c){
           cout << a << " " << c <<" " << b << endl;
       }else if(a >=c){
           cout << c << " " << a << " " << b << endl;
       }
   }else if ((a>=b)&&(b<=c)){
       if(a<=c){
           cout << b << " " << a <<" " << c << endl;
       }else if(a>=c){
           cout << b << " " << c <<" " << a << endl;
       }
   }else if ((a>=b)&&(b>=c)){
       cout << c <<" " << b << " " << a << endl;
   }
   
    return 0;
}


Measured memory_bytes: 3080
from math import sqrt, ceil
n = int(input())
def ans(n):
  if n == 2:
    return 1
  # divisors of n-1
  count = sum(2*int((n-1)%i==0) for i in range(2, ceil(sqrt(n-1))))
  # check the square root of n-1
  if ceil(sqrt(n-1)) == int(sqrt(n-1)):
    count += 1
  # n-1 is always a divisor of n-1
  count += 1
  # divisors of n
  for i in range(2, ceil(sqrt(n))):
    if n%i==0:
      x = n
      while x%i == 0:
        x = x//i
      count += int((x-1)%i==0)
      other_divisor = n//i
      x = n
      while x%other_divisor == 0:
        x = x//other_divisor
      count += int((x-1)%other_divisor==0)
  # check the square root of n
  if ceil(sqrt(n)) == int(sqrt(n)):
    i = int(sqrt(n))
    x = n
    while x%i == 0:
      x = x//i
    count += int((x-1)%i==0)
  # n is always a divisor of n that reduces to 1 by division once
  count += 1
  return(count)
print(ans(n))

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

char f[110][110];
int m[26];

int main() {
    int h,w;
    cin>>h>>w;
    
    rep(i,h){
        rep(j,w){
            cin>>f[i][j];
            m[f[i][j]-'a']++;
        }
    }

    if(h%2==0 && w%2==0){
        rep(i,26){
            if(m[i]%4!=0){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
    }
    else if(h%2==0 && w%2==1){
        rep(i,(h*w-h)/4){
            rep(j,26){
                if(m[j]>=4){
                    m[j]-=4;
                    break;
                }
                if(j==25){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
        rep(i,h/2){
            rep(j,26){
                if(m[j]%2!=0){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
        cout<<"Yes"<<endl;
    }
    else if(h%2==1 && w%2==0){
        rep(i,(h*w-w)/4){
            rep(j,26){
                if(m[j]>=4){
                    m[j]-=4;
                    break;
                }
                if(j==25){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
        rep(i,w/2){
            rep(j,26){
                if(m[j]%2!=0){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
        cout<<"Yes"<<endl;
    }
    else{
        rep(i,(h*w-w-h+1)/4){
            rep(j,26){
                if(m[j]>=4){
                    m[j]-=4;
                    break;
                }
                if(j==25){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
        rep(i,(w-1)/2){
            rep(j,26){
                if(m[j]>=2){
                    m[j]-=2;
                    break;
                }
                if(j==25){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
        rep(i,(h-1)/2){
            rep(j,26){
                if(m[j]>=2){
                    m[j]-=2;
                    break;
                }
                if(j==25){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>
#include <iomanip>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	ll q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	
	ll bottom = min( {4LL * q, 2LL * h, s} );
	ll two = n / 2LL;
	ll ans = min(two * d + (n - 2LL * two) * bottom, n * bottom);
	
	cout << ans << endl;
	
	return 0;
}


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

inline perm Unrank(int n, int r){
  perm p(n);
  for(int i=0;i<n;i++)p[i] = i;
  
  for(int i=n;i>0;i--){
    swap(p[i-1], p[r%i]);
    r /= i;
  }
  return p;
}

inline int Rank(perm p){
  int n = p.size();
  perm inv(n);
  for(int i=0;i<n;i++)inv[p[i]] = i;

  stack<int> s;
  for(int i=n;i>0;i--){
    s.push(p[i-1]);
    swap(p[i-1], p[inv[i-1]]);
    swap(inv[s.top()], inv[i-1]);
  }
  int r = 0;
  for(int i=1;i<=n;i++){
    r = s.top() + i * r;
    s.pop();
  }
  return r;
}

const int fact[] = {1,1,2,6,24,120,720,5040};
int dp[2][5040];
int n,d[110],a[110];

inline int cal(int pos, perm p){
  bool f = 0;
  int score = 0;
  rep(k,p.size()){
    if(p[k] == 0)f=1;
    else if(f && p[k]<=d[pos])score += a[pos];
    else if(!f && p[k]<=d[pos+p[k]])score += a[pos+p[k]];
  }
  return score;
}

inline perm red(perm p){
  perm np;
  rep(i,p.size()){
    if(p[i]>0)np.push_back(p[i]-1);
  }
  return np;
}

int main(){
  cin >> n;
  rep(i,n)cin >> d[i];
  rep(i,n)cin >> a[i];

  rep(i,n){
    int cur = i&1, nxt = 1-cur;
    int len = min(n-i, 7), nxtlen = min(n-i-1, 7);
    rep(j,fact[nxtlen])dp[nxt][j] = 0;

    rep(j,fact[len]){
      perm p = Unrank(len,j);
      
      if(len==nxtlen){
	perm np = p;
	np.push_back(p.size());
	int nxthash = Rank(red(np));
	dp[nxt][nxthash] = max(dp[nxt][nxthash], dp[cur][j]+cal(i,np));

	rep(k,len){
	  swap(np[len-k],np[len-1-k]);
	  int nxthash = Rank(red(np));
	  dp[nxt][nxthash] = max(dp[nxt][nxthash], dp[cur][j]+cal(i,np));
	}
      }else{
	int nxthash = Rank(red(p));
	dp[nxt][nxthash] = max(dp[nxt][nxthash], dp[cur][j]+cal(i,p));	
      }

    }
  }

  cout << dp[n&1][0] << endl;
}

Measured memory_bytes: 1264
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
#include <iomanip>
#include <vector>
#include <queue>
#include <map>
#include <numeric>
//#include <bits/stdc++.h>

using namespace std;
const int INF = 1 << 30;
map<int,int> m;

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int x;
    int ans=0;
    for(int i = 0 ; i < n ;++i)
    {    
        cin>>x;
        m[x]++;
    }
    for(auto i: m )
    {
        
        if(i.second%2)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4992
n = int(input())
a, b = map(int, input().split())
p = [int(x) for x in input().split()]


q1 = sum(x <= a for x in p)
q2 = sum(a < x <= b for x in p)
q3 = sum(b < x for x in p)

print(min(q1, q2, q3))



Measured memory_bytes: 9184
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 3005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,m;
int dp[MAXN][MAXN][2];
void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;}
void dec(int &a,int b) {a-=b; if(a<0) a+=MOD;}
int main()
{
    scanf("%d%d",&n,&m);
    n--;m--;
    for(int i=1;i<=n;i++) dp[0][i][0]=1;
    dp[0][0][1]=1;
    for(int i=0;i<m;i++)
    {
        for(int j=0;j<=n;j++)
        {
            for(int k=0;k<2;k++)
            {
                if(!dp[i][j][k]) continue;
                add(dp[i+1][j][k],2LL*dp[i][j][k]%MOD);
                if(j>0)
                {
                    if(k==0&&j==1) add(dp[i+1][j-1][1],dp[i][j][k]);
                    else add(dp[i+1][j-1][k],dp[i][j][k]);
                }
                if(j!=n) add(dp[i+1][j+1][k],dp[i][j][k]);
            }
        }
    }
    int ans=0;
    for(int i=0;i<=n;i++) add(ans,dp[m][i][1]);
    ans=4LL*ans%MOD;
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 70656
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N,M;
int K[30];
int A[30][30];
int res[31];

int main(){
    cin>>N>>M;
    rep(i,N){
        cin>>K[i];
        rep(j,K[i]){
            cin>>A[i][j];
            res[A[i][j]]++;
        }
    }

    int ans=0;
    repn(i,M){
        if(res[i]==N) ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	map<int,int> m;
	m[4]=1,m[6]=1,m[9]=1,m[11]=1;
	m[2]=3;
	m[1]=2,m[3]=2,m[5]=2,m[7]=2,m[8]=2,m[10]=2,m[12]=2;
	
	int a,b; cin >> a >> b;
	if(m[a] == m[b]) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string.h>
#include<queue>
#include<stack>
#include<climits>
#include<cmath>
#include<stdio.h>
using namespace std;

struct food{
    string name;
    int weight;
    int ue;
    int id;
};
struct com
{
    inline bool operator() (const food& f1, const food& f2){
        return (f1.id > f2.id);
    }
};
int main(){
    int n;
    while(cin>>n,n){
        vector<food>vec,v;
        int totWeight=0;
        for(int i=0;i<n;i++){
            food f;
            cin>>f.name>>f.weight>>f.ue;
            f.id=i;
            totWeight += f.weight;
            vec.push_back(f);
            v.push_back(f);
        }
        sort(vec.begin(),vec.end(),com());
        vector<pair<double,vector<int> > >ve;
        do{
            bool ok=true;
            int tot=0;
            for(int i=n-1;i>=0;i--){
                if(tot>vec[i].ue){
                    ok=false;
                    break;
                }
                tot+=vec[i].weight;
            }
            if(ok){
                double x=0;
                for(int i=0;i<n;i++){
                    x+=(n-i)*vec[i].weight;
                }
                x/=totWeight;
                vector<int>ids;
                for(int i=0;i<n;i++){
                    ids.push_back(vec[i].id);
                }
                ve.push_back(make_pair(x, ids));
            }
        } while(next_permutation(vec.begin(), vec.end(), com()));
        sort(ve.begin(),ve.end());
        for(int i=0;i<n;i++){
            cout<<v[ve[ve.size()-1].second[i]].name<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 22580
#include<bits/stdc++.h>
using namespace std;
int main(){
  int c[3][3],s[3];
  for(int i=0;i<9;i++)cin>>c[i/3][i%3];
  for(int i=0;i<12;i++){
    s[i%3]=c[(i<6)?i%3:i>8][(i<6)?i>2:i%3]-c[(i<6)?i%3:(i>8)+1][(i<6)?(i>2)+1:i%3];
    if(i%3==2&&(s[0]-s[1]||s[1]-s[2])){cout<<"No";return 0;}
  }
  cout<<"Yes";return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

//Winter Bells
public class Main{

	int[] d;
	void run(){
		Scanner sc = new Scanner(System.in);
		int INF = 1<<27;
		d = new int[100];
		int[][] wf = new int[100][100], e = new int[100][100];
		double[] K = new double[100], R = new double[100];
		for(;;){
			int n = sc.nextInt(), m = sc.nextInt(), p = sc.nextInt();
			if((n|m|p)==0)break;
			for(int[]a:wf)Arrays.fill(a, INF);
			for(int[]a:e)Arrays.fill(a, INF);
			for(int i=0;i<n;i++)wf[i][i]=0;
			for(int i=0;i<m;i++){
				int s = sc.nextInt(), t = sc.nextInt(), c = sc.nextInt();
				e[s][t] = e[t][s] = wf[s][t] = wf[t][s] = c;
			}
			for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)wf[i][j]=Math.min(wf[i][j], wf[i][k]+wf[k][j]);
			PriorityQueue<Integer> q = new PriorityQueue<Integer>(n, new Comparator<Integer>() {
				public int compare(Integer o1, Integer o2) {
					return d[o1]-d[o2];
				}
			});
			Arrays.fill(K, 0);
			K[n-1] = 1;
			for(int i=0;i<n;i++){
				d[i] = -wf[0][i]; q.add(i);
			}
			while(!q.isEmpty()){
				int v = q.poll();
				for(int i=0;i<n;i++){
					if(i==v || e[i][v]==INF)continue;
					if(wf[0][n-1]==wf[0][i]+e[i][v]+wf[v][n-1]){
						K[i]+=K[v];
					}
				}
			}
			Arrays.fill(R, 0);
			R[0] = 1;
			for(int i=0;i<n;i++){
				d[i]=wf[0][i];
				q.add(i);
			}
			while(!q.isEmpty()){
				int v = q.poll();
				for(int i=0;i<n;i++){
					if(i==v || e[v][i]==INF)continue;
					if(wf[0][n-1]==wf[0][v]+e[v][i]+wf[i][n-1]){
						R[i]+=R[v];
					}
				}
			}
			while(p--!=0){
				int k = sc.nextInt();
				System.out.printf("%.8f\n", K[k]*R[k]/R[n-1]);
			}
			System.out.println();
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned x){
  int s=0;
  char f[10];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned long long x){
  int s=0;
  char f[21];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(double x){
  printf("%.15f",x);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
inline void wt_L(string &x){
  int i=0;
  for(i=0;x[i]!='\0';i++){
    putchar_unlocked(x[i]);
  }
}
template<class T> int Factor_L(T N){
  T i;
  int sz = 0;
  if(N%2==0){
    while(N%2==0){
      N /= 2;
    }
    sz++;
  }
  for(i=3;i*i<=N;i+=2){
    if(N%i==0){
      while(N%i==0){
        N /= i;
      }
      sz++;
    }
  }
  if(N > 1){
    sz++;
  }
  return sz;
}
template<class T> inline T GCD_L(T a,T b){
  T r;
  while(a){
    r=b;
    b=a;
    a=r%a;
  }
  return b;
}
long long A;
long long B;
int main(){
  rd(A);
  rd(B);
  wt_L(Factor_L(GCD_L(A, B))+1);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190929-1 [beta]

// --- original code ---
// ll A, B;
// {
//   rd(A,B);
//   wt(Factor(gcd(A,B))+1);
// }


Measured memory_bytes: 256
//#define _XCODE_DEBUG

#include <iostream>
#include <queue>
#include <algorithm>

#ifdef _XCODE_DEBUG
    #include <fstream>
#endif

int main() {
    #ifdef _XCODE_DEBUG
        std::ifstream in("input.txt");
        std::cin.rdbuf(in.rdbuf());
    #endif
    
    // input data
    int H, W;
    std::cin >> H >> W;
    char maze[H][W];
    int cmap[H][W];
    std::queue<int> qi;
    std::queue<int> qj;
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            std::cin >> maze[i][j];
            cmap[i][j] = 0;
            if (maze[i][j]=='#') {
                qi.push(i);
                qj.push(j);
            }
        }
    }
    
    // bfs
    int di[4] = {1,-1,0,0};
    int dj[4] = {0,0,1,-1};
    while (!qi.empty()) {
        int i = qi.front(); qi.pop();
        int j = qj.front(); qj.pop();
        for (int k=0; k<4; ++k) {
            int mi = i + di[k];
            int mj = j + dj[k];
            if (maze[mi][mj]=='#') continue;
            if (mi<0 || mi>=H || mj<0 || mj>=W) continue;
            maze[mi][mj] = '#';
            cmap[mi][mj] = cmap[i][j] + 1;
            qi.push(mi);
            qj.push(mj);
        }
    }
    
    int max_v = 0;
    for (int i=0; i<H; ++i) max_v=std::max(max_v, (int)*std::max_element(cmap[i],cmap[i]+W));
    std::cout << max_v << "\n";
    return 0;
}

Measured memory_bytes: 13056
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define loop(n) for(int i=0;i<n;i++)
using namespace std;
void leftrotate(int arr[], int n, int d) 
{ 
    int g_c_d = gcd(d, n); 
    for (int i = 0; i < g_c_d; i++) { 
        /* move i-th values of blocks */
        int temp = arr[i]; 
        int j = i; 
  
        while (1) { 
            int k = j + d; 
            if (k >= n) 
                k = k - n; 
  
            if (k == i) 
                break; 
  
            arr[j] = arr[k]; 
            j = k; 
        } 
        arr[j] = temp; 
    } 
} 
void reverseArray(int arr[], int start, 
                            int end) 
{ 
    while (start < end) 
    { 
        std::swap(arr[start], arr[end]); 
        start++; 
        end--; 
    } 
} 
  
/* Function to right rotate arr[] 
of size n by d */
void rightrotate(int arr[], int n, int d)
{ 
    reverseArray(arr, 0, n-1); 
    reverseArray(arr, 0, d-1); 
    reverseArray(arr, d, n-1); 
} 
  
int main()
{
  ll n;cin>>n;
  vector<ll> a(n,0);
  ll d;
  cin>>d;
  while(d--)
  {
    ll i1;cin>>i1;
    for(int i=1;i<=i1;i++)
    {
      ll tmp;cin>>tmp;
      a[tmp-1]++;
    }
  }
  ll count=0;
  for(ll i:a)
  if(i==0)
  count++;
  cout<<count<<"\n";

}

Measured memory_bytes: 3584
#pragma once
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  string N,M;
  int ans = 0;
  cin >> N>>M;
  if (N[0] == M[0]) {
  ans++;
  }
  if (N[1] == M[1]) {
    ans++;
  }
  if (N[2] == M[2]) {
    ans++;
  }

  cout << ans;
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
  cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> vec;
vec.at(i)
vector<vector<int>> vec(10, vector<int>(10));
sort(all(vec));
sort(all(vec), greater<int>());
    //配列の内容表示
dout << "====vecの内容====\n";
for (int i = 0; i < N; i++) dout << vec[i] << endl;
dout << "====ここまで====\n";
*/

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




int main(){
    ll n; cin>> n;
    ll e=1000000007, f0=1, f9=1, f8=1;
    while(n){
        f0*=10;
        f0%=e;
        f9*=9;
        f9%=e;
        f8*=8;
        f8%=e;
        n--;
    }
    cout<< (f0-f9-f9+f8+e+e)%e<< endl;
}


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

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h,"");
    for(int i = 0; i < h; i++) cin >> s[i];
    
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] != '#'){
                
                int sum = 0;
                for(int k = 0; k < 8; k++){
                    const int nx = j + dx[k];
                    const int ny = i + dy[k];
                    if(nx < 0 || nx >= w) continue;
                    if(ny < 0 || ny >= h) continue;
                    if(s[ny][nx] == '#') sum++;
                }
                s[i][j] = (char)(sum + '0');
                
            }
        }
    }
    
    for(int i = 0; i < h; i++) cout << s[i] << endl;;
}

Measured memory_bytes: 256
def ZZ(): return list(map(int, input().split()))
def Z(): return int(input())

A, B, C, K = ZZ()
ans = 1 * min(A, K)
K -= min(A, K)
ans += 0 * min(B, K)
K -= min(B, K)
ans += -1 * min(C, K)
print(ans)

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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> u(10);
    while (k--) {
        int d;
        cin >> d;
        u[d] = 1;
    }
    for (int i = n;; ++i) {
        bool f = true;
        int j = i;
        while (j) {
            if (u[j % 10]) {
                f = false;
                break;
            }
            j /= 10;
        }
        if (f) {
            cout << i;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256