akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[12];
	int i,j;
	int cut=0;
	int b[3]={1,5,9};
	for(i=0;i<12;i++){
		cin>>a[i];
	}
	for(i=0;i<12;i++){
		for(j=11;j>i;j--){
			if(a[i]>a[j]){
				swap(a[i],a[j]);
			}
		}
	}
	//cout<<"a"<<endl;
	for(i=0;i<3;i++){
		for(j=b[i];j<=b[i]+2;j++){
			if(a[b[i]-1]==a[j]){
				cut++;
			}
		}
	}
	if(cut==9){
		cout<<"yes"<<endl;
	}
	else{
		cout<<"no"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifndef bhartiya
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif


typedef long long ll;
typedef pair<ll, ll> pll;
typedef gp_hash_table<long long, long long> umap;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> oset;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#define inf 200000000000000ll
#define mod 1000000007ll
#define eps 1e-7
#define PI 3.1415926535897932385
// #define PI acos(-1)

#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))

#ifdef bhartiya
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
inline bool equals(double a, double b) {return fabs(a - b) < 1e-9;}
ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }

const ll maxn = 2005;
ll n,m;
ll dp[maxn][maxn];
ll a[maxn], b[maxn];

int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(10); //cout<<fixed;
    cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        cin>>n>>m;
        fr(i,1,n) cin>>a[i];
        fr(i,1,m) cin>>b[i];
        rep(i,n+1){
            dp[0][i] = 1;
        }
        fr(i,1,m){
            dp[i][0] = 1;
            fr(j,1,n){
                dp[i][j] = dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1];
                if(b[i] == a[j]){
                    dp[i][j] += dp[i-1][j-1];
                }
                dp[i][j] %= mod;
                dp[i][j] += mod;
                dp[i][j] %= mod;
            }
        }
        cout<<dp[m][n];
    }
    end_routine();
}

Measured memory_bytes: 31616
#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>

using namespace std;

long long int result = 0;
int H, W;
int cost[10][10] = {};
int A[210][210] = {};
int minn[10] = {};
int countt[10] = {};

int wf[10][10] = {};

int bufI = 0;

int main() {
	minn[1] = 0;

	cin >> H >> W;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> cost[i][j];
			wf[i][j] = cost[i][j];
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A[i][j];
			if (A[i][j] >= 0) {
				countt[A[i][j]]++;
			}
		}
	}


	for (int k = 0; k < 10; k++) {
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
				if (wf[i][j] >wf[i][k] + wf[k][j]) {
					wf[i][j] = wf[i][k] + wf[k][j];
				}
			}
		}
	}


	for (int i = 0; i < 10; i++) {
		minn[i] = wf[i][1];
	}


	for (int i = 0; i < 10; i++) {
		result += countt[i] * minn[i];
	}

	cout << result << endl;

return 0;
}

Measured memory_bytes: 384
n=int(input())
a,b=[0]*n,[0]*n
s=[[0 for i in range(2)] for j in range(n)]
for i in range(n):
    a[i],b[i]=map(int,input().split())
    s[i][0]=a[i]+b[i]
    s[i][1]=i
s.sort(reverse=True)
s1=0
s2=0
for i in range(n):
    if i%2==0:
        s1+=a[s[i][1]]
    else:
        s2+=b[s[i][1]]
print(s1-s2)


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

const int p=1e9+7;
int mod_pow(int a,int N){
	if(N==0)return 1;
	if(N%2==1)return (a*mod_pow(a,N-1))%p;
	int tmp=mod_pow(a,N/2);
	return (tmp*tmp)%p;
}

signed main(){
    int N; cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int keta=0,tmp=*max_element(A.begin(),A.end());
    while(tmp>0){tmp/=2; keta++;}
    vector<pair<int,int>> dig(keta,make_pair(0,0));
    //dig[i]: firstにi桁目の1の数、secondに0の数
    for(int i=0;i<N;i++){
        for(int j=0;j<keta;j++){
            if(A[i] & (1LL<<j))dig[j].first++;
            else dig[j].second++;
        }
    }
    int ans=0;
    for(int i=0;i<keta;i++){
        int tmp=mod_pow(2,i);
        tmp*=dig[i].first; tmp%=p;
        tmp*=dig[i].second; tmp%=p;
        ans+=tmp; ans%=p;
    }
    cout<<ans%p<<endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N;
   cin >> N;
   int p[N];
   int cnt = 0;
   for (int i = 0; i < N; i++) {
      cin >> p[i];
      if (p[i] != i + 1) cnt++;
   }
   if (cnt == 2 || cnt == 0) cout << "YES" << endl;
   else cout << "NO" << endl;
   return 0;
}


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

using namespace std;

int main() {
    while(1<2){
        int money,change,coin=0;

        cin>>money;
        if(money==0)break;
        change=1000-money;
        while(change-500>=0){
            coin+=1;
            change-=500;
            if(change<500)break;
        }
        
            while(change-100>=0){
            coin+=1;
            change-=100;
            if(change<100)break;
        }
        
                while(change-50>=0){
            coin+=1;
            change-=50;
            if(change<50)break;
        }
        
                while(change-10>=0){
            coin+=1;
            change-=10;
            if(change<10)break;
        }
        
                while(change-5>=0){
            coin+=1;
            change-=5;
            if(change<5)break;
        }
        
                while(change-1>=0){
            coin+=1;
            change-=1;
            if(change<1)break;
        }
        
        cout<<coin<<endl;
    }
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
const int sz = 2e5+10;

 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int t;
    t=1;
    // cin>>t;
    for(int cs=1;cs<=t;cs++)
    {
 
        int n;
        string s1,s2;
        cin>>s1>>s2;
        n=s1.length();
        int res=0;
        for(int i=0;i<n;i++)
        {
            if(s1[i]!=s2[i])
                res++;
        }
        
        cout<<res<<endl;
 
 
 
    }
    return 0;
} 

Measured memory_bytes: 3820
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>

#define MAX_N 100'000

using namespace std;

int Y[MAX_N];

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

int main() {
  int N, X;
  cin >> N >> X;
  for (int i = 0; i < N; ++i) {
    cin >> Y[i];
  }
  sort(Y, Y + N);
  int res = abs(X - Y[0]);
  for (int i = 0; i < N - 1; ++i) {
    res = gcd(res, Y[i + 1] - Y[i]);
  }
  printf("%d\n", res);
}

Measured memory_bytes: 3544
def main():
    a,v = map(int,input().split())
    b,w = map(int,input().split())
    t = int(input())
    dist = abs(a-b)
    speed_per_second = v-w
    if dist - speed_per_second * t <= 0:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()


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

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i,n) for(int i = 0; i < n; i++)
#define for1(i,n) for(int i = 1; i <= n; i++)
#define ford(i,n) for(int i = n-1; i >= 0; i--)
#define fore(i,a,b) for(int i = a; i <= b; i++)

using namespace std;

typedef long long ll;
typedef double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;


const  int MAXn= 3e5+5;
const  long long INF= 1e18;
const long long mod= 1e9+7;

vector<int> adj[MAXn];
vector<bool> visited(MAXn,false);

ll bfs(int u, int k){
	ll ans=k;
	int color=k-2;
	k--;
	queue<int> q;
	visited[u]=true;
	
	for(int x: adj[u]){
		ans= (ans*k)%1000000007;
		//cout<<ans<<" ";
		visited[x]=true;
		q.push(x);
		k--;
	}
	
	while(!q.empty()){
		int v=q.front();
		q.pop();
		int temp=color;
		for(int x:adj[v]){
			if(!visited[x]){
				ans=(ans*temp)%1000000007;
				temp--;
			//	cout<<ans<<" ";
				visited[x]=true;
				q.push(x);
			}
		}
	}
	return ans;
}
	


int main(){
        int n,k;
        cin>>n>>k;
        n--;
        while(n--){
			int a,b;
			cin>>a>>b;
			adj[a].pb(b);
			adj[b].pb(a);
		}
	ll ans =	bfs(1,k);
	
	cout<<ans;	
	
		
        
    }


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

int main (){

  int A, B, sum, keta1, keta2, keta4, keta5, Ai;
  cin >> A >> B;
  sum = 0;
  Ai = A;
  for (int i = 0; i < B - A + 1; i++){
    keta1 = Ai % 10;
    keta2 = Ai / 10 % 10;
    keta4 = Ai / 1000 % 10;
    keta5 = Ai / 10000 % 10;
    Ai++;
    if (keta1 == keta5 && keta2 == keta4){
      sum++;
    }

  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
using namespace std;
map<string,int>M;
vector<int>G[1<<17];
int n,m;
string s[100];
bool used[1<<17];
int dfs(int u)
{
	if(used[u])return 0;
	used[u]=1;
	if(G[u].size()==0)return 1;
	int ans=0;
	for(int i=0;i<G[u].size();i++)ans+=dfs(G[u][i]);
	return ans;
}
main()
{
	while(cin>>n,n)
	{
		for(int i=0;i<n;i++)cin>>s[i];
		for(int i=0;i<m;i++)G[i].clear(),used[i]=0;
		M.clear();
		m=0;
		for(int i=0;i<n;i++)
		{
			int j=s[i].find(":");
			string t=s[i].substr(0,j),tt="";
			if(M.find(t)==M.end())M[t]=m++;
			j++;
			for(;j<s[i].size();j++)
			{
				if(s[i][j]==','||s[i][j]=='.')
				{
					if(M.find(tt)==M.end())M[tt]=m++;
					G[M[t]].push_back(M[tt]);
					tt="";
				}
				else tt+=s[i][j];
			}
		}
		cout<<dfs(0)<<endl;
	}
}



Measured memory_bytes: 6404
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int now=10,last=1,i,ans=0;
	for(i=1;i<=5;i++){
		if(now>n)break;
		if(i&1)ans+=now-last;
		now*=10,last*=10;
	}
	printf("%d\n",ans+(i%2)*(n-last+1));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <string>
using namespace std;
int main(void){
    string s;
    int a, b;
    stack<int> st;
    
    while(cin >> s){
        if(s == "+"){
            a = st.top(); st.pop();
            b = st.top(); st.pop();
            st.push(a + b);
        } else if(s == "-"){
            b = st.top(); st.pop();
            a = st.top(); st.pop();
            st.push(a - b);
        } else if(s == "*"){
            a = st.top(); st.pop();
            b = st.top(); st.pop();
            st.push(a * b);
        } else {
            st.push(atoi(s.c_str()));
        }
    }
    cout << st.top() << endl;
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define taskname "A"
#define pb push_back
#define mp make_pair
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
const int maxn = 2e3 +5;
const int mod =924844033;
const int inf = 1e9 + 1;
const ll llinf = 1e18 + 5;
int f[maxn][maxn][2];
int g[maxn];
int dp[maxn];
int fac[maxn];

int n , k;
void add(int & x , int y){
    x += y;
    if(x >= mod)x -= mod;
    if(x < 0)x += mod;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if(fopen(taskname".inp", "r")) {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }
    cin >> n >> k;
    f[0][0][1] = 1;
    for(int i = 1 ; i <= n ; ++i){
        for(int j = 0 ; j <= i ; ++j){
            if(j > 0)add(f[i][j][1] , f[i - 1][j - 1][0]);
            add(f[i][j][0] , f[i - 1][j][0]);
            add(f[i][j][0] , f[i - 1][j][1]);
        }
    }
//    cout << f[n][0][0] + f[n][0][1] << endl;
    dp[0] = 1;
    int cur = 0;
    for(int i = 1 ; i <= min(n , 2 * k) ; ++i){
        fill_n(g,maxn,0);
        int cnt = ((n - i) / k + 1);
        int len = cnt;
        if(i > k)len++;
        if(i + cnt * k <= n)len++;
//        cout << len << " " << cnt << endl;
        for(int j = 0 ; j <= cur; ++j){
            for(int t = 0 ; t <= cnt ; ++t){
                add(g[j + t] , (ll)dp[j] * (f[len][t][0] + f[len][t][1]) % mod);
            }
        }
        cur += cnt;
        for(int j = 0 ; j <= cur ; ++j){
            dp[j] = g[j];
        }
    }
    fac[0] = 1;
    for(int i = 1 ; i <= n ; ++i){
        fac[i] = (ll)fac[i - 1] * i % mod;
    }
    int res = 0;
    for(int i = 0 ; i <= n ; ++i){
        if(i & 1)add(res , (ll)-fac[n - i] * dp[i] % mod);
        else add(res , (ll)fac[n - i] * dp[i] % mod);
//        cout << dp[i] * fac[n - i] << endl;
    }
    cout << res;
}



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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

constexpr int MAX = 3010000;
constexpr int MOD = 1000000007;

//Please set MAX and MOD!!========================================

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

ll COM(int n, int k) {
	if (n < k || n < 0 || k < 0) return (0);
	return (fac[n] * (finv[k] * finv[n - k] % MOD) % MOD);
}


void Main() {
	int K; string S; cin >> K >> S;
	int N = S.size();

	ll sum = 0;
	ll val = 1;
	COMinit();
	for (int i = K+N; i >= N; i--) {
		(sum += val * COM(K+N, i)) %= mod;
		(val *= 25) %= mod;
	}
	cout << sum << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


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

int main(){
  int a, b, k;
  cin >> a >> b >> k;
  for(int i = a; i < min(a + k, b+1); i++){
    cout << i << endl;
  }
  for(int i = max(b - k + 1, a + k); i <= b; i++){
    cout << i << endl;
  }
}

Measured memory_bytes: 3616
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>

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

int main()
{
	int n, m;
	cin>>n>>m;
	unordered_map<int, int> mp[100001];
	for(int i=0; i<n; i++){
		int x; cin>>x;
		mp[x%m][x]++;
	}
	int ans=0;
	int s=0;
	for(auto p:mp[0]){
		s+=p.second;
	}
	ans+=(s/2);
	if(m%2==0){
		s=0;
		for(auto p:mp[m/2]){
			s+=p.second;
		}
		ans+=(s/2);
	}
	for(int i=1; i<(m+1)/2; i++){
		int s1=0, s2=0, m1=0, m2=0;
		for(auto p:mp[i]){
			s1+=p.second;
			m1+=(p.second/2);
		}
		for(auto p:mp[m-i]){
			s2+=p.second;
			m2+=(p.second/2);
		}
		if(s1==s2){
			ans+=s1;
		}else if(s1<s2){
			if(2*m2>=s2-s1-1){
				ans+=((s1+s2)/2);
			}else{
				ans+=(s1+m2);
			}
		}else{
			if(2*m1>=s1-s2-1){
				ans+=((s1+s2)/2);
			}else{
				ans+=(s2+m1);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    if(N==7 || N==5 || N==3){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    


    return 0;
    

}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int m,n,x,y,p,xx,yy,d,l,o;
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
main(){
  cin>>m;
  while(m--){
   if(o++)cout<<endl;
    cin>>n;l=0;
    string s[n];
    r(i,n)r(j,n)s[i]+='#';
    s[n-1][1]=' ';
    xx=0,yy=n-1,d=0;
    while(1){
      int c=0;
      r(i,4){
        if(!l)c--;
        y=dy[i]+yy,x=dx[i]+xx;
        if(y<0||y>=n||x<0||x>=n){
          c++;
          continue;
        }
        else if(s[y][x]==' ')c++;
      }
      if(c>=3)break;
      y=dy[d]+yy,x=dx[d]+xx;
      if(y<0||y>=n||x<0||x>=n)d=(d+1)%4;
      else if(s[y][x]==' ')d=(d+1)%4;
      else{
        yy=y+dy[d],xx=x+dx[d];
        if(yy>=0&&yy<n&&xx>=0&&xx<n&&s[yy][xx]!=' '){
          p=(d+1)%4;
          yy=y+dy[p],xx=x+dx[p];
          s[yy][xx]=' ';
        }
        yy=y,xx=x;
      }l++;
    }
    r(i,n)cout<<s[i]<<endl;
  }
}

Measured memory_bytes: 3020
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
ll n,m,c;
cin>>n>>m>>c;
ll b[m];
ll ans=0;
for(int i=0;i<m;i++){
    cin>>b[i];
}
ll a;
for(int i=0;i<n;i++){
    ll sum=0;
    for(int j=0;j<m;j++){
        cin>>a;
        sum+=a*b[j];
    }
    if(sum+c>0){
        ans++;
    }
}
cout<<ans<<endl;
}












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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const int MOD=1e9+7;

vector<vi> G;
vector<bool> visit;
vi cnt;

void dfs(int v, int sum){
    visit[v]=true;
    for(auto nv : G[v]){
        if(visit[nv]) continue;
        dfs(nv, sum+cnt[v]);
    }
    cnt[v]+=sum;
}

int main(){
    int N, Q; cin >> N >> Q;
    G.resize(N);
    visit.assign(N, 0);
    cnt.resize(N, 0);
    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);
    }
    for(int i=0; i<Q; i++){
        int p, x; cin >> p >> x;
        cnt[p-1]+=x;
    }
    dfs(0, 0);
    for(int i=0; i<N; i++){
        if(i != 0) cout << " "; 
        cout << cnt[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 23552
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;

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

    vector<int> v;
    for (int i = 1; i <= min(A, B); i++){
        if (A % i == 0 && B % i == 0){
            v.push_back(i);
        }
    }
    std::sort(v.begin(), v.end(), std::greater<int>() );
    cout << v[K - 1] << endl;
    return 0;
}



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

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

    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    int sum = 0;
    rep(i, n - 1) sum += p[i];
    cout << sum + p[n - 1] / 2 << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(raw_input())
s = str(raw_input())

ans=[]
black=[]
for i in range(0,n):
    ans.append(-1)
    black.append(-1)
ans[0]=0
if s[0]==".":
    black[0]=0
else:
    black[0]=1

for i in range(1,n):
    if s[i] == ".":
        black[i] = black[i-1]
        ans[i] = min(black[i-1], ans[i-1]+1)
    else:
        black[i] = black[i-1] + 1
        ans[i] = min(ans[i-1], black[i-1]+1)

print ans[n-1]


Measured memory_bytes: 17092
d ={"o":0, "x":1}
e =["S","W"]
n = int(input())
s = [d[t] for t in input()]

for i in range(4):
  a = [-1]*(n+2)
  a[0] = i%2
  a[1] = i//2
  for i in range(n):
    a[i+2] = a[i] ^ a[i+1] ^ s[i]
  if a[0] == a[n] and a[1] == a[n+1]:
    print("".join([e[t] for t in a[1:n+1]]))
    quit()
print(-1)

Measured memory_bytes: 6268
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	vector<ll> A(N);
	ll ans = 1;
	bool ng = false, zero = false;
	REP(i, N) cin >> A[i];
	REP(i, N) {
		if ((double)A[i] * ans > longINF) { ng = true; break; }
		ans *= A[i];
	}
	REP(i, N) if (A[i] == 0) zero = true;
	
	if (zero) {
		puts("0");
		return 0;
	}
	if (ans > 1000000000000000000) ng = true;
	if (ng) puts("-1");
	else cout << ans << endl;
	return 0;
}


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

using namespace std;

#define ll long long
int m = 1000000007;

ll bin_pow(int a, int pow) {
    if (pow == 1) return a % m;
    if (pow % 2 == 0) {
        ll tmp = bin_pow(a, pow / 2) % m;
        return tmp * tmp % m;
    }
    return (a % m) * (bin_pow(a, pow - 1) % m) % m;
}

int fact(int x) {
    int ans = 1;

    for (int i = 1; i <= x; i++) ans *= i;
    return ans;
}

int count(vector<int> a) {
    int ans = 0;
    unordered_set<int> was;
    for (int i = 0; i < a.size(); i++) {
        int count = a[i] - 1;
        for (int j = 1; j < a[i]; j++) {
            count -= was.count(j);
        }
        ans += count * fact(a.size() - i - 1);
        was.insert(a[i]);
    }

    return ans;
}

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

    unordered_set<int> correct;

    int n;
    cin >> n;
    vector<int> a(n), b(n);

    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];

    cout << abs(count(a) - count(b));

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LENGTH 100005

typedef struct pp{
  char na[10];
  int time;
}X;

X A[LENGTH];
int top,end,num;

void enqueue(X a){
  A[end] = a;
  end = (end +1 )% LENGTH;
}

X dequeue(){
  X a= A[top];
  top = (top + 1) % LENGTH;
  return a;
}

int min(int a, int b){
  return a < b? a:b;
}

int main(){
  int elaps =0,ci;
  int i,q;
  X ui;
  scanf("%d %d",&num,&q);

  for(i=1;i<=num;i++){
    scanf("%s",&A[i].na);
    scanf("%d",&A[i].time);
  }

  top = 1;
  end = num +1;

  while(top != end){
    ui = dequeue();
    ci = min(q, ui.time);
    ui.time -= ci;
    elaps += ci;
    if(ui.time>0) enqueue(ui);
    else{
      printf("%s %d\n",ui.na,elaps);
    }
  }
  return 0;
}



Measured memory_bytes: 3272
#include<bits/stdc++.h>
using namespace std;
typedef long long l;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a*2<=b&&a*4>=b)
	{
		if(b%2==0)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;
import java.util.Arrays;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] x = new int[m];
        if(n >= m){
            System.out.println(0);
        }else{
            for(int i = 0; i < m; i++){
                x[i] = sc.nextInt();
            }
            Arrays.sort(x);
            int[] sa = new int[m - 1];
            for(int i = 0; i < m - 1; i++){
                sa[i] = Math.abs(x[i + 1] - x[i]);
            }
            Arrays.sort(sa);
            int ans = 0;
            for(int i = 0; i < m - n; i++){
                ans += sa[i];
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 51072
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
G = [-1 for i in range(N+1)]

for i, v in enumerate(P):
    G[i+1] = (v, C[v-1])

ans = -float("inf")

for i in range(1, N+1):
    loop = []
    S = i
    visited = [False for i in range(N+1)]
    while visited[S] == False:
        loop.append(G[S][-1])
        visited[S] = True
        S = G[S][0]

    circle_sum = sum(loop)
    this_case_ans = -float("inf")

    if circle_sum < 0:
        pass_sum = 0
        for i in range(len(loop)):
            pass_sum += loop[i]
            this_case_ans = max(this_case_ans, pass_sum)
        ans = max(ans, this_case_ans)
        continue

    else:
        L = len(loop)
        for i in range(1, L):
            loop[i] += loop[i-1]
        loop.insert(0, -float("inf"))
        for i in range(1, L+1):
            loop[i] = max(loop[i], loop[i-1])
        loop[0] = 0
        if K//L > 0:
            this_case_ans = max(K//L * circle_sum +
                                loop[K % L], (K//L-1)*circle_sum + loop[-1])
        else:
            for i in range(1, K+1):
                this_case_ans = max(this_case_ans, loop[i])
        ans = max(ans, this_case_ans)

print(ans)

Measured memory_bytes: 129904
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

void sputs(){}
template <class Head, class... Tail>
void sputs(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(Tail) == 0) { cout << endl; }
  else { cout << " "; }
  sputs(std::move(tail)...);
}

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

signed main() {
  int n,k;cin>>n>>k;
  vector<int> a(n+1);
  rep(i, n) {
    cin>>a[i+1];
  }
  dump(a);
  vi ca = a;
  rep(i, 1, n+1) ca[i]+=ca[i-1];
  dump(ca);

  vi v;
  rep(i, 1, n+1){
    rep(j, i, n+1){
      v.pb(ca[j]-ca[i-1]);
    }
  }
  dump(v);

  int ans = 0;
  rrep(d, 45){
    int D = 1LL<<d;
    vi nv;
    int cnt=0;
    rep(i, sz(v)){
      if (v[i]&D) {
        cnt++;
        nv.pb(v[i]);
      }
    }
    if (cnt>=k) v = nv, ans += D;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 6512
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
//#include<chrono>
//#include<time.h>
//#include<windows.h>
using namespace std;
 
//#define int ll
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
//static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
struct edge {int /*from,*/to,cost;};

main(){
    string s;
    cin >> s;
    reverse(ALL(s));
    REP(i,LEN(s)){
        if(s.substr(i,5)=="maerd" || s.substr(i,5)=="esare") i += 4;
        else if(s.substr(i,6)=="resare") i+= 5;
        else if(s.substr(i,7)=="remaerd") i+= 6;
        else {
            puts("NO");
            return 0;
        }
    }
 
    puts("YES");
    return 0;
}


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

int main() {
    int arr[26] = {0};
    string w; cin >> w;
    for (int i = 0; i < w.size(); i++) {
        arr[w[i] - 'a']++;
    }
    for (int i = 0; i < 26; i++) {
        if (arr[i] % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include <bits/stdc++.h>
//1000000000000223
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int n, m, l, r, c;
ll t[400009], inf=2e14;
vector<pair<int, pair<int,int> > > v;
void update(int v, int s, int e, int pos,ll val)
{
    if(s==e)
    {
        t[v]=min(t[v],val);
        return ;
    }
    int m=(s+e)/2;
    pos<=m ? update(2*v,s,m,pos,val) : update(2*v+1,m+1,e,pos,val);
    t[v]=min(t[2*v],t[2*v+1]);
}
ll solve(int v, int s, int e, int l, int r)
{
    if(s>r||e<l)
        return inf;
    if(s>=l &&e<=r)
        return t[v];
    int m=(s+e)/2;
    return min(solve(2*v,s,m,l,r),solve(2*v+1,m+1,e,l,r));
}
int main()
{
    IO
    cin>>n>>m;
    while(m--)
    {
        cin>>l>>r>>c;
        v.push_back({l,{r,c}});
    }
    for(int i=1;i<=4*n;i++)
        t[i]=inf;
    sort(v.begin(),v.end());
    if(v[0].first!=1)
        return cout<<-1, 0 ;
    for(auto i : v)
    {
        if(i.first==1)
        {
            update(1,1,n,i.second.first,i.second.second);
            continue;
        }
        ll x=solve(1,1,n,i.first,n);
        update(1,1,n,i.second.first,i.second.second+x);
    }
    ll x=solve(1,1,n,n,n);
    if(x>=inf)
        x=-1;
    cout<<x;

    return 0;
}


Measured memory_bytes: 4596
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int INF = 1e9;

int main() {
    int n, m;
    cin >> n >> m;
    VVI e(n,VI(n,INF));
    REP(i,n) e[i][i] = 0;
    while (m--){
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        e[a][b] = c;
        e[b][a] = c;
    }
    VVI d(e);    
    REP(i,n) REP(j,n) REP(k,n) d[j][k] = min(d[j][k], d[j][i] + d[i][k]);

    int ans = 0;
    REP(i,n) REP(j,i){
        if (e[i][j] == INF) continue;
        if (e[i][j] > d[i][j]) ans++;
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    string s;

	cin >> s;

    map<char, int> table;

	int i, len = s.size();

	rep(i, len) table[s[i]]++;

	repit(table) {
		if (it->Y % 2 != 0) {
			Out("No");

			return 0;
		}
	}

	Out("Yes");
	
	return 0;
}


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

using namespace std;

int main() {
	vector<int64_t> L(3);
	for (int64_t i = 0; i < 3; ++i) {
		cin >> L[i];
	}

	for (int64_t i = 0; i < 3; ++i) {
		if (L[i] % 2 == 0) {
			cout << '0' << endl;
			return 0;
		} 
	}

	sort(L.begin(), L.end());
	int64_t A, B, C1, C2;
	A = L[0];
	B = L[1];
	C1 = L[2]/2;
	C2 = L[2] - C1;
	cout << abs(A*B*C1 - A*B*C2) << endl;
}

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

int main()
{
    int i,j,k,n,a;
    vector<int>v;
    vector<int>::iterator l;
    int ans=0;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> a;
        if(v.size()==0)
        {
            ans++;
            v.push_back(a);
        }
        else
        {
            l=upper_bound(v.begin(),v.end(),a,greater<int>());
            j=l-v.begin();
            if(j==ans)
            {
                ans++;
                v.push_back(a);
            }
            else
            {
                v[j]=a;
            }
        }
    }
    cout << ans << endl;
}



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

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

    if ((int)lang.length() == 6){
        string a = lang.substr(2,1);
        string b = lang.substr(3,1);
        string c = lang.substr(4,1);
        string d = lang.substr(5,1);
        if (a == b && c == d)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
// AOJ 	0601 Sugar Glider
// 2018.1.16 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define QMAX 350000
typedef struct { long long t; int s; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void max_heapify(int i)
{
	int l, r, max;
	QUE qt;
	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t > que[i].t) max = l; else max = i;
	if (r < qsize && que[r].t > que[max].t) max = r;
	if (max != i) {
		qt = que[i], que[i] = que[max], que[max] = qt;
		max_heapify(max);
	}
}

void deq()
{
	que[0] = que[--qsize];
	max_heapify(0);
}

void enq(int s, long long t)
{
	int i, max;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t;
	while (i > 0 && que[max = PARENT(i)].t < que[i].t) {
		qt = que[i]; que[i] = que[max], que[max] = qt;
		i = max;
	}
}

typedef struct { int a, b, t; } T;
T tbl[300002];

int h[100002];
int *to[100002], *dt[100002], hi[100002];
char used[100002];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

long long dijkstra(int start, int goal, int val)
{
	int i, s, e, c;
	long long d, x;

	qsize = 0;
	enq(start, val);
	while (qsize) {
		s = que[0].s, d = que[0].t, deq();
		if (s == goal) return val + h[goal] - d*2;
		if (used[s]) continue;
		used[s] = 1;
		for (i = 0; i < hi[s]; i++) {
			e = to[s][i];
			c = dt[s][i];
			if (used[e] || c > h[s]) continue;
			x = d - c; if (x > h[e]) x = h[e];
			enq(e, x);
		}
	}
	return -1;
}

int main()
{
	int n, m, x, a, b, t;
	int i, k;

	n = in(), m = in(), x = in();
	for (i = 0; i < n; i++) h[i] = in();
	for (i = 0; i < m; i++) {
		tbl[i].a = a = in()-1, tbl[i].b = b = in()-1, tbl[i].t = in();
		hi[a]++, hi[b]++;
	}
	for (i = 0; i < n; i++) {
		to[i] = calloc(hi[i], sizeof(int));
		dt[i] = calloc(hi[i], sizeof(int));
	}
	memset(hi, 0, sizeof(hi));
	for (i = 0; i < m; i++) {
		a = tbl[i].a, b = tbl[i].b, t = tbl[i].t;
		k = hi[a]++, to[a][k] = b, dt[a][k] = t;
		k = hi[b]++, to[b][k] = a, dt[b][k] = t;
	}
	printf("%lld\n", dijkstra(0, n-1, x));
	return 0;
}


Measured memory_bytes: 17284
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def each_cons_with_ends(num)
    array = []
    each_cons(num).with_index do |*x, i|
      prev = i > 0 ? self[0..i-1] : []
      following = self[(i+num)..]
      yield(*x, prev, following) if block_given?
      array << [*x, prev, following]
    end
    array.to_enum
  end

  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

def exponential_with_mod(n, k, mod)
  return 1 if k == 0
  return n if k == 1

  if k % 2 == 1
    (n * (exponential_with_mod(n, k/2, mod) ** 2 % mod)) % mod
  else
    (exponential_with_mod(n, k/2, mod) ** 2) % mod
  end
end

# mod m での aの逆元
# mが素数のときのみ有効
def modinv(a, m)
  b = m; u = 1; v = 0

  while b != 0
    t = a / b
    a -= t * b
    c = a; a = b; b = c
    u -= t * v
    c = u; u = v; v = c
  end
  u %= m
  u += m if u < 0
  u
end

def nCk(n, k, mod)
  ue = 1
  shita = 1
  k.times do |a|
    ue = ue * (n - a) % mod
    shita = shita * (k - a) % mod
  end
  ue * modinv(shita, mod) % mod
end

N = get_int

MOD = 10 ** 9 + 7

@memo = Array.new(N+1) { {} }

def ok(last4)
  4.times do |i|
    return false if last4.include?('ACG')
    chars = last4.split('')
    return false if chars.each_cons_with_ends(2).any? do |(a, b), prev, fol|
      (prev + [b, a] + fol).join.include?('ACG')
    end
  end
  return true
end

def dfs(cur, last3)
  return @memo[cur][last3] if @memo[cur][last3]
  return 1 if cur == N

  ret = 0
  %w[A C G T].each do |s|
    ret = (ret + dfs(cur+1, last3[1..] + s)) % MOD if ok(last3 + s)
  end
  @memo[cur][last3] = ret
  ret
end

puts dfs(0, 'TTT')


Measured memory_bytes: 14948
import sys

input = sys.stdin.readline
A = int(input()) + 1
B = int(input()) + 1
C = int(input()) + 1
X = int(input())
counter = 0
for a in range(A):
    for b in range(B):
        for c in range(C):
            if (500 * a + 100 * b + 50 * c) == X:
                counter += 1
print(counter)


Measured memory_bytes: 3060